From fredrik at pythonware.com Thu May 11 07:54:43 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 11 May 2000 13:54:43 +0200 Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> <8fe5t1$mgf$1@nnrp1.deja.com> Message-ID: <00f101bfbb40$21918830$0500a8c0@secret.pythonware.com> erik_wilsher at my-deja.com wrote: > Q: I have modified the bisect module somewhat > (doc strings, find function, sortlist class). > What should be done with this? Vault? Patch list? http://www.python.org/patches/ From jkraska1 at san.rr.com Wed May 24 20:51:28 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 00:51:28 GMT Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8ggso4$67a$1@slb6.atl.mindspring.net> Message-ID: <392C79B3.C02C8E40@san.rr.com> > No, I think it's more that many of us have an instinctive revulsion > against trying to read code with random case. If you read the posts in > all these threads, there is much more acceptance of mono-case languages > than case-insensitive languages. Shrug. Allegro Common Lisp allows you to type in any case you want, but is case-insensitive. Haven't seen any problems there, yet. C/ From intmktg at Gloria.CAM.ORG Sat May 27 10:31:03 2000 From: intmktg at Gloria.CAM.ORG (Marc Tardif) Date: Sat, 27 May 2000 10:31:03 -0400 Subject: vars between classes Message-ID: How can I maintain variables between classes and superclasses without passing explicitly as methods arguments? For instance: class first: def __init__(self, var): self.var = var self.myMethod() def myMethod(): print "first:", self.var second(self.var) print "last:", self.var class second(first): def myMethod(): print "second:", self.var self.var = 3 def test(var): first(var) if (__name__=='__main__'): test(2) Problem is, I would like the printed line containing "last" to output "3" as defined in the second class but it outputs "2" instead. Basically, I'd like to be able to pass variable pointers instead of variables values or perhaps maintain global variables. Whichever solution is most appropriate, I'd appreciate suggestions and comments. Marc Tardif From mwh21 at cam.ac.uk Sun May 14 13:38:39 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 May 2000 18:38:39 +0100 Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> Message-ID: rturpin at my-deja.com writes: > In article <391ED8C9.BC2BAE8D at san.rr.com>, > Courageous wrote: > > Are you talking about some kind of strategy where > > you allocate a maxsize and then put the used memory > > in the middle? > > Yep. You wouldn't have to do this on first allocation, > but could do so only on first prepend that runs over > the start of the buffer, on the assumption if it > happens once, it might happen again. Then you get > efficiency in both directions. The object pointer > still points to the zero-th element, so indexing is > no different. Below the zero-th element, you have > pointers to both ends of the buffer. Prepending > would be a BIT more expensive than appending, since > you have to move these pointers. But you don't have > to move the entire vector each time you prepend, > which seems to be what is now done. Creating vectors > of length n by prepending elements one at a time is > now an n^2 operation! So create it by appending n elements and then reverse it... this is still n^2, I guess, but for the numbers you can deal with before the universe dies a heat death, this will be vastly quicker than anything else you can do in Python. (let ((result ())) (dotimes (i n) (rplacd (last result) (cons i nil)))) is O(n^2), yet people still manage to program in Common Lisp... does-anyone-else-think-people-are-looking-for-problems-where-there -are-none?-ly y'rs M. -- About the use of language: it is impossible to sharpen a pencil with a blunt axe. It is equally vain to try to do it with ten blunt axes instead. -- E.W.Dijkstra, 18th June 1975. Perl did not exist at the time. From emile at fenx.com Tue May 2 14:18:01 2000 From: emile at fenx.com (Emile van Sebille) Date: Tue, 2 May 2000 11:18:01 -0700 Subject: How to get the list of imported variables/functions Message-ID: <0b6c01bfb462$d2c84c40$1906a8c0@fc.fenx.com> Well, I got this to work: a = dir(sys.modules['imported_mod']) then filter as needed. I couldn't get the keys attribute of the module though. Should I have been able to? Emile van Sebille emile at fenx.com ------------------- Michael Hudson wrote in message news:... > Ah, that's probably because I used a string method; try > > filter(lambda s:s[1]<>'_',sys.module['imported_mod'].keys()) > > instead. > > From shapr at uab.edu Thu May 25 11:27:38 2000 From: shapr at uab.edu (Shae Erisson) Date: Thu, 25 May 2000 15:27:38 GMT Subject: Pointrel Data Repository System for Python References: <392AA43E.B3014C3B@kurtz-fernhout.com> Message-ID: <392D4BE1.1A9AB90C@uab.edu> Paul Fernhout wrote: > > This is the very first (rough!) version of the Pointrel Data Repository > System. This sounds like a three-way linked list with indexes. Am I close? The only difference I see is that a linked list is generally thought of as a linear construct whereas this looks more like spaghetti. How is this different from something like Gadfly[1]? The idea somewhat reminds me of natrificial's TheBrain software. I guess arbitrary relationships is one of its strong points? No disrespect meant, I'm just trying to understand more about Pointrel. [1] http://www.chordate.com/gadfly.html -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From jraven at psu.edu Thu May 4 05:58:21 2000 From: jraven at psu.edu (Jeff Raven) Date: 4 May 2000 09:58:21 GMT Subject: Generating combinations with repetitions References: Message-ID: On Thu, 4 May 2000 10:29:50 +0200, Tomaz Ficko wrote: >This is not quite what I meant. I want it to generate combinations not >variations, order of the elements is irrelevant. >Example: 121 is equal to 211 or 112. >Anyway thanks. > >Tomaz > Ah. Then perhaps the following will do. Jeff Raven ------ Code ------ def rchoices(n, k) : # Returns a list consisting of all k-element subsets # of {1 ... n} -- with repetitions. result = [] if k <= 0 : return result current = [1] * k while 1 : result.append(current[:]) index = k - 1 while index >= 0 : if current[index] < n : break index = index - 1 else: break current[index] = current[index] + 1 while index < k - 1 : current[index + 1] = current[index] index = index + 1 return result From tim_one at email.msn.com Fri May 5 03:23:30 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 5 May 2000 03:23:30 -0400 Subject: Copyright and License In-Reply-To: <3911D9F8.CC361B85@colconsulting.com> Message-ID: <000601bfb662$d0d47ce0$d02d153f@tim> [Frank V. Castellucci] > I'm looking for something more along the lines of the Python GPL. There > is a Python accepted (Open Source) license, but it points back to the > Python specific one. I don't understand what you're saying. Assuming nobody else does either, that may explain why you're not getting the answer you want . There is only one CPython license, at http://www.python.org/doc/Copyright.html > I guess I can assume that changing the copyright > owner in the statement is fine for now. You certainly cannot change the copyright owner! The only thing you're required to do is to reproduce the copyright notice (verbatim) in your documentation. As the page explains, there's no GNU copyleft intent here -- you're merely being asked to acknowledge that your work incorporates Python, which is itself under such-and-such a copyright notice. The real intent of that appears to be to create some legal smoke so that Python's sponsoring organizations can't be sued for your use of it. > And FYI: I am asking because of starting a open development project. That's fine. Fine too if it's a closed project. Python is free for all. even-the-military-ly y'rs - tim From petersc at stud.ntnu.no Mon May 15 09:22:52 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 15 May 2000 15:22:52 +0200 Subject: displaying images Message-ID: <391FFA2C.F5EFB1CE@stud.ntnu.no> Hei! I have an algorithm that outputs one image for each iteration. I'd like to display these images (2-dimensional arrays of bytes) in a display that is updated after each iteration so that I can monitor the progress. How can I achieve this without too much hassle? I run under Linux with Tk, KDE/Qt and GTK installed. I would prefer Tk though. Thnx for any idea, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From petersc at stud.ntnu.no Sat May 27 21:31:10 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Sun, 28 May 2000 03:31:10 +0200 Subject: Getting Variables from a file References: <39305D9F.B1201DD4@fenx.com> Message-ID: <393076DE.F41132A8@stud.ntnu.no> I would be careful about using this new string attributes. After all not everyone has 1.6a2 installed. import string for line in string.split(vars,"\n"): try: k,v = string.split(line," = ") exec(line) except: # does not protect you from evil code # but may show some mistakes print "warning: not an assignment '"+line+"'" pass emile at fenx.com wrote: > > This should get you started: > > for line in vars.split("\n"): > try: > k,v = line.split(" = ") > exec (line) > except: > # doexn't parse out as tuple w/ interspersed = > pass > -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From ecastro at cicei.ulpgc.es Thu May 4 12:42:03 2000 From: ecastro at cicei.ulpgc.es (Enrique Castro) Date: 4 May 2000 16:42:03 +0000 Subject: help installing wxPython Message-ID: <39119A7F.B6FE8B0B@cicei.ulpgc.es> Hi, I have just discovered Python and I am exploring its features, in a Win95 system. I have tried to install and use wxPython (wxWindows is already installed and working), but I cannot. Python cannot import the wxc module in wxPyhon package. The interpreter says that a DLL is missing. The error message is: import wxPython >Traceback (innermost last): > File "", line 1, in ? > File "D:\Python\wxPython\__init__.py", line 20, in ? > import wxc >ImportError: DLL load failed: One of the library files needed to run this applic >ation cannot be found. But wxc.pyd DLL is there in the python\wxPython dir. What is happening here? Another fool question (I have not seen in FAQ, probably is too silly) I have set PYTHONHOME variable and associated python.exe to .py extensions, but I cannot "run" some file.py from the prompt. I mean some "executable" demos, not mere class-definition *.py files I would appreciate any help. I am not a professional programmer. Aactually I am a neuroscientist trying to find a new enviroment for rapid development of almost use-and-forget customized tools for data analysis. I used to work small DOS applications, but now my students (and myself, you get used to) want GUI in the applets and huge memory space (and I hate the MS-Windows API). After playing around with Java, I have got the feeling that there are too much movements around JVMs, SWING etc ant that's not an stable base. From urner at alumni.princeton.edu Mon May 29 01:13:12 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 28 May 2000 22:13:12 -0700 Subject: Compact syntax for 0-matrix? References: <3931D5F1.B1DEAA76@mit.edu> Message-ID: <61v3js0e35og41utcmv64cg5r82jlvjpus@4ax.com> Alexander wrote: > > >You can use Numeric Python to do that. >it has function "zeros" for doing that. > Yes, I know, but I don't want to depend on Numeric Python in this instance. The point in this context is transparency: students need to see everything. Here's another function I like OK: def zeromatrix(n,m): output = [] for i in range(n): output.append([0]*m) return output Kirby From paul_pelletier at iname.com Thu May 11 11:57:50 2000 From: paul_pelletier at iname.com (paul_pelletier at iname.com) Date: Thu, 11 May 2000 15:57:50 GMT Subject: Problem with stdout in embedded python Message-ID: <8fel9i$8fu$1@nnrp1.deja.com> Hi all! I've embedded python in a dll of my application and for some reason I dont see any output made by my scripts using print. Would anyone know what might be wrong? Thanks! Paul Sent via Deja.com http://www.deja.com/ Before you buy. From wlfraed at ix.netcom.com Wed May 17 23:14:37 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 17 May 2000 20:14:37 -0700 Subject: Bit length of int or long? References: <392317CF.D6F878F5@python.org> Message-ID: On Wed, 17 May 2000 19:05:19 GMT, Guido van Rossum declaimed the following in comp.lang.python: > This is not a very commonly requested operation, so there's no built-in for > it. > I would suggest this approach: > > def bitl(x): > assert x >= 0 > n = 0 > while x > 0: > n = n+1 > x = x>>1 > return n > How about... import math def bitlen(x): assert x > 0 return math.floor (math.log10(x) / math.log10(2) ) + 1 >>> for j in range(1,20): ... print j, bitlen(j) ... 1 1.0 2 2.0 3 2.0 4 3.0 5 3.0 6 3.0 7 3.0 8 4.0 9 4.0 10 4.0 11 4.0 12 4.0 13 4.0 14 4.0 15 4.0 16 5.0 17 5.0 18 5.0 19 5.0 >>> >>> bitlen(sys.maxint * 2L) 32.0 >>> bitlen(sys.maxint) 31.0 >>> -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From tim_one at email.msn.com Tue May 23 03:02:43 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 23 May 2000 03:02:43 -0400 Subject: longinteger on Cray J90 In-Reply-To: <39290C9A.D5434C3F@onera.fr> Message-ID: <000201bfc484$e4da4460$742d153f@tim> [posted & mailed] [Marc Poinot] > I'm trying to use Python on a J90. Poor Marc! > This Cray, and its folks, has 8 bytes > size shorts, int, long, long long, etc... > Looks like some hardware discount ;) ? > > I have a 8 bytes concern with longobject.c > which manipulates heavily bit masks. > > I found that the carry (add) and borrow (sub) > are not "masked" correctly as shorts. I don't know what this means, alas, but since you're likely the only person on c.l.py with access to a J90, you're going to have to work hard to be clear. > Thus, it looks like some of the asserts are > not relevants (i.e. assert(borrow == 0) ), > but not only the asserts. The asserts are certainly relevant. If the asserts are triggering, something is wrong with the code. > As soon as your long object is larger than SHIFT, > at least the borrow/carry is not "cleared" correctly. > > Python 1.5.2 (#16, May 22 2000, 12:14:02) [C] on unicos10 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> a=01000000000000000 Is there some reason this is in octal? And/or some reason 2**45 is especially interesting? > >>> a-1 > 35184372088831 > >>> b=long(a) > >>> b > 35184372088832L > >>> b-1 > Assertion failed: borrow == 0, file longobject.c, line 1120 > Abort(coredump) Well, *that's* not good . > I've read some emails from Konrad H. and Tim P. > about that. K.Hinsen has problems with regexp. > T.Peters suggested the use of a macro > to mask the shorts. That was different: the old regex code (which Guido didn't write) assumed that sizeof(short) == 2 exactly, and that's a bad assumption. Python's longint code *intended* to assume only that 1. sizeof(unsigned short) >= 2 2. sizeof(unsigned long) >= 4 There is *no* intended assumption that sizeof(unsigned long) >= 2*sizeof(unsigned short), or any of the other bad assumptions you're thinking of. So, given that this code doesn't work for you, there are two likely possibilities: A. The compiler is generating bad code. Did you try compiling Python *without* optimization? If not, try that. B. It's a shallow bug in a line or two of longobject.c, easy to track down if you run under a debugger on a machine where it fails, but could be impossible to track down via email without access to a failing platform. > But such a use seems difficult as the long object representation > has a digit typedef, I have to find back the use of this type in the > whole Python code... (I am wrong, K.P. ?). The "digit" typedef is used only in longintrepr.h and longobject.c. If you stop being paralyzed long enough to look at them , you'll find that almost all uses are already *obviously* properly masked; e.g., v->ob_digit[i] = (digit) (t & MASK); > The description in Include/longinterp.h gives some > details about what the short/digit/wdigit types should > be able to do. But in my case, I wonder how to make > a wdigit able to handle twice the size of a digit? That's not the assumption the code makes. A twodigit thing needs to be able to hold an int no bigger than MASK << SHIFT, and MASK is just BASE-1, and BASE is just 1<SHIFT. */ borrow = a->ob_digit[i] - b->ob_digit[i] - borrow; z->ob_digit[i] = borrow & MASK; borrow >>= SHIFT; borrow &= 1; /* Keep only one sign bit */ } for (; i < size_a; ++i) { borrow = a->ob_digit[i] - borrow; z->ob_digit[i] = borrow & MASK; borrow >>= SHIFT; } assert(borrow == 0); Note that the second "for" loop does not have the borrow &= 1; /* Keep only one sign bit */ line that's at the bottom of the first "for" loop. Try copying that line into the bottom of the second "for" loop too: for (; i < size_a; ++i) { borrow = a->ob_digit[i] - borrow; z->ob_digit[i] = borrow & MASK; borrow >>= SHIFT; borrow &= 1; /* Keep only one sign bit */ ADD THIS LINE ****** } Without that, if the first line ever computes a negative value, "borrow" at the bottom on your machine will retain 64-15 = 49 copies of the sign bit. On machines where sizeof(short) == 2, it retains just 16-15=1 sign bit. Fixing that may well be all there is to this -- but I can't test it for you. the-line-that's-broken-is-always-the-line-closest-to-the-assert-ly y'rs - tim From markx.daley at intel.com Tue May 16 14:41:27 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Tue, 16 May 2000 11:41:27 -0700 Subject: No, it's a list, really! Message-ID: <75F7304BB41CD411B06600A0C98414FC0A412C@ORSMSX54> I am getting terribly confused. Here is the code I am using for an SQL DB query (this may look familiar to those who have helped me in the past): import time, os, sys from strptime import * import dbi, odbc if os.path.exists(os.environ['SystemDrive'] + '/data'): pass else: os.mkdir(os.environ['SystemDrive'] + '/data') servername = ['ServerA', 'ServerB', 'ServerC'] print "This program pulls data from all servers for name and dates of choice." name = ['None', 'nameA', 'nameB', 'nameC', 'nameD', 'nameE', 'nameF', 'nameG', 'nameH', 'nameJ', 'nameK', 'nameL', 'nameM'] choose = input("Select family name:\n\ 1: nameA\n\ 2: nameB\n\ 3: nameC\n\ 4: nameD\n\ 5: nameE\n\ 6: nameF\n\ 7: nameG\n\ 8: nameH\n\ 9: nameJ\n\ 10: nameK\n\ 11: nameL\n\ 12: nameM\n") start = raw_input("Start date? (YYYY-MM-DD):") stop = raw_input("Stop date? (YYYY-MM-DD):") check1 = time.mktime(strptime(start, '%Y-%m-%d')) check2 = time.mktime(strptime(stop, '%Y-%m-%d')) if check1 > check2: print "Start date occurs after stop date!" time.sleep(5) sys.exit() else: pass print "Working" for index in servername: try: alt = 1 verify = 0 if os.path.exists(os.environ['SystemDrive'] + '/data/' + name[choose] + '_' + index + '.txt'): verify = 1 answer = raw_input("File " + os.environ['SystemDrive'] + '/data/' + name[choose] + '_' + index + '.txt' + " already exists. Overwrite? (y/n):") if answer in ('y', 'Y'): verify = 0 if answer in ('n', 'N'): alt = 0 alternate = raw_input("Enter desired file name (no extension):") dbc = odbc.odbc(index + '/username/password') crsr = dbc.cursor() crsr.execute("""select * from subtestlist\n\ where (errorcode<>'null'\n\ AND familyname='"""+name[choose]+"""'\n\ AND PackageStartTime>'"""+start+""" 00:00:00.00'\n\ AND PackageStartTime<='"""+stop+""" 23:59:59.99');""") result = crsr.fetchall() while verify == 1: if os.path.exists(os.environ['SystemDrive'] + '/data/' + alternate + '_' + index + '.txt'): answer = raw_input("File " + os.environ['SystemDrive'] + '/data/' + alternate + '_' + index + '.txt' + " already exists. Overwrite? (y/n):") if answer in ('y', 'Y'): verify = 0 if answer in ('n', 'N'): alternate = raw_input("Enter desired file name (no extension):") else: verify = 0 if alt == 1: if os.path.exists(os.environ['SystemDrive'] + '/data/' + name[choose] + '_' + index + '.txt'): os.remove(os.environ['SystemDrive'] + '/data/' + name[choose] + '_' + index + '.txt') f = open(os.environ['SystemDrive'] + '/data/' + name[choose] + '_' + index + '.txt', 'a') else: f = open(os.environ['SystemDrive'] + '/data/' + alternate + '_' + index + '.txt', 'a') f.write("modulename, subtestnum, subtestname, familyname, releasenum, productcode, serialnum, servername, id, subtestendtime, packagestarttime, opid, errorcode, errormessage, isfinalsubtest, duration, firstsn" + '\n') z = 0 for item in range(len(result)): modulename, subtestnum, subtestname, familyname, releasenum, productcode, serialnum, servername, id, subtestendtime, packagestarttime, opid, errorcode, errormessage, isfinalsubtest, duration, firstsn = result[item] subtestendtime = time.ctime(subtestendtime) packagestarttime = time.ctime(packagestarttime) f.write(`modulename` + ',' + `subtestnum` + ',' + `subtestname` + ',' + `familyname` + ',' + `releasenum` + ',' + `productcode` + ',' + `serialnum` + ',' + `servername` + ',' + `id` + ',' + `subtestendtime` + ',' + `packagestarttime` + ',' + `opid` + ',' + `errorcode` + ',' + `errormessage` + ',' + `isfinalsubtest` + ',' + `duration` + ',' + `firstsn` + '\n') z = z + 1 f.write('\n' + "Total error count = " + `z`) f.close() except dbi.opError: servername.append(index) print servername print "Files written for import to Excel. Location: " + os.environ['SystemDrive'] + "\data" time.sleep(7) (Names have been changed to protect the innocent...namely, me) Here is the output from IDLE: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import query This program pulls data from all servers for name and dates of choice. Select family name: 1: nameA 2: nameB 3: nameC 4: nameD 5: nameE 6: nameF 7: nameG 8: nameH 9: nameJ 10: nameK 11: nameL 12: nameM 1 Start date? (YYYY-MM-DD):2000-04-01 Stop date? (YYYY-MM-DD):2000-05-16 Working ['ServerA', 'ServerB', 'ServerC', 'ServerA'] Traceback (innermost last): File "", line 1, in ? import query File "C:\PROGRA~1\Python\query.py", line 87, in ? servername.append(index) AttributeError: 'string' object has no attribute 'append' >>> What I don't understand is, why did the append work the first time (as evidenced by the list printout after 'Working') and not work the second time? Please forgive the crude interface code, it was the only way I knew how to do it at the time, but, "I'm getting better!" TIA, - Mark From mhammond at skippinet.com.au Thu May 4 02:01:52 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 04 May 2000 06:01:52 GMT Subject: What's gives with Activestate? References: Message-ID: "Don Tuttle" wrote in message news:nHVP4.77747$cZ.175635 at typhoon.southeast.rr.com... > I went to Activestate http://www.activestate.com to see how their Python > development efforts are coming along but couldn't find any Python news > anywhere! In fact I had to dig for several minutes to even find the word > "Python" used on the web sight! It looks like a Perl only website. > > Message to Dick Hardt, "Stop jerking us around! Python is not the red haired > stepchild! If you are really going to support Python, you have to be > willing to talk about it in mixed company. (That is, in front of Perl > zealots) At least make a web page that refers to Python, gives us some > news, and has a few relevant links. Is that asking too much?" You will need to be a little more patient. I only officially started with ActiveState a few days ago, and David Ascher is in the middle of moving, and only recently been able to dedicate serious time on this. We are looking to hire, but it is a long and difficult process finding the right people... I agree the WebSite should change, but OTOH, we really need to _do_ something first! Mentioning we "do Python", but not having anything relevent would also be a problem... So, be patient. I promise Dick will see this, and I promise we are working on things we can do - they just take time with our other responsibilities... Mark. MarkH at ActiveState.com :-) From jmassung at magpiesystems.com Tue May 9 12:19:18 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Tue, 9 May 2000 10:19:18 -0600 Subject: Converting a Binary References: <8f98bk$a6c28@esiami.tsai.es> Message-ID: AMR wrote in message <8f98bk$a6c28 at esiami.tsai.es>... >What module I need to convert a number to binary?, In string format? Assuming 24-bit integer: def itob(i): t=2**23 b='' while i>0: if i>=t: b=b+'1' i=i-t elif b!='': b=b+'0' t=t/2 return b Sorry, I'm new to Python, so if some of this can be done easier or quicker, I'd like to know how, too ;) Jeff From jhauser at ifm.uni-kiel.de Wed May 24 03:34:58 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 24 May 2000 09:34:58 +0200 Subject: Python / Visual Basic mathematical comparison References: <47smis4m1e93nlq5smoskg8h5l46par5r5@4ax.com> Message-ID: <87snv8jt99.fsf@ifm.uni-kiel.de> Look into the topic guide at http://www.python.org/topics/scicomp/ There you will find links to many tools for number crunching and I'm sure that NumPy can withstand a comparison against Visual Basic, although I would also be interested what is lacking. HTH , __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From frankc at colconsulting.com Mon May 15 20:39:20 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Mon, 15 May 2000 20:39:20 -0400 Subject: location of home made modules References: <20000515181351.A3758@better.net> Message-ID: <392098B8.B42BFA35@colconsulting.com> William Park wrote: > > On Mon, May 15, 2000 at 10:01:28PM +0000, Huaiyu Zhu wrote: > > What is the standard place to put one's home-made modules? > > How to get Python to know that place? I tried to put modules in > > ~/lib/python/ with the following in ~/.pythonrc > > > > import sys, os > > sys.path.append("%s/lib/python" % os.environ["HOME"]) > > > > This works in the interactive interpreter but does not get the module from > > program files. Previously all my modules stay in the same directory as the > > programs that load them so this problem did not manifest itself. > > > > > > I can't find where in the docs this is mentioned. > > Thanks for any pointer. > > > > -- > > Huaiyu Zhu hzhu at knowledgetrack.com > > Use environment variable > PYTHONPATH=~/lib/python > or put the module in > /usr/local/lib/site-python/... > > Python online doc explain this. Search for 'PYTHONPATH' or > 'site-packages' or 'site-python'. > > --William Or put a link in /usr/lib/python/site-packages/ to where you modules reside. -- Frank V. Castellucci http://corelinux.sourceforge.net OOA/OOD/C++ Standards and Guidelines for Linux http://PythPat.sourceforge.net Pythons Pattern Package From vetler at ifi.uio.no Sun May 7 18:55:37 2000 From: vetler at ifi.uio.no (Vetle Roeim) Date: Mon, 8 May 2000 00:55:37 +0200 (MET DST) Subject: Future of the Python Linux Distribution In-Reply-To: Message-ID: on 2000-05-07, Glyph Lefkowitz wrote: > > - age. the other "P" language[0] has been around a little longer.. right? > > I hear this tossed around a lot. How *much* longer? I'm not really sure.. > > - forced intentation. a friend of mine once said that he > > categorically dislikes languages that forces that kind of > > limitations on the programmer. > > what language does this guy use? I imagine that it forces him to > treat stack frames as implicit... possibly even to use an imperative > syntax. Or infix notation. Anyone who believes that the language > they use doesn't impose restrictions and enforce a paradigm on them is > deluding themselves (and not well, at that). he uses a lot of them. Common Lisp, Ada, Simula, C++, C, Haskell, ML. he knows languages impose restrictions, but he dislikes the restrictions Python impose. > > this aspect of Python *is* a litle weird. but all languages have > > their weirdness.. many people judge are scared of new things. > > I was scared of python for this very reason for *ever*. We need a > publicized, annoying, LOUD defense of this feature of the language. > Every time I look at python code these days, I feel like slamming my > head into the wall; to THINK that I missed out on this for a YEAR > because I was dumb enough to think that enforced whitespace was not > only a big deal, but a BAD thing!! .. but let's not make this a religous war. Python is not the solution to all problems, and we should not make it. Some people ask me: "why should I use Linux?" I usually answer: "if you need it, you'll know." [snip] > > - books. I may be very wrong about this, but are there more books > > about the other "P" language? > > It requires more documentation. I can't make it 5 lines through a > perl script without 25 consultations of the Camel Book. > I bought two python books from o'reilly on principle, but I haven't > really needed them. This is a *GOOD THING*. We need more python > books that cover higher-level concepts. Learning Python isn't about > "learning python"... it's about unobscuring good programming. I mainly use the documentation available on python.org, and for Tkinter I use John Graysons excellent book, "Python and Tkinter Programming", as well as the Tkinter (and Pmw) source. I haven't read Learning Python, but I hear it's really good. > Learning Perl is about learning perl. Capitalization important there: > uppercase-P is the language, lowercase-p is the interpreter. If you > don't know the in-and-outs of the perl interpreter, and the quirks it > has, you can't do anything. Now, python has some nifty quirks too (my > code is riddled with __setattr__ and __getattr__. I LOVE them!) but I > seriously doubt there will ever be a JPerl. ssssshhhhhh! don't give them any ideas! (when we're on the subject of Java: there's a graduate student at my university who's working on a Simula-to-Java compiler.. :-)) > > - not hackish enough. Python code is nice to look at. code written in > > the othet "P" language looks cooler.. to me (I'm an academic) it > > just looks ugly. code should be beautiful. > > > but some people see that Python is all nice and tidy, and so they > > dislike it because they can't write ugly, unmaintainable code[2] > > Stupid, stupid, stupid, stupid... > > First of all, this is NOT an admirable goal as an engineer, and it's a > problem with the software industry at large, not with Python... ^^^^^^ Perl, right? anyway; many programmers are _not_ engineers. they may have learned programming on their spare time, and therefore approach programming in a different way. I'm not saying people without degrees are stupid, but programming is a lot of things. It is an art, a science, a hobby, and engineering. Sometimes an engineer is needed. Not an artist. > Secondly; > > def hash_coerce(l): > d={} > map(lambda x,d=d: apply(lambda k,v,d=d:d.update({k:v}), > string.split(x,'.')), > l) > return d > > map, lambda, apply, filter. Obfuscation at your fingertips. :-) Using > {}.update(), I believe it's possible to write programs that use only > expressions; no statements. Yes, of course. But I have a feeling many people don't use these functions, unless they have taken a course on functional programming ;-) It's often very useful to use these functions, but they provide solutions not easily available in more popular programming languages, such as C and Java. I refrain from mentioning C++ in the previous sentance, because C++ actually has those functions (except lambda), although many people don't know about them. But it's difficult to write nice code in Perl. At least I think so.. when I start using references, everything blows up in my face.. Perhaps this is my fault. > > - bad PR-agency[3]. until a year ago, I hadn't heard about Python. > > now I use it all the time. > > We need more cybernetic time-travelling marketing executives from the > year 2038 to subdue perl and java proponents with their psychic > freeze-rays. Good idea! :) > Failing that, a "banner campaign", where everybody who has a web page > that uses python advertises it incessantly (this would hopefully > include every Zope site too) might do some good... Yes, well.. this will perhaps increase the popularirt of Python as a web-language, but it is so much more. A few years ago, someone asked me about the origins of the other "P" language. He said: "It was created for web-programming.. right?" I don't know what my point is here, but perhaps I just need some sleep. > Unfortunately, one of the best features of the python community is > that it seems to have a sane group of people in it who know multiple > languages and will choose appropriate ones for the appropriate task. The official language motto? "Python. For sane people." > We need more rabid, unabashed evangelists. :-) Those frigging sane people! Why can't they be more like the Java-people?! > > [0]: no, I'm not referring to Pascal.. or Prolog. you know what I'm > > referring to, you little weasel > > Perhaps you mean you little *camel* I stand corrected. :) > > [1]: I like Lisp, but it *does* have a PR-problem. > > Lisp *IS* a PR-problem. Lisp needs to change its name and shed some > syntax before it's ever going to get 'mainstream' acceptance; the > ideas in lisp are good, but too many cs students have been tortured > with it ... I'm afraid I haven't been tortured with it myself. I've been tortured with Standard ML, Prolog, Java and stone-age C++ (pre ISO/IEC 14882:1998), but not Lisp (I have encountered other languages, but I've just been slapped hard by them.. not tortured). I've tried learning Common Lisp, but I've never found mych use for it. I did use it for some HTML-generation, and it worked great, but after a while I got more interested in Perls fantastic modules (this was in my pre-Python years).. and after a while I forgot about Lisp.. too bad, really. [snip] > > [3]: I know there's no PR-agency. it's a joke. laugh. > > If there's no PR-agency, where are we going to get our nuclear-powered > psychic cyborg executives? Do you think microsoft has any extra? Microsofts nuclear-powered psychic cyborg executives are probably leaving the company like rats leaving a sinking ship, so we can probably get 'em cheap. I-want-a-psychic-freeze-ray-too-ly y'rs, vr From leapinglemur00 at my-deja.com Wed May 17 19:32:52 2000 From: leapinglemur00 at my-deja.com (leapinglemur00 at my-deja.com) Date: Wed, 17 May 2000 23:32:52 GMT Subject: newbie - tkinter - how to do button rollover Message-ID: <8fva74$caa$1@nnrp1.deja.com> I seem to be missing something -- I'd like to do a "rollover" sort of effect with the image on a button changing as the mouse goes over it. I know how to respond to the mouse event, but how do you change the image? Is there a method on the Button class to set the image? Is there some place in the documentation where I could find this? Thanks a lot... Sent via Deja.com http://www.deja.com/ Before you buy. From intmktg at CAM.ORG Sat May 27 10:53:41 2000 From: intmktg at CAM.ORG (Marc Tardif) Date: Sat, 27 May 2000 10:53:41 -0400 (EDT) Subject: vars between classes In-Reply-To: Message-ID: OK, here's working code now. My previous code was only meant to help demonstrate my problem. In this new code, I have tried to change var in the first class by calling "first" explicitly. Unfortunately, "3" is still not printed: #!/usr/local/bin/python class first: def __init__(self, var): self.var = var self.myMethod() def myMethod(self): print "first:", self.var second(self.var) print "last:", self.var class second(first): def myMethod(self): print "second:", self.var first.var = 3 def test(var): first(var) if (__name__=='__main__'): test(2) From gee308 at mediaone.net Sat May 27 13:16:49 2000 From: gee308 at mediaone.net (Toy) Date: Sat, 27 May 2000 17:16:49 GMT Subject: example code Message-ID: <3930085E.F092EA91@mediaone.net> Hi, I'm a programming/python newbie. Where can I find some good examples of code for me to analyze. I've read "Learning Python" from Oreilly, but now I want to see some useful code online. Thanks for your time and help in advance. Jason Toy gee308 at mediaone.net From tim_one at email.msn.com Mon May 8 02:52:11 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 8 May 2000 02:52:11 -0400 Subject: Copyright and License In-Reply-To: <20000506212800.7453.qmail@cranky.arctrix.com> Message-ID: <000701bfb8b9$efacc100$b12d153f@tim> [Tim] > If you assert copyright, you're making a legal claim. If you > want to avoid lawyers, avoid making legal claims . [Neil Schemenauer] > What about significant contributions to Python? Do you have to > sign the CNRI copyright assignment form of you place your code in > the public domain? The CNRI forms http://www.python.org/patches/bugrelease.html http://www.python.org/patches/wetsign.html don't ask you to assign copyright, just to give CNRI a broad, no-cost license. Since the only discernible purpose is to create enough smoke to discourage suing CNRI, yes, they want the forms from everyone. It's not your software they're worried about, it's you . even-bots!-ly y'rs - tim From mwh21 at cam.ac.uk Fri May 19 04:04:58 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 May 2000 09:04:58 +0100 Subject: starship status? Message-ID: Is starship now more or less functional? I tried to post to crew at starship, but didn't get it back... If it is mostly working, perhaps it's time to replace the current rather forbidding front page with something less likely to scare off the passer-by; some links to the rest of the starship would be a nice start! Also, are there any plans to get zope up again soon? (no particular reason for asking...). Cheers, M. -- There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies. -- C. A. R. Hoare From akuchlin at mems-exchange.org Fri May 5 13:06:02 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 05 May 2000 13:06:02 -0400 Subject: Copyright and License References: <000601bfb662$d0d47ce0$d02d153f@tim> Message-ID: <3dya5pylj9.fsf@amarok.cnri.reston.va.us> "Neil Hodgson" writes: > I think I understand what Frank wants because I've already done it. If > you want a license that is just like the Python license but with the serial > numbers filed off then just do it. Replace all references to "Stichting > Mathematisch Centrum" and "CNRI" with "Frank V. Castellucci" or whatever you > wish to call your coding collective. Note that Python's licence is in fact the MIT X11 licence, with MIT filed off and CNRI written in its place in crayon. (JPython's licence is different, though.) --amk From agcolstonNOagSPAM at buckman.com.invalid Mon May 8 15:34:32 2000 From: agcolstonNOagSPAM at buckman.com.invalid (Tonetheman) Date: Mon, 08 May 2000 12:34:32 -0700 Subject: HTMLParser tag contents References: <391544E1.6F0@seebelow.org> <39159114.BFB@seebelow.org> <8f6uav$8cj@drn.newsguy.com> Message-ID: <1b57d290.0052be06@usw-ex0102-013.remarq.com> Sadly enough even in the Python groups you need to watch what you ask... most people will assume that you have checked everything that they know first... which is sort of sad. I am also very new to Python and I was trying to do something with the HTMLParser by creating another class... I just gave up finally and switched to another language. Mainly because I could not find any examples... and I tried to find examples... I just did not know where to look, which is always the problem I guess. If you want to see newbie bashing go to the C++ group... they are REALLY pissed off about anyone asking questions. Oh well. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From boncelet at udel.edu Wed May 3 02:59:18 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Wed, 03 May 2000 16:59:18 +1000 Subject: Numpy, map References: Message-ID: <390FCE45.70FF01E@udel.edu> Josef Dalcolmo wrote: > Hello, NumPy Wizards! > > I am still missing something equivalent to map() > When I define a function, it is not always possible to use only ufuncs for > it. When I then want to apply such a homemade function to an array, I either > have to loop, or to map and then convert. I wish there was something like > 'amap()', which takes an arbitrary function and returns an array. > So do I. One trick: If your function can be computed with a look-up table, then use "take". >>> lut = [] >>> for i in range(256): >>> lut.append(func(i)) >>> b = Numeric.take(lut, a) It can be much faster than computing the function on each element of a. (Of course, many functions can't be computed this way.) Charlie Boncelet -- ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From embed at geocities.com Wed May 10 12:30:12 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 10 May 2000 12:30:12 -0400 Subject: Python/Zope References: <3DDBDA594E55C9EC.E425C32F683DAB41.92F6E57858733657@lp.airnews.net> <8fblee$8h3$1@news.sysnet.net.tw> Message-ID: <3cgS4.18401$HG1.467033@nnrp1.uunet.ca> > I have searched Zope.org, but unfortunatelly i didin't find anything about > a newsgruop, but a lot of mail-box-filling-out-mailing-lists. Newsgroups are usually preferable, however if that is not possible, you can always avoid the Mailbox Filling aspects of mailing lists by: 1. Signing up for the digest version. then you get 1 message a day maximum 2. Get another free email account and use it only for the mailing list. Use mail.yahoo.com or something similar. when you want to read that mailing list, log into your free web mail account. mail.yahoo.com also allows you to download using pop3 and upload with smtp. Warren From jae at ilk.de Thu May 4 18:22:25 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Fri, 05 May 2000 00:22:25 +0200 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) In-Reply-To: <39116EE5.8EFE6228@san.rr.com> (message from Courageous on Thu, 04 May 2000 12:33:58 GMT) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> Message-ID: <05052000.1@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Courageous" == Courageous writes: [...] Courageous> But really. Good grief. Micromanagement in variable Courageous> naming is the last thing the world needs. Indeed mind Courageous> numbing. "long* iamaLP;" Yeah, you're a long Courageous> pointer. Like, dude! NO, DUH. LOL. Thanks-for-the-laugh-ly y'rs, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard I'm a FIG (http://www.fig.org) "No matter how cynical I get, I can't keep up." -- Bruce Schneier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjkR+CAACgkQN0B+CS56qs3spgCfckJD8PLMGH2pHeTguR5FlGmz v78AnjQqFJJwf71aFKxiO3l1w4oZhwS7 =hESb -----END PGP SIGNATURE----- From nick_knight at my-deja.com Tue May 9 08:39:58 2000 From: nick_knight at my-deja.com (nick_knight at my-deja.com) Date: Tue, 09 May 2000 12:39:58 GMT Subject: wierd error after if or while Message-ID: <8f90uq$u4v$1@nnrp1.deja.com> I am a newbie - in fact I just downloaded it today, and so far it looks like a very useful language. The only problem is I seem to be doing something stupid. If I run the folloing bit of code x = 4 if x==4: print "hello" I get the following error message File "", line 2 print "hello", ^ This seems perfectly legal to me - am I missing something or has the install gone wrong perhaps. There was one error message on install about the version of mscvcrt???.dll being the NT version but it seemed to install correctly after that. Thanks Nick Knight Sent via Deja.com http://www.deja.com/ Before you buy. From tagore at internexus.net Fri May 19 11:25:49 2000 From: tagore at internexus.net (Tagore Smith) Date: Fri, 19 May 2000 11:25:49 -0400 (EDT) Subject: The REALLY bad thing about Python lists .. In-Reply-To: <3926363A.B1F@seebelow.org> Message-ID: On Sat, 20 May 2000, Grant Griffin wrote: > Garry Hodgson wrote: > > > > Grant Griffin wrote: > > > > > (BTW, why to you Unix people > > > separate your packager gizmo from your compression gizmo? Very > > > strange...) > > > > not strange at all. these are two completely different > > functions, and thus belong in different programs. > > Well, in the context of a 1970's-style command line OS, which > synthesizes complex behavior by stringing primitive commands together, > maybe so. But surely it causes you people a lot of typing. (Or maybe > you people write a shell script to mitigate that.) I can type tar -xvzf much faster than winzip can start up. Even with long commands a good shell has aliasing, command completion and history, so a few keystrokes is all you need a lot of the time. I find typing faster than mousing anyway (thus shortcut keys in applications). > But in the context of a modern GUI OS, it makes a lot more sense to have > all such functionality built into a single program. I have never seen a > Windows equivalent of "tar" (that is, a packager, less compression), nor > have I ever wanted one: if you're packaging, you might as well compress; > if you're doing both, they might as well both be in the same program. > > Perhaps the '70s approach saved a little disk space or whatever by not > repeating tar's functionality in each compression program, but clearly > that isn't worth the extra trouble it causes for users to have to > repeatedly invoke tar every time they want to de-compresss a package. > The point isn't really to save disk space. It's to allow you to hook up a bunch of little tasks into one big task. Say I have 100 small utility programs, and I can pipe the output of any of them to input of any other. Then I have 100 * 100 = 10000 possible combinations. Not all of them are going to makes sense of course, but enough of them will that this is very useful. And since I can hook up three or four or more it's actually more dramatic than that. It also means that I can do things with these utilities that were not thought of by their authors. If I _want_ a gui based interface to untarring and decompressing I can write just the GUI and call the utilities. So what might have been a pretty serious effort becomes close to trivial. Particularly if I can use Tk instead of Motif and tcl or python instead of C :-). [snip] I'm not bashing windows- there are some things about windows that the *nices could learn from, and it has gotten a lot better since 3.11- but one thing I really miss on both the Mac and on Windows is a good shell and a lot of little utilities that I can easily drive using the scripting language of my choice. In that respect at least I think that Windows has yet to catch up to 1970's technology. And though I think that Python and other scripting languages are valuable on all three major platforms, I think Unix supports them best by making all these little utilities available. Tagore From loewis at informatik.hu-berlin.de Wed May 24 08:11:41 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 May 2000 14:11:41 +0200 Subject: [PATCH] A compromise on case References: <8gefi7$l7b$1@info3.fnal.gov> Message-ID: nickm at mit.edu (Nick Mathewson) writes: > Thanks! I'm going to hold off on this for a few more iterations; > the patch I wrote is not very clean or well-tested, and it > definitely doesn't belong in the main dist. Why not? It is helpful to all users, beginners or not. The only disadvantage is the slow-down that it causes. That also is not a problem if the exception results in program termination, since the execution time of formatting a traceback is not relevant. It only matters in cases where the caller expects to receive a NameError, in which case the computation of the alternative name is wasted time. > I mainly intended it as a demonstration of how I think errors should > work. If people agree with me, then I'll clean up the code. I have two suggestions: In order to avoid hard-coding the error message, I recommend to put this code into NameError and AttributeError, like this: class NameError(StandardError): def __str__(self): if len(self.args)==2: return "unknown name %s, do you mean %s ?" % self.args else: return StandardError.__str__(self) Then, you create a name error with NameError(not_found, do_you_mean) Next, if you want to delay computation of the alternative name, you could also define class AttributeError(StandardError): def __str__(self): if len(self.args)==2: name = self.args[0] obj = self.args[1] otype = type(obj) if otype in [InstanceType, ClassType, ModuleType]: dict = obj.__dict__ rname = find_nearest_match(dict,name) if rname: return "%s object has no attribute %s, maybe you meant %s"\ % (otype.__name__, name, rname) return "%s object has no attribute %s" % (otype.__name__,name) return StandardError.__str__(self) Then, an attribute error would be raised as AttributeError(name,obj). That holds a reference to the object, but that should be ok, since it does not introduce a cyclic reference. Given an intelligent implemenentation of find_nearest_match, it could also detect other kinds of typos. I'd love to see such a feature in standard Python. Regards, Martin From adjih at inria..fr Mon May 1 19:12:05 2000 From: adjih at inria..fr (Cedric Adjih) Date: 1 May 2000 23:12:05 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> <20000430170952.A502@datapro.co.za> <8ehrb9$mm5$1@ites.inria.fr> Message-ID: <8el305$h77$1@ites.inria.fr> Samuel A. Falvo II wrote: > In article <8ehrb9$mm5$1 at ites.inria.fr>, Cedric Adjih wrote: >> If you can read, you should be able to read the definition of >>any variable, and there are serious drawbacks. A flame of this >>notation is for instance in "Developing Windows NT Device Drivers": >>"The so-called `Hungarian Notation' (developped by a Hungarian >>programmer at Microsoft) is one of the worst ideas to have hit >>software development in many years" > "All good ideas are judged from the enemies they make." -- I forgot who. >> The main problem, is that when you change the type of a structure >>you _cannot_ change the name (because other people are using it), >>so the type specification becomes plain wrong. The 'wParam' >>is reported to be such an example (now unsigned 32 bits), there >>are other examples in Microsoft API (should be worse with Win64). > Hungarian notation is fine for the definition of an API, as long as its used > to describe abstract concepts, like arrays, pointers to things, a count of > whatever, etc. Hardcoding the bit-widths of types is obviously going to get > you into trouble in the future. Just because Microsoft fscked up the > execution doesn't mean the idea is somehow "bad." > Like I said earlier, I use it only when it makes *sense* to. Like anything > else you have in your toolshed, Hungarian notation is a tool. Those who are > skilled in its use will not have the problems you cite above. :) Those who > aren't only use it because it's a fad. It's ok. It's just that most of the time I've read some code using it, it was following Microsoft broken conventions. I personally don't like marking pointers/arrays (he! that would be like Perl), but I using it in a clever way, is of course quite good. >> Also each time you change the type of one variable/parameter, >>you have change all the variable names of all the code under >>your control. > In my work with Dolphin, I've found, on several occasions, where I needed to > change symbol names pervasively throughout the source. I have found #MORE > BUGS# just waiting to crop up and bite me in the butt this way than through > any other technique. The very thing you cite as a "problem" is the very > thing that will help reduce the number of bugs in Dolphin upon its final > release. Is it painful? You bet. Just ask Billy -- the translation from > old symbol names to new names broke the compile for weeks. But once it was > all over, I had fixed no less than 14 bugs that would *never* become > apparent until after I'd released the code to the public. Most of the bugs > were bound to be of the "intermittent" type too, so I was particularly > pleased at the end result. > > I view it as sheer laziness on the programmers part. You get what you pay > for. That's right. This is why, when I change code and break some invariant/expectation (even if the types aren't changed), I often change the variable/struct/function names, to review all the code possibly using it. >> And finally, for multi-platform code, it makes less sense: >>what happens if you don't have 2-bytes integers and you >>have code with wXXXX variables (unsigned int 16 bits) ? > On PowerPCs, a word is 32-bits. On Intels, 16-bits. So what's the lesson > to be learned here? Don't hardcode widths in the meanings of your symbols. > Hungarian notation as used by Microsoft is by far NOT the only way to use > it. No but the very name "Hungarian notation" comes from its (incorrect) use at Microsoft. > For example, I *never* identify word-widths in my Hungarian notated > variable names. Why? Because of the very problem you cite above. However, > I do indicate higher-level meanings with prefixes: p for pointer, c for a > count (e.g., cb for a count of bytes, cuint32 for a count of 32-bit unsigned > integers, etc), a for array, etc. > Again, it takes skill to use a tool well. Agreed. -- Cedric From claird at starbase.neosoft.com Mon May 15 10:40:00 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 May 2000 09:40:00 -0500 Subject: Java vs Python References: Message-ID: <4790568F8505079C.4C564E45732EDB9A.4D76AF043C3460B3@lp.airnews.net> In article , Huy Do wrote: >Hi, > >I would just like to know how serious python is taken in the IT industry and >how it compares to something like Java. > >For example > >If a web applicatoin was written in both Java and Python, >which would companies prefer ? > >1. Which is more maintainable ? >2. Which is more scaleable ? >3 Which is faster eg. Java servlets or Python CGI with mod_python ? > >Please do not interpret this message as an excuse to discredit java or >python. I am >about to start a major web project using Java but have been referred >to python as an alternative so I am investigating this option. . . . Have you seen ? Which is faster? Both are. Run-time performance of the common implementations (and Web embeddings) of Java and Python are suffici- ently close that the comparison depends strongly on the details of the application under consideration. Vulgar recognition of this often appears as, "benchmarks are garbage." In fact, benchmarks are very valuable. It's quite likely in your case that run-time perfor- mance is *not* a significant differentiator. Others have already written you about scalability and maintainability. Python's more portable than Java. You didn't ask, but you should know that. Java's improving, and someday will probably dominate here. A few years ago, we thought surely it'd happen by now. It hasn't, yet. As others have hinted, it's not necessary to put the two in opposition. It can be quite rational to use both Python and Java, sometimes together, with JPython (or even more esoteric bindings). Yes, I understand MISthink that claims to want to standardize on One True Language. If that's truly a constraint on you, we can discuss strategies for dealing with it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From arcege at shore.net Tue May 9 15:48:25 2000 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 09 May 2000 19:48:25 GMT Subject: Help! References: <39133790.8D4D8275@cpsc.ucalgary.ca> Message-ID: Kevin X. Liang wrote: : I am a newbie with Python 1.5 on Linux (RH-6.1). I have a problem with : importing modules. When I tried to import a module 'pyjbt', defined : myself, I got the following error message: : ImportError: : /home/grads/xkliang/research/Linux/jsp/jpy/modules/pyjbtmodule.so: : undefined symbol: PyType_Type : It seems to me that the system could not find the external module : defining PyType_Type used in Python include file object.h. I am : wondering what is the proper setup for PYTHONPATH in order to load all : the necessary modules and libraries and get rid of the above import : probelm. My currect PYTHONPATH is : ['', '/home/grads/xkliang/research/Linux/jsp/jpy/modules', : '/home/grads/xkliang/lib/Linux', '/usr/lib/python1.5/config', : '/usr/lib/python1.5/', '/usr/lib/python1.5/plat-linux-i386', : '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload', : '/usr/lib/python1.5/site-packages'] : where '/home/grads/xkliang/research/Linux/jsp/jpy/modules' contains my : own modules. : I appreciate very much any help from the Python experts in this group. Hello Kevin, It looks like the pyjbtmodule.so shared object is expecting the python1.5 library to already be loaded into the program and that is not the case (it sounds very much like you are embedding Python in an application). You will want to link with the Python library when building the pyjbt extension module. All libraries are not Python modules. Python modules would only get loaded from an "import" command. Libraries would get loaded by being referenced (during the build) in the program or other libraries. However the build process must now about that library to look for it when the program runs. You probably want to include "-lpython1.5" when making the .so file (and you will want to add the appropriate -L option too, for example -L/usr/local/lib/python1.5/config). This would go in the Setup file if you are working through that, otherwise inside the Makefile. Without more specifics, I can't add too much more. -Arcege From aaron at mancala.semo.net Wed May 3 16:07:55 2000 From: aaron at mancala.semo.net (Aaron Malone) Date: 03 May 2000 15:07:55 -0500 Subject: How do you send mail through python References: <8epu0e$ltq$1@nnrp1.deja.com> Message-ID: <87ya5rcs84.fsf@mancala.semo.net> Sindh writes: > I have been struggling to findout which module has the facilities for > sending email through python. Take a look at the "smtplib" module. It's quite simple and straightforward. -- Aaron Malone (aaron at semo.net) System Administrator I can bend minds with my spoon. Poplar Bluff Internet, Inc. http://www.semo.net From lexberezhny at email.msn.com Fri May 12 19:21:00 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Fri, 12 May 2000 19:21:00 -0400 Subject: AI and Python Message-ID: Hi, I was wondering if anyone has dont any artificial inteligence with Python. I am writing a program for my school, which is ment to talk to kids in trouble, it will ask some simple questions based on the student answers, there is already a list of questions that we might want answered, so its not really AI. But I wanted any opinions on this topic. Thanks. - Lex From stephen at cerebralmaelstrom.com Mon May 29 02:20:15 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Mon, 29 May 2000 06:20:15 GMT Subject: PyCFunction? What is it? Message-ID: In the process of doing my embedding, I looked at some files in Modules\* to get examples of various functions, INC/DECrementing and so on and so forth.. I noticed that the method-tables cast the function names in the Modules\* dir (cStringIO specifically) to PyCFunction, and that the embedding-demo did not. What *is* PyCFunction and do method defs need to be cast to it? (I also found where to put doc strings this way..whee..which I didn't notice in the actual docs :)) --S From dalke at acm.org Sat May 6 16:37:43 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 6 May 2000 14:37:43 -0600 Subject: Irix 6.5, gcc 2.95.2, readline and control-C problem References: Message-ID: <8f2031$m9o$1@slb3.atl.mindspring.net> George White asked: >Does anyone have readline working for n32 python on Irix 6.5? I never did get that fixed. It only occurs for me when I ^C during readline (as compared to when a Python program is running), so I got into the habit of not doing that. Andrew From arnold at dstc.edu.au Mon May 1 02:46:28 2000 From: arnold at dstc.edu.au (David Arnold) Date: Mon, 01 May 2000 16:46:28 +1000 Subject: UNIX domain sockets problem In-Reply-To: Your message of "Mon, 01 May 2000 16:41:10 +1000." <200005010641.QAA13793@piglet.dstc.edu.au> Message-ID: <200005010646.QAA03219@piglet.dstc.edu.au> -->"davida" == David Arnold writes: davida> i don't think listen() is not supported for datagram davida> (ie. SOCK_DGRAM) sockets. doh. let's try ... i don't think listen() is supported for datagram (ie. SOCK_DGRAM) sockets. sorry ... d From nicshane at my-deja.com Thu May 18 05:02:20 2000 From: nicshane at my-deja.com (nicshane at my-deja.com) Date: Thu, 18 May 2000 09:02:20 GMT Subject: SWIG compilation Message-ID: <8g0bim$goh$1@nnrp1.deja.com> I am trying to compile swig.exe using borland 5.5 under windows NT. The compilation seems to work but the following errors occur at link. MAKE Version 5.2 Copyright (c) 1987, 2000 Borland "Making the SWIG Parser..." MAKE Version 5.2 Copyright (c) 1987, 2000 Borland "Make Modules..." MAKE Version 5.2 Copyright (c) 1987, 2000 Borland tlink32.exe /Tpe @MAKE0001.@@@ Turbo Link Version 1.6.72.0 Copyright (c) 1993,1996 Borland International Error: Unresolved external '@__InitExceptBlockLDTC' referenced from module swigmain.cxx Error: Unresolved external '_vector_delete_ldtc_(void*,unsigned int,unsigned int,unsigned int,void*)' referenced from module types.cxx Error: Unresolved external '_vector_new_ldtc_(void*,unsigned int,unsigned int,unsigned int,void*,unsigned int,void*)' referenced from module types.cxx Fatal: General error in module types.cxx ** error 1 ** deleting ..\swig.exe ** error 1 ** deleting swig.exe Any ideas as to how to fix this ?? Regards, Shane Baker. Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at rocket.knowledgetrack.com Wed May 24 20:47:39 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Thu, 25 May 2000 00:47:39 GMT Subject: object browser in emacs Message-ID: I just realized the folowing interesting thing: If you enable jde mode for java, you can use the speedbar which lists objects in a convenient tree in a separate window. Now if you edit python code it automatically lists python objects (including all python modules in the directory). Really cool. Is the speedbar a part of jde-mode that happens to also work in python-mode, or is it a language-neutral app? Can I ask python-mode to use it automatically? I could have examined the elisp code ... but I'm no expert and somebody may already know the answer. Huaiyu From laurent at lfmm.org Sun May 28 02:53:46 2000 From: laurent at lfmm.org (Laurent Martin) Date: 28 May 2000 08:53:46 +0200 Subject: Getting rid of extra spaces in print Message-ID: Hi, I've just started learning Python. I try to write a simple script that reads a file one character at a time and then prints it. Thus I wrote: f = open('toto.src','r') car = f.read(1) while len(car): print car, f.close() Unfortunately the 'print' function adds an extra space between my characters. I've found a solution on Deja.com: to set sys.stdout.softspace to 0 before each call to print. This works but is there a simpler and more elegant solution to this problem? Laurent. From pinard at iro.umontreal.ca Wed May 17 13:16:31 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 May 2000 13:16:31 -0400 Subject: Bit length of int or long? Message-ID: Hi, people. I would have vaguely hoped that len(3) or len(3L) gives me the number of bits taken by the integer 3, but that function is not available over integers. The closest thing I found is `math.frexp', but the library reference for 1.5.2 is much too terse (and probably wrong) about it. It says: frexp(x) Return the mantissa and exponent for x. The mantissa is positive. With Python 1.6a1, I may get a negative mantissa: >>> math.frexp(-1024) (-0.5, 11) The manual should say that the exponent is an exponent of two. It should also say that the mantissa is returned as a float for which the absolute value is in the closed-opened interval [0.5, 1.0), and which has the sign of the argument. This is presuming I'm correctly guessing how it works, but as an apparent special case, `math.frexp(0)' returns `(0.0, 0)'. If I had a precise specification for `math.frexp', like above, I could use it a bit more seriously. Programs should ideally not rely on guess work :-). Could the documentation be amended and made precise for this? P.S. - Yet, how does one ideally proceed to know the bit length of an integer? I presume `math.frexp' is not too slow at producing the first float. Floats are a bit unexpected in my little integer-only application. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From dima at xenon.spb.ru Sat May 20 05:51:36 2000 From: dima at xenon.spb.ru (Dmitry Rozmanov) Date: Sat, 20 May 2000 13:51:36 +0400 Subject: odbc.dll vs. mxODBC Message-ID: <39266028.212B88C9@xenon.spb.ru> Hi. What are the pros of mxODBC in comparision with odbc module that comes with win32 extention to Python? Currently I use module from extention. Will there be any good if I install mxODBC. Actually I have all I need. But if mxODBC exists so there is some reasons, but I don't know them;) :(. Thank you. ---Dmitry. From embed at geocities.com Mon May 15 10:53:04 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 15 May 2000 10:53:04 -0400 Subject: Stand-alone Python Apps? References: Message-ID: <4fUT4.20380$HG1.517119@nnrp1.uunet.ca> "Nathan Gundlach" wrote in message news:X0TT4.1732$W45.3792 at newsfeed.slurp.net... > Is there any way to create stand-alone apps in Python that I can use on > Windows, Linux/UNIX, and Mac? I would like a tool which would create source archives, binaries for Win-x86, Linux-x86, and Mac PPC, handling all possible Windows DLLs, Unix Shared Libraries, and Mac shared libraries, various GUI toolkits, etcetera, etcetera. Once I have a tool that complicated I should only have one more step to make a really useful python utility.... one that could write most of my application for me while I'm at it! Seriously, I think there is some room for improvement in making Python programs easier to "pack and go". There are several tools out there that you should examine, search for Install and Freeze on the Python Search Page for starters. I think you'll need to narrow down your search by choosing an appropriate GUI toolkit and other packages you'll need to use. Once you've built one installer, the rest will be a cinch. Python can be used for so many purposes, some of which are portable, and some of which are not, that I can hardly see a single universal Installer Tool. Making such a tool would be complicated by the many binary and python extensions available for Python. If you use any DLL extensions (.pyd files on Windows) then your program is not going to fit in a single file. If standalone means "make a nice install program" then I'm sure many people are working on improving their installer scripts, but I am not aware of any one tool that is aware of all the things like Tcl/TK, wxPython, and whatever other extension DLLs or Scripts you might use in your application. The closest you're going to get is manually building three separate binary installation programs, one for each platform, plus providing separate copies of the source/script files. Then users might pick and choose between them, and everybody might be reasonably happy. Except you, because it's a lot of work making all those binary installation programs. The other thing is that Python programs provided as source are inherently more useful because you can change them. I suspect that a Python program distributed without its source is going to be a lot less popular. Has anyone formed a project or SIG to discuss simplifying installation and deployment of Python applications, including the various GUI toolkits around? My own bias is towards wxPython. I am hoping Boa Constructor will include a deployment wizard to help make shipping applications to people who don't have Python and WxWindows + WxPython a little bit easier. Warren From titus at caltech.edu Tue May 16 15:24:17 2000 From: titus at caltech.edu (Titus Brown) Date: Tue, 16 May 2000 12:24:17 -0700 Subject: [PyWX] Re: Choice of language In-Reply-To: <14625.32542.132486.760008@marzipan.emphatic.com>; from bobg@emphatic.com on Tue, May 16, 2000 at 10:02:22AM -0700 References: <3921523B.F93EF787@mindspring.com> <14625.32542.132486.760008@marzipan.emphatic.com> Message-ID: <20000516122416.H21435@cns.caltech.edu> -> Chuck Esterbrook writes: -> > Given the success, maturity, functionality and stability of the -> > Python programming language, as well as the ease of embedding and -> > extending it, has anyone in the Latte community considered creating -> > a Python version of Latte? -> -> Well it certainly sounds like you have! [ munch ] I'm not sure what Chuck was suggesting: there are two options, right? Write a Latte parser in Python; this would let many Web servers incorporate it easily, not the least of which would be AOLserver. Separately, adapt the Latte language to a Pythonesque syntax, which it sounded like Chuck was suggesting. I am very much in favor of the first; the second sounds a bit more difficult to do cleanly. cheers, --titus P.S. plug: http://pywx.idyll.org, PyWX: Python for AOLserver. -- Titus Brown, titus at caltech.edu From aahz at netcom.com Wed May 24 11:47:41 2000 From: aahz at netcom.com (Aahz Maruch) Date: 24 May 2000 15:47:41 GMT Subject: translating Perl Cookbook? References: <12113.000523@satunet.com> Message-ID: <8ggtit$7ll$1@slb0.atl.mindspring.net> In article <12113.000523 at satunet.com>, wrote: > >Just wondering if anybody is interested in translating the recipes >(and as much as the other code snippets) from The Perl Cookbook into >Python. There was a discussion of this a few months ago, and I wrote to O'Reilly asking if they wanted to hire me to do it. They said they already had someone working on the project, but I don't know what the ETA is. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From itdcgb at its.hants.gov.uk Tue May 16 11:57:59 2000 From: itdcgb at its.hants.gov.uk (Graham Bleach) Date: Tue, 16 May 2000 16:57:59 +0100 Subject: how to use a proxy? References: Message-ID: <8frr0r$73k$1@news.hants.gov.uk> "Charlie Derr" wrote in message news:LOBBJCAMDNLNCGCCHGEIEEJCEJAA.drivel_drool at bigfoot.com... > you have to set an environment variable > > HTTPProxy=
No, it is http_proxy # this usually works import os, urllib os.environ["http_proxy"]="http://firewall.bad.com:9999" urllib.urlretrieve('http://www.python.org/') # This should put a copy of said page into a temp file. > i might not have the case right, i remember looking through the source of > urllib and finally finding it I'm not sure about the case - it might be case insensitive, I always use lowercase. It might be that I'm using NT, which does not have case-sensitive environment variables. Anyone? > and you'd need another one for > > FTPProxy > > etc... The convention is _proxy i.e. https_proxy > hth, > ~c > > ~ > ~ Hi! > ~ > ~ How can I use a proxy (I'm behind a firewall) to get HTML pages > ~ from the net? > ~ I hade a look on HTTPlib and URLlib but there is no comment about proxies. > ~ > ~ Regards, > ~ Mike > ~ G From dana at oz.net Sat May 13 02:34:14 2000 From: dana at oz.net (Dana Booth) Date: 13 May 2000 06:34:14 GMT Subject: python book recommendations? References: <8fgsqq$kuo@news.or.intel.com> Message-ID: <8fit16$dc3$0@216.39.141.21> Firehawk343 wrote: F: I'm new to Pyhton and would appreciate advice on what book(s) will help me F: ramp up the fastest. If you already program, David Beasly's "Python Essential Reference" is very good. Another plus is that the book is high quality. My O'Reilly books always seem to fall apart quickly. -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From olipt at mayo.edu Fri May 12 02:27:17 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Fri, 12 May 2000 01:27:17 -0500 Subject: How to identify memory leaks in extensions? In-Reply-To: References: <391AF390.C419189A@spacenet.tn.cornell.edu> Message-ID: > > The short answer is, everything must be DECREF'd. > > okay. i am confused now. even if one is __returning__ the array? > I'm sorry for the confusion. Of course you should NOT DECREF arrays you are going to return (unless you INCREF'd them for some reason in your code), or your process will lose the memory previously allocated for them. *** *** I meant you should DECREF everything you don't want to have a *** increased reference for when your done with the subroutine. *** > ============================== > ... > indep = (PyArrayObject *) PyArray_FromDims( IND_DIM, &dims[1], PyArray_DOUBLE); > dep = (PyArrayObject *) PyArray_FromDims( DEP_DIM, dims, PyArray_DOUBLE); > > indepPtr = (double *)indep->data; > > /* now let PyArray_As2D re-arrange, if necessary (?), */ > /* our array and set the pointers to the rows of array */ > PyArray_As2D( (PyObject**)&dep, (char ***) &numarr, > &dims[0], &dims[1], PyArray_DOUBLE ); > > > /* do stuff */ > > return Py_BuildValue("(OO)", indep, dep); > ============================== > > okay, from your post those 'OO' should be 'NN'. but even then ... > Yes, no need to DECREF if you use "(NN)" (since you do want these variables to stay around after you leave this subroutine). > > Whenever you use a PyArray_XXXXXXX construct that gives you back a > > PyArrayObject, you own a reference. You must DECREF before leaving > > the subroutine or you have a memory leak. Change this to. You must DECREF before leaving the subroutine if you did not intend to have an increased reference count. > > you're saying i have to DECREF indep and dep before i return????? its > confusing. i allocate arrays with PyArrayXXX to do stuff with and > return them, in my python code i set references to them. somehow the > 'setting reference in the python code' is an INCREF over and above the > PyArrayXXX? No I don't think so. I didn't mean to imply that. If you want to return the array don't DECREF it (unless you use "O" in Py_BuildValue). > > so, lets see. every PyArray does one INCREF. every Py_BuildValue does > another one if you use the 'O', and when you set a refernece equal to > it in a return value, thats yet another?????? or maybe i am confusing > the last INCREF with the first one. I don't think the last INCREF happens, so don't let my quick explanation confuse you. > > but if i go > > x = 3 > y = x > > that y = adds a reference to the 3 object. > > thanks This is my understanding of this sequence: x=3: "3" is evaluated (because "3" is an integer between -1 and 100, the the reference count to the integer 3 is incremented and a pointer to the object is returned). So the evaluation does the INCREF. Since x is a name it binds this name to the returned object (no further reference count increase). y = x The reference count of x is incremented during evaluation of x and a reference is returned. This reference is bound to y. Again, the INCREF happens at evaluation. x = 4 "4" is evaluated as before, INCREF'ing the reference count. Now since x is already bound, the object x references ("3") is DECREF'd. Then, the new object (with it's already increased reference count) is bound to the name ("x"). The language reference leads me to believe that this is sort of how it works. I have not carefully looked through this part of the Python source code, however. This model lets me write code that does not have memory problems, however. Good luck, Travis From nickm at mit.edu Tue May 23 15:34:16 2000 From: nickm at mit.edu (Nick Mathewson) Date: Tue, 23 May 2000 19:34:16 GMT Subject: [PATCH] A compromise on case References: <3dn9nnkt.fsf@SNIPE.maya.com> Message-ID: On 23 May 2000 14:11:46 -0400, Jeff Senn wrote: [...] >Merits of the patch aside (I like the idea!), it still doesn't get to >the core of *why* Guido suspects there are benefits to making the >language case-insensitive. > >Just consider how to handle the more complex case of code like: > > CountOfLumberJacksAvailable = 12 > if something.or.other(): > CountOfLumberjacksAvailable = CountOfLumberJacksAvailable + 1 > print CountOfLumberJacksAvailable > >Code, which you will notice, generates no "errors"... Hm. This would call for a 'identifier-only-used-once' kind of an error. Within a function, this is fairly reasonable. The problem is what to do when you see things like the code above at the module level. Personally, I think that case-insensitivity is not really the right way to solve the issue you address. Even if you solve the error in the code above, I know from experience that I will sometimes mistype 'CountOfLumberJacksAvailable' not only as 'CountOfLumberjacksAvailable' but also as 'NumberOfLumbarJacksAvailable' and as 'NumberOfLumberJacksAvailable'. Having a good, built-in PyLint-ish tool could help for all of these cases. -- Nick Mathewson http://www.mit.edu/~nickm/ From m.faassen at vet.uu.nl Tue May 23 05:54:19 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 09:54:19 GMT Subject: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3o85$esa$1@news.hants.gov.uk> <392706CC.6DEE@seebelow.org> <8gau6q$bhu$1@newshost.accu.uu.nl> <392AF801.44C@seebelow.org> Message-ID: <8gdkgb$nju$1@newshost.accu.uu.nl> Grant Griffin wrote: [I am surprised you would take a year learning Python] > Well, lemme give you an example. I figured out the other day that the > way to do sscanf was: > map(float, string.split(s)) # (IIRC) > Well, obviously! I never used that. 'for' loops are generally more clean and more extensible in Python. I only find myself using map() rarely, filter() even more rarely, and reduce() hardly at all. Of course your mileage may vary. > Besides map, Python has lots of built-in functions emboding concepts > which aren't familiar to me as an experienced C/C++ programmer, for > example: map, reduce, lambda, filter, etc. I think Guido's idea here is you shouldn't use those a lot anyway. It's said he rather regrets adding 'lambda' to the language, after all. Not that this kind of functional programming can't be fun. > Sure, one can RTFM about > these. But learning the "what" is just the beginning: learning the > "why" and the "when" is what takes a lot of practice. (Anytime someone > says "the Pythonic way to do that would be...", they're talking about > what I'll be learning over about the next year or so.) Okay, that's picking up some idioms. It's just that after a few weeks you can already write programs that, while they might not use the absolute 'best' in idioms, they're already pretty *close* to what an expert would write. So while you can still pick up stuff, you're actually quite up to speed after a short while. > Oh, and did I mention the libraries? More study and practice is > required here. Whatever their intrinsic merits, Python's libraries are > at least significantly different from the libraries of other languages > (which are likewise different from each other.) Some of them are; many of them are simple wrappers about C libraries (which I never used when I used C, now I would use them far more :). Of course learning the libraries is an eternal process, but I wouldn't classify that under learning *Python*. In general, it's not like most Python standard modules are like C++'s STL or the stream library, after all. You don't have to know their ins and outs before you can claim you know the language. If-you-had-I-couldn't-claim-I-did-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aahz at netcom.com Wed May 10 09:53:06 2000 From: aahz at netcom.com (Aahz Maruch) Date: 10 May 2000 13:53:06 GMT Subject: Python/Zope References: <3DDBDA594E55C9EC.E425C32F683DAB41.92F6E57858733657@lp.airnews.net> <8fblee$8h3$1@news.sysnet.net.tw> Message-ID: <8fbpk2$poc$1@slb3.atl.mindspring.net> In article <8fblee$8h3$1 at news.sysnet.net.tw>, Fabio Augusto Mazzarino wrote: > > I have searched Zope.org, but unfortunatelly i didin't find anything about >a newsgruop, but a lot of mail-box-filling-out-mailing-lists. > I know you are wondering why I am looking for a newsgroup... but... >nevermind... keep wondering. Someday I'll tell you. Well, I don't know your reasons, but I certainly agree with you about the mailbox-filling, so I stick to newsgroups myself (for the most part). -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Internet $tartup$: Arbeit ueber alles --Aahz From exarkun at flashmail.com Mon May 8 18:36:58 2000 From: exarkun at flashmail.com (Jp Calderone) Date: Mon, 08 May 2000 18:36:58 -0400 Subject: exception handling Message-ID: <3917418A.E3B57E17@flashmail.com> Is there any way to catch *all* exceptions raised in a try/except block *and* get a reference to the exception that was raised? I basically just need to print out the exception, as the interpreter does when an unhandled exception is raised, but with extra formatting and such. I've tried the sys.exc_info() function, but it always seems to return (None, None, None) - even when it is being called in an except block, where it obviously *should* have info on an exception. Thanks in advance, Jp -- -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GCS dpu>-- s+: a--- C++++ UL++++ P+ L+++ E---- W++ N++ o+ K- w--- O-- M- V- PS+++ PE- Y+ PGP t+ 5+ X++ R+ tv+ b++ DI++ D--- G e* h! !r y-- ------END GEEK CODE BLOCK------ -- 6:34pm up 5 days, 23:02, 6 users, load average: 0.07, 0.09, 0.03 From claird at starbase.neosoft.com Sat May 20 01:56:42 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 May 2000 00:56:42 -0500 Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fsgon$jei$1@newshost.accu.uu.nl> Message-ID: In article , Neel Krishnaswami wrote: . . . >semantics are de-facto defined by a single implementation. JPython >would be a really good thing if only because it helps keep CPython >honest about what's intended and what's an interpreter quirk. . . . Already true. JPython *has* been "a really good thing ... because ..." -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From herzog at online.de Mon May 15 18:41:01 2000 From: herzog at online.de (Bernhard Herzog) Date: 16 May 2000 00:41:01 +0200 Subject: python improvements (Was: Re: New Language) References: <8fpfoj$e0m$1@nntp6.u.washington.edu> Message-ID: "Russell E. Owen" writes: > I would personally like to be required to declare variables before using > them, a la smalltalk. (Just declare the names, not specify a "type".) It > would greatly simplify this kind of error checking. I suppose it would be possible to introduce an optional 'local' declaration similar to the already exisiting 'global' and to have a command line flag that makes it mandatory. > Also on my wish list (inspired by Smalltalk): > - class instance variables and class variables are declared as part of > the class declaration and nowhere else. The current system seems > dangerous, especially for class variables. It's too easy to mis-type a > variable name and so create a new one. My experience so far is that this doesn't happen as often as one might expect. However, the reason for that may be that I frequently use Emacs' dynamic abbrevs to complete longer identifiers. I use this feature so often that I sometimes mistype newly introduced identifiers consistently. :-) M-/-ly y'rs -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From moshez at math.huji.ac.il Tue May 23 07:04:57 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 23 May 2000 14:04:57 +0300 (IDT) Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <8gdlta$nju$6@newshost.accu.uu.nl> Message-ID: [Moshe] > >>>> A=1 > >>>> a > > Traceback (innermost last): > > File "", line 1, in ? > > NameError: a > >>>> a=1 > > Traceback (innermost last): > > File "", line 1, in ? > > NameError: A already exists > > > (Thanks for Guido for giving me a copy of the binaries of 2003 Python. > > This is without the --readable-error-messages switch) [Martijn] > Also, I don't think > this would help a lot in the newbie example. Your example might confuse > newbies even more. ("I'm trying to assign to A and now I can't because A > already exists?") Let me re--run the examples with --reable-error-messages: >>> a = 1 >>> A NameError: "A" is not a defined name. Perhaps you mea n"a"? >>> A = 1 NameError: "a" is defined, and "A" differs only by case Is that understandable enough? -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From g2 at seebelow.org Fri May 26 17:28:38 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 26 May 2000 22:28:38 +0100 Subject: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3o85$esa$1@news.hants.gov.uk> <392706CC.6DEE@seebelow.org> <8gau6q$bhu$1@newshost.accu.uu.nl> <392AF801.44C@seebelow.org> <8gdkgb$nju$1@newshost.accu.uu.nl> Message-ID: <392EEC86.53ED@seebelow.org> Edward S. Vinyard wrote: > > On 23 May 2000, Martijn Faassen wrote: > >I never used that. 'for' loops are generally more clean and more > >extensible in Python. I only find myself using map() rarely, filter() > >even more rarely, and reduce() hardly at all. Of course your mileage may > >vary. > > How are 'for' loops more extensible in Python? > > Grant Griffin wrote: > >> Besides map, Python has lots of built-in functions emboding concepts > >> which aren't familiar to me as an experienced C/C++ programmer, for > >> example: map, reduce, lambda, filter, etc. > > map, reduce, and filter have equivalents in the STL. > Well, as an experience C/C++ programmers, I've learned not to use the STL. ;-) (as-slow-as-them-darn-things-are,-you-might-as-well-just-use-a -good-high-level-scripting-language-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From stuart at bmsi.com Tue May 16 13:33:48 2000 From: stuart at bmsi.com (Stuart D. Gathman) Date: Tue, 16 May 2000 13:33:48 -0400 Subject: Decimals to fraction strings References: Message-ID: <3921867C.7CAF105C@bmsi.com> Scott wrote: > Does anyone know of a way to convert decimal numbers to a string > representation of the fractional value? For example: > 0.5 = "1/2" > or > 1.125 = "1 1/8" 1) Convert to a fraction by counting places after the decimal: 0.5 -> 5 / 10 1.125 -> 1125 / 1000 2.6 -> 26 / 10 3.14156295 = 314159265 / 100000000 2) Divide top and bottom by their GCD (greatest common divisor): 5 / 10 -> 1 / 2 1125 / 1000 -> 9 / 8 26 / 10 -> 13 / 5 314159265 / 100000000 -> 62831853 / 20000000 3) If desired (I don't), convert to mixed notation when num > den by finding quotient and remainder of num / den: 9 / 8 -> 1 rem 1 -> 1 1/8 13 / 5 -> 2 rem 3 -> 2 3/5 62831853 / 20000000 -> 3 2831853/20000000 From adjih at crepuscule.com Wed May 17 06:05:40 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 17 May 2000 10:05:40 GMT Subject: Network statistics program References: Message-ID: <8ftqtk$25a$1@ites.inria.fr> Greg Fortune wrote: > I'm currently working on a program that will run some network statistics > for me over the span of months. I want to send a ping every minute, collect > the results, and then store that information in a database. I think I can > get everything working, but the issue of the one minute interval is killing > me. How do I make my program just sit there and do nothing until the system > clock says it has been a minute? Never before have I *tried* to make a > program do nothing :). > I consider a while loop with a pass statement or a time check, but that > seems like it would take up processor cycles for little reason. > I also considered letting ping handle the interval and just use ping as > the piped input. Although this may be the simplest solution for me at this > time, I really want to learn how to implement delay. You can use module time, function sleep: time.sleep(1.1) # sleep 1.1 seconds Or if you are waiting for events or for a timeout, select will be helpful: select.select([file desc list]..., timeOutInSeconds) For instance if you are waiting for a ping reply. -- Cedric From scott2237 at my-deja.com Thu May 25 11:07:02 2000 From: scott2237 at my-deja.com (scott2237 at my-deja.com) Date: Thu, 25 May 2000 15:07:02 GMT Subject: syntax highlighting for Kedit Message-ID: <8gjfi6$bke$1@nnrp1.deja.com> Python ppl: Does anyone in the Python community use Kedit? Do you have a syntax highlighting module for _.py files? Can you share? Thank you in advance... scott2237 Sent via Deja.com http://www.deja.com/ Before you buy. From dan at cgsoftware.com Tue May 2 12:18:42 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Tue, 2 May 2000 09:18:42 -0700 (PDT) Subject: How many is "too many" with lists? In-Reply-To: Message-ID: No, i meant, how are you accessing them? You are probably doing linear searchs rather than binary ones. On Tue, 2 May 2000, Matthew Hirsch wrote: > I'm building a list of lists each holding a combination of nCk where n > is the total number of numbers and k is the number you are choosing. > For example, I have 27 numbers, 0-26. Looking at all combinations of 6 > taken from this sample produces 27!/(27-6)!6! =296010 different > combinations stored in the original list. > > Matt > From stevena at permanent.cc Fri May 12 22:56:11 2000 From: stevena at permanent.cc (Steven D. Arnold) Date: Fri, 12 May 2000 22:56:11 -0400 Subject: python improvements (Was: Re: New Language) In-Reply-To: <8fhva4$h5i$1@newshost.accu.uu.nl> References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> Message-ID: <4.3.1.2.20000512224530.01a92e48@phear.dementian.com> Hi Martijn, At 10:07 PM 5/12/2000 +0000, Martijn Faassen wrote: >Steven D. Arnold wrote: >[snip] > > 1. I'd like an equivalent to perl's "use strict" pragma. It's annoying to > > have to be so paranoid about making a typo in a variable name. I'd like > > the compiler to be able to catch those errors for me. > >How exactly would this work? It would seem hard to make this work >right in a dynamic language, but perhaps I'm missing some simple >strategies. I'm not familiar enough with 'use strict' in Perl to know >what Perl is doing in this respect. In perl, `use strict' means that you must declare that a variable will be used in a function before you use it. In python, the following error is possible: def foo(bar): doh = bar * bar return duh + 5 With a strict pragma, it'd be more like this: def strict foo(bar): declare doh doh = bar * bar return duh + 5 Since `duh' was never declared, you'd get a compile-time error. > It'd be nice to have a bit >more compile-time checking, but Python's extremely dynamic, so this >would seem very hard to do in the general case. Perhaps for >local and variables it'd be possible, but attributes are tougher; >we have __getattr__(), after all. Yes. The strict pragma would not affect class attributes, at least not as I'm describing it. It would only affect variables directly used in the function. A class could also use the strict pragma; such a thing would only affect variables used at the class scope. > > 2. I'd like the ability to specify that a certain parameter or variable is > > of a given type. >[snip] > >Ooh, lots of us would! Join the types-SIG. :) *grin* >You seem to want DOC and ERR mostly. Yes, though of course I also favor anything that improves performance with no significant sacrifices. ;-) >There's also a counter force, let's call it RAD: > >RAD -- we want to develop our systems rapidly. We want interfaces that can > deal with lots of inputs, without having to think about it a lot. > Dynamic typing helps us set these up without hassle. I agree with the poster who said that any such tools must be optional. Any variable may be declared to be of a specific type or not. In Objective-C, a variable of no particular type was declared as type `id'. This was essentially a generic object pointer. Thanks for the links, also. :-) -- Steven D. Arnold Que quiero sera stevena at permanent.cc "We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard." -- John F. Kennedy From darrell at dorb.com Sun May 28 02:28:26 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 27 May 2000 23:28:26 -0700 Subject: vars between classes References: Message-ID: <049701bfc86d$ef2fa210$6401a8c0@home> Marc Tardif wrote: > Indeed this is related to a concrete programming problem. I'm trying to > write a small class to parse html tables into lists. Of course, I have > searched Parnassus for such code, but what was available didn't support > embedded tables. I'm therefore writing my own class to recursively go > through embedded tables and I think I'm almost there. This would be a good job for one of the standard parsers. But I like to write parsers so your problem sounded fun. This needs a decent regression test, but I've run out of time. Thought a test that generates random tables and checks them would be cool. import re class TagParser: """ Given a list of tags use getTags(buf) to parse buf. The result is a dictionary tree. Each element found has an entry in the tree. The dictionary key is the tag type and a count for that tag type. Each key has a list for it's data. The list holds each child tag. The first element of each list is a tuple(start, end) which outlines the elements contents. """ def __init__(self, tagList): self._tagList=tagList def getTokens(self, buf, patList): """ patList is a list of tags to search for. Return list of (tagOffset, matchObject) """ pat = "(?i)" for p in patList: pat=pat+"(<%s>)|()|"%(p,p) pat = pat[:-1] res = self.findallExt(pat, buf, 0, len(buf)) res1=[] for r in res: cnt=0 for n in r.groups(): if n: res1.append((cnt, (r.start(), r.end()))) break # cnt will correspond to the offset in patList cnt=cnt+1 return res1 def findallExt(self, pat, buf, start, end): """ Search buf for pat. Return a list of matchObjects """ pat=re.compile(pat) res=[] last=start while 1: mo=pat.search(buf,last, end) if mo==None: break res.append(mo) last=mo.end() return res def getTags(self, buf): tokens = self.getTokens(buf, self._tagList) self._tags = {'Root':[]} parent = self._tags["Root"] parentKey = "Root" parentStack = [] tagCnt= [0]*len(self._tagList) def openTag(self, mo, tagType, parentKey, tags, tagCnt): """ A new tag is opening. Adjust the key and add a new element to tags. """ childKey= parentKey+"/%s%s"%(self._tagList[tagType], tagCnt) parent = tags[parentKey] parent.append(childKey) tags[childKey]=[mo[-1]] return childKey for m in tokens: tagType=m[0]/2 if m[0]%2 == 0: # Keep track of parents as we go down parentStack.append(parentKey) parentKey = openTag(self, m, tagType, parentKey, self._tags, tagCnt[tagType]) tagCnt[tagType]=tagCnt[tagType]+1 else: body=self._tags[parentKey][0] self._tags[parentKey][0]=(body[1],m[1][0]) if 0: # Wast time by cutting the text self._tags[parentKey][0]=buf[body[1]:m[1][0]] # Restore previous parent parentKey=parentStack.pop() return self._tags def testSimp(self): self.getTags(open("table.html").read()) import pprint pprint.pprint(self._tags) def regress(self): funcs=self.__class__.__dict__.keys() funcs.sort() funcs=filter(lambda x: re.match('test',x), funcs) for f in funcs: getattr(self,f)() parser = TagParser(["Table","tr","td"]) parser.regress() ************* output {'Root': ['Root/Table0'], 'Root/Table0': [(7, 270), 'Root/Table0/tr0', 'Root/Table0/tr1', 'Root/Table0/tr4'], 'Root/Table0/tr0': [(13, 51), 'Root/Table0/tr0/td0', 'Root/Table0/tr0/td1', 'Root/Table0/tr0/td2'], 'Root/Table0/tr0/td0': [(19, 21)], 'Root/Table0/tr0/td1': [(30, 32)], 'Root/Table0/tr0/td2': [(41, 43)], 'Root/Table0/tr1': [(63, 214), 'Root/Table0/tr1/Table1'], 'Root/Table0/tr1/Table1': [(74, 201), 'Root/Table0/tr1/Table1/tr2', 'Root/Table0/tr1/Table1/tr3'], 'Root/Table0/tr1/Table1/tr2': [(83, 130), 'Root/Table0/tr1/Table1/tr2/td3', 'Root/Table0/tr1/Table1/tr2/td4', 'Root/Table0/tr1/Table1/tr2/td5'], 'Root/Table0/tr1/Table1/tr2/td3': [(92, 95)], 'Root/Table0/tr1/Table1/tr2/td4': [(104, 107)], 'Root/Table0/tr1/Table1/tr2/td5': [(116, 119)], 'Root/Table0/tr1/Table1/tr3': [(144, 191), 'Root/Table0/tr1/Table1/tr3/td6', 'Root/Table0/tr1/Table1/tr3/td7', 'Root/Table0/tr1/Table1/tr3/td8'], 'Root/Table0/tr1/Table1/tr3/td6': [(153, 156)], 'Root/Table0/tr1/Table1/tr3/td7': [(165, 168)], 'Root/Table0/tr1/Table1/tr3/td8': [(177, 180)], 'Root/Table0/tr4': [(225, 263), 'Root/Table0/tr4/td9', 'Root/Table0/tr4/td10', 'Root/Table0/tr4/td11'], 'Root/Table0/tr4/td10': [(242, 244)], 'Root/Table0/tr4/td11': [(253, 255)], 'Root/Table0/tr4/td9': [(231, 233)]} ************ input
a1a2a2
aa1aa2aa2
bb1bb2bb2
b1b2b2 From btang at pacific.jpl.nasa.gov Fri May 5 16:45:23 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Fri, 05 May 2000 13:45:23 -0700 Subject: batch ftp Message-ID: <391332E3.955E277A@pacific.jpl.nasa.gov> Are there any python scripts to do ftp for a whole directory tree? I have seen ftpmirror.py in the standard python installation. But it ony does get, not put. Also it would be nice to preserve the time stamps and permission bits of the original files. From cjc26 at nospam.cornell.edu Tue May 16 23:18:05 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 17 May 2000 03:18:05 GMT Subject: Sharpening comparative concepts (was: Java vs Python) References: <18CD0C3E9F8D621D.066D4CC984A07877.88E0A688930DFD0D@lp.airnews.net> Message-ID: * Cameron Laird menulis: | I've been thinking about I/O. Is Java *wrong* | (in the sense that, say, inter-module communi- | cation through FORTRAN common blocks is an | unacceptable hazard), or just different, in | this regard? Myself, I much prefer event-ori- | ented programming, and think that threads are | generally dangerous in the hands of amateurs; | on the other hand, I find Java's I/O just a | *different* programming model, one not inher- | ently inferior. I'd guess that waiting for a condition on a pool of, say, 10 sockets would be faster and less memory/cpu intensive than doing context switches between 10 different threads over and over again. but-I'll-let-someone-else-do-the-benchmarks-ly y'rs, -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "One man's nirvana is another man's map." icq 68165166 From stevena at permanent.cc Fri May 12 17:34:30 2000 From: stevena at permanent.cc (Steven D. Arnold) Date: Fri, 12 May 2000 17:34:30 -0400 Subject: python improvements (Was: Re: New Language) In-Reply-To: <8fh57c$19s$1@nnrp1.deja.com> Message-ID: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> At 02:41 PM 5/12/2000 +0000, pohanl at my-deja.com wrote: >Ok, here are some ideas for the new language... [...] >This new language would have components with no constraints on values >passed to it. First let me say that I love Python. It's a dazzlingly good language. When I started programming perl, I marvelled that there was a language that went so far out of its way to make the programmer's life easy and enjoyable; I still owe perl a debt of gratitude for being the first in that category, at least the first I was exposed to. Perl wasn't a theoretical purist's language; it was a language intended to help the programmer, period. However, putting sentimentality aside, python is both theoretically brilliant and extremely helpful to the programmer, as much or more than perl in every regard I care about. From the work I have done already in python, I can say without the slightest hesitation that manipulating complex data structures, using and writing complex class hierarchies, etc, is far easier in python than perl. Python is definitely more pleasant to read, more pleasant to write, syntactically far clearer....etc. I would far rather maintain a complex python project than a complex perl project. Having said that, I feel python can use some improvements. (So could any world-class Olympic athlete.) I will allow that this point of view may be a misperception on my part due to an incomplete understanding of the langauge; and I invite anyone with more knowledge than I to show me how the following goals can be cleanly attained in python. 1. I'd like an equivalent to perl's "use strict" pragma. It's annoying to have to be so paranoid about making a typo in a variable name. I'd like the compiler to be able to catch those errors for me. 2. I'd like the ability to specify that a certain parameter or variable is of a given type. This can help prevent a class of runtime errors (though of course we could use introspection and try/except blocks, but that adds code that, with a type declaration, could be avoided). Furthermore, I would find it very useful when I'm trying to understand a method or function. Often I see a parameter and I have no idea what type the parameter is supposed to be. What class do I look in to find the method this var is supposed to be using? I have to guess. If I had a sophisticated class browser for python, this task would be easier, but it could still involve guessing. One addendum to the above: If I declare a variable to be of a given class, I should also be able to pass any subclass. 3. I'd like to allow for the formal declaration of protocols a la Objective-C. A protocol is a set of method calls that an object can claim to support or not. Protocols can be defined to support a variety of useful behaviors. For example, drag 'n' drop might be implemented as a protocol, where you accept a given data stream as part of a protocol::drop method. This also prompts an extension to suggestion (2) above: I should be able to declare that a given parameter requires an object that conforms to a given protocol. Then, instead of being a specific type, the object is guaranteed to support the protocol (actually, its class has registered support for the protocol and implements the required methods and perhaps the optional methods). Don't misunderstand the intent of these suggestions: I do not want to make python more like C++ in the sense of imposing a bunch of annoying strictures. I merely want to give the programmer the option of being more restrictive, especially if it helps ferret out bugs early. Let's give python programmers the option of using some of the features of C++ that find bugs early in the development process, even if we don't require programmers to use those facilities. Nuff said. Python kicks ass. I'm a convert! -- Steven D. Arnold Que quiero sera stevena at permanent.cc "We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard." -- John F. Kennedy From MSteed at altiris.com Fri May 19 12:26:58 2000 From: MSteed at altiris.com (Mike Steed) Date: Fri, 19 May 2000 10:26:58 -0600 Subject: why tar is strange (was: The REALLY bad thing about Python li sts ..) Message-ID: <65118AEEFF5AD3118E8300508B1248774CB306@ALTNET> > From: Graham Bleach [mailto:itdcgb at its.hants.gov.uk] > Sent: Friday, May 19, 2000 10:01 AM > To: python-list at python.org > Subject: Re: why tar is strange (was: The REALLY bad thing > about Python > lists ..) > > > For a few weeks I had this idea in the back of my mind to make UNIX > pipelines accessible to non-programmers. They would be able to > visually join logical operations together in some way. Anyway some > other idea evicted this from my mind until I read your post and now > it's back :) My main problem is that I have little GUI > design/programming experience and that generally I have not enjoyed > creating user interfaces :) You may be interested in Khoros and friends: http://www.khoral.com/ or LabVIEW (tailored for instrumentation): http://www.ni.com/labview/ There are probably others out there... -- M. From psl at mitre.org Tue May 30 13:26:30 2000 From: psl at mitre.org (Peter Leveille) Date: Tue, 30 May 2000 13:26:30 -0400 Subject: Tk events Message-ID: <3933F9C6.F67412D8@mitre.org> Does anyone know what the event name is for catching mouse movement without a button pressed? Grayson's book "Python and Tkinter Programming" mentions a PointerMotionMask for the Motion event, but I can't find any more info on that mask. From stephen at cerebralmaelstrom.com Thu May 18 12:37:06 2000 From: stephen at cerebralmaelstrom.com (Stephen) Date: Thu, 18 May 2000 16:37:06 GMT Subject: Python(Path) Question, Number Two :) References: <8g0a5u$ffb$1@nnrp1.deja.com> <39242B47.659FD3EC@python.org> Message-ID: Ahh, cool, you rule. I was wondering which .c file it was in :) Thanks. --Stephen > > No time to explain it all, but you can read the details in PC/getpthp.c. > Note that in Python 1.6 this has changed a lot (for the better). > > --Guido van Rossum (home page: http://www.python.org/~guido/) From bjorn at roguewave.com Thu May 18 11:37:32 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 18 May 2000 09:37:32 -0600 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newsho Message-ID: <39240E3B.5BC6DA3C@roguewave.com> Peter Schneider-Kamp wrote: > Martijn Faassen wrote: > > > > In the case of 'foo'.join() this stops making sense: > > > > I join the list of strings with spaces. > > > > ' '.join(list) > > Well how about this: > The space joins the elements of the list. Oh, you mean.... list.append(' ') > > ' '.joins(list) > > > lots-of-instinctive-language-analysis-ly yours, > > more-of-that-stuff-ly y'rs keeping-a-good-thing-going-ly y'rs bjorn From vinyard at arlut.utexas.edu Thu May 25 09:35:54 2000 From: vinyard at arlut.utexas.edu (Edward S. Vinyard) Date: Thu, 25 May 2000 08:35:54 -0500 Subject: What's in a name? In-Reply-To: <392D06E1.415DFEF1@uab.edu> References: <392D06E1.415DFEF1@uab.edu> Message-ID: On Thu, 25 May 2000, Shae Erisson wrote: >"Edward S. Vinyard" wrote: >> My intent was to stimulate discussion along these lines, rather than >> rehash the case sensitivity vs. case insensitivity arguments that have >> been presented in other threads on this newsgroup. I apologize if this >> was not clear from my original messages. > >The case-sensitive issue just might be the same as the whitespace issue. >Python's unconvential approach works quite well for me in whitespace, >I'm willing to give another unconvential approach a chance at least. Other posts to this thread continue to compare the use of capitalization in Python to the use of capitalization in English, which makes no more sense than comparing their respective uses of whitespace. Syntax in English obviously has little to do with syntax in Python! :-) Languages with block delimiters don't require the use of whitespace, but most programmers make use of whitespace to impart some implicit semantic meaning (grouping blocks of code together). Python requires this whitespace, making block delimiters unnecessary, and making the semantic information provided by whitespace standard. Martijn Faassen pointed out that making the language case insensitive would have the opposite effect that whitespace block delimiters have, and I agree. Case insensitivity by itself removes the implicit information that some Python programmers embed in capitalization entirely. Case sensitivity by itself only makes the convention implicit and nonstandard. For example, forcing the first letter of class names to be capitalized makes it visually clear which names are classes. I enjoy Python's lack of block delimiters and I think I would enjoy the lack of implicitness here, too. Ed From greg at cosc.canterbury.ac.nz Tue May 23 22:06:17 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 24 May 2000 14:06:17 +1200 Subject: Case sensitivity (Was: Re: NumPy and FFT) References: <392A2F23.FD2E3127@san.rr.com> Message-ID: <392B3919.E984ACEF@cosc.canterbury.ac.nz> Courageous wrote: > > Well, there's always: > > import big_fft > big_y = big_fft.little_fft(little_y) There may actually be a serious point in there somewhere. If we're robbed of the ability to use case for semantic distinctions, we're going to have to adopt some other conventions to make those distinctions. Then there's room for different people and different modules to use different conventions, and at least as much scope for confusion -- probably more. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From newsbunny at noether.freeserve.co.uk Wed May 3 15:05:11 2000 From: newsbunny at noether.freeserve.co.uk (Martin P Holland) Date: Wed, 3 May 2000 20:05:11 +0100 Subject: How to get terminal width? References: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <8epl60$1b42$1@nntp6.u.washington.edu> Message-ID: On 3 May 2000 16:46:56 GMT, Donn Cave wrote: >think of on UNIX is to read the output of "stty -a", where the first line >usually reports these values. Empirically, I find that it always uses the stty size just gives the rows and columns here (linux) but may be this is not standard. atb Martin -- http://www.noether.freeserve.co.uk http://www.kppp-archive.freeserve.co.uk From eviltofu at rocketmail.com Sun May 14 23:55:04 2000 From: eviltofu at rocketmail.com (Jerome Chan) Date: Mon, 15 May 2000 03:55:04 GMT Subject: Compiling Python for BeOS 5 Message-ID: I've managed to compile it but under make test it just hangs on test_p_open2.py. Once I remove that file from the testing sequence seems to go into an infinite loop after test_threading. Also the struct module test failed as well. Does anyone have any hints in configuring Python for BeOS? From wlfraed at ix.netcom.com Sun May 21 22:02:59 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sun, 21 May 2000 19:02:59 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: <284his4te203rh27l4nk18urfag8dj4vd3@4ax.com> On 21 May 2000 11:55:09 -0700, Phil Austin declaimed the following in comp.lang.python: > Actually modern Fortran is still case-insensitive -- the existing code > base is simply too large to consider changing this. > Based upon the Fujitsu COBOL supplied with "COBOL: From Micro to Mainframe", COBOL is also case insensitive. Not surprising, since it too came from the era of caps-only keypunch machines. However, I consider case sensitivity/insensitivity to be something in a language from the beginning -- not something to be changed mid-stream. Even Fortran-90 (which declared that "Fortran" is now a name and not an acronym for FORmula TRANslator ) doesn't enforce case -- even if most of the rest of the language is much different (continuation lines, in particular). If Python-to-be is going to affect things that much, call it... Monty... -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From stephen at cerebralmaelstrom.com Tue May 30 06:55:35 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Tue, 30 May 2000 10:55:35 GMT Subject: stdin, stdout References: <#2z0XYay$GA.311@net003s> Message-ID: I *believe* you don't actually need to modify stdin/stdout.. Each is just a basic file-object (implementing read() and write() respectfully?)... So, if you want to alter their behavior, just make your own little class that implements read() and write() a la files, then do: sys.stdin = YourNewStdin sys.stdout = YourNewStdout In YourNew* you can write to the origional std(in/out) through the __stdin__ and __stdout__ file-objects. You could make your stdin/stdout do just about anything, I think. Then again, I havn't gone to bed yet tonight so I could still be in my own little universe of obsessive purplenses. --S :) A[r]TA wrote in message news:#2z0XYay$GA.311 at net003s... > Hi, > > I want to write an own INPUT-module. > But not like the raw_input(). It has to be something like that, but > it is not allowed to stop de continue streams of data. > I want it, so I can write commands easily while my server is online. > If you do it with raw_input() then the select.select() won't continue > till you hit enter. And that isn't the purpose. > In the Python-docs the stdin and stdout -modules are mentioned. > Because they're taking care from the print and raw_input(). > If I could modify them! But that isn't possible, 'cause I don't have > the source from the sys-module. > > > (Maybe, it's possible if there's something in Python like in BASIC > : the LOCATE-command. You just put the cursor somewhere and there > it'll print.) > > > A[r]TA > > -- > We shall not cease from exploration, and the end of all our exploring will > be to arrive where we started and know the place for the first time. > - T. S. Eliot > > > > > From python at channel21.com Wed May 10 16:10:46 2000 From: python at channel21.com (Channel21 Python Team) Date: Wed, 10 May 2000 16:10:46 -0400 Subject: OK - Figured it out... Message-ID: <81DD38F43381D111BA3E00A076A0998A45A05D@XENON> ok: (notes for code below) 1. adding user w/o password 2. popen pipe to passwd 3. write password 3.a. make sure to flush, or it won't actually take the input... 4. repeat 3,3.a 5. close ** added the sleeps because machine is too slow (it spat back conversation errors otherwise) this seems to be working fine and doing just what I wanted (I am sure there must be a better way, but this works... ;>) #################################################### #!/usr/bin/python import os, sys import time def adduser(username, password): cmd = "/usr/sbin/useradd %s" %username os.system(cmd) time.sleep(2) p = os.popen("passwd %s" %username, 'w') time.sleep(2) p.write(password) time.sleep(2) p.flush() time.sleep(2) p.write(password) time.sleep(2) p.flush() time.sleep(2) p.close() if __name__ == '__main__': usage = "usage: %s username [password]" % \ os.path.basename(sys.argv[0]) if len(sys.argv) < 2: print usage sys.exit(1) username = sys.argv[1] if len(sys.argv) > 2: password = sys.argv[2] else: from getpass import getpass password = None while password is None: p1 = getpass("Password for user '%s':" % username) p2 = getpass("Re-enter user '%s' password:" % username) if p1 == p2: password = p1 else: print "Passwords don't match." adduser(username, password) From francis at robinton.demon.co.uk Sun May 14 18:05:47 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Sun, 14 May 2000 23:05:47 +0100 Subject: (gulp) newbie question - portablity of python References: <8fmtjo$3ub$0@216.39.141.21> Message-ID: In article , Keygrass writes >Oh, I see now. I have to install Python. I certainly don't mind >installing Python on my home computer; no problem there. But I don't have >access to install Python at the unix workstation at my job. :-( They use >unix on the Sun systems, I believe. > >I could ask a network adminstator if he or I could install Python. But ... >I don't think it will receive a warm welcome since many files (I strongly >believe they are text based, but I am not 100% sure) are highly sensitive. >I figured they don't want any unnecessary program lurking on the hard >drives, regardless of the benevolence Python could do for us. Well, I >suppose I will eventually have to ask. But until then, I need to first back >up my claim with a reliable Python program. You mean they will allow you to bring in compiled programs when they have sensitive files around? Wow, they must be crazy. Now if they have Java installed you might consider JPython. Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From mhammond at skippinet.com.au Tue May 2 01:49:04 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 02 May 2000 05:49:04 GMT Subject: COM question References: <390CDC8B.779DB0C3@world.std.com> <390D16B7.B2524B@world.std.com> <8_9P4.3745$Px3.100662@news2-win.server.ntlworld.com> <390DACB0.9FCA96B3@world.std.com> <390E1B0E.D973BEEF@world.std.com> Message-ID: "David Lees" wrote in message news:390E1B0E.D973BEEF at world.std.com... > Yes you are correct about the version. You imply that something has to > have VBA for me to be able to talk to it using Python? I thought I > could start up word from Python by just knowing it's COM name? In fact, > I can find the CLSID in the registry, but have no idea how to use that > in place of "word.application". The older versions of Word used a different name that currently escapes me. There is no decent way to browse the COM objects by name, other than by hand (or, I suppose, with a quick Python script :-) Basically, you browse the top-level of HKEY_CLASSES_ROOT. Any key with a CLSID value is likely to be the name of the COM object (and FYI, if you then look this CLDID key up under HKCR\CLSID, you will find the implementation details for the object) Mark. From pinard at IRO.UMontreal.CA Fri May 26 14:37:00 2000 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 26 May 2000 14:37:00 -0400 Subject: Python equivalent to Perl's warn/confess/die In-Reply-To: Paul Prescod's message of "Fri, 26 May 2000 13:16:37 -0500" References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> <392EBF85.9179FD59@prescod.net> Message-ID: Paul Prescod writes: > sys.stderr.write *is* the warn function. > "die" is an exception mechanism so I would argue that that is somewhat > separate. I use `raise' instead of `die'. You even get a traceback for free! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From yawyi at gmx.de Sat May 27 06:39:27 2000 From: yawyi at gmx.de (Johannes Stezenbach) Date: Sat, 27 May 2000 12:39:27 +0200 Subject: Dictionaries and Threads References: <3926A8EF.C3C1914B@jslove.net> <8gm2on$2ju$1@slb6.atl.mindspring.net> <392ebd70$0$18389@personalnews.de.uu.net> <8gmfbk$cf8$1@slb3.atl.mindspring.net> Message-ID: <392fc322$0$18381@personalnews.de.uu.net> Aahz Maruch wrote: >In article <392ebd70$0$18389 at personalnews.de.uu.net>, >Johannes Stezenbach wrote: >>Why not? The global interpreter lock isn't released in the code of >>builtin_map() or builtin_reduce(), so no other thread can change the >>sequence while the map/reduce loop is running. > >IIRC, the global interpreter lock can get released when the function >gets called; it's possible that the lock can't get released if the >function is a built-in. In any event, my statement that map() and >reduce() (and also filter()) are not by definition thread-safe stands. After sleeping the night over it, I now see that my statement is rubbish because any number of thread switches can occur while the function argument to map/reduce is called. So only the map(None, S) special case is thread save... Johannes From dalke at acm.org Sun May 28 00:38:51 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 27 May 2000 22:38:51 -0600 Subject: [PATCH] A compromise on case - another suggestion References: <34575A892FF6D1118F5800600846864D35F585@intrepid> <8gpihf$set$1@nntp.Stanford.EDU> <8gq3pk$kpd$1@slb0.atl.mindspring.net> <3930990D.FE8D5F80@stud.ntnu.no> Message-ID: <8gq7mt$drb$1@slb0.atl.mindspring.net> Peter Schneider-Kamp wrote: >Andrew Dalke wrote: >> >> The IndexError check is also used to signify the end of the list, as in: > >Is that really so? From a quick look at the relevant sources I saw >at least some places where IndexError is checked. So you may be right. > >But does it have to be like that? Can't we use the length of the list >to check? You can check by implementing your own list-like object: class List: def __getitem__(self, i): if i == 5: raise IndexError, i return i def __len__(self): return 2 >>> for x in List(): ... print x ... 0 1 2 3 4 >>> I believe Python 1.4 was the switch from using __len__ to using an IndexError. The problem with __len__ comes when implementing list-like interfaces to objects which don't know their length, like a forward iterator. One example is the FileInput class in the standard library module 'fileinput'. >> BTW, the failure goes from O(1) to O(N) because it has to check >> every available value. I don't know internals well enough to know >> if getattr() is also affected by the patch - it shouldn't be. That >> would leave an O(1) test available. > >I don't understand this part. I would think printing the range >is O(1). Sorry, my fault for the confusion. That comment was meant to refer to the NameError exception patch of Nick's. I just assumed you would read my mind :) Andrew dalke at acm.org From walter at data.franken.de Mon May 1 18:46:12 2000 From: walter at data.franken.de (Walter Doerwald) Date: Tue, 02 May 2000 00:46:12 +0200 Subject: [Python-Dev] Re: Python 1.6a2 Unicode bug (was Re: comparing strings and ints) References: <39072F0C.5214E339@lemburg.com> <45919986@data.franken.de> <048501bfb0b4$c793d760$4add3fcb@neil> Message-ID: <45919997@data.franken.de> On Sun, 30 Apr 2000 17:43:10 +0100 Just van Rossum wrote: > At 9:56 AM +0200 28-04-2000, Walter Doerwald wrote: > > But I find UCS-2 much cleaner, because it's easily distinguished from > > ASCII/UTF-8/ISO8859-1/..., distinguishing between UTF-8 and ISO8859-1 has > > to be done by "external" methods. How does Python do it? > > It doesn't; it'll just assume utf-8... Ouch, does this means that I have to type my source code in plain ASCII, as long as I don't have a texteditor that doesn't save UTF-8, but only ISO-8859-1? This seems really bad to me. Bye... Walter Doerwald From scarblac-spamtrap at pino.selwerd.nl Sun May 14 17:13:55 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 14 May 2000 21:13:55 GMT Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> <8p6snvkyjdj.fsf@Eng.Sun.COM> Message-ID: Mike Coffin wrote in comp.lang.python: > Michael Hudson writes: > > > So create it by appending n elements and then reverse it... this is > > still n^2, I guess, but for the numbers you can deal with before the > > universe dies a heat death, this will be vastly quicker than anything > > else you can do in Python. > > Reversing a list is not N^2, it's linear in N. Appending is O(n^2) in theory, though, since the list has to be resized (and copied) every once in a while. In practice this effect is minimal, of course... -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From matt at mondoinfo.com Sun May 21 19:22:41 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 21 May 2000 18:22:41 -0500 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <39276946.90FE82A2@san.rr.com> Message-ID: <210520001822413314%matt@mondoinfo.com> In article <39276946.90FE82A2 at san.rr.com>, Courageous wrote: [snip] > The truth of the matter is that, irrespective of whether or > not a language is case sensitive or not, using inconsistent > case for the same thing is an extraordinarily bad idea, and > would be extremely poor engineering practice. [snip] I certainly agree that inconsistent capitalization of identifiers would be a bad idea. But I think that distinguishing identifiers by capitalization alone would be an equally bad idea. NewtonScript, the language used to program the old Apple Newtons is similar in many respects to Python (high-level, highly dynamic, object-oriented, byte-code compiled, etc.). It is case-preserving-but-ignoring. I haven't used NewtonScript in some years, but I don't recall any problems that were caused by its being case-insensitive. Indeed, I don't even remember anyone mentioning that aspect of the language. It's true that the projects NewtonScript was used for weren't enormous, but many were distinctly non-trivial. Regards, Matt From dfan at harmonixmusic.com Thu May 11 16:57:45 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 11 May 2000 16:57:45 -0400 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391AED9E.30C70EF@yahoo.com> Message-ID: Paul Winkler writes: | The key line is this, in my version: | | for f in friends[name]: | | Your version: | | for $f (@{ $friends{ $name } }) { | | > Of course, the de-referencing of the array reference looks bizarre, | ^^^^^^^^^^^^^ | | Yes, it does. :) More to the point, I got too frustrated with | staring at man perldsc and man perllol trying to understand it. Can | you explain the meaning of each bit of punctuation on that line? This is the wrong newsgroup, I realize, but I thought I should share the Rule That Makes Using Perl References Easy (well, straightforward, at least): Wherever you can normally use a raw variable name (sans punctuation prefix), you can use a reference. e.g., ${$ref} (or $$ref) is 'the scalar $ref' just as $foo is 'the scalar foo'. @{$friends{$name}} is 'the array $friends{$name}' just as @foo is 'the array foo'. That said, I like Python better than Perl too (except for ten-line text-munging programs). -- Dan Schmidt | http://www.dfan.org From neilh at scintilla.org Mon May 1 18:25:50 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 01 May 2000 22:25:50 GMT Subject: DCOM References: Message-ID: > I've read the DCOM stuff in Programming on Win32 but it seems to indicate I > have to register the script on the client (which would mean installing > Python). You may be able to just write a register script (.reg file) for a simple case where everything is static. If you have a recent version of the OS then you can write a small registration script in Javascript or VBS. If you have appropriate permissions, you can also edit or script registries on other machines. Neil From effbot at telia.com Mon May 29 14:12:10 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 29 May 2000 18:12:10 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> Message-ID: <_pyY4.10102$Za1.160118@newsc.telia.net> Johannes Stezenbach wrote: > >like, for example, joining strings efficiently? > > > >(If you don't see my point, try benchmarking your code vs. string.join > >on 10, 1000, 100000 substrings. Do you think the timing difference can > >be eliminated by writing your code in C?) > > So why not using the C equivalent of > > def join(self, separator): > if type(separator) == type(""): > # insert efficient implementation of current " ".join here > else: > result = self[0] > for x in self[1:]: > result = result + separator + x > return result > > and by that having both efficient (for strings) and general (usable for > other types) list element joining. have you looked at "string.join" in 1.6? here's the actual code: def join(words, sep = ' '): return sep.join(words) it's not that different from your example, with one notable exception: it doesn't work if the separator class doesn't provide an "efficient implementation of join". (on the other hand, it works for any type providing an implementation, not just 8-bit strings. python 1.6 has more than one string type, you know...) now, would your modified version be a great improvement over the current 1.6 release? that pretty much depends on your answers to these two questions: -- does "join" really make sense on things that are not strings? (hint: does "+" always mean concatenation? does "join" make sense if it doesn't? should join([1, 2, 3], 10) really return 36?) -- does it really matter if the implementation hook happens to be called "join"? in the current release, the answers are "no" (hypergeneralization) and "no" (no matter what it's called, people will find it and use it). if you have better answers, please motivate. > If I remember this right, the argument against list.join(separator) > was "don't put string knowledge in the list class". But with the above > implementation this is avoided because the efficient string joining > is just a special case optimization which isn't visible from the outside. oh, you just have to close your eyes and pretend it's not visible ;-) From pointal at lure.u-psud.fr Thu May 18 12:30:52 2000 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Thu, 18 May 2000 16:30:52 GMT Subject: Bit length of int or long? References: <000201bfc066$85951380$872d153f@tim> <200005181616.JAA03886@cj20424-a.reston1.va.home.com> Message-ID: <3924184d.3899038951@news.u-psud.fr> On Thu, 18 May 2000 09:16:30 -0700, Guido van Rossum wrote: >: >: In my defense: Francois didn't mention long ints in his first post. You'r= >: e >: right of course that a method of ints and longs is the right solution. An= >: other >: method should count '1' bits (useful when using long ints as sets of ints= >: ). As I remember, ADA has a "'Size" operation for number sizes (there is also other operations for floating point numbers characteristics). More generally, there may be a method in the sys module (as there is already one which return the reference counter of an object), like sys.getsize(x) which could return the full byte size of the object x, and sys.getdatasize(x) which could return the byte size of the object x without considering the header. [but I dont know if numbers have extra-datas and if such methods could be applicable]. Note the sys.maxint which can be used to find how bytes are used. A+ Laurent. --- Laurent POINTAL - CNRS/LURE - Service Informatique Experiences Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 email : pointal at lure.u-psud.fr ou lpointal at planete.net From rcc at nospamthanks_jennic.com Wed May 3 09:27:19 2000 From: rcc at nospamthanks_jennic.com (Robert Cragie) Date: Wed, 03 May 2000 13:27:19 GMT Subject: Any python code prettifiers out there? References: Message-ID: Have you looked at the standard 'pprint' module? http://www.python.org/doc/current/lib/module-pprint.html are-we-all-supposed-to-sign-off-like-this-ly yr's Robert Ryan wrote in message news:evrugs0ensnmom9nqfmlbv7cv9kff686b1 at 4ax.com... | I know that Python's syntax rules force one's code to be much more | readable by default than most other languages; however, in certain | instances, there still exist different styles that individual | programmers can use. | | Consequently, I'm wondering if there exists any Python equivalent to | the FSF program "indent" for C code. I would find this an extremely | useful tool for providing a quick way to make large sets of Python | source files follow a standard. As the simplest example of a feature | of such a program: it could line up consecutive assignment statements. | | I tried the search engine on python.org and I couldn't find anything | relevant. | | Thanks for any info :) | | --Ryan From markos at elite.org Sun May 21 11:01:59 2000 From: markos at elite.org (Marko Samastur) Date: Sun, 21 May 2000 16:01:59 +0100 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: <3927FA67.94D85CAF@elite.org> Fredrik Lundh wrote: > > http://www.alice.org/advancedtutorial/ConwayDissertation.PDF > > some relevant quotes: > > "Python is case sensitive. While we, as programmers, were com- > fortable with this language feature, our user community suffered > much confusion over it. At least 85% of users who were observed > using the Alice tutorial made a case error at some point during the > experience. While explaining the case rule was simple enough > ("upper and lower case mean different things to Alice"), this was > not sufficient to instill a "case aware" sense in our users. Of the > users who had problems with case, most continued to type case- > incorrect tokens in their programs for a short period. Coming to ^^^^^^^^^^^^ Part of every learning is making mistakes. Nobody picked up a bicycle and knew how to ride it immediately. If you make certain mistake only for a short period of time, I'd say whatever you are trying to do was quite well designed. Marko P.S: As mathematician I too quite like expressiveness that comes with case sensitivity. I also dislike the idea that integer math could go away. From scarblac-spamtrap at pino.selwerd.nl Thu May 4 03:06:19 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 4 May 2000 07:06:19 GMT Subject: Generating combinations with repetitions References: Message-ID: Tomaz Ficko wrote in comp.lang.python: > Can someone post code for generating all combinations of k elements out of n > elements with repetitions. > > Example: > elements = 1,2,3,4 and k=3 > > 111, 112, 113, 114, > 222, 221, 223, 224, > 333, 331, 332, 334, > 444, 441, 442, 443, > 123, 124, 134, 234 def combs(elements, k): length = len(elements) # Compute the numer of combinations n = long(length) ** k result = [] for combination in xrange(n): onecomb = [] for digit in range(k): onecomb.append(str(elements[combination % length]) combination = combination / length result.append(onecomb) return result Basically, it lists the numbers 0 to length**k, written in a base that uses 'elements' as its digits. -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From dale at out-think.NOSPAMco.uk Fri May 5 11:18:33 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 5 May 2000 16:18:33 +0100 Subject: Newby help References: <8epob5$jnk$1@supernews.com> Message-ID: <8euool$qdl$1@supernews.com> Thanks. I got it working. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Robert Cragie wrote in message news:newscache$jdb3uf$ltb$1 at jenpc07.jennic.co.uk... > The following works properly: > > def walk(dir, dent = 1): > print ">" * dent, dir > for item in os.listdir(dir): > if os.path.isdir(dir + '\\' + item): > walk(dir + '\\' + item, dent + 3) > else: > print " " * dent, item > > print "\n\n\n\n" > > walk("C:\\program files\\python\\") > > Robert Cragie > > Dale Strickland-Clark wrote in message > news:8epob5$jnk$1 at supernews.com... > | I'm learning Python - just for the hell of it really - but I don't > | understand what's going on here: > | > | import os > | > | def walk(dir, dent = 1): > | print ">" * dent, dir > | for item in os.listdir(dir): > | if os.path.isdir(dir + item): > | walk(dir + item, dent + 3) > | else: > | print " " * dent, item > | > | print "\n\n\n\n" > | > | walk("C:\\program files\\python\\") > | > | > | If I run the above code, it throws an "OSError: [Errno 3] No such process" > | error at the 'for' statement. > | > | This is on NT 4 and the os.listdir(whatever) works fine interactively. > | > | I know there's a walk function already but I'm trying to get the hang of > | this. > | > | Thanks for any help. > | > | -- > | Dale Strickland-Clark > | Out-Think Ltd, UK > | Business Technology Consultants > | > | > | > > From donn at oz.net Mon May 8 00:43:57 2000 From: donn at oz.net (Donn Cave) Date: 8 May 2000 04:43:57 GMT Subject: PyBalsa? References: Message-ID: <8f5gmd$ccm$0@216.39.151.169> Quoth Michael Hudson : [... re why mailers get written in C ... ] | Well, they could have done it in C++... | | I agree wholeheartedly with you. To me, implementing a MUA in C/C++ | is just silly. Use Python, use scheme, use lisp, use smalltalk, use | ocaml, use tcl, use perl (shudder) - use just about anything else, and | you're pretty likely to end up with a better, more stable solution | faster. | | Mind you, I hate all forms of GUI programming, some I'm not going to | write that killer MUA in Python ... it does surprise me that noone has | written one yet though. Or maybe they have, and I just don't know | about it? The thing about Python is that most of it's already done, thanks to the imaplib, poplib and smtplib modules. I wrote one for my own use on BeOS, and the library modules saved an awful lot of time. Mine isn't any kind of killer, though, and that's fine with me. I have enough troubles without trying to keep a bunch of email users happy. Maybe the strange breed of programmer who does want to take on that kind of grief has an altogether different outlook on life, where the advantages of Python aren't so obvious. I just wanted to get it done, these guys are going to be working on it the rest of their natural lives. I think there might be a handful of reasons why they want to write in C++. They want to keep their source private. They feel that it will be slow (that's mostly silly, but startup and some text processing can indeed be pretty pokey.) They don't want their program to be exposed to the vagaries of an interpreter that the user obtains, installs and maintains separately. Maybe they want to implement everything themselves, this is not uncommon, and the parts Python would do for them are the fun parts - remember, they have to write a GUI anyway. Donn Cave, donn at oz.net From dworkin at ccs.neu.edu Fri May 26 16:54:25 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 26 May 2000 16:54:25 -0400 Subject: global or not global? In-Reply-To: "Ralf Claus"'s message of "Fri, 26 May 2000 20:56:04 +0200" References: <8gmhe4$1m5$11$1@news.t-online.com> Message-ID: "Ralf Claus" writes: > class any(): > > def what(): > > def this(): > > def unknown(): > > How can i define a variable, they could change in all this functions? > And all functions must be read this variable! Just an example, using your class and method names: class any: def __init__(self): self.spam = 0 def what(self): print self.spam def this(self): self.spam = self.spam + 1 def unknown(self): self.spam = 0 To understand the use of 'self' there, read the standard Python documentation, especially the sections on classes. The tutorial is a good place to start. -Justin From moshez at math.huji.ac.il Mon May 1 01:23:51 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 1 May 2000 08:23:51 +0300 (IDT) Subject: Discrepency between JPython and CPython In-Reply-To: Message-ID: On 30 Apr 2000, Venkatesh Prasad Ranganath wrote: > Hi, > > Consider the expression str(1.14 * 200). > In CPython it yields 228.0 > In JPython it yields 227.99999999999997 > > Shouldn't this result in consistent values across variuos implementation? No. Don't use floats if you expect any kind of consistency. java-floats-are-fscked-up-any-way-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From ullrich at math.okstate.edu Thu May 18 14:09:50 2000 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 18 May 2000 18:09:50 GMT Subject: Decimals -> Fraction strings, my solution References: <3922bbbb.59529999@client.ce.news.psi.net> <3922E238.29CEDE3B@stud.ntnu.no> Message-ID: <39242f0a.1044508290@news> On Wed, 17 May 2000 20:17:28 +0200, Peter Schneider-Kamp wrote: >Dave Hansen wrote: >> >> A very nice implementation of Euclid's algorithm. I would suggest a >> couple small changes to make it more robust. Shouldn't hurt the >> efficiency significantly... >> >> > >> >def gcd(a, b): >> a = abs(a) >> b = abs(b) > >Probably a good idea given Python's implementation of modulo. Why does Python's implementation of modulo make this a good idea? Is there a problem with the "original" def gcd(a, b): while a: a, b = b % a, a return b that I've just never found? This is identical to a routine I've used for quite a while with no problem. (Of course gcd(a,b) sometimes comes out negative - if that's the problem what's the problem with that?) The reason the counter-quibble seems worth mentioning is that the abs makes it much less generic: Without the abs you can use the function for any objects with a __mod__ method (assuming that a has to eventually become false for some reason). For example you can use it to find the gcd of two polynomials a and b, if you give your polynomials an appropriate __mod__. (I don't think there's any such thing as an appropriate __abs__ for polynomials...) DU > >> if b > a: >> a, b = b, a > >This is IMHO absolutely unneccessary and just bloats the code. >Why do you want to check when in the case that b is greater >than a the first step just reverses the arguments? So in case >b is greater than a you trade in a division against a >comparison and more code. In the case that a is already >greater than b you gain nothing and pay a comparision and >more code. > >Ha det bra >Peter >-- >Peter Schneider-Kamp ++47-7388-7331 >Herman Krags veg 51-11 mailto:peter at schneider-kamp.de >N-7050 Trondheim http://schneider-kamp.de > From vogler123 at my-deja.com Tue May 23 19:09:06 2000 From: vogler123 at my-deja.com (vogler123 at my-deja.com) Date: Tue, 23 May 2000 23:09:06 GMT Subject: newbie python 1.5.2/Tk/WinNT install question Message-ID: <8gf327$76j$1@nnrp1.deja.com> Sorry to bother you all but I ran into a problem and after searching the archives on comp.lang.python I came up empty handed. I finally upgraded to python1.5.2/tk8.3/tcl8.3 on WinNT from python1.4. I went ahead and built python the following projects in Visual C++ 6.0 as per instructions: python15 python _tkinter Everything went as planned and I tried the following: C>python.exe >>> from Tkinter import * >>> root = Tk() I then got an "Application Error" dialog message stating that "The memory could not be "read". Debugging the application resulted in the following error message: "Unhandled exeption in python.exe (TK83.DLL) 0xC0000005: Access Violation" Does anyone out there in Python-land know what I am doing wrong? Everything else appears to be working fine (tried out testpy.py). It appears to be a problem with Tcl/Tk. TIA Bill Vogler PS - please also respond via email also Sent via Deja.com http://www.deja.com/ Before you buy. From dagchess at frognet.net Mon May 15 11:00:49 2000 From: dagchess at frognet.net (Nathan Gundlach) Date: Mon, 15 May 2000 11:00:49 -0400 Subject: Stand-alone Python Apps? References: <4fUT4.20380$HG1.517119@nnrp1.uunet.ca> Message-ID: Thanks a bunch! I'll look into this. If it's as good as it sounds, it's great. Maybe I should clarify exactly what I mean by "stand-alone." All I want to create is a simple program with a GUI that does not require that Python be installed on my end user's computer. Warren Postma wrote in message <4fUT4.20380$HG1.517119 at nnrp1.uunet.ca>... > >"Nathan Gundlach" wrote in message >news:X0TT4.1732$W45.3792 at newsfeed.slurp.net... >> Is there any way to create stand-alone apps in Python that I can use on >> Windows, Linux/UNIX, and Mac? > > >I would like a tool which would create source archives, binaries for >Win-x86, Linux-x86, and Mac PPC, handling all possible Windows DLLs, Unix >Shared Libraries, and Mac shared libraries, various GUI toolkits, etcetera, >etcetera. Once I have a tool that complicated I should only have one more >step to make a really useful python utility.... one that could write most >of my application for me while I'm at it! > > >Seriously, I think there is some room for improvement in making Python >programs easier to "pack and go". There are several tools out there that you >should examine, search for Install and Freeze on the Python Search Page for >starters. > >I think you'll need to narrow down your search by choosing an appropriate >GUI toolkit and other packages you'll need to use. Once you've built one >installer, the rest will be a cinch. Python can be used for so many >purposes, some of which are portable, and some of which are not, that I can >hardly see a single universal Installer Tool. > >Making such a tool would be complicated by the many binary and python >extensions available for Python. If you use any DLL extensions (.pyd files >on Windows) then your program is not going to fit in a single file. If >standalone means "make a nice install program" then I'm sure many people are >working on improving their installer scripts, but I am not aware of any one >tool that is aware of all the things like Tcl/TK, wxPython, and whatever >other extension DLLs or Scripts you might use in your application. > >The closest you're going to get is manually building three separate binary >installation programs, one for each platform, plus providing separate copies >of the source/script files. Then users might pick and choose between them, >and everybody might be reasonably happy. Except you, because it's a lot of >work making all those binary installation programs. > >The other thing is that Python programs provided as source are inherently >more useful because you can change them. I suspect that a Python program >distributed without its source is going to be a lot less popular. > >Has anyone formed a project or SIG to discuss simplifying installation and >deployment of Python applications, including the various GUI toolkits >around? My own bias is towards wxPython. I am hoping Boa Constructor will >include a deployment wizard to help make shipping applications to people who >don't have Python and WxWindows + WxPython a little bit easier. > >Warren > > > From emile at fenx.com Mon May 15 14:42:04 2000 From: emile at fenx.com (emile at fenx.com) Date: Mon, 15 May 2000 11:42:04 -0700 Subject: newbie confession Message-ID: <392044FC.DDC944FC@fenx.com> HI STEVE! Emile van Sebille emile at fenx.com sn wrote in message news:<39203962.2685CFB3 at yahoo.com>... > My name is Steve and I'm a Pythonoholic. > > It started innocently enough. Like many people, I experimented with > BASIC. It was just for fun. "I can quit any time I want," I said. > > Then I found the Web and started coding HTML. "Just one more page and > I'll quit," I kept telling myself. But soon I was dabbling in > Javascripts. "It's just a phase," my friends said. I struggled to hide > my all night Java compiling binges. > > I started downloading C/C++ tutorials, but before I could get my hands > on a compiler, I ran into Python. > > Soon I was up to three, four scripts per day. I needed help. My > bookstore sold me books by Lutz and Grayson. I was building Tk gui's. > It was getting hard to hide my habit from co-workers. > > Then the boss confronted me: "Can you write something to make this > project work?" > > "I don't know, but let me try," I said, trying to hide my grin. In two > weeks I came up with something the $1000-a-day consultant said wasn't > doable. > > So, yes, I am hooked. > > My name is Steve, and I'm a Pythonoholic. > > > -- > http://www.python.org/mailman/listinfo/python-list > From mnot at mnot.net Thu May 11 01:33:02 2000 From: mnot at mnot.net (Mark Nottingham) Date: Wed, 10 May 2000 22:33:02 -0700 Subject: Filtering web proxy In-Reply-To: <8dgigi$89e$1@nntp.Stanford.EDU>; from amitp@Xenon.Stanford.EDU on Tue, Apr 18, 2000 at 02:49:54AM +0000 References: <8dgigi$89e$1@nntp.Stanford.EDU> Message-ID: <20000510223302.A10511@mnot.net> On Tue, Apr 18, 2000 at 02:49:54AM +0000, Amit Patel wrote: > Even with a fast connection, there are still things like filtering out > pop-ups, blocking cookies from certain sites, forcing pages to be > cachable (by modifying Cache-Control headers .. evil evil!) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Naughty! There's enough confusion out there already... *grin* -- Mark Nottingham http://www.mnot.net/ From darrell at dorb.com Wed May 17 00:02:34 2000 From: darrell at dorb.com (Darrell Gallion) Date: Tue, 16 May 2000 21:02:34 -0700 Subject: Decimals to fraction strings Message-ID: <002101bfbfb4$bd221850$6401a8c0@home> Check out http://www.dorb.com/darrell/numberTheory/numberTheory.py --Darrell Gallion "Scott" wrote in message news:slrn8i1cv1.8mf.kain at cableadmin.com... > Hi, > > Does anyone know of a way to convert decimal numbers to a string > representation of the fractional value? For example: > 0.5 = "1/2" > or > 1.125 = "1 1/8" > > Thanks, > Scott > > -- > http://www.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at jessikat.demon.co.uk Fri May 12 04:14:06 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 12 May 2000 09:14:06 +0100 Subject: py2pdf --> can't get thisPageRef -- not declared inPage ??? HELP! References: <8fg22f$qu9$1@nnrp1.deja.com> Message-ID: In article <8fg22f$qu9$1 at nnrp1.deja.com>, rayleyva at my-deja.com writes ... I assume you have the recent py2pdf 0.5; which version of ReportLab? What command line did you use? I have been using py2pdf recently to print windows from idle I didn't see that mesage, but it may be I'm using the latest and greatest reportlab. -- Robin Becker From stephen at cerebralmaelstrom.com Mon May 15 04:26:31 2000 From: stephen at cerebralmaelstrom.com (Stephen) Date: Mon, 15 May 2000 08:26:31 GMT Subject: Python(path) and the location of the Python DLL. Message-ID: Hello, all. I'm working on embedding Python into a program i'm working on in C++Builder. I got past the problem of importing VC++ DLLs into C++Builder by searching Dejanews, so now before I continue I have a couple questions... #1) I'll be using the latest version (1.6a2), but I don't want it to get involved with any current versions running on the same machine. Is there anything wrong with me renaming the DLL? #2) Where can I change the registry key that my DLL looks for to find the python path information? Thanks, --S From pinard at iro.umontreal.ca Wed May 17 15:42:43 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 May 2000 15:42:43 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: Michael Hudson's message of "17 May 2000 10:49:10 +0100" References: Message-ID: Michael Hudson writes: > You have the right approach (continued fractions), but you're > implementation is more complex than it needs to be. [...] Same numbers > as before, but rather less effort to get them, I think. Thanks for sharing this. Your solution computes a single continued fraction to the maximum precision, and then uses it to show the successive approximations up to that maximum precision. Which surely is a good thing. My solution computes a single continued fraction, but stops the computation when some error tolerance has been reached. I then called the whole thing many times to make experiments, resulting indeed in much total work. In practice, I guess it is programmatically easier to decide of some tolerance in advance, and find a single solution from it, than to find all solutions up to the maximum precision possible, and later scan all these to decide which is one that should be retained. Yours is surely more entertaining when used interactively! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From quinn at riyal.ugcs.caltech.edu Sat May 13 11:07:51 2000 From: quinn at riyal.ugcs.caltech.edu (Quinn Dunkan) Date: 13 May 2000 15:07:51 GMT Subject: Passing by value instead of reference References: Message-ID: On Wed, 10 May 2000 13:33:52 -0600, Jeff Massung wrote: >Sorry, I don't ;) - I was thinking like this (I understand how my previous >example was wrong). > >>>> def test(x): > x.append(3) >>>> z = [1,2] >>>> test(z) >>>> z >[1, 2, 3] >>>> > >How can I get x to have the value of z, modify it, and use the modified >value, without z being modified overall? Thanks, guys ;) Make a copy: def test(x): x_copy = x[:] x_copy.append(3) print x_copy z = [1, 2] test(z) Although usually I'd write a function to operate on its args in place, and the caller can pass a copy if that's what he wants. Actualy, usually I write a method which naturally operates on its self in-place :) Also see the `copy' module for deep copies. From effbot at telia.com Mon May 29 19:52:25 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 29 May 2000 23:52:25 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> Message-ID: Courageous wrote: > > > > words = ["foo", "bar", "baz"] > > > print words.join(" ") > > > print ( "foo", "bar" ).join(" ") > > I've thought about this for a bit, and it's quite clear to me that > these idoms are the natural representation for this. Whether or > not their implementation in python is easily/optimally acheived > is another issue altogether, but this representation is natural > and, IMO, right one. ...and here we go, back to the beginning of this thread... as people have pointed out a couple of hundred times in this thread, lists and tuples are *heterogeneous* containers. you can put *any* kind of Python object in them, not just strings. for other arguments against your "natural" and "righteous" solution, check the archives. or don't -- I'm sure your time could be better spent on hunting down real problems in the 1.6 alphas... From m.faassen at vet.uu.nl Sun May 28 17:48:42 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 May 2000 21:48:42 GMT Subject: Java vs Python References: <8goqht$439$1@nnrp1.deja.com> Message-ID: <8gs47q$m7m$7@newshost.accu.uu.nl> faatdilac at my-deja.com wrote: [snip] > It's a thankless & shameless attitude to say that C is not generally > useful while C has been feeding generations of software professionals. Have you actually observed this thankless and shameless attitude towards C in this thread? Some people have said they didn't think C was the ideal language for everything, basically, and that's just plain true. C's fine for what it does, but C is not always the right answer. Would it be a thankless and shameless attitude to say that MSDOS is not generally useful while MSDOS has been feeding generations of software professionals? :) Not that I'm comparing C with MSDOS here, it's just that this argument by itself doesn't make much sense. > The name Dennis M. Ritchie shines as long as Perl, Tcl/Tk, Python exist. > Show me a commercially successful language compiler developed in any of > the scripting languages. Show me an OS developed in any of the > scripting languages. So C is good for what it does; it's a systems programming language. You use it when you want to have some portability but still low-level access and speed. An interpreted language is generally not the ideal solution for these tasks. Anyway, you sound as if C's under attack here. I don't think it is. It's just people discussing its relative merits. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkraska1 at san.rr.com Sat May 13 01:34:09 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 05:34:09 GMT Subject: python improvements (Was: Re: New Language) References: Message-ID: <391CE9E8.C7D9305@san.rr.com> > all-problems-are-ancient-as-are-all-cures-ly y'rs - tim Okay. That's it. I *give*. Here I've been quietly thinking nobody will notice I'm not part of the "in crowd". I admit it. I'm a newbie. Wazzup-wit-all-dis-ell-why-shit-braddah? C/ From fdrake at acm.org Tue May 30 17:21:34 2000 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 30 May 2000 17:21:34 -0400 (EDT) Subject: os.linesep under Windows In-Reply-To: <20000530165508.A16926@corrada.com> References: <14644.9070.713948.988357@cj42289-a.reston1.va.home.com> <20000530165508.A16926@corrada.com> Message-ID: <14644.12510.157556.765244@cj42289-a.reston1.va.home.com> andres at corrada.com writes: > This one has bitten me in the past, but on a Mac. Am I correct in saying > that the way sys.write( os.linesep ) works on the Windows platform is: The C stdio functions convert '\n' to the underlying operating system's line separator; that's what their supposed to do. (The stdio functions are the ones that operate on FILE* values, not file descriptors.) So '\n' converts to '\x0D\x0A' ('\r\n') in the C libraries, and that's what appears in the file. The '\x0D\x0A' is converted back to '\n' when read back in. Note that these conversions are not performed if the file is opened in binary mode; open(..., 'wb') does not enable this conversion. This doesn't actually have much to do with Python, but rather with the underlying libraries. > Fred, out of curiosity, what applications need to worry about os.linesep > and/or what are those few cases where it should be used directly? I think sockets are always opened in binary mode, so this could be useful when sending data over a socket, but it assumes that the other end uses the same line separator as the local host (a bad assumption!). The most reasonable use is when converting text that uses any line separator (or a mix) to the local separator, but that's a stretch. I'm not sure what the specific situation was that called for the addition of os.linesep. Perhaps someone needed to be able to predict the value that would be returned from .tell() after writing a line separator? That sounds a little bogus, but only a little. -Fred -- Fred L. Drake, Jr. From akuchlin at mems-exchange.org Sat May 20 14:28:05 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 20 May 2000 14:28:05 -0400 Subject: Damnation! References: Message-ID: <3dvh09cc0a.fsf@amarok.cnri.reston.va.us> Michael Hudson writes: > s/months/weeks/ I thought? I mean, June 1 was the projected release > date, wasn't it? In theory, but software is always late and free software is no exception to that rule. Given that there hasn't even been a beta yet, and there are serious things such as a new version of SRE to be dropped into place, to aim for a 1.6 final for June 1 is completely impossible. I'd expect the usual 3 beta versions to shake out all the minor issues that usually pop up. -- A.M. Kuchling http://starship.python.net/crew/amk/ Since I've done fewer than my normal quota of futile things this week, I thought I'd post to remind people that ... -- Phil Austin, 9 Dec 1999 From aahz at netcom.com Fri May 26 10:46:47 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 May 2000 14:46:47 GMT Subject: Dictionaries and Threads References: <3926A8EF.C3C1914B@jslove.net> Message-ID: <8gm2on$2ju$1@slb6.atl.mindspring.net> In article <3926A8EF.C3C1914B at jslove.net>, Jay Love wrote: > >Are dictionary lookups threadsafe? > >ie, can I lookup and retrieve an item in a dictionary while another >thread is adding an item? In general yes, if you do it in single lines of code: Thread1: var = dict['foo'] Thread2: dict['foo'] = 'bar' However, if you have something like this if dict.has_key('foo'): var = dict['foo'] else var = None it is *not* thread-safe and you need to use some kind of locking mechanism. Of course, in this specific instance, you can replace the above code with a single line: var = dict.get('foo',None) Note very carefully, though, that map() and reduce() are not thread-safe. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From pinard at iro.umontreal.ca Mon May 22 13:33:24 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 13:33:24 -0400 Subject: Case sensitivity/insensitivity In-Reply-To: Bjorn Pettersen's message of "Mon, 22 May 2000 10:12:56 -0600" References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> <39271A25.A348E4B9@roguewave.com> <39295C88.EFEDE889@roguewave.com> Message-ID: Bjorn Pettersen ?crit: > as (with the Norwegian mapping...): > s? lenge som 1: > linje = f.lesLinje() > hvis ikke linje: > brekk > ... > hey, it's much easier for every Norwegian speaking person (and I'm sure > the f-bot can read it too ;-) I'd loved this as well, for French. (When using Pascal, we also had French keywords, and it was delightful for the local community.) It might especially please the adoption of Python for teaching programming to younger children. English keywords are kind of unacceptable. Yet, I was once chatting with Guido about internationalisation matters, and he quite misread or misinterpreted one of my suggestion, and thought I was proposing international keywords, to which he violently objected, to my surprise. But the impression remained to me that Guido seems reluctant to such things. So, a consequence is that CP4E might well be CP4ESE after all (the last two letters meaning "speaking English" :-). A bad point for Python in schools. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From python at commandprompt.com Fri May 26 11:22:29 2000 From: python at commandprompt.com (python at commandprompt.com) Date: Fri, 26 May 2000 08:22:29 -0700 (PDT) Subject: [OT] OpenSource Documentation Fund In-Reply-To: Message-ID: For Immediate Release: OpenDocs Publishing announces: The Open Source Documentation Fund. The Fund, which will be driven by sales from OpenDocs Books is being implemented to help invigorate the Open Source Documentation Community. Traditionally documentation has been the lame duck of the Open Source community. Although the documentation is usually technically accurate it is difficult for new users to understand or written in what we like to call "Geek Grammar". Geek Grammar isa mix between leaving out punctuation and having 65 word sentences. Although Geeks usually can read this without blinking an eye, novices geeks sometimes have a problem interpreting the point an author is trying to make. The Fund will have an selective bid process that allows people and businesses to submit a request for funds for documentation. Although the final implementation details have yet to be solidified this is what we do know: 1. Authors will be able to request funds for work on existing projects 2. Authors will be able to request funds for new (yet to be written) projects 3. People and Companies will be able to request that a project be started 4. People and Companies will be able to request that a document or project be updated or edited. 4. Editors will be hired to help authors keep their writings readable 5. There will be a set amount per book sold that is set aside for the fund The second book OpenDocs published; Administrating Linux: The Basics is the first that will be part of this fund. The book is available now from leading Linux sites such as: http://www.linuxports.com and http://www.linuxcentral.com. Every time somebody purchases the book Administrating Linux: The Basics OpenDocs will place 3.00-5.00 USD into the fund. If we sell 1000 books we will disperse anywhere from 3000.00-5000.00 in to the fund. If we sell 5000 books we will disperse anywhere from 15,000-25,000 into the fund, etc... More information about OpenDocs Publishing can be found at http://www.opendocspublishing.com From senn at maya.com Wed May 10 16:21:11 2000 From: senn at maya.com (Jeff Senn) Date: 10 May 2000 16:21:11 -0400 Subject: PalmPilot and python In-Reply-To: Jeff Collins's message of "Wed, 10 May 2000 11:00:22 -0700" References: <8fc11i$9q8$1@nnrp1.deja.com> <14617.37067.507992.310545@malibu.aero.org> Message-ID: Jeff Collins writes: ... > memory. First, on the PalmIII (PalmOS 3.0), there is only about 48K > (roughly 96K total) of usable heap space, a large portion of which the > python VM gobbles upon initialization. This is improving on the newer > devices, which contain as much as 256K of heap. The small 4K stack FWIW- on a similar project we are considering writing a malloc-ish thing for the Palm that uses a records in a "scratch database" as "heap".... just a thought... (Gah! I wish they got PalmOS right-er...at least it's not WinCE...) Any psychic energy I can send along to aid the Palm port is on its way... ;-) -Jas From invalid.address at 127.0.0.1 Fri May 5 18:00:59 2000 From: invalid.address at 127.0.0.1 (David) Date: Fri, 05 May 2000 22:00:59 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> Message-ID: <39144449.8020228@news.telus.net> On 4 May 2000 22:24:16 GMT, kc5tja at garnet.armored.net (Samuel A. Falvo II) >Then I realized, "You know -- it's just not worth it." We're arguing over >personal preferences here. But I was still angry enough to not just let it >go myself. > >So in the end, I too need to apologize. God, I love this newsgroup/community! I haven't programmed a line of Python in about a year, but I'm still reading and learning, just because it's so *nice* to be here. Thanks to *every* sane and sensible person who has ever, or will ever, post their thoughts, their help, their questions and their ideas here! From debl.nospamm at world.std.com Sat May 13 02:30:09 2000 From: debl.nospamm at world.std.com (David Lees) Date: Sat, 13 May 2000 06:30:09 GMT Subject: Help for a newbie trying to run PIL Message-ID: <391CF66F.B64C1F2E@world.std.com> I have tried installing PIL and am running Python 1.5.2 under Win95. When I try running the viewer.py script I get the following errors. Sorry about cr/lf being messed up. I just did a paste and cut. Could someone point me to documentation on installing and using PIL? Thanks. David Lees PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au) >>> Traceback (innermost last): File "g:\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "G:\Python\py152\Scripts\viewer.py", line 44, in ? UI(root, im).pack() File "G:\Python\py152\Scripts\viewer.py", line 23, in __init__ self.image = ImageTk.PhotoImage(im) File "g:\Python\PIL\ImageTk.py", line 67, in __init__ image.load() File "g:\Python\PIL\ImageFile.py", line 117, in load self.map = Image.core.map(self.filename) File "g:\Python\PIL\Image.py", line 40, in __getattr__ raise ImportError, "The _imaging C module is not installed" ImportError: The _imaging C module is not installed Exception exceptions.AttributeError: '_PhotoImage__photo' in The usual thing when there is a difference between running interactively and as a CGI is something to do with permissions. Because the problem crops up when you are trying to do a delete I suspect this is the cause. You probably created the database and when you are running the script interactively your script, which inherited your permissions, is able to delete. When the CGI gets called from the web page it will be running with the permissions of the web server. Those are usually deliberately set to deny such things as deleting. In other words, read but don't write. The solution probably depends on your operating system and the web server, but this is where I'd start to look. Good luck, -Doug- > -----Original Message----- > From: Rob Elder [mailto:rob at electric-id.com] > Sent: Saturday, May 27, 2000 9:37 PM > To: python-list at python.org > Subject: cgi odbc sql delete ? > > > Hello, > > I have a problem that is driving me crazy. > I have created a set of routines to do sql functions (odbc, > access) in a > cgi script. When the script runs the Insert routine works but > the Delete > does not. However, in the interactive Python window on the > very same server > both function work fine. The code is referenced below fyi. If > I comment the > actual delete line in the routine out, there is no problem. There is > something wrong with: > > dbcursor.execute("DELETE FROM userTable WHERE userID = %s" % sysID) > > It probably is a format problem (???) but I don't know what > it is. If the > problem is not obvious, please give me some ideas on how to > debug this. I > have totally run out of ideas. TIA. > > -r > > REFERENCE_________________________ > > def DeleteRecord(sysID): # this does not work cgi but does work > interactively > > dbconn = odbc.odbc('xFrame_db') > dbcursor = dbconn.cursor() > dbcursor.execute("DELETE FROM userTable WHERE userID = > %s" % sysID) > dbcursor.close() > dbconn.close() > > def InsertRecord(sysID): # this works both interactively and cgi > > dbconn = odbc.odbc('xFrame_db') > dbcursor = dbconn.cursor() > dbcursor.execute("INSERT INTO userTable (userID) VALUES > (%s)" % sysID) > dbcursor.close() > dbconn.close() > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From jkraska1 at san.rr.com Sun May 7 21:27:50 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 08 May 2000 01:27:50 GMT Subject: Tricks to do "enums"? Message-ID: <391618DF.19F55C6C@san.rr.com> So, I've been doing module level enums like this: ## My module VAL1=0 VAL2=1 VAL3=3 While this works, and gives me great namespace protection (individuals using my "enum" prefix it with the module name), I'm wondering if there's any trick that will produce these without requiring me to renumber them? I'm getting tired of typing in new numbers for them if I decide to reorder them or insert elements... C/ From noreply at nospam.org Sun May 14 16:25:24 2000 From: noreply at nospam.org (Brian) Date: Sun, 14 May 2000 20:25:24 GMT Subject: GUIs References: <7ACS4.5039$ur1.107262@news6-win.server.ntlworld.com> <391cb04a.62616489@news.telus.net> Message-ID: I believe they now have support for the Scintilla (http://www.scintilla.org/) text editing component as part of wxPython. Download it and give the demo ago. HTH "Cliff Crawford" wrote in message news:slrn8hs4k6.bv.cjc26 at localhost.mindriot.net... > * David menulis: > | > | Certainly [wxPython] has become much more powerful over the past year. > | Rather remarkable, some of the things it can do now. Grids, especially... > > Does it have anything like the Tk Text widget? > > > -- > cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ > "One man's nirvana is another man's map." icq 68165166 From gherman at darwin.in-berlin.de Wed May 10 10:50:33 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Wed, 10 May 2000 16:50:33 +0200 Subject: ANN: py2pdf 0.5 - Code coloring and printing with PDF Message-ID: <39197739.2E654631@darwin.in-berlin.de> This is to announce the availability of py2pdf 0.5. I wrote this mostly for providing embellished and (inden- tation-)fool-proof versions of Python source code for ma- gazine publishers, but quickly found out it would be use- ful for teaching/presenting/reviewing/printing Python code, too. A nice new feature in 0.5 is the ability of browsing more intelligently through the code using PDF bookmarks that will point you directly to all class/method/function defi- nitions, at least in Acrobat Reader. You'll find py2pdf 0.5 (with lots of examples) either in the eGroups.com vault of the ReportLab users group in the same place (you'll need to become a group member first) or in my temporary home for stuff that has been lost after the Starship desaster: http://www.egroups.com/files/reportlab-users/dinu http://me.in-berlin.de:8080/members/DinuGherman Needless to say, I appreciate all feedback, Regards, Dinu -- Dinu C. Gherman ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From tim_one at email.msn.com Mon May 29 22:44:24 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 29 May 2000 22:44:24 -0400 Subject: Triple quote problem in Pythonwin In-Reply-To: <6956js4qo9jamd6i86iccch7blsct7qs6n@4ax.com> Message-ID: <000001bfc9e0$f764d120$742d153f@tim> [dej] > ... have come across a problem with triple quotes in Pythonwin > build 125. For example, the following results in a > "SyntaxError: invalid token" in Pythonwin: > > s=""" > > or if I type in: > > """Here is a very long string that can > if we wish span several... > > I get the "SyntaxError: invalid token" as well. Works for me: >>> s = """Here is ... a not so very ... long line""" >>> s 'Here is\012a not so very\012long line' >>> That's pasted from a PythonWin build 125 shell. > ... I am running Win98 Japanese version but I don't think the > problem is related to the OS. The above was from Win95 US. Something to try: at the end of the line, press & hold the Ctrl key while you hit ENTER. If that works, ask Mark Hammond to explain why; if that doesn't work, ask Mark why it doesn't . long-lines-short-lives-ly y'rs - tim From paul at prescod.net Fri May 26 14:57:54 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 26 May 2000 13:57:54 -0500 Subject: Beginners' Question -- Assigning variables in a lambda References: Message-ID: <392EC932.4141FB51@prescod.net> > After I've done my getopt (or maybe instead, if I can get this to work) I > want to avoid the if/elif/else from hell by having a dictionary of > parameter names and functions, something like: Lambda is just a short form syntax for function definition and assignment. You can set up a dictionary of plain old functions: def setBandwidth: bandwidth = get_number(" + x + ")" handler={"b":setBandwidth} -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From g2 at seebelow.org Fri May 26 17:14:15 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 26 May 2000 22:14:15 +0100 Subject: IDEs, ID or EGO? (was: Decimals -> Fraction strings, my solution References: <3921D4C6.91B2090F@acm.org> <39221911.C3FB9056@san.rr.com> Message-ID: <392EE927.38A0@seebelow.org> Courageous wrote: > > > Just because M$ doesn't want to reveal all the command line > > options to work from outside of their "visual" environment doesn't mean > > the language requires it > > Ironically, I'm in Visual Studio right now using GVIM. This > works fine. You just get this annoying "the file such-n-such > has changed, would you like to load it?" every time you context- > switch. All you do is hit return and it goes away. Very easy > to tolerate for the pleasure of using the World's Greatest > Editor (tm). This is probably a good time to confess that I've recently taken to using Visual Studio as my Python IDE. I tried Pythonwin, which is very, very good, but I got frustrated with the fact that each time I tried to run my revised Python code, it seemed to remember the old version. (Maybe there's a workaround, but the easiest one I've found is to use an IDE that isn't written in Python. ;-) Now, if only Visual Studio could be configured to do Python syntax highlighting... not-only-is-free-software-free,-the-right-to-complain-about-it -is-too--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From jwiegley at inprise.com Fri May 19 15:10:08 2000 From: jwiegley at inprise.com (John Wiegley) Date: 19 May 2000 12:10:08 -0700 Subject: Attribute support and multi-threading for Pyro Message-ID: The following diffs will add remote attribute getting/setting support to Pyro, as well as threading (pass "threaded = 1" to Pyro.core.Daemon). These were sent to the author, but he must be very busy, and I would like further comments by anyone else who is using Pyro. These diffs (which can be merged with your sources using 'patch') are against the 1.1 package, which was announced recently. ---------------------------------------------------------------------- --- Pyro/core.py Mon May 8 13:11:21 2000 +++ Pyro/core.py Fri May 19 11:55:43 2000 @@ -52,6 +52,23 @@ args=args[:-1]+args[-1] return apply(getattr(self.delegate,method),args,keywords) +class ObjBaseWithAttrs(ObjBase): + def remote_hasattr(self, attr): + attr = getattr(self, attr) + if attr is not None: + from types import MethodType, BuiltinMethodType + if type(attr) in (MethodType, BuiltinMethodType): + return 'method' + else: + return 'attr' + return 0 + + def remote_getattr(self, attr): + return getattr(self, attr) + + def remote_setattr(self, attr, value): + return setattr(self, attr, value) + ############################################################################# # @@ -147,10 +164,13 @@ def __init__(self, URI): self.URI = URI self.objectID = URI.objectID - self.adapter = Pyro.protocol.getProtocolAdapter(self.URI.protocol) - self.adapter.bindToURI(URI) + self.adapter = None def __getattr__(self, name): + # allows one of these to be safely pickled + if name != '__getinitargs__': self._name=name; return self.__invokePYRO__ + else: + raise AttributeError() def __repr__(self): return '' def __str__(self): @@ -159,10 +179,67 @@ # Note that a slightly faster way of calling is this: # instead of proxy.method(args...) use proxy('method',args...) def __call__(self,method,*vargs, **kargs): - return self.adapter.remoteInvocation(method,RIF_Varargs|RIF_Keywords,vargs,kargs) + self._name = method + return self.__invokePYRO__ def __invokePYRO__(self, *vargs, **kargs): - return self.adapter.remoteInvocation(self._name,RIF_Varargs|RIF_Keywords,vargs,kargs) + if self.adapter is None: + self.adapter = Pyro.protocol.getProtocolAdapter(self.URI.protocol) + self.adapter.bindToURI(self.URI) + return self.adapter.remoteInvocation(self._name, + RIF_Varargs|RIF_Keywords, + vargs,kargs) + def __getstate__(self): + temp = {} + for key in self.__dict__.keys(): + if key != "adapter": + temp[key] = self.__dict__[key] + return temp + + def __setstate__(self, value): + for key in value.keys(): + self.__dict__[key] = value[key] + self.__dict__['adapter'] = None +class DynamicProxyWithAttrs(DynamicProxy): + def __init__(self, URI): + self.attr_cache = {} + DynamicProxy.__init__(self, URI) + + def remote_getattr(self, attr, value = 0): + if value: meth = 'remote_getattr' + else: meth = 'remote_hasattr' + self._name = meth + return self.__invokePYRO__(attr) + + def findattr(self, attr): + if self.attr_cache.has_key(attr): + return self.attr_cache[attr] + + # Go look it up, and cache the value + self.attr_cache[attr] = self.remote_getattr(attr) + return self.attr_cache[attr] + + def __setattr__(self, attr, value): + result = self.findattr(attr) + if result == 'attr': + self._name = 'remote_setattr' + return self.__invokePYRO__(attr, value) + else: + raise AttributeError() + + def __getattr__(self, attr): + # allows one of these to be safely pickled + if attr != '__getinitargs__': + result = self.findattr(attr) + if result == 'method': + self._name = name + return self.__invokePYRO__ + elif result is not None: + return self.remote_getattr(attr, 1) + else: + raise AttributeError() + else: + raise AttributeError() ############################################################################# # @@ -173,7 +250,7 @@ ############################################################################# class Daemon(Pyro.protocol.TCPServer): - def __init__(self,protocol='PYRO',port=0): + def __init__(self,protocol='PYRO',port=0,threaded=0): self.hostname = Pyro.protocol.getHostname() if port: self.port = port @@ -185,10 +262,12 @@ self.adapter = Pyro.protocol.getProtocolAdapter(protocol) self.adapter.setDaemon(self) try: - Pyro.protocol.TCPServer.__init__(self, DaemonSlave(), self.port) - except socket.error: - Log.error('Daemon','Couldn\'t start Pyro daemon- already running?') - raise DaemonError('Couldn\'t start Pyro daemon- perhaps it\'s running already?') + Pyro.protocol.TCPServer.__init__(self, DaemonSlave(), self.port, + threaded) + except socket.error, msg: + text = 'Couldn\'t start Pyro daemon: ' + str(msg) + Log.error('Daemon', text) + raise DaemonError(text) def __del__(self): # server shutting down, unregister all known objects in the NS @@ -219,10 +298,13 @@ self.implementations[object.GUID()]=(object,name) # register the object with the NS if self.NameServer: - self.NameServer.register(name,PyroURI(self.hostname,object.GUID(), - protocol=self.protocol,port=self.port)) + URI = PyroURI(self.hostname,object.GUID(), + protocol=self.protocol,port=self.port) + self.NameServer.register(name, URI) + return URI else: Log.warn('Daemon','connecting object without naming service specified:',name) + return None def disconnect(self,object): try: @@ -303,4 +385,3 @@ _initGeneric_post() if banner: print 'Pyro Server Initialized. Using Pyro V'+Pyro.PYRO_VERSION - --- Pyro/protocol.py Sun May 7 13:40:35 2000 +++ Pyro/protocol.py Fri May 19 11:59:05 2000 @@ -7,8 +7,9 @@ # ############################################################################# -import select, socket, struct +import select, socket, struct, time import Pyro +from threading import Thread from Pyro.util import pickle, Log from Pyro.errors import * @@ -176,7 +177,7 @@ #-------- TCPServer base class class TCPServer: - def __init__(self, requestServer, port): + def __init__(self, requestServer, port, threaded): self.slave = requestServer self.slave.daemon=self self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -184,6 +185,8 @@ self.sock.listen(5) self.connections = [] self.setParamsForLoop(5) + self.threaded = threaded + self.handling = [] def __del__(self): if len(self.connections)>0: Log.warn('TCPServer','Shutting down but there are still',len(self.connections),'active connections') @@ -202,30 +205,51 @@ self.adapter.sendAccept(csock) self.connections.append(conn) Log.msg('TCPServer','new connection from',addr,'#conns=',len(self.connections)) + return conn else: # we have too many open connections. Disconnect this one. Log.msg('TCPServer','Too many open connections, closing',addr,'#conns=',len(self.connections)) self.adapter.sendDeny(csock) + return None + + def handleRequest(self, c): + try: + time.sleep(.001) + self.slave.handleRequest(c) + except: + self.handleError(c) + if self.threaded and c in self.handling: + self.handling.remove(c) def handleRequests(self, timeout=None, others=[], callback=None): activecnt=1 while activecnt: - socklist = self.connections+[self.sock]+others + connections = [] + for conn in self.connections: + if conn not in self.handling: + connections.append(conn) + socklist = connections+[self.sock]+others + time.sleep(.001) if timeout==None: ins,outs,exs = select.select(socklist,[],[]) else: ins,outs,exs = select.select(socklist,[],[],timeout) activecnt=len(ins) + time.sleep(.001) if self.sock in ins: - self.newConnection(self.sock) + conn = self.newConnection(self.sock) ins.remove(self.sock) + if conn: ins.append(conn) + time.sleep(.001) for c in ins: if isinstance(c,TCPConnection): - try: - self.slave.handleRequest(c) - except: - self.handleError(c) + if self.threaded: + self.handling.append(c) + Thread(target=self.handleRequest, args=(c,)).start() + else: + self.handleRequest(c) ins.remove(c) + time.sleep(.001) if ins and callback: # the 'others' must have fired... callback(ins) @@ -243,5 +267,8 @@ def removeConnection(self, conn): if conn in self.connections: self.connections.remove(conn) - Log.msg('TCPServer','removed connection with',conn.addr,' #conns=',len(self.connections)) + if self.threaded and conn in self.handling: + self.handling.remove(conn) + Log.msg('TCPServer','removed connection with',conn.addr, + ' #conns=',len(self.connections)) From rayleyva at my-deja.com Mon May 15 12:28:14 2000 From: rayleyva at my-deja.com (rayleyva at my-deja.com) Date: Mon, 15 May 2000 16:28:14 GMT Subject: Another more complete screen dump. Any ideas are appreciated. References: <8fg22f$qu9$1@nnrp1.deja.com> Message-ID: <8fp8i6$h09$1@nnrp1.deja.com> > I assume you have the recent py2pdf 0.5; Yes ? which version of ReportLab? reportlab 0.92 > What command line did you use? Here's a quick dump straight from the screen : C:\Apps\inet\Python\grail-0.6>python ../py2pdf/py2pdf.py Viewer.py Traceback (innermost last): File "../py2pdf/py2pdf.py", line 1546, in ? main(sys.argv) File "../py2pdf/py2pdf.py", line 1531, in main p.process(f) File "../py2pdf/py2pdf.py", line 1397, in process self.writeFile(self.taggedData, inPath, outPath) File "../py2pdf/py2pdf.py", line 1206, in writeFile self.writeData(data, inPath, outPath or self.outPath) File "../py2pdf/py2pdf.py", line 1385, in writeData self.formatLine(line) File "../py2pdf/py2pdf.py", line 1294, in formatLine method(groups, eol) File "../py2pdf/py2pdf.py", line 1348, in _formatKw self.formatLine(after, eol) File "../py2pdf/py2pdf.py", line 1294, in formatLine method(groups, eol) File "../py2pdf/py2pdf.py", line 1303, in _formatIdent self.layouter.addIdent(id) File "../py2pdf/py2pdf.py", line 1019, in addIdent c.bookmarkHorizontalAbsolute0(nameTag, pos) File "C:\Apps\inet\Python\reportlab\pdfgen\canvas.py", line 362, in bookmarkHorizontalAbsolute0 pageref = self._doc.thisPageRef() File "C:\Apps\inet\Python\reportlab\pdfbase\pdfdoc.py", line 333, in thisPageRef raise ValueError, "can't get thisPageRef -- not declared inPage" ValueError: can't get thisPageRef -- not declared inPage Sent via Deja.com http://www.deja.com/ Before you buy. From relder at omegabit.com Thu May 18 21:34:47 2000 From: relder at omegabit.com (Rob Elder) Date: Thu, 18 May 2000 18:34:47 -0700 Subject: SQL SELECT question... Message-ID: Hello, guys I'm struggling with using SQL with Python. One question please. How should I structure the following operation using odbc: cursor.execute('SELECT someField FROM someTable WHERE someField="someString"') This does not work for me. How is this supposed to be structured? TIA. -r From audun at stud.cs.uit.no Tue May 2 04:55:52 2000 From: audun at stud.cs.uit.no (User audun) Date: 2 May 2000 08:55:52 GMT Subject: Python/C API question Message-ID: <8em56o$i55$1@news.uit.no> I'm working on a Python module written in C, and I keep getting impressed by Python's design and it's C/C++ API. However, I find the "Python/C API Reference Manual" and the "Extending and embedding" manuals weak on one point: The exact protocol in defining custom type objects. My implementation has therefore been largely influenced by the Python source code on these on this. There is one detail I'd like to ask about. Let's say I've constructed (in C) a Python object of type ekkiekki. In the file ekkiekki.c I've defined the methods associated with the object in a PyMethodDef structure that is used by ekkiekki's setattr and getattr functions. Furthermore, let's imagine that the method static PyObject * tapang(self, args) is such a method associated with ekkiekki. My question is then: Is it wise and/or necessary to do any type checking on the self-argument in such built-in methods (as in calling a Ekkiekki_Check(self))? And what about setattr/getattr and the other "basic" methods defined in ekkiekki's PyTypeObject-structure? Does the interpreter make any guarantees about "who" being able to call an object's internal methods? Note: In the above I've tried to use naming conventions from the Python sourcecode for clarity. I hope it helped :) I tried to look elsewhere for these answers without luck. If these questions have been answered elsewhere, I apologize. Regards, __ Audun Nordal From jkraska1 at san.rr.com Fri May 19 23:52:24 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 20 May 2000 03:52:24 GMT Subject: Case sensitivity/insensitivity Message-ID: <39260CB6.464EE302@san.rr.com> I thought about this for a while, and my suspicion is that the first negative reaction that people have against case insensitivity is probably the instinctive (and false) idea that everyone would be writing python programs without case. The occasions in which you really want to have variables/ attributes which differ by case alone are quite rare. About the only time I have ever seen this regularly is in some types of code where accessors (in c++/java) differed from private attributes only in case, ala: class Myclass { private int myvar; int Myvar(); } I can't really see any other real use of actual case sensitivity in the language. Does anyone out there actually make use of case sensitivity? Truly curious. I guess what I'm saying is, now that I think about it, "so what, no big loss." Kind of like the braces, only far less consequential. C/ From remove.me.wwicker at spectratechnologies.com Tue May 2 18:52:39 2000 From: remove.me.wwicker at spectratechnologies.com (William Wicker) Date: Tue, 02 May 2000 22:52:39 GMT Subject: Python COM troubles References: <390a2f04.149999918@news.onlineisp.com> <390acf5e.62946872@news.onlineisp.com> Message-ID: <390f5bc8.14290929@news.onlineisp.com> On Fri, 28 Apr 2000 23:09:14 GMT, "Mark Hammond" wrote: >"William Wicker" wrote in >message news:390acf5e.62946872 at news.onlineisp.com... >> On Thu, 27 Apr 2000 00:46:35 GMT, "Mark Hammond" >> wrote: >> >> >"William Wicker" wrote in >> >message news:390a2f04.149999918 at news.onlineisp.com... > >> >[BTW - drop them a line, and tell them they should fix their objects >:-] >> > >> >> Can you fill me in with what in particular I should complain about? >> Comments that RTTI was lacking brought the response that >> QueryInterface was supported. > >Their IDispatch implementation should implement GetTypeInfo() - it should >be quite trivial to do, as they already have the type info available, it >just isnt connected to the objects at runtime. > >> Also, (did I already ask this?) I'm guessing that using the >> EnsureModule approach will make DispatchWithEvents unavailable. >> Reading dynamic.py suggests that there is an alternate (more complex?) >> way. > >It _should_ work - but instead of passing a CLSID, pass the object >itself - eg, instead of passing: > >ob = DispatchWithEvents("Foo.Bar", your_class) > >use: >mod = gencache.EnsureModule(...) >ob = mod.FooBar() # To work around the lack of type info. >ob = DispatchWithEvents(ob, your_class) > Well, it almost works:( When I try this, I get a traceback indicating an AttributeError on GetTypeInfo. (thus confirming what you said about SolidWorks not implementing GetTypeInfo(). Oh well. Maybe they'll fix it in a future release. William. From db3l at fitlinxx.com Thu May 11 21:02:28 2000 From: db3l at fitlinxx.com (David Bolen) Date: 11 May 2000 21:02:28 -0400 Subject: Problem with stdout in embedded python References: <8fel9i$8fu$1@nnrp1.deja.com> Message-ID: paul_pelletier at iname.com writes: > I've embedded python in a dll of my application and for some reason I > dont see any output made by my scripts using print. Would anyone know > what might be wrong? Assuming that this is under Windows, if the main application that is using your DLL is a graphical (versus console) application, then there may be no console attached to your process for the output to go to and it just gets thrown away. What I've found helpful when embedding Python within another application (even when that application is a console application), is to reroute stdout/stderr to my own functions, which can then control exactly how that output is managed. Not only does this ensure I can present the output in a manner suitable for the surrounding environment (or even duplicate it in a log file), but I can massage the data if necessary (e.g., adding timestamps or highlighting errors versus standard output). And because it's still stdout/stderr from the perspective of Python, it catches everything - from print's to uncaught tracebacks. For example, in one application of mine (the surrounding application provides an "ecna" module for use by embedded scripts), I internally execute the following code in advance of any scripts: import sys class StdoutCatcher: def write(self, stuff): ecna.stdout(stuff) class StderrCatcher: def write(self, stuff): ecna.stderr(stuff) sys.stdout = StdoutCatcher() sys.stderr = StderrCatcher() (The ecna.stdout/stderr functions are provided by the surrounding application, and display the output in a trace window). I don't know if something like that would work well in your particular environment or not, but it might be one approach to try. -- -- 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 glyph at twistedmatrix.com Mon May 15 14:03:37 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 15 May 2000 13:03:37 -0500 Subject: Stand-alone Python Apps? In-Reply-To: "Nathan Gundlach"'s message of "Mon, 15 May 2000 11:00:49 -0400" References: <4fUT4.20380$HG1.517119@nnrp1.uunet.ca> Message-ID: "Nathan Gundlach" writes: > Thanks a bunch! I'll look into this. If it's as good as it sounds, it's > great. Maybe I should clarify exactly what I mean by "stand-alone." All I > want to create is a simple program with a GUI that does not require that > Python be installed on my end user's computer. The problem with this, as it seems to me, is that Python *must* be installed on the end-user's computer. The best you can do is hide the fact that it is from them. If you use a tool which "bundles up" your whole application into one big .EXE, or whatever, you are going to need to put the interpreter into that EXE. Whereas, if you get them to install the interpreter once, they can download newer versions of your app in 500k instead of 5M. not-sure-how-you-explain-that-to-the-end-user-though-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From garry at sage.att.com Thu May 18 11:06:16 2000 From: garry at sage.att.com (Garry Hodgson) Date: Thu, 18 May 2000 15:06:16 GMT Subject: seeking volunteer position References: <3921691e.793513@news> Message-ID: <392406E8.5E22D11@sage.att.com> Matt Dunford wrote: > Anyway, if you're willing to volunteer for documentation, > check out www.gnu.org > > They have many projects under their wing. or for something closer to (python) home, try http://zdp.zope.org/ Zope could *really* use better documentation, and you'd be learning some very cool stuff in the process. (if your head doesn't explode). -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From moshez at math.huji.ac.il Mon May 8 13:39:02 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 8 May 2000 20:39:02 +0300 (IDT) Subject: Future of the Python Linux Distribution In-Reply-To: Message-ID: On 8 May 2000, Alex wrote: > > > What about hand-coding graphics directly in Postscript ? > > I reckon that wouldn't make you a wizard, that would just make you a > masochist. :) I completely fail to see the point. PostScript is a cute language in which it is easy to hand-code graphics. What other way is there? working-on-Python-to-PostScript-compiler-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From peter at norvig.com Wed May 17 18:37:32 2000 From: peter at norvig.com (Peter Norvig) Date: Wed, 17 May 2000 15:37:32 -0700 Subject: AI and Python In-Reply-To: References: <39230B65.EB54DC2B@norvig.com> Message-ID: What I meant was the crime is that people in AI spent years duplicating work that had already been done in OR (and perhaps the reverse as well; I don't know the history of OR well enough). An example is Marcel Schoopers work on universal plans -- important work, but largely duplicative of OR work on policies. It would have saved the field a lot of work if this had been known earlier. -Peter At 5:47 PM -0400 5/17/00, Fran?ois Pinard wrote: >Peter Norvig ?crit: > >> You make a good observation that AI and operations research have a >> large overlap in the problems they address: basically, what is the >> right program or policy to decide what to do in a complex, uncertain >> environment? It is a crime that the fields developed independently with >> little interaction, but in the last five or ten years this has changed, >> and AI now encompasses OR techniques, and is much better suited for >> dealing with real-world programs. > >Surely no crime here. That various fields synergise is undoubtedly a >good thing. What I did not like much, retrospectively, is all the fuss >AI people were making all along. > >Can Python do AI? I'm not sure what AI means. OK, yes, Python can! :-) > >-- >Fran?ois Pinard http://www.iro.umontreal.ca/~pinard _____________________________________________________ Peter Norvig peter at norvig.com http://www.norvig.com home:650-852-1220 work:650-604-6207 cell:650-279-0474 From rjroy at takingcontrol.com Tue May 16 00:13:12 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Tue, 16 May 2000 04:13:12 GMT Subject: os.path.walk() question. References: <8e55m0$pvl$1@hammer.msfc.nasa.gov> Message-ID: <3920c9fc.2166140@news1.on.sympatico.ca> On 25 Apr 2000 22:19:44 GMT, "Andrew McDowell" wrote: names[:] = [] >I didn't see this question mentioned in any older posts so forgive me if I'm >dragging up and old topic...but: > >I need to find out if a file exists under a directory hierarchy. >The hierarchy could be quite large so I don't want to continue recursing >through the hierarchy if the file is found one or two directories down. Is >there a way that you can tell os.path.walk() to stop searching? > >I suppose I could customize the code, but my first notion was that someone >on the group had probably addressed this before. > >Any advice would be much appreciated :) > >-Drew > > > > From andrew at andrewcooke.free-online.co.uk Sun May 7 08:28:49 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Sun, 07 May 2000 12:28:49 GMT Subject: Software Carpentry first round winners Message-ID: <8f3nho$78s$1@nnrp1.deja.com> Hi, Apologies if I'm repeating an earlier message, but I've just searched on Deja and can't find any mention... Anyway, the first round winners for the Software Carpentry competition were announced a while back - there's a link at www.python.org or go directly to http://software-carpentry.codesourcery.com/ The competition is for development tools written in Python - if anyone is interested check out the winning designs and make comments on the mailing list. I think (I'm not involved) that the first round winners will submit more detailed designs soon and then the "best" will be implemented. I get the impression that comments made on the mailing list will influence the finalists, so it's a good time to throw in your own opinions.... Cheers, Andrew PS I really did search Deja for previous posts - I'm surprised no-one has mentioned this.... apologies if Deja is broken (I know they're moving servers and very old posts are not available). Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Sat May 20 03:49:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 20 May 2000 03:49:09 -0400 Subject: Checksum routine - new to Python In-Reply-To: <392638BE.DD502E36@stud.ntnu.no> Message-ID: <000701bfc22f$e2f19d80$f52d153f@tim> [posted & mailed] [Guido] > Note that this is the same crc32 algorithm as the one in zlib! (Dunno > about which is faster, but I wouldn't be surprised if they both derive > from the same code as well.) [Peter Schneider-Kamp] > Excuse me, but how can you be sure it is the same algorithm? > As far as I can read the sources to zlibmodule.c it uses the > function crc32 defined in zlib.h of the underlying platform. > > Now I would almost dare to bet that any sane system uses the > standard algorithm in its zlib, but who can tell? The details of zlib's format (including checksum algorithm) are defined by RFC 1950; anyone adhering to that spec must use an equivalent crc32 algorithm; anyone not using an equivalent crc32 algorithm shouldn't be calling their offering zlib . See, e.g, ftp://ftp.freesoftware.com/pub/infozip/zlib/zlib_docs.html on-rare-occasions-stds-actually-help-ly y'rs - tim From slhath at flash.net Thu May 11 12:16:18 2000 From: slhath at flash.net (Scott Hathaway) Date: Thu, 11 May 2000 16:16:18 GMT Subject: regular expressions newbie Message-ID: I have the following situation. I want to go through all the .html and .js files in a directory. If anyone of them have links to other files in any manner (through a link, script call, css external file, etc) I want to make that filename lowercase in the .html or .js file call. Is there an easy way to do this with regular expressions? Thanks, Scott From froydnj at rose-hulman.edu Sun May 7 15:17:19 2000 From: froydnj at rose-hulman.edu (Nathan Froyd) Date: 7 May 2000 19:17:19 GMT Subject: + and * operators References: <3915B949.46649689@stud.ntnu.no> Message-ID: In article <3915B949.46649689 at stud.ntnu.no>, Peter Schneider-Kamp wrote: >Is there some way to refer to the + and * >operators as functions? import operator >reduce(+,map(*,v)) reduce(operator.add, map(operator.mul, v)) -- froydnj at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ From boud at rempt.xs4all.nl Wed May 24 14:04:08 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 24 May 2000 18:04:08 GMT Subject: Graphical User Interface application References: <8F3DE03A5beable@207.211.168.81> <392BFFE7.82DBCB10@world.std.com> Message-ID: <8gh5io$64d$1@news1.xs4all.nl> David Lees wrote: > As a VB user taking a look at Python, you interpret the question exactly > as I understood it. Thanks. There's one project that aims exactly at what you want - a VB/Delphi clone environment for Python. It's Vipyl, by Henning Schroeder, and it's at: http://vipyl.sourceforge.net. However, it needs some _serious_ work. I mean, for now it's not much more than a proof-of-concept for a Visual Basic 1.0 clone, but the beginning is there, at least, and it _does_ run, and looks very promising. -- Boudewijn Rempt | http://www.valdyas.org From andymac at bullseye.apana.org.au Sun May 28 18:06:38 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Mon, 29 May 2000 08:06:38 +1000 (EST) Subject: Multfile C Extensions In-Reply-To: Message-ID: On Sun, 28 May 2000, Pete Shinners wrote: > i've got a C python extension that has gotten pretty large. > i'd like to break the file up into smaller components, but > i'm finding this is actually pretty tricky. > > since all functions/variables must be static (aside from init) > how can i get the different files to work with each other? Its ugly, but what I've done for something I'm working on is to have a master source file for the module that #includes the various other source files. In my particular case I have a number of modules using a lot of common code (but only one of the modules can be loaded at any one time), and so the master file actually has the init routine in it. Hope this helps. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From dima at xenon.spb.ru Fri May 19 18:31:19 2000 From: dima at xenon.spb.ru (Dmitry Rozmanov) Date: Sat, 20 May 2000 02:31:19 +0400 Subject: PostgreSQL from Python 1.5.2 References: <3924599A.9CEB3FB1@xenon.spb.ru> <39254C2F.E0C02F1E@ironwater.com> Message-ID: <3925C0B7.F619E082@xenon.spb.ru> Thank you guys. Case Van Horsen wrote: > > Use the Windows ODBC drivers for Postgresql From junkster at nospam.rochester.rr.com Tue May 9 16:44:10 2000 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 09 May 2000 20:44:10 GMT Subject: Help w/ODBC + Access 97 & Web CGI Message-ID: I'm running into a slight problem here that I'm having difficulty tracking down. I'm running Python v1.52 with Win32 extensions using ODBC to communicate with a MS Access 97 database. I've successfully used both MxODBC & the ODBC with the Win32 extensions.... Here's the "funny" part. One of the tables in the database is a "Users" table, containing, name, password, comments, etc. I can access my user record (Record 0), but if I attempt to login as any other user, the login is successful, but if I try any comments, the CGI seems to lockup until the process times out from IIS. I don't see any obvious problems, with the database, nor the ODBC code that I am using, in fact, the USER STATUS command I'm issuing reads all the data back from a COOKIE, not from the Database.... To illustrate: - Login (Read / compare data from database) |- Writes user record information to a cookie - User Status |- Reads data from cookie, displays on screen - User Edit |- Reads account from cookie, displays for editing, saves back to database I'm using the Cookie module from Timothy O'Malley, v2.25 05/03/2000. Has anyone hit a problem like this before? I tried going through the archives, but didn't see anything obvious in the web search's that I performed. Here's the ODBC wrapper, I wrote....Feel free to point out any problems: (Keep in mind, this is my first real attempt at ODBC related code.) import dbi, ODBC # ODBC modules import time # standard time module def login_to_homepage ( username='', passwd=''): login_string = '' database_conn = ODBC.Windows.Connect( # open a database connection 'homepages', username, passwd) # 'datasource/user/password' return database_conn def logout_database (database): database.close() def do_SQL_statement ( sql_statement, database_handle, database_description = None ): crsr = database_handle.cursor() # create a cursor crsr.execute (sql_statement) # execute some SQL database_description = crsr.description results = crsr.fetchall() crsr.close() return results, database_description def do_update_statement ( sql_statement, database_handle ): crsr = database_handle.cursor() # create a cursor results = crsr.execute(sql_statement) # execute some SQL #results = crsr.fetchall() crsr.close() return results def do_insert_into_statement ( sql_statement, data, database_handle ): crsr = database_handle.cursor() # create a cursor results = crsr.execute(sql_statement, data) # execute some SQL crsr.close() return results ==================================================== (Remove "NoSpam" to Email me) ==================================================== Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From wtanksle at dolphin.openprojects.net Mon May 22 21:58:05 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 23 May 2000 01:58:05 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> <3929C933.3ED830E@tcac.net> Message-ID: On Mon, 22 May 2000 18:56:35 -0500, Albert Wagner wrote: >The illiterate in every language, computer or natural, English or >German, would prefer to ignore case, just as they would prefer to ignore >punctuation and grammer. Case sensitivity adds expressiveness to a >language, yet with no real overhead. Case carries additional >information for the readers of a language, information that is lost and >obscured when case is ignored. Wait a 'mo, though. Information is only carried when there is a choice. In a case insensitive language I, the programmer, can use capitalization to convey information to my reader in a way that the compiler won't notice. So case insensitivity provides _more_ information-carrying capacity. I've always wanted to have covert channels in my Python code. I mean, aside from the comments :-). But this isn't an argument _for_ case insensitivty, just a dismissal of your argument against. In fact, I've never seen an argument about which I cared less. I'm completely case insensitivity insensitive. >Small is Beautiful -- -William "Billy" Tanksley From faatdilac at my-deja.com Thu May 25 12:22:23 2000 From: faatdilac at my-deja.com (faatdilac at my-deja.com) Date: Thu, 25 May 2000 16:22:23 GMT Subject: Java vs Python References: <8fo465$2u5$0@216.39.141.21> Message-ID: <8gjjva$f5l$1@nnrp1.deja.com> In article , claird at starbase.neosoft.com (Cameron Laird) wrote: > In article <8fo465$2u5$0 at 216.39.141.21>, dana_booth wrote: > >Huy Do wrote: > > > >HD: I would just like to know how serious python is taken in the IT industry and > >HD: how it compares to something like Java. > > > >Larger companies probably do not take Python seriously. In the industry, > . > . > . > Larger companies like Intel, Motorola, Microsoft, Compaq, IBM, ...? > See, for example, > . > > That's a cheap shot on my part. Mr. Booth is right. Conservative > (in some sense) MIS departments *are* wont to scorn Python. It can > be tough getting approval from many of them to use Python for a > project such as that under consideration here. > > It's worth it, though--*particularly*, I claim, for Web work. > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html > My management approves every language provided that it comes with the box, no download. As of now, only Perl, Tcl/Tk and Expect come with every Unix box. So I am enjoying making ~ 85K writing programs in Perl & Tcl/Tk & Expect. Unless Python/Ruby come with all Unix box, they have no future for me. Yes, "unless" is very powerful in Perl. faatdilac Sent via Deja.com http://www.deja.com/ Before you buy. From blablu at gmx.net Tue May 30 04:19:51 2000 From: blablu at gmx.net (Mike 'Cat' Perkonigg) Date: 30 May 2000 08:19:51 GMT Subject: how to update objects? References: <8F437ADE8mikecat@192.168.10.38> Message-ID: <8F446F72Emikecat@192.168.10.38> loewis at informatik.hu-berlin.de (Martin von Loewis) wrote in : >noemail at nowhere.hades (Mike Cat) writes: > >> I update a class with 'reload (module)'. >> How can I update the instances too? > >You'd have to find the instance one-by-one. If you manage to get hold >of them, you can set their __class__ attribute to the new class: > >>>> class A: >... def doit(self):print "old" >... >>>> a=A() >>>> class A: >... def doit(self):print "new" >... >>>> a.doit() >old >>>> a.__class__=A >>>> a.doit() >new > >Regards, >Martin > > Yes, I found this way too, but I thought there could be a better way (or maybe a cleaner) to do this. Thank you! Regards, Mike From niels at endea.demon.nl Thu May 25 14:14:56 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Thu, 25 May 2000 20:14:56 +0200 Subject: print, softspace, and stdout -- Newbie References: Message-ID: <392D6D9F.60AD4BB8@endea.demon.nl> Brandon Irons schreef: > Since the softspace attribute was made writeable, it seems to me > there must be a way to get this output using print and softspace. > What is it? print 'a', sys.stdout.softspace = 0 print 'b' I don't think the softspace attribute is really intended to be used this way. The print statement uses it to keep track of whether the next item printed is at the start of a line (softspace == 0) or after a previous item (softspace == 1), so every print statement resets softspace. > > My second question is: In that last code snippet, how would I go > about re-opening stdout? There is no general way to reopen a file after you close it, because it might not even exist anymore. It wouldn't do what you want anyway, if that's any comfort. -- Niels Diepeveen Endea automatisering From mhammond at skippinet.com.au Thu May 11 11:05:38 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 May 2000 15:05:38 GMT Subject: win32all-128 keys for auto-complete References: <391AB083.80A4C0EE@gmx.net> Message-ID: <6%zS4.768$Kc3.3869@news-server.bigpond.net.au> "Robert Kiendl" wrote in message news:391AB083.80A4C0EE at gmx.net... > does anybody know the keys for auto-completition ? selecting one of item > in the scrollbox with a keystroke? Tab. Alt+/ or Ctrl+Space do auto-expand (no list - just looks for similar words in the same buffer) Mark. From andres at corrada.com Thu May 25 06:43:04 2000 From: andres at corrada.com (andres at corrada.com) Date: Thu, 25 May 2000 06:43:04 -0400 Subject: Looking up caller's namespace In-Reply-To: <392CF58E9D.DF41YEMARTIN@smtp.garage.co.jp>; from Yves-Eric Martin on Thu, May 25, 2000 at 06:42:38PM +0900 References: <392CF58E9D.DF41YEMARTIN@smtp.garage.co.jp> Message-ID: <20000525064304.A31100@corrada.com> On Thu, May 25, 2000 at 06:42:38PM +0900, Yves-Eric Martin wrote: > > I need your help for a problem my little Python knowledge cannot > solve. In short, what I want to do is to access, from a function in a > module, an object of the caller. The catch is that I don't want to pass > it as an argument to the function, but to look it up in the caller's > namespace. (See note 2 for why I want to do that). >. >. >. > Note 1: I am currently using the following workaround (which may actually > be nicer than what I am trying to do, but it does not answer my > question about accessing caller's namespace): > > --- mymodule.py --- > def myadd(y,z): > return y+z > ------------------- > > ----- test.py ----- > import mymodule > def myadd(a): > return mymodule.myadd(a,b) > a,b=3,4 > print myadd(a) > ------------------- > I don't know the answer to your question but I came up with another workaround: class AllKnowing: def __init__( self, callingNamespace ): self.__dict__ = callingNamespace def sum( self, a ): z = self.__dict__['b'] return a + z Firing up the interpreter I get: >>> knowItAll = AllKnowing( globals() ) >>> b = 1 >>> knowItAll.sum( 2 ) 3 ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From garry at sage.att.com Tue May 30 14:09:27 2000 From: garry at sage.att.com (Garry Hodgson) Date: Tue, 30 May 2000 18:09:27 GMT Subject: OT: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <392EEEE3.2D37@seebelow.org> Message-ID: <393403D7.CAA8AB7D@sage.att.com> Grant Griffin wrote: > Well, I'm an old DOS man, so I tend to flatter myself that I have a > balanced view of the command-line-versus-GUI thing. that's a bad assumption to make. the DOS command shell is so pitifully lame that it doesn't serve well as a basis for comparison. it'd be like me flaming GUI's based on my windows 2.0 experience. > But when extracting > from someone _else's_ archive, I think the GUI thing clearly has the > command-line approach beat. maybe. i type "Unpack archive-name" in a shell window, and i'm done. "Unpack" being a trivial python or ksh (i forget which, and don't care) script which figures out the right thing to do. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From jkraska1 at san.rr.com Wed May 31 21:30:35 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 01 Jun 2000 01:30:35 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <3933777F.262E1E15@san.rr.com> Message-ID: <3935BD58.E76888AB@san.rr.com> > > When benching your code, I was surprised for a moment that > > your 1000 entry test was so much faster than mine (I ran > > the test a half dozen times), but then discovered that my > > original reported result in that category was a typo. Whoops. > > This does make a very compelling case for the deque in > > deque implementations likely to hold 1,000 or so objects > > (rare, probably). > > There's also one other point which should probably be included in any > such discussion, although I expect those following this thread are > implicitly aware of it. Whether or not the above numbers make a "very > compelling" case can't be gauged from the numbers alone, but must take > into account the overall operation of the surrounding application - > even for native lists. Err, right. Generally I begin my optimization with algorithms at the top of the profiler readout. For example, in my simulation environment, the single biggest consumer of time is the priority queue. Hence the attempt to optimize it. The implementation of the deque was more of an academic exercise. Several people here posted that it wasn't particularly relevant to most everyday problems. I didn't believe them. :) C/ From loredo at spacenet.tn.cornell.edu Thu May 11 18:48:24 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Thu, 11 May 2000 18:48:24 -0400 Subject: How to identify memory leaks in extensions? References: <391AF390.C419189A@spacenet.tn.cornell.edu> Message-ID: <391B38B8.545C100@spacenet.tn.cornell.edu> Thank you, Travis! That fixed it! The "N" vs. "O" issue would have escaped my notice for a long time without your help.... -Tom Loredo From scarblac-spamtrap at pino.selwerd.nl Tue May 9 13:11:13 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 9 May 2000 17:11:13 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: tony summerfelt wrote in comp.lang.python: > correct me if i'm wrong, but a duplicate of the last line is what's checked? > > the code i posted (typos and all) the duplicate items could have been > anyhere in the file: > > > one > one > two > three > > or: > > one > two > three > one > > the perl's hashes make that possible Python's dictionaries are similar to Perl's hashes. What he wrote is what Unix uniq does, I think. I couldn't read your original version, but if you want to put every line into a hash so that you can find the uniques, that's easy. (Oh wait, I think you put them into a list as well - to preserve order? Let's do that to). #!/usr/local/bin/python import sys try: file1 = open(sys.argv[1],'r') file2 = open(sys.argv[2],'w') except: print "Usage: unique.py file1 file2" print print "An error occurred. You didn't give the right arguments, or the" print "files couldn't be opened." sys.exit(1) dict = {} uniques = [] for line in file1.readlines(): if not dict.has_key(line): dict[line] = 1 uniques.append(line) file2.writelines(uniques) This does slurp in the whole file at once. If you don't like that, replace the 'for line in...' line with something like while 1: line = file1.readline() if not line: break -- Remco Gerlich, scarblac at pino.selwerd.nl -rwxr-xr-x 1 root 5.89824e37 Oct 22 1990 /usr/bin/emacs [STR] From tismer at tismer.com Tue May 2 15:51:01 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 02 May 2000 21:51:01 +0200 Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> Message-ID: <390F31A5.6452D256@tismer.com> Will Ware wrote: > > Courageous (jkraska1 at san.rr.com) wrote: > > It's always possible if someone > > convinces Sun of the wonders of Microthreads and shows > > them how to make their JVM stackless. They'd benefit > > immensely, IMO. > > There is a free software implementation of the JVM with available > source code, called Kaffe, at > http://www.transvirtual.com/products/downloads.html > If a stackless version of Kaffe could be developed, it might be > possible to convince Kaffe's maintainer (Tom Wilkinson, owner of > the transvirtual.com site) to fold the changes into its official > distribution. It would give him an advantage over Sun, so before > too long, they might follow suit. Hey, this is just an incredible idea. Java with first class continuations, let that drop through your brains. 90 percent of java threads would be replaced by microthreads. I will read the Kaffe source and think how this must be. It can become quite a revolution for Java. bye-bye-Python-I-have-no-time-for-your-for-quite-a-long-time-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From ljz at asfast.com Sun May 14 10:08:33 2000 From: ljz at asfast.com (Lloyd Zusman) Date: 14 May 2000 10:08:33 -0400 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: jimn at minusen.force9.co.uk writes: > Lloyd Zusman wrote: > : "Andrew Dalke" writes: > > [snip] > : Clearly, there are two widely used representations of the square root > : of -1: "i" and "j". Forgive me if this question has been answered and > : beaten to death in one or more earlier discussions, but is there any > : reason why Python couldn't use both "i" and "j", as well? Given that > : things such as "1 + 3i" are currently illegal in Python, I don't > : believe that any legacy code could possibly break if in a future > : Python release, any one of 4 values ("j", "J", "i", and "I") could be > : appended to a number to cause it to be treated as imaginary, instead > : of just the two values we have today. > > As I see it, the problem would come when converting a complex number > to a string - which representation should it use? Is it not preferable > to use the same representation for display as is used for literals? But even now, there are two choices: "j" and "J". When converting the number to a string, "j" is always used, irrespective of whether "J" was used within the original complex literal. This could still be the case in the hypothetical future if "i" and "I" could also be used for the numeric literals. > Just my 2p worth. > > Jim -- Lloyd Zusman ljz at asfast.com From katz at Glue.umd.edu Sun May 21 00:19:24 2000 From: katz at Glue.umd.edu (Roy Katz) Date: Sun, 21 May 2000 00:19:24 -0400 Subject: Case-sensitivity: why -- or why not? In-Reply-To: References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: On Sun, 21 May 2000, Guido van Rossum wrote: > Here's a way to make your vote count: explain what it is about case > sensitive languages that you hate. Then we can have a discussion > about it. Guido, What I like in Python now is its case-consistency: 1. strings sare case-sensitive (of course) 2. import C symbol names are case sensitive 3. Python modules are case sensitive 4. Python's keyword set is case sensitive. (1) is a non-issue for me. I'm happy that "print 'Python'" and "print 'python'" output different strings. (2) presents a problem: Suppose one implements the following: class Node {...}; Node node; and then registers the structure and the instance with Python's run-time system (er, just assume). Now we have two separate symbols which differ only by case. Now assuming that the run-time Python environment is case-insensitive, and that I import my module, what would the run-time think I am referring to? Case sensitivity on (3) would break the following: class A: pass a = A() But that's a minor nit, IMHO. It's just that I see so much of this code used in small scripts, examples, etc. For (4), (first, an analogy) You've mentioned that one of the reasons for Python's asbence of curly braces is that it limits the amount programmer conventions; for example, in Python the following would never be an issue: int func( ) { } int func( ) { } int func( ) { } (this inconsistency tends to drive me nuts for large C functions). Python's elimination of braces does away with this. In other words, Python restricts the programmer, and in doing so, yields more readable code (it narrows down the quantity of disparate styles and conventions we use). If Python were made case-insensitive, wouldn't that lead to more irregular programming conventions? I would rather introduce a restricted set of conventions so that the student wouldn't go on fragmenting from the norm and developing their own style. That's one more style that I have to get used to when I read their code. Roey Katz comp-eng soph. University of Maryland, College Park USA. p.s. If (4) sounds confusing, tell me. From m.faassen at vet.uu.nl Sun May 28 16:47:25 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 May 2000 20:47:25 GMT Subject: OT: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <392EEEE3.2D37@seebelow.org> <8gpk7k$h70$3@newshost.accu.uu.nl> Message-ID: <8gs0kt$m7m$1@newshost.accu.uu.nl> Neil Hodgson wrote: >> A command line with filename completion (and a history, though DOS has a > mode >> for that, and actually powerful commands) is very different from the DOS >> command line. > On NT 4 and W2K you can have filename completion if you want: > Create the DWORD value CompletionChar in > HKEY_CURRENT_USER\Software\Microsoft\Command Processor and set it to 9. On > W2K the setting was already there but set to 0. Cool. :) That would help, but it doesn't bode well that this is an apparently hidden away option.. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From danny_ob at my-deja.com Thu May 11 10:54:13 2000 From: danny_ob at my-deja.com (danny_ob at my-deja.com) Date: Thu, 11 May 2000 14:54:13 GMT Subject: Help with Callback References: <8fefmi$1r0$1@nnrp1.deja.com> Message-ID: <8fehib$434$1@nnrp1.deja.com> Problem solved.... It was a matter of reorging the order of creation and the packing Thanks..... In article <8fefmi$1r0$1 at nnrp1.deja.com>, danny_ob at my-deja.com wrote: > I have the following problem with a callback: > > I am creating 'Widget A' and a callback for this widget. > In the callback I need to set a variable in 'Widget B', > ...However this widget has not been created yet! > (The order of creation cant be changed) > > Any help would be much appreciated ! > Thanks, > Dan > > def makeWidgets(self): > self.Widget_A() > self.Widget_B() > > def Widget_A_callback(self, tag): > ... > ... > self.WidgetB_field.setentry('x') > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From jwbnews at scandaroon.com Sun May 28 13:32:03 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 28 May 2000 10:32:03 -0700 Subject: Not well supported on the Mac? References: <03a201bfc8c2$49691fa0$1906a8c0@fc.fenx.com> Message-ID: I use BBEdit and sometimes Alpha when I write Python on the Mac. And sometimes I use Just's IDE. I use emacs when I write Python on our Unix and Linux machines. I've never used IDLE (we don't run X). Just, of course, will speak for himself. --John Baxter In article <03a201bfc8c2$49691fa0$1906a8c0 at fc.fenx.com>, "Emile van Sebille" wrote: > Just, > > As it happens, I was thinking of asking about Mac GUI's > this morning. ;-) What do you use? > > Emile van Sebille > emile at fenx.com > ------------------- > > > ----- Original Message ----- > From: Just van Rossum > > > Python is in general pretty well supported on MacOS. However, > Tk(inter) and > > therefore IDLE are not so good, due to lack of interest: Jack & I > don't use > > Tkinter ourselves, and it's up to others to improve the situation... > > > > Just > > > > -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From pinard at iro.umontreal.ca Fri May 12 19:16:51 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 12 May 2000 19:16:51 -0400 Subject: Fun with primality testing Message-ID: Hi, people. For your mere enjoyment! Here is Python code which prints primes below 1000. At the local Perl mongers meeting, someone showed this nicety to me. import re for n in range(2, 1000): if not re.match('(11+)\\1+$', '1'*n): print n -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hgg9140 at seanet.com Sun May 7 14:43:43 2000 From: hgg9140 at seanet.com (Harry George) Date: 07 May 2000 11:43:43 -0700 Subject: PyBalsa? Message-ID: I like the look-and-feel of the gtk-based balsa emailer. But it has classic C-based crashes in the current pre-release. I was wondering if anyone knows of a python-based rendition? A lot of replicated funcionality, I know, but I hate non-gc'd languages. -- Harry George hgg9140 at seanet.com From fiona at sitegnome.com Thu May 25 11:22:50 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 25 May 2000 15:22:50 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 25th, 2000 Message-ID: <20000525152250.17249.qmail@synop.com> Hi All: Yet another group of entries entered into http://python.faqts.com cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- Searching a comparision between the Python and Visual Basic languages? Mathematical comparison specifically. http://www.faqts.com/knowledge-base/view.phtml/aid/3243 ------------------------------------------------------------- Fiona Czuczman Janko Hauser, Erik Wilsher, Travis Oliphant Look into the topic guide at http://www.python.org/topics/scicomp/ There you will find links to many tools for number crunching and I'm sure that NumPy can withstand a comparison against Visual Basic, although I would also be interested what is lacking. You can also have a look at: http://www.python.org/doc/Comparisons.html (general) http://lheawww.gsfc.nasa.gov/users/barrett/IDAE/table.1.html (specific). ------- I have been programming in both (although I stopped with VB after I discovered Python:-), so here is a short summary. If we look at the bare facts we have: Py VB Int*2 N Y Int*4 Y[1] Y Long[2] Y N Real*4 N Y Real*8 Y Y Currency N Y Array arith. Y[3] N[4] Callbacks Y[5] Y Modules Y Well, sort of Dynamic YES N Interactive Y Not very good complex (not in VB) and exceptions (poor in VB) 1: Can be Int*8 on 64 bit machines 2: Long is abitary precision integer values 3: Through NumPy 4: Not that I know of 5: From within python only [Insert : Through NumPy you have Int*2, and Real*4.] Looking at the above, it can appear that the two languages are running head-to head. But you should also consider: 1) You probably don't need real*4, real*8 is just as fast 2) You don't need int*2 3) VB makes some things extremly tedious. Compare py>>> FiltConst = [1., 2., 1.5, 3.2, 6.2, 4.3] VB: Dim FiltConst(6) as Double FiltConst(1) = 1. FiltConst(2) = 2. etc.... 4) The prototyping offered through an interactive environment (=Python) speeds up developement quite a lot. The fact that you can include test code in your modules for easy testing lets you develop your application in a modular fashion and test each part before "assembly". 5) The speed issue is difficult: a) If you run lots of matrix math you can use NumPy, and it is *fast*. There is no alternative to NumPy in VB (to my knowledge) [Insert: You can use NumPy for lots of things besides just "matrix" math. You can store large amounts of data in a small space and do rapid operations on that data as well. As a result, image processing can be done very well using the NumPy object.] b) If you on the other hand run lots of "itty nitty" numeric calculations VB is approx 15x faster than Python (highly informal test). The question you need to ask yourselves on speed is "how fast is fast enough". At present Python is (unfortunatly) not fast enough for our line of work (real time calculation of large ODE's), but the speed is sufficent for most other tasks. If you find that Python is fast enough (execution speed), it offers great advantages in development speed!! Have you tried multipack? It contains a module that links the FORTRAN integration routines in ODEPACK. It is rather fast, but because it calls a Python function at each step it is not "as fast as machinely possible." Still, a combination of Python/(C,FORTRAN) is very fast. ------------------------------------------------------------- How do I create a binary file and write to it? http://www.faqts.com/knowledge-base/view.phtml/aid/3237 ------------------------------------------------------------- Fiona Czuczman Travis Oliphant The idea is to write a string to the file where the string is just a collection of bytes representing the data. There are lot's of ways to proceed here. (1) Use the struct module to create a string with the machine representation of the integer in question and write that out: import struct n = 1066 bfile.write(struct.pack('i',n)) (2) Use the *default* array module to store the numbers and then use it's tofile() method or its tostring() method import array numbers = array.array('i',[1066,1035,1032,1023]) bfile.write(numbers.tostring()) ## OR numbers.tofile(bfile) (3) Use Numerical Python's array module to store the numbers and then use the tostring() method of the NumPy array. import Numeric numbers = Numeric.array([1,2,3,4,5,6],'i') bfile.write(numbers.tostring()) (4) Use Numerical Python and mIO.py which is part of signaltools (http://oliphant.netpedia.net). This will let you write a binary file directly from a NumPy array (without the intervening copy-to-string which can save a lot of memory if you have *a lot* of numbers). import mIO, Numeric bfile = mIO.fopen('somefile','w') numbers = Numeric.array([1,2,3,4,5,6],'i') bfile.fwrite(numbers) bfile.close() # You could also say for example # bfile.fwrite(numbers,'float') to write them as floats ------------------------------------------------------------- How do I get IDLE to run a script on startup? http://www.faqts.com/knowledge-base/view.phtml/aid/3241 ------------------------------------------------------------- Fiona Czuczman Shae Erisson Problem: I've created a script called $IDLESTARTUP.py in the IDLE directory, and I'm running idle.pyw with the -s switch, but it doesn't appear to be working. (Running IDLE 0.5 on Win98.) Solution: $IDLESTARTUP actually means "read the value of the environment variable IDLESTARTUP" That means if you add a line in your autoexec.bat that says: SET IDLESTARTUP="C:\Program Files\Python\Tools\idle\autoidle.py" Then the -s switch will work (as long as you have a file name autoidle.py in the correct path that's a python file that is :) You can of course change the value of that variable to start with any file you prefer. For shell variables, you don't need to surround them with double quotes if there aren't any spaces in the path you're giving it. ex: SET IDLESTARTUP=C:\Python\Tools\idle\idlesetup.py that will work fine since there aren't any spaces (like "Program Files") in the directory specification. ------------------------------------------------------------- Is there any way on NT that I can use a function such as "flock()"? On unix, it seems "fcntl" module is available. http://www.faqts.com/knowledge-base/view.phtml/aid/3242 ------------------------------------------------------------- Fiona Czuczman Lyle Johnson, Mark Hammond, Jeff Kunce There is a function _locking() which I haven't used, but which sounds like it does the same thing as flock() under Unix. The prototype is: _locking(int handle, int mode, long nbytes) Look it up in the MSDN documentation for more details. Also, you will find it in the builtin msvcrt module... -------- I extended the posixfile file locking protocol to work on NT. I never used it in production, so test it well before using. See: ntposixfile.py at: http://starship.python.net/crew/jjkunce/python/ntposixfile.py ------------------------------------------------------------- Is there a simple script somewhere I can look at that sends and retrieves cookies via CGI? http://www.faqts.com/knowledge-base/view.phtml/aid/3238 ------------------------------------------------------------- Fiona Czuczman Oleg Broytmann, Michal Wallace # ----- create ----- #! /usr/local/bin/python -O def set_cookie(): import time t = time.gmtime(time.time()) t = (t[0] + 10,) + t[1:] # add 10 years :) import Cookie cookie = Cookie.Cookie() cookie["id"] = str(1024) cookie["id"]["expires"] = time.strftime("%a, %d-%b-%Y %T GMT", t) cookie["id"]["path"] = "/" print cookie try: print "Content-type: text/html" set_cookie() print "Location: test_c.py" except: #print exception # ----- test ----- #! /usr/local/bin/python -O def get_cookie(): import os, Cookie cookie = Cookie.Cookie(os.environ.get("HTTP_COOKIE")) c = cookie.output("Cookie: ") if c: print c else: print "Cookies not found" try: print "Content-type: text/html" print get_cookie() except: #print exception If you use weblib (http://weblib.sourceforge.net/ - get the cvs version, not the snapshot): ----------------------- import weblib ## show cookies from the browser: print "the cookies are:" print "
    " for c in weblib.request.cookie.keys(): print "
  • %s - %s
  • ", (c, weblib.request.cookie[c]) print "
" ## set some new cookies: weblib.response.setCookie("x", "this is x") weblib.response.setCookie("y", "this is y") From vetler at news.ifi.uio.no Mon May 22 12:53:40 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 22 May 2000 18:53:40 +0200 Subject: PyOpengl... gone forever? References: <5hcW4.5291$wYl.211543552@newsb.telia.net> Message-ID: * Fredrik Lundh > Pete Shinners wrote: > > i've asked once before, but i'm still lost here. > > > > my top spies have informed me that pyopengl lives on > > the starship at http://starship.python.net:9673/crew/da > > > > this site has been inactive for too long now. > > fwiw, that URL works just fine from here... I believe Petes point was that the pages there says that the current version is 1.5.5 (dated January 7th, 1999). of course; it could be that they have built a dead solid code, and there is no need to update it :-) clean-room-development-ly y'rs, vr From effbot at telia.com Fri May 12 10:07:02 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 12 May 2000 14:07:02 GMT Subject: Convert Latin-1 to UTF-8 References: <8fh072$rd9$1@nnrp1.deja.com> Message-ID: wrote: > Anybody who knows if there is a function in > Python for converting Latin-1 to UTF-8? here's one way to do it (well, two ways, actually): import string, sys if sys.version[:3] >= "1.6": def utf8(str): return unicode(str, "iso-8859-1").encode("utf-8") else: # brute force translation from latin 1 to utf 8 def utf8(str): out = [] append = out.append for ch in str: if ch < "\200": append(ch) else: ch = ord(ch) append(chr(0xc0 | (ch >> 6))) append(chr(0x80 | (ch & 0x3f))) return string.join(out, "") From mikael at isy.liu.se Tue May 23 02:30:22 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 23 May 2000 08:30:22 +0200 (MET DST) Subject: Case sensitivity/insensitivity In-Reply-To: <39295C88.EFEDE889@roguewave.com> Message-ID: On 22-May-00 Bjorn Pettersen wrote: > But all those English keywords must be very confusing to people who do > not speak the language... I suggest we implement a global dictionary > that maps the language specific keyword names (or phrases, not all words > have a one-to-one mapping) to their canonical form... Just think, I > could spell the common pydiom (I'm assuming this was perfectly clear to > the Alice people ;-): > > while 1: > line = f.readline() > if not line: > break > ... > > as (with the Norwegian mapping...): > > s? lenge som 1: > linje = f.lesLinje() > hvis ikke linje: > brekk > ... > > hey, it's much easier for every Norwegian speaking person (and I'm sure > the f-bot can read it too ;-) This is really in the spirit of CP4E. If E is to mean everybody, that should include kids, grown-ups, aswell as pensioners, in all countries. That more or less makes such dialects necessary. I shall not argue about how to implement such beasts, since that is beyond my competence. In (my) Swedish dialect: medan 1: rad = f.l?sRad() om inte rad: bryt /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-May-00 Time: 08:07:14 This message was sent by XF-Mail. ----------------------------------------------------------------------- From hinsen at cnrs-orleans.fr Fri May 5 05:05:21 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 05 May 2000 11:05:21 +0200 Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> <39120F04.7B396522@oreilly.com> Message-ID: "Stephen R. Figgins" writes: > One complaint I often hear about Python is that it has no CPAN like > module repository. > > So, who all is working on this? Is this an appropriate item for a sig? > I would love to get involved with other working to make this happen. Perhaps the DistUtils SIG would be a good starting point; after all, a standard distribution tool like DistUtils is almost a prerequisite for standardized module distribution. Of course the logistics of implementing servers is a separate task, but it should interest the same people. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From m.faassen at vet.uu.nl Sun May 28 17:40:47 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 May 2000 21:40:47 GMT Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <8F3F72DB7davemrquizorg@212.27.32.76> <392E4163.668C3BC9@darmstadt.gmd.de> Message-ID: <8gs3ov$m7m$6@newshost.accu.uu.nl> Robb Shecter wrote: [snip] > I don't this does justice to the Java idea. Java has the design goal > of hiding -all- system dependencies. And, features that are dependent > on certain operating systems are clearly seperate from the standard > Java packages. Yes, this could also be called 'reinventing the wheel'. :) > Python seems to go about half-way in this direction. Some libraries > seem to hide OS differences via an adapter sort of design, but there > are many standard libraries that are purely only for certain types of > systems. Not that this is bad, it's just different. Most commonly used standard libraries can be used on every system Python runs on, though. The thin-layer design over C is a very good idea; you get to exploit C and you don't have to reinvent the wheel. So lots of pay-off for a *lot* smaller investment than what went into Java. This thin-layering over C is one of the lesser known great ideas in Python, in fact (though of course this is also used in other scripting languages). > I use Python for 90% of my new projects. (I work only on Linux.) > But, if I know that the software has to run on, say Linux and NT, then > I'll use Java. I've seen, first hand, successful cases of "porting" a > Java program that was written on Linux to NT by just copying the class > files. Um, but I've seen the same happen over and over again in Python. Less so if there's a GUI involved, of course, but take for instance the entire Zope code base as an example; it works on Windows and on Linux and I don't think there are big porting hassles -- certainly not for Zope products; I've personal experience writing those on Linux and getting them deployed on NT. As long as you stick to portable libraries (which is usually not hard to do), Python code is about as portable as Java code, I'd say. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From chibaA at TinterlogD.Tcom Wed May 10 19:00:22 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 10 May 2000 23:00:22 GMT Subject: Question re: cursorField using MySQLdb References: <3919e5c0.441747739@news1.on.sympatico.ca> Message-ID: <3919e9a5.442744673@news1.on.sympatico.ca> Sorry... let me clear up the pseudo-code a bit. - read column title names (such as "name, email_address, etc.") - already accomplished - read in field info row by row for each column - IF data is a name, hyperlink here - IF data is an email_address, hyperlink somewhere else - IF yada, yada Basic point, I need to find a way to test what column the each cursorField value is, so that I can do the appropriate HTML coding for it. Thanks again, kc On Wed, 10 May 2000 22:55:05 GMT, chibaA at TinterlogD.Tcom wrote: >I'm having a bit of difficulty trying to figure out how I can >determine the column-type for a piece of data. Here's an abbreviated >snippet of code: > >01 for cursorRecord in resultSet: >02 print "\n" >03 for cursorField in cursorRecord: >04 if key == 'email_address': >05 print ""\">" + value + "" >06 else: >07 print "size=2>"+cursorField+"" > >Line 4 is the main culprit. I've placed "key" in there for now - but >that's not what I need. > >Basic scenario - it's reading a line out of the table, with various >pieces of data - like names, addresses, etc. With email_address, I'd >like to be able to add a job into it - >but I don't know how to address that specific piece of data. > >(.. maybe read the pseudo-code below, before you continue...) > >Sorry this is so confusing. In the part before this, each of the >cursorFieldNames & cursorDescriptions are read in (which correspond to >the column names, such as name, email_address, etc.). But I have no >access to these labels when processing the cursorField, and >cursorRecord fields. > >In pseudo-code, this is what I want to accomplish: > >- read in the column names & print them out in a table (DONE) >- read in the fields row by row, AND treat each field of each column >differently when placing it in the table > > ie. fields under the names column might be linked somewhere; > fields under email_address might be linked to their email, >etc. > >Anyone have any ideas? (it's probably a 2 second answer!) >Additionally, I can't seem to get any specific information about >commands for MySQLdb (maybe even with examples)... any ideas on where >I could find some? > >Thanks. > >kc From jonf at connix.com Thu May 4 10:55:02 2000 From: jonf at connix.com (Jon Frechette) Date: Thu, 04 May 2000 10:55:02 -0400 Subject: test harness attempt References: <39118B0B.3948AA61@fenx.com> Message-ID: <39118F46.8BE60B84@connix.com> Wow Thanks, I don't think I would have figured that out in million years. emile at fenx.com wrote: > > Jon, > > I made a few tweaks, and got what appears to be what you're trying > to do (see code below). > > Your object.py module is known as main when it starts, which is why > you couldn't reference it as object. > > HTH, > > Emile van Sebille > emile at fenx.com > > Jon Frechette wrote in message > news:<391185E7.6CD5BC93 at connix.com>... > > I am trying to figure out how to write a test harness for my class. I want pass a code string to a function that will print the string and then exec it. The function should be able to compare the > > value of the statement against an expected value. I've have managed to get it half-way working but I can't seem to do an assignment in an 'exec' statement. Is there any way to do this ? Any help would > > be greatly appreciated. > > > > > import sys > > def nObjects(): > return Object._nObjs > > def _test(): > print '\ntesting object' > _run( 'x = Object()' ) > _run( 'y = Object()' ) > _run( 'z = Object()' ) > _run( 'nObjects()', 3 ) > > def _run( codeStr, test = None ): > if test == None: > print codeStr > exec codeStr in sys.modules[__name__].__dict__ > else: > print codeStr, > exec '_x_ = ' + codeStr in sys.modules[__name__].__dict__ > print '(expecting: ' + `test` + ' got: ' + > `sys.modules[__name__].__dict__["_x_"]` + ')' > > class Object: > > _nObjs = 0 > > def __init__( self ): > Object._nObjs = Object._nObjs + 1 > > if __name__ == "__main__": > _test() From Mark.Hecht at msdw.com Thu May 25 15:14:19 2000 From: Mark.Hecht at msdw.com (Mark Hecht) Date: Thu, 25 May 2000 15:14:19 -0400 Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> <87wvkir0is.fsf@den.home.net> Message-ID: <392D7B8B.BEED6B56@msdw.com> I agree, but it's hard to find a Smalltalk book period! ...mark Frank Sergeant wrote: > ... > > Even more than OOSC, I recommend almost any book on Smalltalk. It > is easy to find a bad Java book but it is hard to find a bad Smalltalk > book. > > ... From n8gray at earthlink.net Tue May 2 17:24:53 2000 From: n8gray at earthlink.net (Nathaniel Gray) Date: Tue, 02 May 2000 21:24:53 GMT Subject: Any Numpy Benchmarks? Message-ID: <390F4856.413BE52A@earthlink.net> Has anybody benchmarked Numpy versus other numerical programming languages (Matlab, Mathematica, Octave, etc...)? Anybody compiled a list of pros and cons? I really like the idea of a first-class scripting language mated with a first-class numerical package but I'd like to know what trade-offs exist in Numpy before I try to sell the idea to my coworkers. Thanks, -- Nathaniel A. Gray -- "But the sun is going down!" "No, no, you're all confused. The horizon is moving up." -The Firesign Theatre -- PGP Key: http://certserver.pgp.com:11371/pks/lookup?op=get&search=0x95345747 For PGP: http://www.pgpi.com/ From thomas at xs4all.net Mon May 15 12:27:12 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 15 May 2000 18:27:12 +0200 Subject: really silly nit: why 3+5j instead of 3+5i? In-Reply-To: ; from wlfraed@ix.netcom.com on Mon, May 15, 2000 at 08:52:56AM -0700 References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> <391E9E84.D1A0D74A@prescod.net> Message-ID: <20000515182712.X13281@xs4all.nl> On Mon, May 15, 2000 at 08:52:56AM -0700, Dennis Lee Bieber wrote: > On Sun, 14 May 2000 08:39:32 -0400, Paul Prescod > declaimed the following in comp.lang.python: > 1000l 1000I 1000J *This* is the best argument for the use of J that I've heard so far. Not that I care much either way, but at least this doesn't leave me with a nagging feeling like the socket.socket() change did (before it was reversed.) To note, I *am* using Courier, and I still consider the above code confusing enough to warrant the use of J. Not confusing in the manner of 'does it say l or i', but rather, 'did the original author mean 'l' or 'i'' ? Still-not-using-complex-numbers-meself-though-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From dieter at handshake.de Mon May 22 17:35:32 2000 From: dieter at handshake.de (Dieter Maurer) Date: 22 May 2000 23:35:32 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: "Fredrik Lundh" writes on Sun, 21 May 2000 11:44:08 GMT: > "During the course of development, we tried very hard not to > modify the Python language. /.../ Unfortunately, we were ulti- > mately forced to abandon pure Python when testing revealed > two flaws in the language that made Python unusable by our > target audience: integer math and case sensitivity." Q: Is the Alice projects target audience identical to that of Python? > "Python is case sensitive. While we, as programmers, were com- > fortable with this language feature, our user community suffered > much confusion over it. Seems that programmers have few problems with case insensitivity. Rather, they like it, because they can name similar things with similar words (only different in case). We have such things in German, too: e.g. Essen (substantive) and essen (verb). For German, it would be wrong to have: "Essen" == "essen". However, even otherwise case insensitive languages would respect case in string constants (whose content are considered outside the language). > "I note with some embarrassment that Hypercard, Pascal and LOGO > were designed for novice or infrequent programmers and each was > case insensitive. It may be that Microsoft's Visual Basic programming > environment provides the best of both worlds by following the user > to type in a case-insensitive way, while the programming environment > applies the proper case to the program text on behalf of the user > whenever possible." I just reread the Pascal specification. Nothing suggests that Pascal was supposed to be a case insentive language. Dieter From cwr at crash.cts.com Sat May 20 01:33:18 2000 From: cwr at crash.cts.com (Will Rose) Date: 20 May 2000 05:33:18 GMT Subject: OT: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3qc9$2m9f$2@thoth.cts.com> <39270848.4947@seebelow.org> Message-ID: <8g582u$11ei$1@thoth.cts.com> Grant Griffin wrote: : Will Rose wrote: :> :> Grant Griffin wrote: : ... :> And you'd need a version of tar which understood all the various forms :> of compression. I come across three or four on a pretty regular basis. :> Generally I find that archiving and compression are more conviently :> considered as two separate processes. : I don't know what the tradeoffs are among the ones you use, but : personally, I greatly prefer the fact that the Windows world only has : one as its de-facto standard. Right. But I use a heterogenous bunch of OSes, including Windows, and I like having the various higher performance tools available where possible. If you just stick to Windows, zip probably isn't much of a handicap, and as you say it's the de-facto standard there. Will cwr at cts.com From adsharma at sharmas.dhs.org.nospam Wed May 10 00:11:24 2000 From: adsharma at sharmas.dhs.org.nospam (Arun Sharma) Date: Wed, 10 May 2000 04:11:24 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> Message-ID: On 9 May 2000 12:14:04 GMT, Bernhard Reiter wrote: > [For using the BSD license.] > > There's no danger that you'll get ripped off in a serious way. > > GNU is pushing a particular ideology for software, but short of > > that most everyone just wants to avoid getting sued. > > This sentences are flawed. If you do not use a strong Free Software > license other Companies might lock up your code and make money from > your work. No one can lock up my code. Big companies lock up *their* code. They'll just be mixing it with mine. I don't particularly care if they make some money using my code. I've seen these license debates go no where, because facts and opinions get mixed up. The first three sentences in my previous paragraph are facts. The last one is an opinion. My personal opinion is that GPL'ed projects hinder further commercial innovation by explicitly prohibiting that. Yes, I know the free beer/speech argument. I also know that companies can survive by providing support for GPL'ed projects, but they don't have enough of an incentive to innovate. -Arun From rzantow at my-deja.com Fri May 5 13:07:41 2000 From: rzantow at my-deja.com (rzantow at my-deja.com) Date: Fri, 05 May 2000 17:07:41 GMT Subject: ftp return format References: Message-ID: <8euv4g$9fq$1@nnrp1.deja.com> In article , "Richard Chamberlain" wrote: > We use a thing called Rumba FileTransfer which is obviously translating > somehow, anyone know how I can do the same? > > e.g. > > from python: > > 0183 > 0000100000000000000000000000000000000000K0000000000000K > 0184 > 0000300000013200000000000000000000000000000000013200000 > 0185 > 0000300001185200000000000000006M0000000000000118520006M > > from Rumba: > > 0183 1 0 0 > 0 -2 0 -2 > 0184 3 132 0 0 0 > 132 0 > 0185 3 11852 0 -64 0 > 11852 -64 > > I realise that it's fix delimited, but then I get stuck on the K and M which > crop up with negative numbers. > Richard, These appear to be overpunched characters (a remnant of cardpunch entry) and the characters directly translate into digits, with the implication that the entire numeric field carries a negative sign. If you isolate the field, Translate '}' to '0', J-R to 1-9 respectively, and multiply its numeric value by -1, you'll get the correct effect. It's likely that someone has already had to do this, but I haven't (in Python, anyway). Pretty trivial, though. -- Pythons, unlike some other snakes, do have hindlimbs, but they never develop beyond vestigial stumps. The arrest of limb development is due to a failure of the sonic hedgehog signalling system ... Sent via Deja.com http://www.deja.com/ Before you buy. From jmg at ecs.soton.ac.uk Sat May 20 08:45:34 2000 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: Sat, 20 May 2000 13:45:34 +0100 Subject: Gnuplot woes. References: <3925AC2A.9CB6DA0D@ecs.soton.ac.uk> Message-ID: <392688EE.75EB1DF4@ecs.soton.ac.uk> Huaiyu Zhu wrote: > I've seen similar behavior on my Linux laptop, probably because the OS does > not write out file promptly (due to apm?). Experimental result: > > for i in range(10): > g.plot(something) > time.sleep(sleeptime) > > works if sleeptime >=0.5, fails if sleeptime <=0.2, and partially fails in > between. The problem in my case seems to be that the file it tries to use has already been replaced by the next temporary file . . . so when it tries to use ####.1, ####.2 has already replaced it . . . however, the following always works: ------------------- while string.lstrip(string.rstrip(command)) != 'quit': g.plot( [[1,1],[2,2],[3,3],[4,4]] ) command = raw_input('plot> ') os.system('ls /usr/tmp') g.hardcopy( 'hmm.ps' ) -------------------- On the other hand, the follwing NEVER works -------------------- while string.lstrip(string.rstrip(command)) != 'quit': g.plot( [[1,1],[2,2],[3,3],[4,4]] ) command = raw_input('plot> ') time.sleep(1) g.hardcopy( 'hmm.ps' ) --------------------- Is there any logic behind this madness ? Jacek From jwbnews at scandaroon.com Tue May 30 10:53:25 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Tue, 30 May 2000 07:53:25 -0700 Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <3933777F.262E1E15@san.rr.com> Message-ID: In article <3933777F.262E1E15 at san.rr.com>, Courageous wrote: > ... FIFO...LIFO > How about: "that data structure that works > like grocery store shelves." :)- That's either of the ideas, depending on whether the store is well-run or not. ;-) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From samschul at pacbell.net Thu May 11 13:51:04 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Thu, 11 May 2000 17:51:04 GMT Subject: Problem with stdout in embedded python References: <8fel9i$8fu$1@nnrp1.deja.com> Message-ID: <8feru1$g7p$1@nnrp1.deja.com> If you are running your application using Python in console mode, you will have to get the pointer to the console stdout. See Microsofts console.h and related documentation. Sam Schulenburg In article <8fel9i$8fu$1 at nnrp1.deja.com>, paul_pelletier at iname.com wrote: > Hi all! > > I've embedded python in a dll of my application and for some reason I > dont see any output made by my scripts using print. Would anyone know > what might be wrong? > > Thanks! > Paul > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From alwagner at tcac.net Mon May 22 19:45:43 2000 From: alwagner at tcac.net (Albert Wagner) Date: Mon, 22 May 2000 18:45:43 -0500 Subject: Damnation! References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <153bb080.5c1c7462@usw-ex0104-031.remarq.com> Message-ID: <3929C6A7.B80F3826@tcac.net> This won't work. It will simply cause a fork in development. It's a one-way street. There is more information in case-sensitivity. The people of the case insensitive fork can easily convert everything to upper or lower case. But then the information is gone and cannot be reconstructed. Hamish Lawson wrote: > > If case insensitivity was introduced, I propose that there > should be a command-line switch to revert to case sensivity for > backwards compatibility (my own preference would actually be to > keep case sensitivity as the default and have a switch to make > it case-insensitive if desired). > > Hamish Lawson > > * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * > The fastest and easiest way to search and participate in Usenet - Free! -- Small is Beautiful From nospam.newton at gmx.li Sun May 28 03:34:43 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Sun, 28 May 2000 07:34:43 GMT Subject: coverting numbers to strings References: <39306546.9DB21A82@fenx.com> Message-ID: <3930c7c9.352515133@news.nikoma.de> On Sat, 27 May 2000 17:16:06 -0700, emile at fenx.com wrote: > BTW, does anyone know if these characters are being generated > on my end or on the sending end? The sending end -- he's sending out the posts UTF-7-encoded, which is even worse to read than quoted-printable in my opinion. (And in a previous post, <8gpbqm$nh3$1 at bob.news.rcn.net>, the article wasn't even flagged as being UTF-7-encoded!) Z 3 Penguin, please turn this off. Not everyone can read UTF-7. Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From cut_me_out at hotmail.com Mon May 1 08:47:32 2000 From: cut_me_out at hotmail.com (Alex) Date: 01 May 2000 08:47:32 -0400 Subject: Discrepency between JPython and CPython References: Message-ID: > No...this is just yet another instance of CPython (less than 1.6) > lying about the value of floats. Since 1.14 is not precise, 1.14 * > 200 can't be...yet the interpreter lies (by rounding off) and pretends > that it is. Oh, OK. Thanks. Alex. From g2 at seebelow.org Thu May 18 17:30:58 2000 From: g2 at seebelow.org (Grant Griffin) Date: Thu, 18 May 2000 22:30:58 +0100 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> Message-ID: <39246112.4F01@seebelow.org> Glyph Lefkowitz wrote: > ... > I have yet to encounter a Linux user (regardless of distribution) who > doesn't have python installed, although most don't know that it's > there. Given how many really useful utilities are written in it, and > how many environments depend on it, it's becoming a basic component of > most modern linux distros. Well, now I gotta tell you a counter-story. I'm a Windows user, for the same reasons most people are. (I won't bore you with the details, but it has something to do with the fact that I started using PCs long before Linux was ever burned into its first CD-ROM.) I'd like to learn Linux and Unix, but frankly, who has the time? And let's face it, Windows works just fine. However, my two web sites run on a Linux box. (Isn't that what you people call 'em--"boxes"? ;-) So I have learned just a few Unix commands, notably "ls" and "chmod", and I use a GUI-based FTP program to cover the rest. It turns out that my web provider (seagull.net: highly recommended) doesn't provide Python by default, although he provides Perl. However, he let's his users install whatever they want on their own disk space. Recently, I wanted Python, so I wrote him a nice note saying that I would probably cause him more trouble than I would save him if I tried to install Python myself. He kindly took the hint, and did so for me. However, in my _own_ environment: I did just fine installing Python on my own Windows machine a few months ago (except that I ran into that darn problem with setting up TCL/TK so it would talk to Python...I had to hit Deja to find the answer.) And I installed Perl a long, long time ago. And, yes, I can even use WinZip. (BTW, why to you Unix people separate your packager gizmo from your compression gizmo? Very strange...) While it's true that the casual user might not want to install all this stuff, luckily both Perl and Python have a "freeze" capability to make that a little easier. (On Perl, they call this capability a "compiler" for some reason. Marketing, Benjamin, marketing.) But if you're having trouble with Windows users not being able to install complex software, I recommend you do what most other Windows programmers do: write an InstallShield script. In fact, I believe that both the Python and TCL distributions come with something like that. (Heck, maybe they're even open source. ;-) 'consumers'-and-'programmers'-be-two-different-animals-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From boncelet at udel.edu Wed May 10 21:33:14 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Thu, 11 May 2000 11:33:14 +1000 Subject: Referencing cells in arrays (numpy) References: <3918caa8.0@news2.cluster1.telinco.net> Message-ID: <391A0DDA.9751213@udel.edu> Duncan Smith wrote: > I am struggling to find out how to reference individual cells in a > multidimensional array. I just don't seem able to find the relevant section > of numeric.pdf. >>>a = array([[1,2,3],[4,5,6]]) >>>a[0,0] 1 >>>a[1][2] 6 (You can use either notation.) > Also, I only want to consider certain cells, so I'm looking for an efficient > method of 'pruning' the array. I'm currently using 'resize', but that still > leaves me with a fairly inefficient 'rejection' approach (at least it will > when I figure out how to reference individual cells). Any ideas? Thanks. > do you mean: >>>a[1] array([1,2,3]) Charlie Boncelet ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From andy at reportlab.com Mon May 22 08:12:44 2000 From: andy at reportlab.com (Andy Robinson) Date: Mon, 22 May 2000 13:12:44 +0100 Subject: ANN: PythonPoint - PDF Presentation Slide Package Message-ID: PythonPoint, from ReportLab, is an Open Source package for making presentation slides. There's still time to use it for Monterey 2000! Slides are defined in an XML syntax, and a Python script converts them into a PDF document. It uses the ReportLab PDF library, the only pdf library to expose advanced Acrobat presentation features. Capabilities include - Outline tree for easy navigation - Page transition special effects - Full control over text attributes - Vector images coded in Python - Accepts bitmap images in most common formats - Style sheets and templates - re-brand presentations in seconds! http://www.reportlab.com/demos/pythonpoint/pythonpoint.html Enjoy! Andy Robinson CEO/Chief Architect, ReportLab Inc. p.s. thanks to Tom Christensen, whose "PerlPoint" last year provided the idea and the name. From pdfernhout at kurtz-fernhout.com Fri May 26 00:04:37 2000 From: pdfernhout at kurtz-fernhout.com (Paul Fernhout) Date: Fri, 26 May 2000 00:04:37 -0400 Subject: Pointrel Data Repository System for Python References: <392AA43E.B3014C3B@kurtz-fernhout.com> <392D4BE1.1A9AB90C@uab.edu> Message-ID: <392DF7D5.58F632DB@kurtz-fernhout.com> Shae- Thanks for the great comments! Shae Erisson wrote: > > Paul Fernhout wrote: > > > > This is the very first (rough!) version of the Pointrel Data Repository > > System. > > This sounds like a three-way linked list with indexes. Am I close? > The only difference I see is that a linked list is generally thought of > as a linear construct whereas this looks more like spaghetti. Very insightful and concise, with one minor quibble that "list" might more accurately be "lists". Yes, I guess that might be in a way a technically accurate description, depending on how broadly one interprets "lists". Obviously Lisp heavily uses lists, and it can do a lot! Like you said, "list" would to me commonly mean something that was intended to be primarily sequential. The Pointrel system allows one to support arbitrary structures. Obviously Lisp supports structures too, made of list elements, and in practice Lisp lists made of two-element pairs are often used to build trees to define structures. Also, "list" implies to me perhaps one list. When using the Pointrel system, you can have multiple structures defined by triads which are not connected in any way, but which you can navigate through if you know the location of an item in the structure. In practice you might anchor these to a common root with some symbolic names to find what you stored again using a text key; so in that way most data might be seen as connected, and in that sense a "list" if you allow "list" to include something that is more like a tree or a web. Also, "indexes" is probably appropriate, but doesn't quite catch the flavor of being able to easily find all the connections to any triad in the system and the implications in terms of transparency of the system. This implementation of the Pointrel system supports creating and traversing webs of nodes (called triads). The nodes can have with from zero up to three ordered (A,B,C) links each. Each node can have an arbitrary binary string associated with it. One can always easily find all the nodes that have linked to any specific node from any particular ordered slot (A,B,C). So, could this be called more or less supporting "three-way linked list(s) with indexes"? I guess so. Could it be called "spaghetti"? I guess so too (depending on how you link up the triads in your repository)! > How is this different from something like Gadfly[1]? > [1] http://www.chordate.com/gadfly.html Here's an analogy. Imagine having a hundred and twenty-two thousand miles of string. :-) Having it all in one piece is like having a relational database management system (RDBMS), like Gadfly. You can cut that string into many strings of whatever length you want, and then use those lengths of string for tying up all sorts of things, using as a leash for your pet cat Eric (if you've got the proper license from the man in the van), or representing weights and measures, and so on. Everyone knows the value of a long continuous piece of string. It's a bit dangerous to keep scissors around for cutting the string of course, but the latest scissors the nice people give out :-) have blunt edges so it's not too bad. It is a pain to keep hauling around a mountain of string though, but you do it because once you cut off a length, it's hard to reuse it, and you want to get the most efficiency out of all that precious string. Now imagine chopping up that string into three-inch lengths. That's the Pointrel Data Repository System. :-) Now, before one calls this "bad planning", consider the following: Fold over the string and tie a knot in the middle. This wil produce something that looks vaguely like this asciii art: ------ ====K ------ These super water absorbent triadal "stringettes" can now be easily tied together to make all sorts of interesting webs without requiring any additional cutting. So, the nice people don't have to worry about providing dangerous sharp devices. You never has to make a big commitment to cutting a specific length of string, and you can easily carry around just a small pile of stringettes and get more if you run out. You never have to worry about keeping track of unusual lengths of string cut to useless lengths due to bad planning -- since all your stringettes are a uniform size, which makes life a lot easier all around! :-) What's more, with a microprint pen, one can write on the knot, thus saving the trouble of encoding text via more stringettes tied to the knot. Further, if you assume a non-euclidian infinite-dimentional space where all string knots are at most apparently less than 1.5 inches apart, you can tie the end of any stringette to the knot of any other stringette, allowing your stringettes to represent arbitrary structures of information. Stringettes for everyone! And now for something completely different.... Gadfly is a great system. I had used it briefly as part of learning to use SQL under Zope. As I understand it, Gadfly is basically a relational database implemented in Python with support for a large subset of SQL. It loads tables into memory before operating on them, which has various implications. So, the question is perhaps more, "how is the Pointrel system different from a typical relational database"? William Kent discusses issues like this at length in his book "Data & Reality". It is in large part an issue of conceptual emphasis. Let me try to explain this difference by giving my take on what types of activities are assumed to be "common", "occasional", or "rare" in the two types of systems. Relational databases are designed for storing large numbers of similar "relations" (table rows). Changing the types of things stored in a relational database is a rare event. "Introspection" of database elements referring to other database elements is also rare. Changing a value in a relation is common event, and adding new data is an occasional event [might be common in some cases]. Processes that need to analyze a significant portion of the data in the database are rare. Deleting data is done occasionally. The Pointrel Data Repository System is designed for storing large numbers of ad-hoc relations, where changing the types of things stored in the database is a common event (but you still want to get at legacy data), "introspection" of database elements referring to other elements is also common, and changing a value in a relation is an occasional event, and adding new data is a common event. Processes that need to analyze a significant portion of the data in the database are common. Deleting data is done rarely. Summary chart: Activity RDBMS Pointrel System =============================================== Changing Types Rare Common Introspection Rare Common Changing Values Common Occasional Adding data Occasional Common Analyze Lots Rare Common Deletion Occasional Rare Some other differences: * The Pointrel system puts all data in one file (well, really two); typically a RDBMS use one file per table. * The Pointrel system never deletes; a typical RDBMS allows deletion (which may require packing). [Deletion can be approximated in the Pointrel System, but only by marking triads deleted and checking for that mark at the application level, creating an alternate structure including only the non-deleted data and working exclusively with the alternate, or cloning the repository without the deleted data]. * The Pointrel system has an absolute minimum of base concepts (triad and string); a RDBMS typically has many base concepts to learn (like table restructuring, allowable data types, indexing methods, etc.). Succesfully using the Pointrel system does require learning many new concepts, but those are more at the application level (i.e. how to represent and retrieve application specific data in useful ways.) * The Pointrel system uses triads to allow arbitrary higher relational layers to be built; a RDBMS typically implements relations as arrays of values in files. * The Pointrel database makes it easy and fast to dive recursively into relations; a RDBMS with SQL typically is not designed to support queries where one is taking a value from a row (relation) and using that value to drill down into rows (relations) of the same table (type). [You can do it, but I not easily.] * The Pointrel system leans towards supporting information retrieval where the information retrieved may change what additional information is retrieved and what it means (by encouraging fine grained traversal); a RDBMs with SQL leans towards supporting information retrieval where the major variable is how many records might come back and you know what the structure of the query result will be (by what SQL's syntax makes convenient). * The Pointrel system could easily (not implemented yet) support doing reports on a consistent view of the database by ignoring all triads after a certain location; a RDBMS has to work hard to provide a consistent view (if it can) given all the various tables and such which may be undergoing changes while the report is running. The core Python source file for the Pointrel System is only 20K, but I hope you'll agree it can do quite a bit for such a small size and thus has a high usefulness per byte ratio. Of course, it can't quite match the ratio of the Forth "idea", which can fit a whole OS/Compiler/Linker/Editor in about 1K. I'm sure Pointrel in its current initial state will suffer from the same tradeoffs you get when you use a 1K Forth, compared to a 1MB Forth with lots of bells and whistles. Pointrel will be far more useful when it has lots of Python scripts for importing and exporting data, for searching the data, and for doing other interesting things (versioning, supporting a reliable file system, etc.). But the fact that you can go anywhere with a 1K Forth says there is an elegant idea there. I hope that someday one might say that about the Pointrel Data Repository System vs. a typical RDBMS. It may always be possible to say a RDBMS does things you want to do better than the Pointrel Data Repository System, just like I could say Python does many things I want to do more easily than Forth. If I was fitting an interpreter into 8K, I'd probably pick Forth over Python. If I was fitting an intepreter into 1MB, I'd probably pick Python. So, my hope is to shape the Pointrel system so that it fits some niche very well. Right now I think that niche is as a flexible data repository. Maybe some other niche would be better? In any case, I should look a lot more at Gadfly. It might be possible to merge the Pointrel system with the Gadfly SQL parser and related search code, to make a version of Gadfly that didn't have to load tables in memory. This version would have many of the performance tradeoffs Pointrel has (flexible but much slower for routine things), but it might be interesting... > The idea somewhat reminds me of natrificial's TheBrain software. I guess > arbitrary relationships is one of its strong points? I looked at a few pages on the site http://www.thebrain.com but it wasn't immediately obvious to me how the implemented what they have. Their intent does sound similar: "TheBrain gives people the ability to organize disparate pieces of information into one meaningful structure that conveys valuable relationships in an easily understandable display." Yes, handling arbitrary relationships is (hopefully) a strong point of the Pointrel Data Repository System. I have implemented versions of the Pointrel system focused on n-ary (tuple) relations (not triads), but I feel the triads provide more flexibility, simplicity, and speed, while not loosing that much of the power arbitrary length tuples provide (since you can build more complex relations from triads). There are many systems people have developed to store arbitrary relationships. Many have been done in the past by AI developers (typically with Lisp). Things really clicked for me though when I was sitting in a tutorial about Lisp (around 1982) and I realized "Aha! Lisp culturally is about lists and structures; what I want to do is more about pointers and relationships (hence, "Pointrel".) > No disrespect meant, I'm just trying to understand more about Pointrel. None taken. Thanks again for the great questions. -Paul Fernhout Kurtz-Fernhout Software ========================================================= Developers of custom software and educational simulations Creators of the Garden with Insight(TM) garden simulator http://www.kurtz-fernhout.com From pinard at iro.umontreal.ca Tue May 23 00:19:31 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 23 May 2000 00:19:31 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: "Neil Hodgson"'s message of "Tue, 23 May 2000 04:10:04 GMT" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: "Neil Hodgson" writes: > Some of us want 'case insensitivity' to lessen sloppiness by allowing > only one capitalisation of each name. Orderly naming of modules is a matter of convention. If the conventions are inadequate, these might be improved where they need to be. Tainting a whole language around a few inadequacies would be a gross over-reaction. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From warren at sunesis-pharma.com Mon May 8 11:40:14 2000 From: warren at sunesis-pharma.com (Warren L. DeLano) Date: Mon, 08 May 2000 08:40:14 -0700 Subject: Multithreaded Performance/Embedding References: <39110799.2415927D@sunesis-pharma.com> <8eruks$gnu$1@slb0.atl.mindspring.net> <3911BA11.CDD451DC@sunesis-pharma.com> Message-ID: <3916DFDE.DFDBEC8@sunesis-pharma.com> Problem resolved... It turns out this was a dynamic library linking issue specific to XFree86/DRI which silently falls back to software rendering when the accelerated hardware driver doesn't load. This caused rendering to consume much more processor time than usual (in a separate thread), and make it appear that the pure C thread I was using to evaluate performance was running much more slowly than usual. Thanks for the help! > "Warren L. DeLano" wrote: > > >Just calling the C code directly from Python, I find that the same C code which > >does OpenGL rendering through Mesa with GLUT simply runs 3X slower as a python > >module than as a standalone C program. > > > >Any ideas? -- mailto:warren at sunesis-pharma.com Warren L. DeLano, Ph.D. Informatics Scientist Sunesis Pharmaceuticals, Inc. 3696 Haven Ave., Suite C Redwood City, CA 94063 (650)-556-8800 fax: (650)-556-8824 From guido at python.org Sun May 21 21:45:42 2000 From: guido at python.org (Guido van Rossum) Date: Mon, 22 May 2000 01:45:42 GMT Subject: 1.6 Debugger References: <7xIV4.46$rw2.2245@news1.onlynews.com> Message-ID: <3928BBA2.F6F1EF99@python.org> Greg Fortune wrote: > > I can't figure out how to invoke the 1.6 debugger with my file loaded. It > worked great in 1.52, but the debugger menu selection has moved into a menu > in the interpreter instead of the a menu in the editor. Assuming this is about IDLE: turn on the debugger in the shell's menu, then run the module using F5 or Ctrl-F5 in the editor window. This interface is far from ideal, and we'll probably redesign the whole thing again -- but probably not before 1.6 is released. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From jblazi at netsurf.de Mon May 15 08:14:15 2000 From: jblazi at netsurf.de (Janos Blazi) Date: Mon, 15 May 2000 14:14:15 +0200 Subject: Speed References: <391e9056_3@goliath.newsfeeds.com> <86d7mon3x3.fsf@g.local> Message-ID: <391fe9f2_4@goliath.newsfeeds.com> > (Have you encountered Conway's work on the problem this > little program is investigating?) Thank you for your suggestion. I have not known this has anything to do with Conway (whom I sort of worship), but I would be VERY, VERY MUCH interested in learning about this aspect. (I teach and one of my pupils showed me the problem stating that probably it was not possible to write a computer program for that [ :) ] and I told him that it would probably take less than 10 minutes (which was true) and so I wrote the program but it would be fascinating to learn more about it. Thank you. Janos Blazi -----= 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 effbot at telia.com Thu May 11 02:20:27 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 06:20:27 GMT Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> Message-ID: Courageous wrote: > Okay, I simply have to know for sure that Python > threads are backed by full operating system threads. yes. > To wit: if I create multiple Python threads on a > machine with multiple CPUs, I should be expecting > take advantage of the additional CPU's, correct? no. for more info, see: http://www.python.org/doc/current/api/threads.html From JamesL at Lugoj.Com Tue May 30 23:40:00 2000 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 30 May 2000 20:40:00 -0700 Subject: And now for something completely different. Was: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> Message-ID: <39348990.F7E82EC0@Lugoj.Com> Johannes Stezenbach wrote: > In my very humble opinion > words = ["foo", "bar", "baz"] > print words.join(" ") > looks right and > print " ".join(words) > looks wrong. It will confuse people and provoke programming errors. Speaking of interesting syntax, did you know the following is perfectly valid C/C++: var = 2["abc"]; Points awarded for determining the type of "var" and the value assigned to it. Extra credit points for explaining why this is valid C/C++. (Hint: this has been valid C for as long as the language has been around.) P.S. I find the syntax " ".join(words) natural and somewhat pleasing. And no, I have no strange desire to see a Scotsman on a horse. Why do you ask? From meh9 at cornell.edu Tue May 2 11:17:47 2000 From: meh9 at cornell.edu (Matthew Hirsch) Date: Tue, 02 May 2000 11:17:47 -0400 Subject: How many is "too many" with lists? Message-ID: Hi all, Is there a rough number of elements in a list that python or a computer has trouble dealing with? I'm using a P233 with 64MB RAM. I have ~25000 elements in a list, and things seem to be slowing down. Is there some number that I should try avoiding? Thanks, Matt From boncelet at udel.edu Wed May 10 22:16:50 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Thu, 11 May 2000 12:16:50 +1000 Subject: Python style. References: <200005102207.IAA20656@envy.fulcrum.com.au> Message-ID: <391A1811.A3F733A1@udel.edu> Richard Jones wrote: > [Johann Hibschman] > > What you really want is something like: > > > > for item1, item2 in transpose((list1, list2)): > > > > to go from a tuple of two lists to a list of many tuples. That's what > > that awful map None does. > > And, because I haven't had a chance to write any Python for far too long, > here's an implementation of transpose() :) > > (code deleted) > > Note the slightly different syntax in the call to transpose(). Extending the > transpose class to N lists and re-writing it in C is left as an exercise to the > reader. It's been done. Check out Marc Lemberg's mxTools. His "tuples" function is this. -- ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From m.faassen at vet.uu.nl Fri May 12 15:11:42 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 19:11:42 GMT Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> <8feh9q$3gn$1@nnrp1.deja.com> <8feku2$5ap$0@216.39.141.36> <391b087a.203308261@news.iol.ie> Message-ID: <8fhl1e$nk0$2@newshost.accu.uu.nl> Sean Mc Grath wrote: >>It's similar to where I live in the northwest. No matter what it looks like >>outside, we always tell people it's raining. :) > Yup, you said it. Ireland, North West, raining? Of course it is > raining dammit! > Anyway, getting back on track... I stopped worrying about > Python about a month ago. Traffic on this list has > increased dramatically. Oh me too. Python's now really at the very edge of the 'straight up into infinity' part of the exponential curse, um, curve. We've seen people clamoring for a newsgroup split a while back, and that was I think the first time since I've been here. Luckily the SIG lists can cover a lot of traffic, and of course the Zope lists cover a lot of Zope related traffic, so I hope this nice group can survive for a while longer. Let's just try to avoid getting snippy, and we're safe. :) > Zope is just about the coolest > thing I have seen this century [:-)]. XML and Python are > like burgers'n'chips, salt'n'pepper, Astair and Rogers.... XML and Zope is getting a lot cooler too. :) > Python is on a roll. Enjoy the ride!!!!! [snip long sig] You-forgot-the-"-ly y'rs"-(or my -ly yours flavor)-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From R.Brodie at rl.ac.uk Mon May 15 12:27:42 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Mon, 15 May 2000 17:27:42 +0100 Subject: How python development is speedy! References: <391FFDB5.FC9A85CA@cui.unige.ch> Message-ID: <8fp8i3$tga@newton.cc.rl.ac.uk> "Sunil Hadap" wrote in message news:391FFDB5.FC9A85CA at cui.unige.ch... > When I look at my Python code, I see little difference in terms of > development efficiency as compared to C++ when used with STL and other > good libraries. Does the higher types such as lists and tuples make > Python so powerful, after all C++ had all that. I think part of the problem is that STL is a relatively recent development. Many of the more useful features in C++ like templates and exception handling are the worst implemented, and the least well understood. I think the observation noted in the oft-quoted language comparison http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf is relevant: 'It is an interesting observation that despite the existence of hash table implementations in both the Java and the C++ class libraries none of the non-script programmers used them, whereas for almost all of the script programmers the hash tables built into the language were the obvious choice.' From hzhu at rocket.knowledgetrack.com Tue May 30 21:30:07 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Wed, 31 May 2000 01:30:07 GMT Subject: __builtins__ References: Message-ID: On 30 May 2000 17:57:28 -0700, Johann Hibschman wrote: >Ah. You should not be using __builtins__. As far as I understand it, >that is a hack variable, which you cannot trust. > >The module you seek is __builtin__ (no s.) > >If you want these functions, the Right Thing is to "import >__builtin__" and then use "__builtin__.min". The fact that there is a >variable named "__builtins__" is an accident of the implementation. > Thanks for the info. This choice of name is very confusing, to say the least. I used commandline completion with __buil TAB, and got __builtins__. Should the interpreter be modified to import __builtin__ automatically and to delete __builtins__ before it displays >>>? Huaiyu From tjg at avalongroup.net Tue May 2 19:39:59 2000 From: tjg at avalongroup.net (Timothy Grant) Date: Tue, 02 May 2000 16:39:59 -0700 Subject: Advice on giving a python course References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> Message-ID: <390F674F.9C5C9F1E@exceptionalminds.com> "Richard P. Muller" wrote: > I will be giving a short course on Python to my research group > (computational chemistry and materials science). I would like to raise > the average level of programming ability in our group, so that more > people can take on the "hard" programming projects that until now have > only been undertaken by a few of the better programmers. OK, I'm going to piggyback on Rick's question. My son's school district has asked me to teach an introductory programming class to some of the talented and gifted students this summer. They want me to teach for eight days. 1.25 hours a day for 1-2 graders, 1.25 hours a day for 3-6 graders. I want to use Python, but have no experience with Python on the Mac, which is what the school district uses. First question: what do I need to be careful of, if anything when using Python on Mac? Second question: does anyone know of any curriculum that could be modified for both of these separate age groups where we can actually cover any useful ground in such a short time period. Third question: given that I don't really think there is a good answer to the above question, what should I cover, and do the different age groups need different coverages? (My kids are all less than seven years old, so I don't really know about the skill levels of the older kids). All input would be greatly appreciated. One short anecdote about my six year old... I put him to bed the other night and he said "Dad I have a great idea for a computer game! It would be a cross between Donkey Kong and Bomberman. Can we write it next weekend?" He'll be part of my testbed for the introductory programming course! -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com Red Hat Certified Engineer (503) 246-3630 Avalon Technology Group, Inc. fax (503) 246-3124 >>>>>>>>>>>>Linux...Because rebooting isn't normal<<<<<<<<<<<< From jkraska1 at san.rr.com Tue May 30 04:08:06 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 30 May 2000 08:08:06 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> Message-ID: <3933777F.262E1E15@san.rr.com> > Wouldn't FIFO be the correct term? Err, yes. Egg on my face. :) I find myself doing that again and again. last first first last, gives a guy a headache. How about: "that data structure that works like grocery store shelves." :)- > More results (code attached): I reran your results on my hardware and in my configuration (you must have some nice hardware, by the way). Anyway: # c-deque(tottime) py-queue(tottime) list(tottime) 10 .004 .004 .004 100 .004 .004 .004 1,000 *.014* .050 .24 10,000 .12 .549 1.18 100,000 1.14 5.44 129.01 When benching your code, I was surprised for a moment that your 1000 entry test was so much faster than mine (I ran the test a half dozen times), but then discovered that my original reported result in that category was a typo. Whoops. This does make a very compelling case for the deque in deque implementations likely to hold 1,000 or so objects (rare, probably). >Your C extension is not much faster than a 5 minute Python hack. >Conclusion? Don't write C unless you have to. :) The better question is what is a good metric for "when you have to." While in some cases the code here is 4x faster or so, it would, as I noted earlier, appear in some cases that you won't be seeing that benefit as a matter of practice. Off the cuff, I'd probably say one good rule of thumb would be that if you're call to an external module involves a great number of operations which can be conducted outside of python, that might be a particularly compelling case. Ergo... mymodule.do_lots_of_stuff() ... is much more of a compelling case than... for i in xrange(0,10000) mymodule.do_a_little_bit() ... and so on ... C/ From mfletch at tpresence.com Sun May 21 00:22:27 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 21 May 2000 00:22:27 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) Message-ID: Personally, I have been bit by case problems probably five or six times (in five years or so). That said, I find working with case insensitive languages difficult to the point where I will not use them (particularly in large projects, and particularly where there are multiple people working on the project). In general, I find that I don't "read" variables, rather I "recognize" them as I gaze at entire blocks of code, largely based on their graphic representation (which is largely based on the pattern of character glyphs). Case insensitive languages make this "recognition" difficult (particularly when different programmers use different capitalization patterns). For new users (and infrequent users), who generally are "reading" and "writing" the language word by word, case insensitivity may be helpful. For me, while "reading" entire phrases (or sentences) of code, having to focus on each word slows me down considerably. It's not that I cannot do it, it's just not as efficient for me. From what I've seen, this may be a common phenomenon (the practice of font design seems to bear it out). I would suggest that any case insensitive system be implemented as an editor aide. If this is to be an educational system, have the system train the user (gently) to use case sensitive operations (which are common in most programming languages). An editor which has a mode where a potential case failure is "flagged" with a pop-up saying "potential case mismatch", with an auto-complete drop-down showing the already used casing would likely be sufficient for beginners, while being easily turned off for more advanced users. Similarly, when a name error is encountered, have the beginner mode in the editor search the for equal-save-case names, and suggest capitalisations. My thoughts, Mike -----Original Message----- From: Guido van Rossum [mailto:guido at python.org] Sent: Saturday, May 20, 2000 10:02 PM To: python-list at python.org Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) "Thomas Malik" <340083143317-0001 at t-online.de> writes: > I've just convinced our whole department (at a german bank) to use Python > instead of Perl. A case - insensitive language won't be acceptable by any of > us. So, Guido, should i start looking for another job ...? This is an example of what I meant when I said "voting doesn't help". You're saying it's unacceptable -- a vote. But you don't say *why* you vote that way, so your vote gets multiplied by zero (rather than by the size of your department or the capital of your bank, as you seem to hope by bringing them into the argument :-). Here's a way to make your vote count: explain what it is about case sensitive languages that you hate. Then we can have a discussion about it. I am a very case-sensitive person myself: it bothers me when people don't start their sentences with capital letters or when they refer to themselves as "i" in lowercase -- or when people refer to Python as "python" or "PYTHON". (Come to think of it, it bothered me when you wrote "german" instead of "German" :-). Yet, here are some of the reasons why I am considering making Python case-insensitive: (1) Randy Pausch, a professor at CMU, found, when teaching Python to non-CS students in the context of Alice (www.alice.org), that the number one problem his students were having was to remember that case matters in Python. (The number two problem was 1/2 == 0; there was no significalt number three problem.) (2) I've met many people who are experienced and accomplished Python programmers but who still, when referring to Python modules or functions in an informal context (e.g. email), make up their own case conventions. E.g. people will write me about the String module or about FTPLib. I also know some of the things I plan to do to make the transition painless and to make the usual problems with case insensitivity more palatable. E.g. I may add a case insensitivity feature to IDLE which makes sure that all identifiers are written in a consistent case, I may add flags to pre-Py3k Python interpreters to turn on case insensitivity or case sensitivity or a special warning mode. -- --Guido van Rossum (home page: http://www.python.org/~guido/) -- http://www.python.org/mailman/listinfo/python-list From effbot at telia.com Wed May 17 09:52:16 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 17 May 2000 13:52:16 GMT Subject: python improvements (Was: Re: New Language) References: Message-ID: Mikael Olofsson wrote: > I thought that Emile pointed out a bug, but you obviously seem to > understand what's going on. Could you share your insight? Each instance has a __class__ attribute, which points to the class object. In Python 1.5 and later, that attribute can be changed on the fly. also see: http://www.python.org/doc/current/lib/specialattrs.html From mikael at isy.liu.se Mon May 22 11:19:34 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 22 May 2000 17:19:34 +0200 (MET DST) Subject: Plea for __eql__ In-Reply-To: Message-ID: On 22-May-00 Remco Gerlich wrote: > Let's give an example. I'm writing a set of functions that have to do with > positions in a chess game. Given two Positions A and B, A != B is obvious > to > implement. But to implement that in Python, I have to define __cmp__ - so > not only do I have to define when two positions are equal, I also have to > define when one is smaller than the other - but that is undefined! '<' > should raise an exception, even though '!=' is reasonable. Hear, hear! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 22-May-00 Time: 17:19:19 This message was sent by XF-Mail. ----------------------------------------------------------------------- From pshinners at mediaone.net Sun May 28 15:54:12 2000 From: pshinners at mediaone.net (Pete Shinners) Date: Sun, 28 May 2000 19:54:12 GMT Subject: Multfile C Extensions Message-ID: i've got a C python extension that has gotten pretty large. i'd like to break the file up into smaller components, but i'm finding this is actually pretty tricky. since all functions/variables must be static (aside from init) how can i get the different files to work with each other? i can work around most of the problems, but the biggest one seems to be the initializing stuff. is there an example of a C extension out there that is split into a couple source files? the biggest problem is i want it all in one module... urgh, this shouldn't be so tough? quick pseudo-example, how can i get this working? Thanks! ---mymodule_a.cpp----------------------------- static PyObject* myfunc_a(PyObject* self,PyObject* args); static PyObject* myfunc_b(PyObject* self,PyObject* args); static PyMethodDef __builtins__[] = { { "func_a", myfunc_a, 1, "Func A"}, { "func_b", myfunc_b, 1, "Func B"}, { NULL, NULL } }; void initmymodule() { Py_InitModule3("mymodule", __builtins__, "Doesn't Compile") } static PyObject* myfunc_a(PyObject* self,PyObject* args) { ... } ---------------------------------------------- --mymodule_b.cpp------------------------------ static PyObject* myfunc_a(PyObject* self,PyObject* args) { ... } ---------------------------------------------- From bawolk at ucdavis.edu Wed May 17 10:45:48 2000 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Wed, 17 May 2000 07:45:48 -0700 Subject: Newbie question - TclError References: <34575A892FF6D1118F5800600846864D2920A7@intrepid> Message-ID: <3922B09C.3A91B4E6@ucdavis.edu> I'm not sure why the example was written as it is, but it won't run. Do the following: 1. Comment out the event.bind(etc...) line. 2. Change "def evaluate(event):" to def evaluate():" This will work. When you have an indirect binding using "command=", the callback should not have an argument. Bruce Simon Brunning wrote: > I've been looking at the 'Getting started with Python' article at > sunworld > ( _p.html>), and I'm having a problem getting one of the examples > (calc.py) working. The code is as follows: > > from Tkinter import * > from math import * > > def evaluate(event): > label['text'] = "Result: " + str(eval(expression.get())) > > frame = Frame(None) > > entry = Entry(frame) > entry['textvariable'] = expression = StringVar() > entry.bind("", evaluate) > > label = Label(frame) > > button = Button(frame, text = "Submit", command = evaluate) > > frame.pack() > entry.pack() > label.pack() > button.pack() > frame.mainloop() > > I'm getting the error message 'TclError: no events specified in > binding'. I've had a hunt round the documentation - if there is an > answer in there, *I* can't find it. > > Anyone going to take pity on a frustrated newbie? > > -- > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > The opinions expressed are mine, and are not necessarily those of my > employer. All comments provided "as is" with no warranties of any > kind whatsoever. From tismer at tismer.com Tue May 9 13:44:26 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 09 May 2000 19:44:26 +0200 Subject: Starship update: April 18 References: <3du2gzmiki.fsf@amarok.cnri.reston.va.us> Message-ID: <39184E7A.B034D6C7@tismer.com> Robin Dunn wrote: > > > * If you had downloadable files on Starship (such as software) > > which you no longer have copies of, you might want to post to > > comp.lang.python or the appropriate mailing list and ask if > > anyone grabbed a copy recently. > > > > The only thing of value that I have (potentially) lost is the archives of > the wxPython-users mailman list. Did anybody happen to have downloaded > them? I think to have the complete archive from the beginning, as a Netscape file. It would be possible to recreate the archives from that. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From dana at mmi.oz.net Mon May 15 12:11:43 2000 From: dana at mmi.oz.net (Dana Booth) Date: 15 May 2000 16:11:43 GMT Subject: Java vs Python References: <4790568F8505079C.4C564E45732EDB9A.4D76AF043C3460B3@lp.airnews.net> Message-ID: <8fp7jv$23l$1@216.39.141.36> Cameron Laird wrote: CL: Python's more portable than Java. You didn't ask, but you should CL: know that. Java's improving, and someday will probably dominate here. CL: A few years ago, we thought surely it'd happen by now. It hasn't, yet. A frustrating problem that I ran into regarding Java... My favorite development computer is a Linux with Visual Age for Java installed. Another guy using a Windows computer had been using NetBeans, but the company picked up a new copy of Visual Studio, and he began using J++, which was creating Windows specific code in some cases. J++ has since been dumped, and the department is now in agreement regarding Java, but it was a little bit of a hassle at the time. And in fact, I don't think anyone has banged out any Java code in weeks. :) -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From arcege at shore.net Sat May 6 10:59:42 2000 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 06 May 2000 14:59:42 GMT Subject: Python/C API question References: <8em56o$i55$1@news.uit.no> Message-ID: User audun wrote: : I'm working on a Python module written in C, and I keep getting : impressed by Python's design and it's C/C++ API. However, I find the : "Python/C API Reference Manual" and the "Extending and embedding" : manuals weak on one point: The exact protocol in defining custom type : objects. My implementation has therefore been largely influenced by : the Python source code on these on this. There is one detail I'd like : to ask about. You might want to also read "How to write a Python Extension" (, as yet still uncompleted). : Let's say I've constructed (in C) a Python object of type ekkiekki. In : the file ekkiekki.c I've defined the methods associated with the object : in a PyMethodDef structure that is used by ekkiekki's setattr and : getattr functions. Furthermore, let's imagine that the method static : PyObject * tapang(self, args) is such a method associated with ekkiekki. : My question is then: Is it wise and/or necessary to do any type checking : on the self-argument in such built-in methods (as in calling a : Ekkiekki_Check(self))? And what about setattr/getattr and the other : "basic" methods defined in ekkiekki's PyTypeObject-structure? Does the : interpreter make any guarantees about "who" being able to call an : object's internal methods? You do not necessarily have to check the type, but it is a quick check (comparing two pointers). The interpreter will deal with most all of this for you. The issue will be that the function prototype will want to be PyObject *self, but your object will be ekkiekki. One suggestion is to add a local variable that casts the value for you: PyObject *function(PyObject *self, PyObject *self) { ekkiekki *object = (ekkiekki *)self; I prefer to make macros to access the fields in the structure: #define ekkiekki_fieldname(obj) (((ekkiekki *)(obj))->fieldname) Do this for each field you will want to access. -Arcege From m.faassen at vet.uu.nl Mon May 15 05:07:53 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 May 2000 09:07:53 GMT Subject: Java vs Python References: Message-ID: <8foep9$31k$1@newshost.accu.uu.nl> Huy Do wrote: > I would just like to know how serious python is taken in the IT industry and > how it compares to something like Java. Hm, Java is taken seriously, and Python is what most companies haven't heard about yet (though this is changing rapidly now, like your message shows). Note: I'm biased in favor of Python. I don't have any significant experience programming with Java. I do have significant experience web programming with Python, especially using Zope. But then, you asked it in the Python group. :) > For example > If a web applicatoin was written in both Java and Python, > which would companies prefer ? *companies* would always prefer Java, because that has all the buzz, they've heard of it, it's hyped all over the place. Whether they *should* prefer Java is another question. > 1. Which is more maintainable ? Depends on the code you write, I imagine. Python may be considered less maintainable as it's harder to enforce interfaces, can't do static type checking, etc. Python may be considered more maintainable as its code is shorter, more readable, you get flatter inheritance hierarchies, you can more easily change things around, and you can more easily reimplement things. I myself would prefer Python; I think a solidly engineered piece of Python could would be as maintainable if not more than a solidly engineered piece of Java code, and faster to set up to boot. > 2. Which is more scaleable ? As for features, I'd say this would be Java; it gets more development in this department, and I imagine it can run on SMP machines without any global interpreter lock. That said, the Python environment is more dynamic which may help you in scaling (distributed objects and so on), the Python environment is more compact, Python may be even more portable than Java, so you can scale up to bigger machines. > 3 Which is faster eg. Java servlets or Python CGI with mod_python ? In theory Java code should be faster; it does a lot more optimizing. In practice however.. Zope seems to outspeed some Java servlet servers: http://www.zope.org/Members/BwanaZulia/zope_benchmarks/benchmarks.html More on Zope: http://www.zope.org Zope is based on Python. Definitely do look at Zope if you're into web programming. Doing the same task in Python may often be faster than Java, possibly due to Python's high-level constructs and the huge overhead of the average Java runtime environment. Here's some research on that and more: http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf Note that the *development speed* with Python is generally estimated to be quite a bit faster than the development speed with Java. This is also an important factor! > Please do not interpret this message as an excuse to discredit java or > python. I am about to start a major web project using Java but have been > referred to python as an alternative so I am investigating this option. The main advantage of Python would be its readability and high development speed. Another big advantage of Python is the existence of Zope. Yet another advantage is Python and Zope's open sourceness. The main advantage of Java would be its massive industry support. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Jhlee at Brooks.com Wed May 24 17:28:33 2000 From: Jhlee at Brooks.com (Lee, Jaeho) Date: Wed, 24 May 2000 17:28:33 -0400 Subject: commands.getstatusoutput on NT Message-ID: <857F15D7E3D8D3118D290008C7CF058601347C3A@mail-naeast1.brooks.com> I want to use commands.getstatusoutput on NT. I have some python script works on Unix and I want to port it to NT. Except getstatusoutput, everything is working fine. I made a simple test script. import commands r = commands.getstatusoutput("dir") for s in r: print s But r has the following error message. 1 The name specified is not recognized as an internal or external command, operable program or batch file. What did I do wrong? On Unix, commands.getstatusoutput("ls") works fine. If there is any other method that does same job on NT, I can change my script. What I want to do is run shell command and get the result. Thanks in advance, Jaeho From brent.fulgham at xpsystems.com Thu May 18 14:36:24 2000 From: brent.fulgham at xpsystems.com (Brent Fulgham) Date: Thu, 18 May 2000 11:36:24 -0700 Subject: Java vs Python Message-ID: > My point was not that "world's funniest home videos" is *better* > than "Masterpiece theatre" or anything on the Discovery channel. > My point was that people should consider their choice of words > and that *better* is very ambiguous as (your superlative here) > can apply to numerous scenarios within the same comparison > differently... > > Does WFHV reach a broader audience base - yea - are they uppity > and "englightened" prolly not, but what does that have to do > with better. > We're getting far off topic, but I have to say that the works shown on "Masterpiece Theatre" generally have something important to say about society, life, etc., and are worth seeing. Watching some guy get hit in the nuts by his two-year-old on WFHV does not have the same "lasting impact" on one's development as a human being. From urner at alumni.princeton.edu Wed May 31 12:01:37 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 31 May 2000 09:01:37 -0700 Subject: Wondering about Domingo's Rational Mean book References: <8h1nqs$dvs$1@epos.tesco.net> Message-ID: "Iain Davidson" wrote: >The advantage of standard CFs is that they produce all >best approximations. The mean method for cbrt(2)-1 misses >131/ 504, for example. > Domingo presents several algorithms based on the rational mean. His Rational Process ARP-2b, for example, _does_ pick up the fraction you mention i.e. 635/504 for cbrt(2) or 131/504 for cbrt(2)-1. There's more source code in another branch of this thread over at comp.lang.python, for those of you interested in computerizing continued fractions etc. See: http://x65.deja.com/viewthread.xp?AN=629442249 Kirby From bbp at zen.via.ecp.fr Sat May 6 19:04:52 2000 From: bbp at zen.via.ecp.fr (bbp at zen.via.ecp.fr) Date: Sun, 07 May 2000 00:04:52 +0100 Subject: maximal integer value Message-ID: <8f24th$2h0$1@sam.via.ecp.fr> Hi. Is there a way to know what is the maximal value an integer is allowed to take ? -- BBP From mwh21 at cam.ac.uk Fri May 26 10:40:35 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 May 2000 15:40:35 +0100 Subject: how can I reload 'from *' ? References: <8F407AF9Dmikecat@192.168.10.38> Message-ID: noemail at nowhere.hades (Mike Cat) writes: > Hi! > > How can I reload things imported with 'from HUGO import *' ? import HUGO reload(HUGO) from HUGO import * or reload(sys.modules["HUGO"]); from HUGO import * (another reason not to use "import *"...) Cheers, M. -- 40. There are two ways to write error-free programs; only the third one works. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From cheesefactory at yahoo.com Wed May 17 20:20:20 2000 From: cheesefactory at yahoo.com (Paul Schreiber) Date: Wed, 17 May 2000 17:20:20 -0700 (PDT) Subject: python 1.6a2 and openssl Message-ID: <20000518002020.14299.qmail@web111.yahoomail.com> To install openssl support, (1) what options, if any, are specified with ./configure? (2) in Modules/Setup, there are commented-out lines dealing with the location of SSL files. What should I put there? or will it get uncommented by doing something in (1)? I am running debian linux kernel 2.2.15, and I have debian packages installed for openssl 0.9.4-5, libssl 0.9.4-5, and libssl-dev 0.9.4-5. thanks. Paul __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ From jkraska1 at san.rr.com Fri May 12 20:58:59 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 00:58:59 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: <391CA969.57CCCA6F@san.rr.com> > RAD -- we want to develop our systems rapidly. We want interfaces that can > deal with lots of inputs, without having to think about it a lot. > Dynamic typing helps us set these up without hassle. In a dynamic language, it's crucial that type specification be optional. C/ From mazza at radiumsystems.com.br Wed May 10 08:29:34 2000 From: mazza at radiumsystems.com.br (Fabio Augusto Mazzarino) Date: Wed, 10 May 2000 09:29:34 -0300 Subject: Free hosting services to use python? References: <39184AA6.51500222@swt.edu> Message-ID: <8fblhh$8h6$1@news.sysnet.net.tw> Shah: I'm not sure, but I think that Zope.org members can have python scripts running in their sites. Try this: http://www.zope.org Hope I'm helping. mazza Shah, Navneet escreveu nas not?cias de mensagem:39184AA6.51500222 at swt.edu... > Folks, > > > Do anyone know the website that provides free hosting services that > supports Python. I need to design a site using python. > > Shah From brunnsNObrSPAM at beer.com.invalid Fri May 26 16:34:46 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Fri, 26 May 2000 13:34:46 -0700 Subject: Open Mind References: <200005261515.BAA14056@buffy.tpgi.com.au> Message-ID: <2a390e52.0c8d76aa@usw-ex0104-032.remarq.com> .. but not so open that your brains fall out. Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From mwh21 at cam.ac.uk Sat May 6 04:45:41 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 May 2000 09:45:41 +0100 Subject: Deleting objects in Python 1.6 References: <39116805.86326A69@python.net> Message-ID: Glyph Lefkowitz writes: > This is slightly unnerving ... (good to know, though) ... I want to > write long-running programs in python that run user-supplied code. > > I take it all of these well-known problems will be fixed in python > 1.6? Some will, some won't. I don't think you'll be able to completely protect your process from arbitrary user code without rexec or something of that ilk - I mean: while 1: pass is pretty unhelpful... Cheers, M. -- There are 'infinite' number of developed artifacts and one cannot develop appreciation for them all. It would be all right to not understand something, but it would be imbecilic to put judgements on things one don't understand. -- Xah, comp.lang.lisp From greg at cosc.canterbury.ac.nz Tue May 23 21:58:55 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 24 May 2000 13:58:55 +1200 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> Message-ID: <392B375F.D6B3C89C@cosc.canterbury.ac.nz> "Steven D. Arnold" wrote: > > Perhaps we could allow the programmer of a module to specify sets of names > to be exported. Some conventional export sets would be `*', `interface', > `standard' and `minimal'. Routine use of 'import *' is bad for various reasons, some of which have nothing to do with how exporting is done. I don't think it would be a good idea to encourage the practice by providing yet more variations of it... -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From pshinners at mediaone.net Sat May 13 15:23:44 2000 From: pshinners at mediaone.net (Pete Shinners) Date: Sat, 13 May 2000 19:23:44 GMT Subject: compiling extension errors Message-ID: <4ZhT4.5034$WS3.42757@typhoon.we.rr.com> i'm getting in touch with the author of the module, but i'm trying to compile with extension under win32, with visc6. the code in the header file looks like this. static PyTypeObject CD_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, "CD", sizeof(CD_Object), 0, sdl_cd_dealloc, 0, sdl_cd_getattr, 0, 0, 0, 0, &sdl_cd_as_sequence, 0 }; ok, so this is simple creating a new structure to represent a new type object (right?). When compiling i'm getting this error. "error C2099: initializer is not a constant" this is happening on the line with PyObject_HEAD_INIT(...) i've been trying to track this one back. it looks like the HEAD_INIT just substitutes in a couple int constants (depending on debug settings) and the constant passed in as one of the arguments. the problem seems to be "&PyType_Type" is not a constant. this is defined as extern DL_IMPORT(PyTypeObject) PyType_Type; /* The type of type objects */ is this a windows issue? the fact that the variable lies in a shared library is making it non-constant? does this mean i must compile this extension directly into the interpreter? i'd really like to keep it as shared extension, but i'm not sure what changes can be made. From rkiendl at gmx.net Thu May 11 09:07:15 2000 From: rkiendl at gmx.net (Robert Kiendl) Date: Thu, 11 May 2000 15:07:15 +0200 Subject: win32all-128 keys for auto-complete Message-ID: <391AB083.80A4C0EE@gmx.net> does anybody know the keys for auto-completition ? selecting one of item in the scrollbox with a keystroke? robert From hwkMueller at t-online.de Mon May 8 13:54:49 2000 From: hwkMueller at t-online.de (HWMueller) Date: Mon, 08 May 2000 17:54:49 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> Message-ID: <3916fe42.508601@news.btx.dtag.de> On Mon, 08 May 2000 02:14:00 GMT, spamfranke at bigfoot.de (Stefan Franke) wrote: >I get a reproducable segfault in the PythonWin editor (win32all-131 / >Python 1.6a2) both on a Win98 and NT4 box whenever I have a source >file large enough (~70kB) and hit the ^ key (requires two keystrokes >on my german keyboard: ^ and space). >Can anyone confirm this? - Just copy a couple of lines a few hundred >times and try it. Yes, for the backslash, a small file and W2000/W98 --HW From ben at co.and.co Sat May 27 13:12:58 2000 From: ben at co.and.co (ben at co.and.co) Date: Sat, 27 May 2000 17:12:58 GMT Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <8goufe$17n$1@newsg4.svr.pol.co.uk> <39300308.69576FD@mit.edu> Message-ID: Alexander wrote: > Makhno wrote: > >> >I have implemented loop in Python >> > >> >for k in xrange(1,100000000): >> > pass >> >> Does xrange create an array of numbers 1...1e8? > > Yes, it does > No, it doesn't. Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From guido at python.org Thu May 18 23:43:04 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:43:04 GMT Subject: C++ extension module crashes on Solaris References: Message-ID: <3924E2AA.D16E140@python.org> "Steven E. Harris" wrote: > > I'm trying to write a simple Python extension module using the CXX > kit. When I attempt to import my compiled module, Python dies as > follows: > > Python 1.5.2 (#9, May 18 2000, 13:45:16) [GCC 2.95.2 19991024 (release)] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import seh_test > Fatal Python error: PyThreadState_Get: no current thread > Abort (core dumped) > > The stack trace looks like this: [...] I suggest posting some source code if you expect help. It's probably a simple bug in your code but it's hard to spot without looking at your code. You seem concerned about threads. are you starting threads in your C code that will call on Python? If so, that's where the problem is -- you have to study the C/API docs carefully regarding the interpreter lock. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From senn at maya.com Thu May 11 16:28:19 2000 From: senn at maya.com (Jeff Senn) Date: 11 May 2000 16:28:19 -0400 Subject: Unified VM (was: Re: Stackless/microthreads merge news) In-Reply-To: Andreas Kupries's message of "10 May 2000 20:55:36 +0200" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> <39144E9E.4928C7E2@tismer.com> <39184C59.DD33AA67@tismer.com> Message-ID: Andreas Kupries writes: > > Several times I have considered what it would be like to have a > > 'simple-unified-VM' that supported continuations (if not full > > continuations -- then at least micro-threading) and could run > > Python, Java Script, Ruby, ... [Visual] Basic?, Perl??, > > ... Java????... > > http://mini.net/pub/ts2/minotaur.html > (Forth underneath) This seems to be the moral-equivalent of WSA -- it simply piles all the others into one executable/process -- by implication I would like to have a shared minimal type/object system: for instance if I maintain a big complex list (or object or ...) in Python, then I'd like to be able to directly mung it with Perl and vice-versa...not convert the whole darn thing every time I switch languages. [It would be more work than I let on ;-) - for instance you would have to rewrite/adapt the compilers for each language to the underlying machine and type/object structure... Chris Tismer should be done with this momentarily...] Also it occurs to me that the parsimony necessary for this would also be useful for maintaining source in many different versions of the same language... -- -Jas From dan at cgsoftware.com Tue May 2 11:25:45 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Tue, 2 May 2000 08:25:45 -0700 (PDT) Subject: How many is "too many" with lists? In-Reply-To: Message-ID: Yes. Try avoiding the numbers 7, 11, 58, and 93. I hate 93. Especially after what it did to my sister. But seriously. What are you doing with the lists that is slow? On Tue, 2 May 2000, Matthew Hirsch wrote: > Hi all, > > Is there a rough number of elements in a list that python or a computer > has trouble dealing with? I'm using a P233 with 64MB RAM. I have > ~25000 elements in a list, and things seem to be slowing down. Is there > some number that I should try avoiding? > > Thanks, > Matt > -- > http://www.python.org/mailman/listinfo/python-list > From 340083143317-0001 at t-online.de Sun May 21 06:05:47 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Sun, 21 May 2000 12:05:47 +0200 Subject: PyOpengl... gone forever? References: Message-ID: <8g8cb6$k3v$10$1@news.t-online.com> > > PyOpenGL should likely be put into a sourceforge project with one or two > people signed on as coordinators. I'm not a C++ coder, so I'm not a useful > choice, but there might be someone willing to stand up and stand in. > Hmm, since i've put my own additions into the module, i could propably do the job. I use only GLUT, and it were on a rather infrequent basis, however. Does someone have the email address of the original author ? Thomas From godzilla at netmeg.net Fri May 12 11:17:10 2000 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 12 May 2000 15:17:10 GMT Subject: How to identify memory leaks in extensions? References: <391AF390.C419189A@spacenet.tn.cornell.edu> Message-ID: Travis 'numpy-mmeory' oliphant said: > The short answer is, everything must be DECREF'd. okay. i am confused now. even if one is __returning__ the array? ============================== ... indep = (PyArrayObject *) PyArray_FromDims( IND_DIM, &dims[1], PyArray_DOUBLE); dep = (PyArrayObject *) PyArray_FromDims( DEP_DIM, dims, PyArray_DOUBLE); indepPtr = (double *)indep->data; /* now let PyArray_As2D re-arrange, if necessary (?), */ /* our array and set the pointers to the rows of array */ PyArray_As2D( (PyObject**)&dep, (char ***) &numarr, &dims[0], &dims[1], PyArray_DOUBLE ); /* do stuff */ return Py_BuildValue("(OO)", indep, dep); ============================== okay, from your post those 'OO' should be 'NN'. but even then ... > Whenever you use a PyArray_XXXXXXX construct that gives you back a > PyArrayObject, you own a reference. You must DECREF before leaving > the subroutine or you have a memory leak. you're saying i have to DECREF indep and dep before i return????? its confusing. i allocate arrays with PyArrayXXX to do stuff with and return them, in my python code i set references to them. somehow the 'setting reference in the python code' is an INCREF over and above the PyArrayXXX? hmmmm.... i'm glad someone told me about that ;-) i guess i had just asumed taht the INCREF happens in the python call when i go arr1, arr2 = my_func() # my_func returning those indep, dep arrays but not before. oh well. so, lets see. every PyArray does one INCREF. every Py_BuildValue does another one if you use the 'O', and when you set a refernece equal to it in a return value, thats yet another?????? or maybe i am confusing the last INCREF with the first one. so when i go in python: x = 3 the 3 is created in storage and there is one reference to it, then when i set x = to it, thats another INCREF. makes no sense. cause when i go x = 4, that 3 should go away sometime. which would make on think the INCREF is done at time of object creation. but if i go x = 3 y = x that y = adds a reference to the 3 object. thanks les schaffer From tanzer at swing.co.at Sat May 6 02:49:40 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Sat, 06 May 2000 08:49:40 +0200 Subject: Arg. Silly question! In-Reply-To: Your message of "Sat, 06 May 2000 06:27:01 GMT." <3913BBF0.5F255D1E@san.rr.com> Message-ID: Courageous wrote : > Okay, in all the documentation, I can't find the way that > one goes about determining an object's type/ancestry. > > I have two different types of things that I want to do: > > 1. Figure out if an object is inherited from a particular > class. > > 3. Figure out if an object is an instance of a particular > class. Look for `isinstance' and `issubclass' in the Python Library Reference. `isinstance (o, c)' tells you if `o' is an instance of class `c'. `issubclass (c, p)' tells you if class `c' is a (direct or indirect) subclass of class `p'. For instance: ------------------------------------------------------------------------------- Python 1.5.2 (#5, Jan 4 2000, 11:37:02) [GCC 2.7.2.1] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> class A : pass ... >>> class B (A) : pass ... >>> class C (B) : pass ... >>> a = A() >>> b = B() >>> c = C() >>> isinstance (a,A) 1 >>> isinstance (a,B) 0 >>> isinstance (b,B) 1 >>> isinstance (b,A) 1 >>> issubclass (A,A) 1 >>> issubclass (A,B) 0 >>> issubclass (B,A) 1 >>> issubclass (C,A) 1 >>> issubclass (C,B) 1 ------------------------------------------------------------------------------- -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From mskott at image.dk Thu May 4 08:19:50 2000 From: mskott at image.dk (Martin Skřtt) Date: Thu, 04 May 2000 12:19:50 GMT Subject: Problems with HTMLgen tables References: <3dnzbdty.fsf@jumbo.skott.dk> <3910A2DC.A2D6FAC8@uab.edu> Message-ID: Shae Erisson writes: > It's just a workaround, but I hope it helps. Thanks Shae it worked perfectly (strange the code i posted was very inspired by an example from an older Linux Joournal article). With almost the same code I have now encountered a new problem. Instead of reading a file the data for the table comes from an PostgreSQL database, the query works fine and data is returned as a list of lists. But when I try to place it in a table HTMLgen makes trouble can some body help me? The code and result of running comes here: #!/usr/bin/env python import string, HTMLgen, _pg data = _pg.connect('bog_depot', 'localhost') fila = data.query("select * from test").getresult() doc = HTMLgen.SimpleDocument(title='Interface statistik for ppp0') table = HTMLgen.Table() tabel = [] doc.append(table) for line in fila: tabel.append(line) print line table.body = tabel doc.write("data-pg.html") With the following response: ('ping', '05-04-2000') <-- Query result gets printed to stdout to. Traceback (innermost last): File "./html-pg-tabel.py", line 21, in ? doc.write("data-pg.html") File "/usr/lib/python1.5/site-packages/HTMLgen.py", line 188, in write f.write(str(self)) File "/usr/lib/python1.5/site-packages/HTMLgen.py", line 274, in __str__ s.append((bodystring % tuple(self.contents))) File "/usr/lib/python1.5/site-packages/HTMLgen.py", line 1560, in __str__ self.body[i][j] = string.replace(self.body[i][j], '\n','
') AttributeError: __setitem__ -- Martin Sk?tt mskott at image.dk 'In a certain sense, all decent programming languages are equally powerfull' Dr. Alan Turing From truck at isp.invalid Fri May 26 06:20:35 2000 From: truck at isp.invalid (S D G) Date: Fri, 26 May 2000 10:20:35 GMT Subject: Text processing for a non-programmer Message-ID: I'm a tech writer with practically no programming experience, but I'm interested in learning programming so as to be able to write some text manipulation programs. It seems like Python would be a good language to start with :) As a starting project, I'd like to write something that will format my usenet followups nicely. Something like: Leave all the headers alone Wrap unquoted lines at the 65th column If quoted lines are longer than 80 characters, wrap them Has anybody got a similar python script that I can use as a starting point. I learn best by hacking examples :) -- _________________________________________________________________________ S D G http://www.doco.net From jkraska1 at san.rr.com Fri May 12 20:56:14 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 00:56:14 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> Message-ID: <391CA8C3.7AFD4337@san.rr.com> > 1. I'd like an equivalent to perl's "use strict" pragma. It's annoying to > have to be so paranoid about making a typo in a variable name. I'd like > the compiler to be able to catch those errors for me. This would be useful, albeit for instance vars, you can already do it, by implementing your own __getattr__ and __setattr__ methods, IIRC. For that matter, you could probably fudge something like this by overridding the getattr/setattr methods of the local module namespaces, albeit I'm pretty new at python and haven't tried it, so... :) > 2. I'd like the ability to specify that a certain parameter or variable is > of a given type. I think that it is inevitable that this sort of optional, declarative information becomes available in python, particularly as pressure for mature compiler technology increases. > 3. I'd like to allow for the formal declaration of protocols a la > Objective-C. A protocol is a set of method calls that an object can claim > to support or not. Well, unless I'm misunderstanding you, you can sort of do this now by implementing methods on a baseclass which, if not overridden, throw an exception... ? > Nuff said. Python kicks ass. I'm a convert! What you said. :)- C/ From z3penguin at penguinpowered.com Thu May 18 14:58:03 2000 From: z3penguin at penguinpowered.com (Z 3 Penguin) Date: Thu, 18 May 2000 14:58:03 -0400 Subject: accesing socket at a lower level? References: <8fvahn$qin$1@bob.news.rcn.net> <8g0ool$q09$3@ites.inria.fr> Message-ID: <8g1egp$cpk$1@bob.news.rcn.net> Cedric Adjih wrote in message <8g0ool$q09$3 at ites.inria.fr>... >Z 3 Penguin wrote: >> I am working on writing python code to access the AIM servers. i have been >> looking at what my code sends out, and using something like > >> from socket import +ACo- >> s+AD0-socket(AF+AF8-INET,SOCK+AF8-STREAM) >> s.send(whateverstring) > > Assuming the missing "s.connect(hostname, port)" >(or "s.connect((hostname, port))"), your code looks correct. Oops. > >> tacks on some extra bytes at the beggining. this confuses the AIM servers. >> Any ideas? (Note: I am not good with C and am against having to write this >> in C) > >Hmm... What told you there were some extra bytes at the beginning? TCPDump Log. > >Are you sure: >- AIM servers use TCP? Yes >- Python client is the problem? Yes, because other AIM clients work fine. >- Python socket C code is properly working? Yeah, tryed it under both 1.5.2 (latest debian package) and 1.6a2 (tarball) > (maybe try test_socket.py in somewhere in the library of Python > -- /usr/lib/python1.5/test/test_socket.py or whatever -- or try > one of the socker examples). Also, tryed from socket import * s=socket(AF_INET,SOCKET_RAW) Traceback socket.error: (93, 'Protocol not supported') under 1.6a2 Hmmm. -P > >-- Cedric From no at spam.net Sat May 13 00:37:20 2000 From: no at spam.net (Tom Vrankar) Date: Sat, 13 May 2000 04:37:20 GMT Subject: Q: Python Script vs. Win32 SendTo Message-ID: <4_4T4.1115$Xl.103670@news.goodnet.com> I'm trying to write a python script that I want to place in Win32's SendTo directory. I'm completely confused. I can drop shortcuts to various .exe files in there, and they do what I want. But a .py script... I got nuthin'. I tried to edit the target of the shortcut to insert "python" (it's in my PATH), but that seemed to just run python on the file I sent to the shortcut, not the script referenced by the shortcut. I tried to define a new filetype with an extention of .sendto, with an Open action that would run the command line 'python script.py "%1"', but got same result. I can approximate what I want by creating a batch file, and dropping it's shortcut in SendTo. I've editted the PIF to close on exit and run minimized, but it's unsightly, and slow, and DOS-ifies the paths of the files I send to it. Anyone have any suggestions for the "correct" way to write a sendto-able script in python? Thanks for any ideas. twv@ -- --------------------------------- Tom Vrankar twv at ici.net http://home.ici.net/~twv/ Rhode Island, USA From g2 at seebelow.org Wed May 10 03:52:51 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 10 May 2000 08:52:51 +0100 Subject: HTMLParser tag contents References: <3913CBAA.64BB@seebelow.org> <8f773p$i1f$1@nntp9.atl.mindspring.net> Message-ID: <39191553.26AA@seebelow.org> Aahz Maruch wrote: > > In article <3913CBAA.64BB at seebelow.org>, > Grant Griffin wrote: > > > >I've been trying to figure out how to use HTMLParser. My immediate need > >is to extract the entire of a file. (I could do that with 're', > >but I'm trying to learn HTMLParser.) Sure, HTMLParser will returns a > >tag's _attributes_, but I can't figure out how to get to the tag's > >_contents_. Can it do that? > > Take a look at the handle_data() method. That's a good suggestion, Aahz--thanks. I tried it, and it worked, but there was a problem: if you use the "handle_data" method, you get the _text_ of a tag, but you don't get contained tags. So you have to write an extension to SGMLParser, and include handlers for "handle_unknown_tag" to append contained tags to the text from "handle_data". But then, all tags must be unhandled. Also, to capture the text of just one specific tag, such as , your overridden "handle_data" method has to use a flag in "start_body" and "end_body" to know to capture data. All this works, but it seems awkward because it doesn't generalize; it has to be done on a per-tag basis. And it prevents you from using the capabilities of HTMLParser. Therefore, for Python 1.6, I would like to recommend that SGMLParser be modified to provide a method called "get_tag_contents" (or whatever) which can be called at the point of any "end_xxx" to convey the tag's contents (which would include not only text but contained tags and their text.) (The reason SGMLParser has to be modified is that its index into its "rawdata" array is local to its parser routine.) (surely-i'm-not-the-first-(or-last)-person-to-ever-want-to-capture -a-tag's-contents!)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From jmassung at magpiesystems.com Tue May 2 16:44:47 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Tue, 2 May 2000 14:44:47 -0600 Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> Message-ID: >Every single kid who learned HyperCard (especially me) and tried to go >on to bigger and better things with it was immediately frustrated by >its limitations. There was a long and painful process of unlearning >everything they'd ever done with HyperCard to actually be able to do >anything useful. Interesting. I first learned Basic, Pascal, C/C++, then Hypercard (it was all we had at our school). So it is good to see the perspective from the orther side. >It's also a very bad way of thinking about programming -- the >HyperTalk reference lists hundreds of "commands" that are bindings to >specific functionality, rather than methods or functions; there's no >good way to define a new kind of class, let alone inherit from an >existing one; there are scads of subtly special syntaxes, the language >is hard-wired into a vastly substandard development environment, and >Apple has no intention AFAICT of supporting this under OSX. >Abstraction? Hah! Definitely no disagreement here, I just thought that with the GUI idea of Hypercard would help the learning process. It is interesting to learn the exact opposite! I wonder why...? :) >No offense to the poster of this message, but HyperCard was what >taught me never to rely on commercial software :-) and I really feel >strongly about discouraging its use (no matter what the context) None taken ;), but I'd like to know why, is there psych. behind it? Failure to see what is "really going on behind the curtains" that inhibits the child later? - Jeff Massung (jmassung at magpiesystems.com) - Lead software engineer for Magpie Systems (www.magpiesystems.com) - Bringing smart pigs and data analysis to the pipeline industry! From alwagner at tcac.net Tue May 2 10:18:48 2000 From: alwagner at tcac.net (Albert Wagner) Date: Tue, 02 May 2000 09:18:48 -0500 Subject: Tk button enable/disable? References: <390E4F93.3ADF2ECD@tcac.net> Message-ID: <390EE3C8.2A29CE06@tcac.net> Thank you very much. That works, of course. I completely overlooked .config(). I assume that .update() is not required. I commented it out and .config() works fine by itself. Thanks again. -- Small is Beautiful From fredrik at pythonware.com Fri May 12 07:27:10 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 May 2000 13:27:10 +0200 Subject: correct round of reals? References: <391BE774.95B2C26D@stud.ntnu.no> Message-ID: <006701bfbc05$04bfcbc0$0500a8c0@secret.pythonware.com> Peter Schneider-Kamp wrote: > I have put the rint(3) function in the math module. As > Guido observed this is not an ANSI C function and not > available on every platform. Now I want to "simulate" > rint on those insane platforms. What is the Right Way(TM) > to do it? > > I have written > double myrint(x) double x; { > return floor(x+0.5); > } > so far, but that does not seem to exhibit the same > behaviour. Problems with this definition: > myrint(2.5) gives 3.0, not 2.0 as rint(3) > myrint(3.5) gives 4.0 as expected > > IEEE standard seems to be rounding towards the next > even integer in .5-cases. How do I do that? how about: def rint(v, m=4503599627370496.0): if abs(v) > m: return v if v > 0: return (v + m) - m else: return (v - m) + m (this assumes IEEE doubles) From nicshane at my-deja.com Mon May 15 17:12:16 2000 From: nicshane at my-deja.com (nicshane at my-deja.com) Date: Mon, 15 May 2000 21:12:16 GMT Subject: Attempt to export non-public symbol Message-ID: <8fpp73$4da$1@nnrp1.deja.com> I am currently trying to enable my c code to be called from python. I have written a simple module which worked fine but am now trying to incorporate a much larger module following the same procedures and am not having any success. One difference which I guess is the problem is a warning message I get when linking : Warning : Attempt to export a non-public symbol '_initoptprice' This is the only difference between the working and non-working versions. As it is on the init function it is more than likely the problem ?? Any ideas how to eradicate this ?? Regards, Shane. Sent via Deja.com http://www.deja.com/ Before you buy. From DOUGS at oceanic.com Mon May 29 04:27:06 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sun, 28 May 2000 22:27:06 -1000 Subject: cgi odbc sql delete ? Message-ID: <8457258D741DD411BD3D0050DA62365907A1B0@huina.oceanic.com> The usual thing when there is a difference between running interactively and as a CGI is something to do with permissions. Because the problem crops up when you are trying to do a delete I suspect this is the cause. You probably created the database and when you are running the script interactively your script, which inherited your permissions, is able to delete. When the CGI gets called from the web page it will be running with the permissions of the web server. Those are usually deliberately set to deny such things as deleting. In other words, read but don't write. The solution probably depends on your operating system and the web server, but this is where I'd start to look. Good luck, -Doug- > -----Original Message----- > From: Rob Elder [mailto:rob at electric-id.com] > Sent: Saturday, May 27, 2000 9:37 PM > To: python-list at python.org > Subject: cgi odbc sql delete ? > > > Hello, > > I have a problem that is driving me crazy. > I have created a set of routines to do sql functions (odbc, > access) in a > cgi script. When the script runs the Insert routine works but > the Delete > does not. However, in the interactive Python window on the > very same server > both function work fine. The code is referenced below fyi. If > I comment the > actual delete line in the routine out, there is no problem. There is > something wrong with: > > dbcursor.execute("DELETE FROM userTable WHERE userID = %s" % sysID) > > It probably is a format problem (???) but I don't know what > it is. If the > problem is not obvious, please give me some ideas on how to > debug this. I > have totally run out of ideas. TIA. > > -r > > REFERENCE_________________________ > > def DeleteRecord(sysID): # this does not work cgi but does work > interactively > > dbconn = odbc.odbc('xFrame_db') > dbcursor = dbconn.cursor() > dbcursor.execute("DELETE FROM userTable WHERE userID = > %s" % sysID) > dbcursor.close() > dbconn.close() > > def InsertRecord(sysID): # this works both interactively and cgi > > dbconn = odbc.odbc('xFrame_db') > dbcursor = dbconn.cursor() > dbcursor.execute("INSERT INTO userTable (userID) VALUES > (%s)" % sysID) > dbcursor.close() > dbconn.close() > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From PA0215481 at ntu.edu.sg Tue May 9 08:28:30 2000 From: PA0215481 at ntu.edu.sg (#VEDALA NARASIMHA KUMAR#) Date: Tue, 9 May 2000 20:28:30 +0800 Subject: newbie's question in JPYTHON Message-ID: <0CF260C495FED111A6610000F866308D0E326483@mail3.ntu.edu.sg> Hi there, I have a problem with loading jpython applets. here's the situation. Say, i have this module "Applet.py" I compiled it using 'jpythonc Applet.py' this created 'jpywork' directory with files 'Applet$_PYInner.class' 'Applet.class' and 'applet.java' in it. Now, i'm not able to load this class into browser (appletviewer says not initialized). Is there any further step to this? thanks in advance! kumar. From robinhat at rhk.dk Tue May 9 17:18:22 2000 From: robinhat at rhk.dk (Lars Hoeyrup Jensen) Date: Tue, 09 May 2000 23:18:22 +0200 Subject: MySQLdb + Python + quotes Message-ID: <3918809E.1D5F3CFE@rhk.dk> I use the MySQLdb module to make Python interact with MySQL. I have a problem, when I try to insert strings that contain special characters (here I primarily think of quotes: ' and "). There _must_ be a smart way to escape these characters. I'm looking for something precisely like the Addslashes function in PHP; see this URL: http://dk.php.net/manual/function.addslashes.php3 I've looked through the usenet archives but could only find the same question, but with no answer. Any help will be greatly appreciated, Lars H?yrup Jensen From francis at robinton.demon.co.uk Mon May 8 15:44:56 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Mon, 8 May 2000 20:44:56 +0100 Subject: Copyright and License References: <000801bfb8b9$f0fc7280$b12d153f@tim> Message-ID: In article , Glyph Lefkowitz writes >I think that after this thread I'm going to be putting stuff into the >public domain... (thanks tim!) An alternative is to publish in a place that carries dated archives (so you can proof prior art.) Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From moshez at math.huji.ac.il Sun May 14 18:02:38 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 15 May 2000 01:02:38 +0300 (IDT) Subject: Code sanity checker? In-Reply-To: <39201fc1.10448224@news.btx.dtag.de> Message-ID: On Sun, 14 May 2000, Stefan Franke wrote: > Is there a tool which checks if classes or functions are defined twice > in the same scope of a Python script? No, but it wouldn't be too hard to catch the common cases with the ``parser'' module. From aa8vb at yahoo.com Wed May 31 12:30:00 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 31 May 2000 12:30:00 -0400 Subject: tkinter module on a Sgi In-Reply-To: <8gvtsg$rbo$1@nnrp1.deja.com>; from mturatti@my-deja.com on Tue, May 30, 2000 at 08:24:58AM +0000 References: <8gvtsg$rbo$1@nnrp1.deja.com> Message-ID: <20000531123000.A3125801@vislab.epa.gov> Maurizio Turatti: |I installed the python 1.5.2 package from freeware.sgi.com but when I |import Tkinter it doesn't find the _tkinter module. Should I download |and compile the source or is the precompiled module "hidden" somewhere |into the tarball? I run Tkinter on SGI (one of many I'm sure). If you need any tips, let me know. Really pretty easy. Install tcl/tk, edit Python's Setup file to point to them, build, and away you go. -- Randall Hopper aa8vb at yahoo.com From urner at alumni.princeton.edu Mon May 29 16:01:25 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Mon, 29 May 2000 13:01:25 -0700 Subject: Quadray Coordinates: A Python Implementation Message-ID: <92j5jsgglgudldrto7rs980tr87b5eiccc@4ax.com> I've just put up a first web-ready edition of: Quadray Coordinates: A Python Implementation http://www.inetarena.com/~pdx4d/ocn/pyqvectors.html Thanks to those of you who offered suggestions for improvements (draft text posted earlier to this newsgroup). Kirby From robin at reportlab.com Fri May 19 11:31:20 2000 From: robin at reportlab.com (Robin Becker) Date: Fri, 19 May 2000 16:31:20 +0100 Subject: ReportLab 0.93 Released Message-ID: <958750281.24920.0.nnrp-13.c29f0489@news.demon.co.uk> ReportLab 0.93 Released ReportLab Inc. Proudly releases ReportLab 0.93 an improved version of its PDF generation software. You can get the software from ftp://ftp.reportlab.com/ReportLab_0_93.tgz ftp://ftp.reportlab.com/ReportLab_0_93.zip Main Changes ============ PDFBASE The default font encoding has been changed from macRoman to winAnsi as this is reputedly more common. The default encoding for Symbol remains macRoman, however. PDFGEN The canvas class has been significantly upgraded. Outlines can be generated. PDF Forms are now possible. The platypus document layout software has been improved. Variable page layouts. Intra paragraph style changes using sgml type tags, you can change the colour size and style of text. Paragraphs now split across column/page ends. DEMOS ===== Pythonpoint Andy Robinson's pythonpoint demo has been upgraded; it shows the use of outlines and various other new features. Py2pdf Dinu Gherman has contributed this python --> PDF converter It has nice features and colorization. A patch to make idle use py2pdf is available at ftp://ftp.reportlab.com/idle.pat this patch works with this release or a cutdown version of py2pdf and reportlab which could be installed in the tools subdirectory alongside idle. This cutdown version is at ftp://ftp.reportlab.com/py2pdf.tgz ftp://ftp.reportlab.com/py2pdf.zip Odyssey A sample text printing demo is odyssey.py, or dodyssey.py which can be used to show speed and or formatting capability. From slinkp23 at yahoo.com Sat May 13 01:48:29 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sat, 13 May 2000 01:48:29 -0400 Subject: python book recommendations? References: <8fgsqq$kuo@news.or.intel.com> Message-ID: <391CECAD.7FD241AF@yahoo.com> "Snoopy :-))" wrote: > BTY: "Learning Python" is also a very good book, but as a Newbie I found it > quite overwhealming, to the point, that I almost stopped learning Python. > On the Other hand I am very happy that I bought the "Teach Yourself Python > in 24hrs". I find it considerable easier to comprehend the concepts, etc. OTOH, I got "Learning Python" and I've found that after reading just the first half of the book and doing maybe 1/4 of the exercises, I had a very good grasp of the language, including classes and exceptions (both new ideas to me). From there the next step is to skim the second half looking for useful bits, or poke around in the library reference manual. But then, it did take more than 24 hours. :) -- ................ paul winkler .................. slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From jkraska1 at san.rr.com Fri May 19 02:11:38 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 19 May 2000 06:11:38 GMT Subject: Python3k extended grammar References: Message-ID: <3924DBD5.DE6608C6@san.rr.com> Robert wrote: > > uggh...keep "return"...out with "->"...nuff said! Well, just in case someone mistakes us for a committee :)- I agree. One of python's saving grace's is the approachability of its syntax. Python's syntax is wonderfully lightweight, devoid of the usual mess of symbols which weigh down other languages. Let's keep it that way. C/ From jkraska1 at san.rr.com Sat May 13 21:56:14 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 14 May 2000 01:56:14 GMT Subject: HEAP/priority queue References: <391CA714.3EB0E8B5@san.rr.com> Message-ID: <391E085B.EFFBC2C2@san.rr.com> > Could someone explain to a naive programmer here what the use of that > lovely structure is? I understand what is going on, just not why... A heap priority queue has the property such that the elements can be inserted and pulled out in a user-defined order in O(log N) time. So, for example: heap.push(7) heap.push(3) heap.push(9) heap.push(2) would be popped() as 2,3,7,9 Obviously such a data structure is only needed when appending onto the end all the time isn't possible (otherwise you'd just use something like a fifo, both pushing and popping in O(1)). My application involves scheduling tasks to be time-sliced at absolute simulation times (as opposed to real times). The- simulator is sort of a melding of a full thread scheduling (care of Mr. Tismer's continuation system), combined with discrete event-based simulation, with events (and predicates resolving from those events) having the ability to impact the time slicing of various procedures in the system. I'll probably eventually head to a native implementation for pqueues, but not for a while (push/pop operations are somewhere near 7th in the list of where all execution time is going, so not really high on my own pqueue, yet). C/ From petersc at stud.ntnu.no Fri May 12 07:13:56 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 12 May 2000 13:13:56 +0200 Subject: correct round of reals? Message-ID: <391BE774.95B2C26D@stud.ntnu.no> Hei! I have put the rint(3) function in the math module. As Guido observed this is not an ANSI C function and not available on every platform. Now I want to "simulate" rint on those insane platforms. What is the Right Way(TM) to do it? I have written double myrint(x) double x; { return floor(x+0.5); } so far, but that does not seem to exhibit the same behaviour. Problems with this definition: myrint(2.5) gives 3.0, not 2.0 as rint(3) myrint(3.5) gives 4.0 as expected IEEE standard seems to be rounding towards the next even integer in .5-cases. How do I do that? Any hints appreciated, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From mwh21 at cam.ac.uk Thu May 11 18:41:55 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 May 2000 23:41:55 +0100 Subject: Augmented assignment (ie. += and friends) for Python! References: Message-ID: wtanksle at dolphin.openprojects.net (William Tanksley) writes: > On 10 May 2000 18:53:22 +0100, Michael Hudson wrote: > >I thought I might waste some time by having a crack at implementing += > >and friends in Python. I think I know what I want to do on the > >codegen side, but at the moment that hurdle looks some way off. > > Sounds like fun. And indeed it was; I think I'm done now (well, the hard bits, anyway). I have built myself a Python that does this: Python 1.6a2 (#38, May 11 2000, 18:31:58) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> a=range(10) >>> a[2] *= 4 >>> a[3] -= 4 >>> a [0, 1, 8, -1, 4, 5, 6, 7, 8, 9] Cool, huh? You can read about it and find a patch here: http://starship.python.net/crew/mwh/aug-patch.html Questions, comments, flames, praise, abuse - all welcome. for-my-next-trick---static-typing-(only-joking)-ly y'rs Michael -- 31. Simplicity does not precede complexity, but follows it. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From moshez at math.huji.ac.il Sun May 21 00:11:33 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 21 May 2000 07:11:33 +0300 (IDT) Subject: Damnation! In-Reply-To: <0a9fb4a6.6d6153c1@usw-ex0104-028.remarq.com> Message-ID: On Sat, 20 May 2000, Hamish Lawson wrote: > The issue is essentially about enforcing a naming rule that > disallows names that differ only in case. My idea would be that > namespaces would still be fundamentally case-sensitive, but you > could have the interpreter additionally enforce the above naming > rule. Whether or not this enforcement is the default behaviour, > it can always be turned off. Note: this is my last post on the subject. No, that won't do at all: half the modules in the world will still not be tested with this switch, so you'll still have to run without it a lot of the time. Once you begin running without it, you'll miss the mistakes in your own modules, and turning it back on would mean to fix 10-20 modules before you can continue debugging. It isn't similar to -t and -tt, since once there is a .pyc, these have no effect, while the naming switch will still be needed. It's much better to say "the language is case-insensitive" and to have the tools correct case as you write. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From matthewm at zebrasoft.co.nz Thu May 4 17:26:16 2000 From: matthewm at zebrasoft.co.nz (Matthew Miller) Date: Fri, 05 May 2000 09:26:16 +1200 Subject: Linux and Python install problem References: <3911DA5C.CF54F960@zebrasoft.co.nz> Message-ID: <3911EAF8.A0CF1EC3@zebrasoft.co.nz> Thanks for your reply Martin. I'm running Caldera OpenLinux 2.3. I've tried the Redhat rpm from python.org, but doesn't install correctly on COL2.3, so I've downloaded the py152.tgz from python.org, and tried to install from that. I've written some shell scripts and they all execute fine, so I'm baffed as to why ./configure doesn't work - something simple no doubt. The COL2.3 distro contains a rpm for python-1.5.1, but part of my reason for installing python-1.5.2 and maybe 1.6 is to become more comfortable with using shell scripts to install stuff. "Martin Sk?tt" wrote: > > Matthew Miller writes: > > > Hi everyone, > > > > I'm REALLY new to Linux and I'm stuck. I've downloaded python-1.5.2 and > > untarballed the distro. However, when I run the configure shell script > > using ./configure, bash reports "No such file or directory". I'm doing > > this from within the python directory (ie: not a path issue as far as I > > can tell) and have ensured execute permissions are set etc. Any ideas? > > Thanks... > > Before you start installing to much, which distro are you running? I > guess that the majority of Linux distributions today all include > Python in some strange package format. Try and check your CD or > download server to see if somebody has done all the work for you. > On Red Hat all software packages are placed in the RedHat/RPMS/ > directory. Try doing an ls | grep python in that directory and > install the pachages using rpm -ivh If you are > running Red Hat I guess most of Python has allready been installed > because many of the Red Hat setup tools are written in Python. > > -- > Martin Sk?tt > mskott at image.dk > > 'In a certain sense, all decent programming languages are equally powerfull' > Dr. Alan Turing -- Matthew Miller Zebra Software Ltd. E-mail: matthewm at zebrasoft.co.nz Ph: 025-2920625 / FAX: 03-3842397 From Jhlee at Brooks.com Wed May 24 18:10:31 2000 From: Jhlee at Brooks.com (Lee, Jaeho) Date: Wed, 24 May 2000 18:10:31 -0400 Subject: commands.getstatusoutput on NT Message-ID: <857F15D7E3D8D3118D290008C7CF058601347C3B@mail-naeast1.brooks.com> Trent Mick wrote: >THe commands module is actually using the following code: > > >def getstatusoutput(cmd): > """Return (status, output) of executing cmd in a shell.""" > import os > pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') > text = pipe.read() > sts = pipe.close() > if sts == None: sts = 0 > if text[-1:] == '\n': text = text[:-1] > return sts, text > >i.e. instead of running "dir" is runs "{ dir; } 2>&1" on the >NT shell. NT's >shell does not understand the braces. You can manually use the >same code but >drop the braces (and the semi-colon for that matter). The '2>&1' copies >stderr to stdout so that both streams are captures. > >Note that os.popen (i.e. shell pipes) are, I believe, not >considered fully >reliable on NT (and certainly not on Win9x). The safest way to >do all this is >to redirect shell output to a file and then just process it yourself. >Granted that this is a pain. > >And, by the way, os.listdir() is a better way to get a list of >the files in a >directory. But then you gave a test case and you know that. > >Hope this helps, > >Trent > Thanks Trent, I used the code and made my local getstatusoutput. It works fine. You guessed right. I need more than just 'dir'. It is for preparing test, such as removing garbage file. But I want to user can set the preparation task in the test script. Because this is not critical stuff, I think that I can stay with popen, unless it does not make big disaster. I copied this mail to python-list so that any other people can get help from your mail. Thanks, Jaeho Lee From dag at orion.no Sun May 21 15:18:25 2000 From: dag at orion.no (Dag Sunde) Date: Sun, 21 May 2000 21:18:25 +0200 Subject: Py... is using the .pyc file even if I've edited the source! Message-ID: Is it a way to force Python to skip generating the .pyc file for a module? If I'm editing my main-module and a submodule at the same time, edits in the sub-module is ignored after the first time I run the main module... ( I guess it caches the bytecode???) Anyone? TIA... Dag Sunde From db3l at fitlinxx.com Wed May 3 17:53:40 2000 From: db3l at fitlinxx.com (David Bolen) Date: 03 May 2000 17:53:40 -0400 Subject: Doesn't anybody write to paper anymore? References: <38F5FDF3.EE2FBA01@tcac.net> <38F94701.CA52FDBB@tcac.net> <8dd0gq$crn$1@nnrp1.deja.com> <39103AC0.35E2071D@gssec.bt.co.uk> Message-ID: Alan Gauld writes: > "Hernan M. Foffani" wrote: > > > docs say that os.popen() is "unreliable on Windows." Is this still > > Well, there is a reliable "os.popen()" for windows around there. > > Really where? > I couldn't get popen to work at a;ll on NT4 or win95 os.popen() has been working fine for me on my NT4 systems (SP4 and SP5) to run all sort of sub-processes - what sort of failures have you been having? -- -- 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 m.faassen at vet.uu.nl Tue May 23 19:14:32 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 23:14:32 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <3929D1F5.DC00DBC9@prescod.net> <8geval$e6igp$1@fido.engr.sgi.com> Message-ID: <8gf3co$jce$1@newshost.accu.uu.nl> Paul Jackson wrote: > richard_chamberlain wrote: >> When we teach our children to write we teach them case sensitivity, > Ah - but we teach them that case is partially context sensitive. > Formal names are always capitalized, but most words are only > capitalized at the start of a sentence. > Can you imagine it being that "light" meant of little weight, > whereas a "LIGHT" was a photon emitter, "LIghT" a stream of > photons, and to "liGHt" something was to set fire to it? But in fact 'bill' and 'Bill' do have different meanings. There are more such examples. But in general, there are conventions that have to do with capitals. In English if something starts with a capital it may be: * the starting word of a sentence * a name (and probably some other cases) On the net, all capitals is commonly interpreted as SHOUTING. In Python there are other conventions, but the principle is the same. Capitals are used with class names, for instance, while all-caps are often used for constants. The idiom is different, but the fact that there *is* a consistent idiom for the use of capitals is similar. > Still, I would caution Guido against making too much of the > Alice work. At least in my couple of attempts to introduce > myself and my son to it, it was not particularly compelling > (in contrast to, say, Pokemon), nor intuitive, nor (at least > on my Windows system) stable (that is, it kept crashing). I can definitely concur with the crashing bit. I never got the cool 3d drawing extension working on one machine, and on another machine it worked but seemed to cause crashing. Also that machine seemed to have nonworking sound, which also caused Alice to crash. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From phil at geog.ubc.ca Sun May 14 00:41:02 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 13 May 2000 21:41:02 -0700 Subject: Best HTML module? References: Message-ID: Jason Long writes: > Sorry if this is a silly question, but I'm Python newbie. > > I would like to be able to take an HTML template file and replace > certain tags or comments with data in my Python variables. Is HTMLlib > my best bet here? Python.org mentions ZTemplate from the makers of Zope > for tasks like this, but I couldn't find it on their site. > An (older?) version can be found at: http://classic.zope.org:8080/Download/ZTemplates and for a nice example of its use, take a look at Andrew Kuchlin's nght2html http://www.mems-exchange.org/exchange/software/python/nght2html Phil From g2 at seebelow.org Fri May 26 18:14:10 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 26 May 2000 23:14:10 +0100 Subject: ANNOUNCE: Python CVS tree moved to SourceForge References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> <0AlW4.111443$MB.2189764@news6.giganews.com> <392A10A8.99B10484@yale.edu> Message-ID: <392EF732.1F80@seebelow.org> Paul Magwene wrote: > > Christopher Browne wrote: > > > > > It concerns me somewhat, from the perspective of the one site > > representing a "physical vulnerability." > > > > Thus, "if an asteroid struck VA Linux Systems' offices," a whole lot > > of data could be lost. ... > Well, from a physical standpoint the situation is less worrisome than > you make it out to be. > > From the sourceforge FAQ: > > What is your backup strategy? ... All that notwithstanding, I think the simple fact that many people will have local copies of the source covers the asteroid-and-earthquake thing. the-only-thing-an-asteroid-would-destroy-is-civilization-itself --ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From stevena at permanent.cc Fri May 19 02:57:34 2000 From: stevena at permanent.cc (Steven D. Arnold) Date: Fri, 19 May 2000 02:57:34 -0400 Subject: Python3k extended grammar In-Reply-To: Message-ID: <4.3.1.2.20000519024957.015d3ef8@127.0.0.1> At 02:53 PM 5/18/2000 -0400, Roy Katz wrote: > int = Integer > def add( (int) x, (int) y ) # specifies type of the parameter > return int; # specifies the return type > raise exGenException: # specifies the exceptions thrown > > z = x + y # body > return z # exit. I like your style better than the alternative; note I haven't read the TYPE-SIG stuff in detail yet. I agree that the spirit of python seems to favor making things as clear as possible, avoiding either perl-style terseness or COBOL-style wordiness. The words that you use make the meaning clearer to me than do the symbols. >(what kind of situation >necessates changing the starting array index from 0, anyway?). Perhaps for UNIX nice values, which range from -20 to 20. I don't so much dislike the idea itself; it's just that setting a variable such as: $[ = -20; ...almost couldn't be uglier. On the other hand, python's pleasant class interface makes you want to write a class to handle nice values, if they needed special management, and just keep lists zero-based so everyone can easily maintain it. steve -- Steven D. Arnold Que quiero sera stevena at permanent.cc "We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard." -- John F. Kennedy From noone at do.not.use Sat May 13 16:35:33 2000 From: noone at do.not.use (Russell Turpin) Date: Sat, 13 May 2000 15:35:33 -0500 Subject: Lambda (was: Augmented assignment) References: <000101bfbca3$8a554b40$3f2d153f@tim> <391DA871.DDBAC4DE@do.not.use> Message-ID: <391DBC95.D3E9AB6E@do.not.use> William Tanksley wrote: > Guido, for one. He points out that it doesn't fit into the > language -- its syntax is all wrong, and the scoping rules > you need/want to work with it are very different from the > scoping rules Python enjoys. Maybe it would be more pleasing aesthetically if it were called something other than lambda? I like it in Python, for the very practical reason that it is a nicer way to generate anonymous functions than the alternative. You should not have to create a named function solely for the purpose of spitting out an anonymous function! That often defeats the desire to have an anonymous function .. "gee, might as well use a named function directly, even if all I do is pass it in ..mumble, grumble." > Me? I hate the whole lambda calculus, not because of > what it is, but because of what many people think it is. > They think that it's the whole of computer science, the > ultimate way to express and reason about programs, when > in reality it's merely a shabby and incomplete model of > how Fortran fails to work. .. If you're going to hate the lambda calculus, you should at least hate it for the right reasons. First, nothing about the lambda calculus is a reaction to Fortran. The lambda calculus is a formal logic; Fortran is a programming language. Church published his papers on lambda calculus starting in the 40s; Fortran was invented in the 50s. I could go on, but I think the time precedence pretty much closes the case, weird physics notwithstanding. Second, the lambda calculus IS very important to people who formally reason about systems. I have to point this out, since some of the best people at doing this -- some of the few doing it commercially! -- are friends of mine. BUT .. if you want to point out that formal reasoning about systems is not much of computer science, and has very little to do with practical software construction, especially anything as RADdy and convenient as Python, you would be right on the mark. Russell From pinard at iro.umontreal.ca Tue May 16 19:04:56 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 16 May 2000 19:04:56 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: kain@cableadmin.com's message of "Tue, 16 May 2000 21:51:40 GMT" References: Message-ID: kain at cableadmin.com (Scott) writes: > def gcd (numer, denom): > """Return the greatest common denominator of two numbers""" > if denom % numer == 0: > return numer > p1 = plist (numer) > p2 = plist (denom) > p1.reverse () > for x in p1: > if x in p2: > return x Hi, people. I prefer the following definition for GCD: def gcd(a, b): while a: a, b = b % a, a return b -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From andy at petdance.com Tue May 2 15:20:02 2000 From: andy at petdance.com (Andy Lester) Date: Tue, 2 May 2000 14:20:02 -0500 (CST) Subject: Advice on giving a python course In-Reply-To: <390F23AF.BB3D4B61@asme.org> References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F23AF.BB3D4B61@asme.org> Message-ID: > On some of the slides you use the back-quote, (probably a PowerPoint > formatting feature), to start a string, as in: > > myotherstring = `this is also a string' > > This input will cause an error. And it is hard to tell PowerPoint > that what you really meant is: > > myotherstring = 'this is also a string' It's very simple, actually. Go to Tools-->Options. Go to the Edit tab. The first option is "Replace straight quotes with smart quotes." Check that off, and it will no longer format them. xoxo, Andy -- Andy Lester, andy at petdance.com, http://www.petdance.com "Inflammable material is planted in my head It's a suspect device that's left two thousand dead." "Hey, is this the new Green Day?" From adjih at crepuscule.com Fri May 19 12:36:00 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 19 May 2000 16:36:00 GMT Subject: accesing socket at a lower level? References: <8fvahn$qin$1@bob.news.rcn.net> <8g0ool$q09$3@ites.inria.fr> <8g1egp$cpk$1@bob.news.rcn.net> Message-ID: <8g3qhg$map$1@ites.inria.fr> Z 3 Penguin wrote: > Cedric Adjih wrote in message <8g0ool$q09$3 at ites.inria.fr>... >>Z 3 Penguin wrote: >>> I am working on writing python code to access the AIM servers. i have > been >>> looking at what my code sends out, and using something like >> >>> from socket import +ACo- >>> s+AD0-socket(AF+AF8-INET,SOCK+AF8-STREAM) >>> s.send(whateverstring) >> >> Assuming the missing "s.connect(hostname, port)" >>(or "s.connect((hostname, port))"), your code looks correct. > Oops. >> >>> tacks on some extra bytes at the beggining. this confuses the AIM > servers. >>> Any ideas? (Note: I am not good with C and am against having to write > this >>> in C) >> >>Hmm... What told you there were some extra bytes at the beginning? > TCPDump Log. That's a silly question, but did you take into account the IP headers and TCP headers (with possible options) ? Now some extra bytes _at the end_ would be ok when padding packets to fit Ethernet minimum size. >> >>Are you sure: >>- AIM servers use TCP? > Yes >>- Python client is the problem? > Yes, because other AIM clients work fine. >>- Python socket C code is properly working? > Yeah, tryed it under both 1.5.2 (latest debian package) and 1.6a2 (tarball) >> (maybe try test_socket.py in somewhere in the library of Python >> -- /usr/lib/python1.5/test/test_socket.py or whatever -- or try >> one of the socker examples). > Also, tryed > from socket import * > s=socket(AF_INET,SOCKET_RAW > Traceback > socket.error: (93, 'Protocol not supported') SOCKET_RAW is low level, and should be used only to send raw packets. For UDP it would have been SOCK_DGRAM. But this is not the culprit I don't know what problem you have, but if it is Python, it looks tricky. Here an example program that works perfectly on my machine ---------------------------------------- from socket import * s=socket(AF_INET,SOCK_STREAM) echoTcpPort=7 s.connect(("localhost", echoTcpPort)) s.send("hello") print ">>>%s<<<" % s.recv(1024) ---------------------------------------- (printing ">>>hello<<<", with Debian 2.1 and python 1.5.2 on x86) -- Cedric From ryan at velara.com Wed May 24 15:41:37 2000 From: ryan at velara.com (Ryan Donahue) Date: Wed, 24 May 2000 15:41:37 -0400 Subject: extending Python on NT Message-ID: I want to write some C extensions, but the docs I have seen do not very well explain how to do it on NT with Visual C++. The docs at python.org point to a url that has the compile.py file, which apparently creates a .dsw file for you. However, the url is no longer valid. Does anyone have any suggestions? Ryan Donahue ryan at velara.com From urner at alumni.princeton.edu Wed May 31 11:45:36 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 31 May 2000 08:45:36 -0700 Subject: Wondering about Domingo's Rational Mean book References: <8h1nqs$dvs$1@epos.tesco.net> <8h34a1$6r2$1@nnrp1.deja.com> Message-ID: david_ullrich at my-deja.com wrote: > There was a long thread right here on comp.lang.python >(let's see, is that where I am, I think so...) on continued >fractions recently. A deja search for "continued fraction" >works. > >DU Thanks David! I did the search and indeed retrieved the source code I was looking for, generously provided by Michael Hudson in post: http://www.deja.com/getdoc.xp?AN=624458140&fmt=text ======================================================== epsilon = 2.2204460492503131e-16 def cfrac(x,err=0.0): result = [] err = err + epsilon while 1: a,b = divmod(x, 1.0) result.append( int(a) ) if not b: return result err = err / (b * (b + err)) if err > b: return result x = 1 / b def converge(partials): p_1, q_1, p, q = 0, 1, 1, 0 result = [] for a in partials: p_1, q_1, p, q = p,q, a*p+p_1, a*q+q_1 result.append( (p,q) ) return result ======================================================== Usage: >>> from roots import cfrac,converge >>> val = 2.**(1./3.)-1 >>> val 0.25992104989487319 >>> converge(cfrac(val)) [(0, 1), (1, 3), (1, 4), (6, 23), (7, 27), (13, 50), (59, 227), (72, 277), (131, 504), (1120, 4309), (1251, 4813), (18634, 71691), (19885, 76504), (217484, 836731), (454853, 1749966), (672337, 2586697),(3144201, 12096754)] My Python code for a different method, called RP2 at Domingo's website, gets me the following (numerator, denominator) pairs (Note: I've stripped off the long integer Ls for readability): [(1, 5), (5, 19), (19, 73), (73, 281), (281, 1081), (1081, 4159), (4159, 16001), (16001, 61561), (61561, 236845), (236845, 911219), (911219, 3505753), (3505753, 13487761), (13487761, 51891761), (51891761, 199644319), (199644319, 768096001), (768096001, 2955112721), (2955112721, 11369270485)] Note how the latter series uses the denominator of the previous for the numerator of the next. I'll do a quick comparison of the error (absolute difference from the floating point target value of 2**(1./3.)-1 in the form of a table: METHOD 1 (standard CF) METHOD 2 (rational mean) 0.259921049895 0.0599210498949 0.0734122834385 0.00323684484197 0.00992104989487 0.000352922707867 0.000948515322518 0.000134573026546 0.000661790635614 2.34459423146e-005 7.89501051268e-005 2.80031564742e-006 9.15562174542e-006 2.05026694233e-007 6.7479390618e-006 4.01913080594e-009 4.1497423825e-007 4.48542819553e-009 4.54868859245e-008 9.17280640333e-010 2.73094219461e-009 1.23254961792e-010 1.67198754841e-010 1.10377817997e-011 1.51283430228e-011 2.66620059364e-013 4.93438623295e-013 1.35114142097e-013 1.89515070304e-013 3.44169137634e-014 3.14193115969e-014 5.21804821574e-015 5.55111512313e-016 4.99600361081e-016 Note that METHOD 2 (Domingo's RP2) is actually converging more quickly, right from the start. However, it's also true that "standard CF" is reaching its target with fewer digits (shorter numerators and denominators). Let's compare "total number of digits" for the two methods: Number of total digits in numerator,denominator: METHOD1 METHOD2 2 2 2 3 2 4 3 5 3 7 4 8 5 9 5 10 6 11 8 12 8 13 10 15 10 16 12 17 13 18 13 19 15 21 So it's something of a trade off. You'll get more accurate fractions with fewer iterations using Method2, but you'll need fewer digits for comparable accuracy using Method1. Note that my code for Method2 (so far I haven't shared it, mostly because it's kinda messy) isn't so general in that it doesn't accept floating point values (like math.pi) and aim at them. Rather, my RP2 code finds the nth root of k, with n and k both whole numbers. So at this point I can't easily give a converging series of fractions for math.pi, as Michael does in his post. Kirby From kmossman at hotmail.com Thu May 18 03:14:06 2000 From: kmossman at hotmail.com (Ken_in_Manila) Date: Thu, 18 May 2000 15:14:06 +0800 Subject: anyone using jpython and QT Message-ID: <8g048c$b60$1@nobel2.pacific.net.sg> anyone using jpython and QT how is it - robust, reliable, sufficient flexibility/depth anyone use it with Windows front-end, and UNIX server ?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard_chamberlain at ntlworld.com Mon May 8 08:31:37 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Mon, 8 May 2000 13:31:37 +0100 Subject: ftp return format References: <87em7eeq99.fsf@psyche.evansnet> Message-ID: OK that sounds about right - I installed the Client Access ODBC drivers and was able to return correct data. Is there anyway I can do this without having to install Client Access and an ODBC driver on each client? Thanks (again :) ), Richard Carey Evans wrote in message news:87em7eeq99.fsf at psyche.evansnet... > "Richard Chamberlain" writes: > > > The problem is then when I use ftplib I get the data back in a certain > > format, I've also used the dos ftp command and I get the data the same way. > > > > We use a thing called Rumba FileTransfer which is obviously translating > > somehow, anyone know how I can do the same? > > Rumba is probably using the AS/400 database host servers. This gives > it access to the database fields, which it can write out using fixed > field widths in PC format. > > The equivalent from Python would be to use ODBC, ADODB or the record > level access available from COM in the free parts of IBM Client > Access. ODBC works quite well for me whenever I need to get data from > our AS/400. > > -- > Carey Evans http://home.clear.net.nz/pages/c.evans/ > > CONFIG_IPL_RDR > Select this option if you want to IPL the image from a real card reader. From rolfn+news at pvv.org Tue May 9 21:15:04 2000 From: rolfn+news at pvv.org (Rolf Rander Naess) Date: Wed, 10 May 2000 01:15:04 GMT Subject: dinamical object creation References: <8f74lo$spt$1@nnrp1.deja.com> Message-ID: [ martin valiente, 08 May 2000 19:31 ] > Hi * > > How can I create an object at runtime, giving its module and class name? > In java it would be: > > Class c = class.forName(stringWithFullNameOfTheClass); > Object o = c.newInstance(); It can be done the same pretty much way in python. Classes are separate objects and they are instanciated by calling them as a function. Also, all defined symbols are available through hash-tables (or dictionaries as they are called in python terms). The global namespace is accessed through globals(), and the local through locals(). (See the library reference, section 2.3 for details). In other words, you can do this: >>> class foo: pass ... >>> classname="foo" >>> xyzzy = globals()[classname]() >>> xyzzy <__main__.foo instance at 80e29b8> >>> or encapsulated in a function: def createclass(classname, *parameters): return apply(globals()[classname], parameters) Rolf Rander -- (c) 2000 Rolf Rander N?ss http://www.pvv.org/~rolfn/ My mailer limits .sigs to 4 lines. But ingeniously I bypassed this by From greglandrum at earthlink.net Wed May 24 10:16:14 2000 From: greglandrum at earthlink.net (greg Landrum) Date: Wed, 24 May 2000 14:16:14 GMT Subject: Creating binary files References: Message-ID: <392BE4F3.9A5005AD@earthlink.net> Anders M Eriksson wrote: > > I know how to open a binary file > > bfile = open("bfile","wb") > > but how do I write an integer into the file? > There's probably a better way to do this, but I use the standard 'struct' module: import struct foo = open('foofile','wb') bar = 666 foo.write(struct.pack('i',bar)) then, to read the file: foo = open('foofile','rb') struct.unpack('i',foo.read(4)) Hope this helps -greg -- greg Landrum (greglandrum at earthlink.net) Software Carpenter/Computational Chemist From kc5tja at garnet.armored.net Thu May 4 18:26:09 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 4 May 2000 22:26:09 GMT Subject: metaHungarian? References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> Message-ID: In article , Warren Postma wrote: >HWND aWin32ApiHandleDefinedInWindowsDotH_hwndWindowHandle; YOU FOOL! Now look at all the soda you made me spew onto the keyboard! :) That's a keeper -- I'm printing that one out, framing it, and hanging it on the wall, above my monitor. Much needed humor greatfully appreciated! -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From latrada at netscapeonline.co.uk Tue May 16 09:24:55 2000 From: latrada at netscapeonline.co.uk (latrada) Date: Tue, 16 May 2000 14:24:55 +0100 Subject: Automating PBEM game References: <8frckk$n7e$1@porthos.nl.uu.net> Message-ID: <39213e67$1_1@plato.netscapeonline.co.uk> This is all pretty straight forward in python. You need to get some basic knowledge of your subject though, so peruse www.python.org/doc You should be looking at files, perhaps re or if it's really simple you could just use the string module, and then the email libraries (perhaps poplib and smtplib) in the standard librarie to work with mail. You even get some nice examples. richard Martijn van der Kooij wrote in message news:8frckk$n7e$1 at porthos.nl.uu.net... > Hi, > > I'm currently looking for the best way to automate a PBEM (Play By E-Mail) > game. > > The following is needed: > * Run a game on regular times (1 to 5 times a week) by starting a executable > and send some on hard disk stored files to the players (email adres can be > put into the name of the file or as first line in the file) > * Get mail from a Pop3 account and look for a certain subject: 'orders' when > found this message must be saved to disk and a executable has to be > started > with this file as parameter; as a result a file has to be send to the > sender of the > orders > > I've no experience with Python, but a lot with other languages on windows > 32. > > Do anyone here have a suggestion and or examples how to implement something > like this? > > Martijn van der Kooij > http:\\yi.org\mkgal > > > > From ivanlan at home.com Fri May 5 08:40:32 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Fri, 05 May 2000 06:40:32 -0600 Subject: Learning Python References: Message-ID: <3912C140.83255EB8@home.com> Hi All-- Alan Wu wrote: > > Hi, > This may not be the best place to ask, but I was wondering if you people > here could help me out with my attempt to learn how to program with Python. > By all accounts, Python seems to be a learn-able language that one can do > useful stuff with. I haven't had much experience with programming (except > for a course in Visual Basic I did a year ago in Year 10), so I'm a bit > hesitant as to how to go about learning a programming language. I was > thinking of buying a book, either Learning Python by O'Reilly or The Quick > Python Book by Manning - does that sound wise? Which book would be best for > a newcomer to programming? > Check out _Teach Yourself Python in 24 Hours_. It's written especially for complete beginners. The Visual Basic won't hurt you very much when learning Python. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From phil at geog.ubc.ca Mon May 22 01:30:29 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 21 May 2000 22:30:29 -0700 Subject: binary Numeric.py for win32? References: Message-ID: SC Zhong writes: > Is it possible to get this? I saw the > same question before but not seeing an > answer. Nice if some body can post it > or put it in a webpage. Right, the ftp site pointed to by: http://www.python.org/topics/scicomp/numpy_download.html is pointing to the old LLNL ftp repository. The site has moved to: http://download.sourceforge.net/numpy/ Paul, are you in a postition to fix this page? Regards, Phil From emile at fenx.com Thu May 11 10:13:19 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 11 May 2000 07:13:19 -0700 Subject: access method local variable namespace? Message-ID: <391ABFFF.7D98B3FB@fenx.com> Accessing an instances' values is rather easy, but if I get your meaning, you want to access, eg, local_var from the __init__ method in the sample code below? I don't know how you'd get to it without saving a reference to it somewhere. Maybe someone can point out a way if I'm wrong. Of course, the easy way would be to make it an instance variable. >>> class A: def __init__(self,val): self.val = val local_var = val*2 >>> a = A(3) >>> a.__dict__['val'] 3 Emile van Sebille emile at fenx.com Douglas du Boulay wrote in message news:<391A3F65.54AC9105 at crystal.uwa.edu.au>... > hi, > > I know it's possible to access the names of methods within > class objects from their __class__.__dict__, but I am > wondering if it's also possible to > access the namespace of the local variables in those > methods and to read their contents? > > >From the "Programming Python" book I read that local variables are > stored in an array instead of a dictionary for faster access and that > vars() and locals() can be used to access those variables when > they are in the current scope, but is it possible to this when they > are out of scope? > > Thanks > doug > -- > http://www.python.org/mailman/listinfo/python-list > From nospam.mrquiz at free.fr Fri May 26 06:54:29 2000 From: nospam.mrquiz at free.fr (Dave Simons) Date: Fri, 26 May 2000 10:54:29 GMT Subject: Indented gonads. References: <8gjqer$k8v$1@nnrp1.deja.com> <20000525225425.Z13281@xs4all.nl> <392E3C88.DADE571@geneva-link.ch> Message-ID: <8F40861C1davemrquizorg@212.27.32.77> We've tracked down the source of the following rumour to borcis at geneva-link.ch (Boris Borcic) on the ven., 26 mai 2000 08:57:44 GMT : >Note that MS Outlook of ILOVEYOU fame, ascribes itself the >freedom to concatenate all text/plain attachments to the body >of your message, throwing away file names. Do the persons >responsible for this purposeful break of standards deserve to >keep their gonads ? > >BB No more and no less than those who make the decisions in any of the other divisions of Redmond Garbage Creations Inc. - try typing out case-sensitive code in Word, for example (I know you don't normally write code in a word-processor, but you might want to write *about* code in a word-processor). -- Adam: What kept you, God? God: Rome wasn't built in a day. From thomas at xs4all.net Sun May 14 14:51:55 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 14 May 2000 20:51:55 +0200 Subject: (gulp) newbie question - portablity of python In-Reply-To: ; from nospam@sorry.com on Sun, May 14, 2000 at 06:42:51PM +0000 References: Message-ID: <20000514205155.P13281@xs4all.nl> On Sun, May 14, 2000 at 06:42:51PM +0000, Keygrass wrote: [ about python portability ] > So ... my question is this: Is this really too good to be true? What I want > to do it write the program on my Win98se (at home) and then use that .exe > or .bat file (or whatever extension it is) at work which uses unix. Well, yes and no. If you do not rely on platform-specific extensions (like the Windows COM stuff, or the functionality of fork(), or the posix module) your code will run on many, if not all, platforms. The file will have the '.py' extension, though, and you need to do some magic to make it into a .bat file (see the FAQ for that, i believe) and even more magic to make it into a .exe file. > Basically, I want a build a program that will replace words and number on > another file. For example, if I had a file called "Outdoor_sports" that > contained the word "baseball bat", I would want my program to change it so > it would say "football". This is entirely possible and pretty simple, as long as it's a text file. If you are working with Word-files or Excel sheets or some such, you'll have a tad more trouble. But, honesty compels me to say, you can do the same in Perl, with more or less the same effort (depending on wether you get along with Perl.) If you wonder how, well, take a look at the 'string' and the 'fileinput' modules. 'string.replace' is probably what you want. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mbel44 at dial.pipex.net Fri May 5 10:29:15 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Fri, 05 May 2000 15:29:15 +0100 Subject: Multithreaded Performance/Embedding References: <39110799.2415927D@sunesis-pharma.com> <8eruks$gnu$1@slb0.atl.mindspring.net> <3911BA11.CDD451DC@sunesis-pharma.com> Message-ID: "Warren L. DeLano" wrote: >Just calling the C code directly from Python, I find that the same C code which >does OpenGL rendering through Mesa with GLUT simply runs 3X slower as a python >module than as a standalone C program. > >Any ideas? Different compiler options? Toby Dickenson tdickenson at geminidataloggers.com From elb at cfdrc.com Tue May 2 10:19:58 2000 From: elb at cfdrc.com (Ed) Date: Tue, 02 May 2000 09:19:58 -0500 Subject: CGI File Size Limit? References: <_h6P4.14007$g4.347236@newsread2.prod.itd.earthlink.net> <390DA15A.EAF8D635@cfdrc.com> <390EDF63.F4D1F64E@cfdrc.com> Message-ID: <390EE40E.276D1E7A@cfdrc.com> Thanks, the advice you pointed to looked relevant, so I gave "#!/Software/Python/python -u" a try. Unfortunately, that caused the following crash in rfc822.py.....but I'll keep trying. Premature end of script headers: d:/users/elb/cfd-expert-dev/database/database.py Traceback (innermost last): File "d:/users/elb/cfd-expert-dev/database/database.py", line 223, in ? form = cgi.FieldStorage() File "C:\Software\Python\Lib\cgi.py", line 869, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File "C:\Software\Python\Lib\cgi.py", line 954, in read_multi headers = rfc822.Message(self.fp) File "C:\Software\Python\Lib\rfc822.py", line 92, in __init__ self.readheaders() File "C:\Software\Python\Lib\rfc822.py", line 135, in readheaders startofline = tell() IOError: (0, 'Error') Lyle Johnson wrote: > Ed, > > Don't know if this is the answer or not, but doing a search for "cgi" on > the Python FAQ (http://www.python.org/search/search_faq.html) yielded > this hit: > > 7.12. cgi.py (or other CGI programming) doesn't work sometimes on NT or > win95! > > Be sure you have the latest python.exe, that you are using python.exe > rather than a GUI version of python and that you have configured the > server to execute > > "...\python.exe -u ..." > > for the cgi execution. The -u (unbuffered) option on NT and win95 > prevents the interpreter from altering newlines in the standard input > and output. Without it post/multipart requests will seem to have the > wrong length and binary (eg, GIF) responses may get garbled (resulting > in, eg, a "broken image"). > > Hope this helps, > > Lyle > > Ed wrote: > > > > More information: > > If I test the len(form["userfile"].value), it is only 3134 instead of > > 18k (the "CONTENT_LENGTH"). That means the CGI.py module is not > > getting the data. Something wrong with CGI module reading binary data > > off of the standard input stream. > > > > Have I confirmed that it is a problem with the cgi.py module? > > > > Ed wrote: > > > > > I'm having trouble uploading an 18K file via CGI and saving it to a > > > file from my Python script. The file gets saved, but the file size > > > is only 1k. I'm assuming that the cgi module is only reading the > > > first 1k bytes. I'd like to know if this sounds reasonable and how > > > to solve the problem....and if not reasonable, where else I might > > > look for the problem. Thanks.... From sabren at manifestation.com Mon May 8 17:38:35 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Mon, 8 May 2000 17:38:35 -0400 (EDT) Subject: get the list of expected arguments? Message-ID: Hey all, Given a function (or method), is it possible to know the names of the expected parameters? I'd like to be able to extract this information and generate a form for calling the function. For example, say you have a function that draws a line: def line(m,b, x1=0, x2=10): for x in range(x1, x2): y = m * x + b plot(x,y) ... It might be in a module with a bunch of other geometry functions. I'd like to do something like "showForm(line)" and get: ENTER PARAMETERS FOR LINE: m: _____ b: _____ x1: ___0 x2: __10 Is that possible? I tried dir(line), and got: ['__doc__', '__name__', 'func_code', 'func_defaults', 'func_doc', 'func_globals', and 'func_name'] Func_defaults gives me the 0 and 10, but none of these seem to help with giving the names. Could it possibly be done with a bytecode hack on func_code? Or am I missing something totally obvious? I'm going to keep digging, but I thought I'd ask in case anyone's done this before.. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From ejr at lotus.CS.Berkeley.EDU Wed May 24 18:35:34 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 24 May 2000 22:35:34 GMT Subject: Micro-Threads: uthreadsleep.py -- scheduling of uthreads to c ontinue processing after given seconds References: Message-ID: <8ghlfm$1gp$1@agate.berkeley.edu> And Just van Rossum writes: - - It appears to me that select.select() is only relevant in non-threaded - programs (do you have an example of its use in a threaded - environment?). Zope. In general, any time you can satisfy (100-k)% of the requests immediately, use select for those and spawn threads to handle the other k%. (k depends on architecture, etc.) Jason From loredo at spacenet.tn.cornell.edu Wed May 31 17:44:56 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Wed, 31 May 2000 17:44:56 -0400 Subject: Clifford Algebra References: <8gsehu$btl@gap.cco.caltech.edu> Message-ID: <393587D8.A2953ED3@spacenet.tn.cornell.edu> Robert Kern wrote: > I've been meaning to wrap the XMU library > (http://www.perwass.de/Programs/XMULib/xmulib.html) by Christian Perwass > that implements a C++ class heirarchy for Clifford Algebras. > > Or I might simply re-implement the same ideas in pure Python. Along these lines, there is a MAPLE package that the Cambridge GA group has been using: http://www.mrao.cam.ac.uk/~clifford/software/GA/ For those evesdropping on this thread---this is probably some of the prettiest math you will ever see. Check out the links already provided, esp. the stuff by Hestenes and the Cambridge group (Gull, Lasenby, Doran...). Repeating the link Kirby provided: http://carol.wins.uva.nl/~leo/clifford/ Peace, Tom Loredo From mross at rochester.rr.com Thu May 11 21:03:55 2000 From: mross at rochester.rr.com (Michael Ross) Date: Fri, 12 May 2000 01:03:55 GMT Subject: Import without a .py file Message-ID: <391B58DF.4605438B@rochester.rr.com> I would like to accomplish the equivalent of an import, but store module code in a database (rather than in .py files). Is there any way to create a module using code that did not originate in a file? For example, I can get the text for the code into a string object, and then I'd like to say s = ...string containing code with classes and functions... import module using s obviously I can't do that, but something equivalent would be nice. Thanks! Mike Ross From andy at ictibroker.com Mon May 22 19:48:38 2000 From: andy at ictibroker.com (Andy Smith) Date: Mon, 22 May 2000 19:48:38 -0400 Subject: Weird Database/Web Problem References: <8gbkfa$4c3$1@solaria.cc.gatech.edu> Message-ID: <8gcgtl$jb2$1@bob.news.rcn.net> You haven't specified how you're kicking the script off, but one thing that might cause it is if your ODBC connection is a 'user' connection, and the webserver isn't running as you. If this is the case then delete the 'user' connection and create an identical Machine or system connection and everything should be hunky-dory. Cheers, A. Shengquan Liang wrote in message news:8gbkfa$4c3$1 at solaria.cc.gatech.edu... > under Windows 2000 > > I wrote a python script which runs fine > in my local directory. > > when i tried to invoke it in a > html file by > >
> > it generates an error saying > > dbc = odbc.odbc( # open a database connection > dbi.operation-error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in LOGIN > > > > > > > > > > > > > > how comes that happened? > > > > -- > Shengquan Liang > ________________________________________ > gt2558b at prism.gatech.edu > 332558 GA TECH STATION > Atlanta,GA 30332-1450 From mikael at isy.liu.se Thu May 25 02:32:49 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 25 May 2000 08:32:49 +0200 (MET DST) Subject: What's in a name? In-Reply-To: <392CBAB5.37BFCE21@san.rr.com> Message-ID: On 25-May-00 Courageous wrote: > Of course, we human beings can deal with mount everest and Mount Everest > and know they are the same thing. Likewise joe kraska is Joe Kraska, and > so on. In plain English, case appears to be optional for the most part, > only assisting readers in reading, I think. Can you name some situations > in reading and writing english (heh) where case is essential to being > understood? In another one of these case-threads, someone did give a number of examples. For the moment I remember one of them: Do you like china? Do you like China? Here china is what you might have on your table and China is a place with many many people. > I still think that "we don't care if we break prior code and not maintain > backward compatibility" is a really bad idea, though. Let's say that out loud, everyone. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 25-May-00 Time: 08:27:18 This message was sent by XF-Mail. ----------------------------------------------------------------------- From phd at phd.russ.ru Sat May 13 08:05:20 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 13 May 2000 12:05:20 +0000 (GMT) Subject: Bookmarks database and Internet robot version 3.1 Message-ID: BOOKMARKS database and internet robot WHAT IS IT Here is a set of classes, libraries and programs I use to manipulate my bookmarks.html. I like Netscape Navigator, but I need more features, so I am writing these programs for my needs. I need to extend Navigator's "What's new" feature (Navigator 4 named it "Update bookmarks"). WHAT'S NEW I traced the longstanding bug with always hanging FTP URLs. The bug was in the urllib/ftpwrapper. I updtaed my ftpwrapper to overcome the problem. WHERE TO GET Master site: http://sun.med.ru/~phd/Software/Python/#bookmarks_db Faster mirrors: http://skyscraper.fortunecity.com/unix/797/Software/Python/#bookmarks_db http://members.xoom.com/_XMCM/phd2.1/Software/Python/index.html#bookmarks_db AUTHOR Oleg Broytmann COPYRIGHT Copyright (C) 1997-2000 PhiloSoft Design LICENSE GPL STATUS Parser is Ok. Storage managers: pickle, FLAD (Flat ASCII Database). Writers: HTML, text, FLAD. Robots (URL checker): simple, forking. TODO More storage managers: shelve, SQL, MetaKit. More robots: threading, async. Oleg. ---- Oleg Broytmann http://skyscraper.fortunecity.com/unix/797/ phd2 at email.com Programmers don't die, they just GOSUB without RETURN. From lexberezhny at email.msn.com Fri May 26 22:04:03 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Fri, 26 May 2000 22:04:03 -0400 Subject: API feedback References: Message-ID: <#Il32o4x$GA.267@cpmsnbbsa06> Hi everyone, I dont know if there is a practical reason for it, but is there some specification for an object oriented wrapper to an SQL database? I would like to try writing one, and didnt want to re-invent the wheel by designing one from scratch. Any suggestions, opinions, would be welcome. - Lex Berezhny From dfan at harmonixmusic.com Thu May 11 09:38:39 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 11 May 2000 09:38:39 -0400 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> Message-ID: I agree that Programming Python is not very good to learn from, for the reasons you mention. Learning Python is much much better, and is more complete than you think if you're the kind of person (like me) who generally turns up his nose at 'Learning XXX' books. I skimmed through The Quick Python Book and it also seems very good. -- Dan Schmidt | http://www.dfan.org From jbauer at rubic.com Wed May 10 13:59:23 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 10 May 2000 12:59:23 -0500 Subject: Custom adduser function... References: <81DD38F43381D111BA3E00A076A0998A45A059@XENON> Message-ID: <3919A37B.3AE7D8A8@rubic.com> Channel21 Python Team wrote: > ok - RedHat 6.2 > need to have a function w/ 2 args (username,password) > which will create a system account w/ the username > and passwd passed in... any ideas? The easiest way is to probably pass the arguments to /usr/sbin/useradd via os.command(). Sample code below. I would probably add keyword arguments to support the other account options (i.e. uid, group, shell, home, comment, expire, etc.) Best regards, Jeff Bauer Rubicon Research --- #!/usr/bin/python import os, sys def adduser(username, password): cmd = "/usr/sbin/useradd -p %s %s" % (password, username) os.system(cmd) if __name__ == '__main__': usage = "usage: %s username [password]" % \ os.path.basename(sys.argv[0]) if len(sys.argv) < 2: print usage sys.exit(1) username = sys.argv[1] if len(sys.argv) > 2: password = sys.argv[2] else: from getpass import getpass password = None while password is None: p1 = getpass("Password for user '%s':" % username) p2 = getpass("Re-enter user '%s' password:" % username) if p1 == p2: password = p1 else: print "Passwords don't match." adduser(username, password) From mross at rochester.rr.com Fri May 12 07:54:08 2000 From: mross at rochester.rr.com (Michael Ross) Date: Fri, 12 May 2000 11:54:08 GMT Subject: Import without a .py file References: <391B58DF.4605438B@rochester.rr.com> <1uKS4.9142$H8.775032@news.easynews.com> Message-ID: <391BF148.FA1180D6@rochester.rr.com> I did a cursory search of the group looking for my answer, but somehow missed this article. This looks exactly like what I was looking for. Many thanks! Mike Ross SunGard Trading Systems Fredrik Lundh wrote: > Roger Upole wrote: > > The eff-bot posted an incredibly compact and clever way to do exactly > > this just a couple of days ago. The subject was > > "How to execute lists of code?". > > the article is here: > http://www.deja.com/=dnc/getdoc.xp?AN=621152936 > > > > From jerry_spicklemire at my-deja.com Thu May 25 17:51:03 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Thu, 25 May 2000 21:51:03 GMT Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: <8gk780$ua7$1@nnrp1.deja.com> In article <392CB9B3.F5484CCB at ses.curtin.edu.au>, Nick Bower wrote: > FYI - I'm thinking of picking up Bruce Eskil's "Thinking in Java" for > myself, but wish there was something comparable in Python. > > Nick As the last paragraph of the article (link below) says, ETA is unknown, but it sounds like Bruce indeed has a "Thinking in Python" book in the works, and he intends to have it available online while it's in progress. http://community.borland.com/devnews/article/1,1714,20080,00.html Hoping for sooner rather than later, Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From ajung at sz-sb.de Sun May 14 07:33:34 2000 From: ajung at sz-sb.de (Andreas Jung) Date: Sun, 14 May 2000 13:33:34 +0200 Subject: mod_python - testers needed! In-Reply-To: ; from grisha@ispol.com on Sat, May 13, 2000 at 10:35:26AM -0400 References: Message-ID: <20000514133334.A24345@sz-sb.de> On Sat, May 13, 2000 at 10:35:26AM -0400, Gregory Trubetskoy wrote: > > OK People - > > The very first version of mod_python is available at > > http://www.modpython.org/ > > I don't think this is time for an official release announcement quite yet, > but I would like to make it known to the world that it is out there and > that I need help testing it, as well as any other kind of feedback. > > Enjoy! Hi Gregory, I've been using your former code for a long time in one of my projects. And mod_python seems to be a very good successor :) I am currently reworking my own project PMZ (Poor Mans Zope, pmz.sourceforge.net) to get working with Apache. However it seems to me that your mod_python will be much better. So I can think of an implementation of PMZ using mod_python. PMZ is some kind of HTML-embeded Python. I will take a closer look how it will fit together with mod_python. It would be great to have a fast solution for combining HTML and Python (similar to PHP3/4). What's your opinion ? Cheers, Andreas From rgetter at usa.net Sat May 13 02:28:29 2000 From: rgetter at usa.net (Robert Getter) Date: Sat, 13 May 2000 06:28:29 GMT Subject: Why should I switch to Python? References: Message-ID: In article , ben at co.and.co says... > Charlie Derr wrote: > > [Tim Peters] > > ~ > > ~ [Grant Griffin] > > ~ > Speaking of C, I find myself missing the "x=" operators, and "++". > > ~ > However, I understand and endorse the reasons Python omits them. > > ~ > > ~ While ++ makes little sense in a language with immutable numbers, > > > > I'm probably missing something obvious here, but why? > > > > The only weird part that i see is that in order to implement it you would > > have to do a type check and make sure the operand is of type integer, which > > certainly seems to violate python's spirit, but I don't understand what's > > relevant about numbers being immutable. I never write "5++" it's always > > "varName++", which can obviously be done the long way with "varName = > > varName + 1". Couldn't this be implemented with assignment in this > > fashion? (not that i would want it to be done, i'm just curious) > > There will be some surprises: > > def malicious_print(i): > i++ > print i > > malicious_print(5) # Huh? > b = 5 > malicious_print(b) > print b # Huh? > > Greetings, > What surprise? If i++ is interpreted as i=i+1, then there is no problem. The altered version of the variable is local: >>> malicious_print(5) 6 >>> b = 5 >>> malicious_print(b) 6 >>> print b 5 The real problem arises when you have a user defined object. If you want an object that changes state in response to a ++, this won't work right since there may be several references to a particular object: a = myobj() # instantiate a user defined object b = a # a and b are references to the same object b++ # causes b to point to a new object. a is untouched One way to do it would be to read i++ as i=i+1 only for immutable types. For all other types, require that the developer implement a __postinc__ method. This can certainly work, one problem I can think of right now is the proliferation of methods which would need to be defined: __postinc__() __preinc__() __postdec__() __predec__() __pluseq__() __subeq__() __muleq__() __diveq__() etc. Another problem is the inconsistency where integers, strings, tuples, and other immutables behave differently in some cases from all other types. Fortunately, they still behave the way most people expect them to. -- Rob Getter From sabren at manifestation.com Sun May 21 03:47:00 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sun, 21 May 2000 03:47:00 -0400 (EDT) Subject: case sensitivity and XML Message-ID: How's this: 1. By definition: For python to be case insensitive, the token {A} must be the same as the token {a}. 2. Therefore: x.A = 1 is the same as: x.a = 1 where x is some kind of module or object. 3. Therefore: x.__dict__["A"] = 1 is the same as: x.__dict__["a"] = 1 And/Or: setattr(object, "A", 1) is the same as: setattr(object, "a", 1) 4. Therefore, the string, "A" must be equivalent to the string, "a". 5. Given: XML is a case-sensitive language. 6. By definition: In XML, "a" is different from "A" 7. Therefore: it is possible to have a meaningful xml tag such as: 8. Assumption: In order to access this tag's attributes, we must use a string with the name of an attribute. 9. Therefore: "A" must not equal "a", which contradicts [4]. 10. Assumption: "A" cannot equal "a" and NOT equal "a" at the same time. 11. Given the above, a case-insensitive python cannot parse all XML documents. ----- Does anyone disagree with the conclusion in line 4? Can we have a case insensitive Python without case-insensitive string comparisons? If you don't buy the assumption in line 8, I'd like to see your XML library! :) If you don't buy the assumption in line 10, then would you introduce a separate operator for case (in)sensitive string matching? ----- Another argument has to do with Java. In java, X and x are different. What does that mean for a case insensitive JPython? That we can only script SOME java objects reliably? Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From andymac at bullseye.apana.org.au Tue May 2 18:11:22 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 3 May 2000 08:11:22 +1000 (EST) Subject: BOM should be ignored by Python In-Reply-To: Message-ID: On Tue, 2 May 2000, Neil Hodgson wrote: > > (5) a > > reader of UTF-8 data should be prepared to regard a BOM as legal, not > > a "syntax error". > > This is what I want to see changed. The Python interpreter currently is > not defined to be a UTF-8 reader when reading scripts. I'd like to see it > accept these scripts. I can see this happening on Win2K systems, but on Unix where the #! hack is extensively entrenched and unicode oblivious AFAIK (and likely to be so for some time), I'm wondering where that would leave script portability. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From petersc at stud.ntnu.no Mon May 29 16:39:19 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 29 May 2000 22:39:19 +0200 Subject: Another salvo in the indentation war? I hope not. References: <8gjqer$k8v$1@nnrp1.deja.com> Message-ID: <3932D577.8A41F336@stud.ntnu.no> Lee Joramo wrote: > > The point pertinent to our discussion, is that when you export scripts from > Frontier you may do so either as white space formatted or in a format > similar to C using curly braces and semi-colon's. This C style formatting > ensures that code is not broken due to the vagaries of various transmission > methods. Naturally, when you import C style text back into Frontier, it > converts back into white space formatted. Frontier users would never write > code directly in this C style format. > > While this approach works very well, it would be hard to implement in > Python for several reasons. Okay, all reasons granted. But if you use pindent for sources you're posting somewhere you can have the same effect (albeit with some extra work). If you don't like these "# end"-tags (I find it quite annyoing to read - once you've gotten used to indentation you never wanna go back), just eliminate them after receiving. having-just-send-in-a-patch-to-eliminate-end-tags-with-pindent-ly y'r Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From pinard at iro.umontreal.ca Mon May 22 23:51:52 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 23:51:52 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: hzhu@rocket.knowledgetrack.com's message of "Tue, 23 May 2000 02:49:00 GMT" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) writes: > Why is case sensitivity a language barrier for those who don't want it? > If you don't want two cases, choose one and use that one alone. On the > other hand, case insensitivity can be a big headache for people who need > two cases. The problem is that it is not to be a personal taste and thing. We live in a world of inter-human relations, and computers are instruments in these exchanges. Python programs are being shared, and children (and adult newcomers) will also learn to share as well in their apprenticeship. Python should stay designed so these exchanges are as meaningful as possible, and case confusion directly goes against peaceful exchanges. The natural sloppiness of many people should not get conveyed and imposed to others, without Python somewhat imposing its distinct legibility features. It just does not fit together to have a clean syntax with a sloppy tokenizer. This is tearing apart the own elegance of the language, and somewhat destroying one of the quality which made it attractive. I quite understand that some people just do not mind, and that children may not see the benefit by themselves, right away. It is even likely that studies might even demonstrate that a bit of learning is needed: let's keep calm! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From borcis at geneva-link.ch Fri May 19 04:58:33 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Fri, 19 May 2000 10:58:33 +0200 Subject: Fractran machine! References: Message-ID: <39250239.D384FF0D@geneva-link.ch> Fran?ois Pinard wrote: > > Hi, people. Here is a Fractran machine, with a demo program. How long does the demo take to halt ? BB From tim at pnorthover.freeserve.co.uk Sun May 14 08:06:37 2000 From: tim at pnorthover.freeserve.co.uk (Tim Northover) Date: 14 May 2000 13:06:37 +0100 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: jimn at minusen.force9.co.uk writes: > Lloyd Zusman wrote: > : "Andrew Dalke" writes: > [snip] > As I see it, the problem would come when converting a complex number > to a string - which representation should it use? Is it not preferable > to use the same representation for display as is used for literals? I'm quite a newbie (read very), but it seems that there is a precedent in strings which can be either ' or " but ' is used for printing. Is this now considered to have been a mistake or a special case? I'm probably missing something fundamental. Tim N. From tismer at tismer.com Mon May 29 06:35:00 2000 From: tismer at tismer.com (Christian Tismer) Date: Mon, 29 May 2000 12:35:00 +0200 Subject: CRAZY: First class namespaces References: Message-ID: <393247D4.B745B628@tismer.com> Moshe Zadka wrote: > > On Mon, 29 May 2000, Christian Tismer wrote: > > > What would be better for the language, dynamic or lexical? > > I really don't know, please tell me your thoughts. > > Definitely lexical. > I do miss closures... > Dynamic scopes breaks the abstraction that a function is a "black box": a > function shouldn't be able to look inside its caller. Why not? Who said that a function should be a black box? Lexical scope is one thing to be considered. It is related to the program text, also has the cyclic reference problems, it introduces lookup hierarchies for names. This makes of course sense to me. Dynamic scope is about function instances coping with each other. This is something completely different, and of course I don't want to use it for automatic name lookup or something. But I can imagine that one makes sense of it. In comparison to the __parent__ (which is lexical scope), I would have a __caller__ property which allows for explicit attribute access if desired. This is of course a dynamic scope, but made explicit. I don't get at the moment why functions should be black boxes. If you compare this to how classes and instances are implemented today, you see that these are no black boxes as well. You can access everything, and not to do so is up to the programmers decision. I therefore don't see a good reason to forbid it in the first place if it is easy to implement. But I'm open for reasoning - ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From tim_one at email.msn.com Fri May 26 01:27:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 May 2000 01:27:09 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Message-ID: <000301bfc6d3$09ab8ce0$c52d153f@tim> [Fran?ois Pinard, with a meta-meta-comment about Les Schaffer's meta- speculations about why the newsgroup is "wasting its time" on this issue] > We live in the terror of the damage to come. If we loose our precious > time into these discussions, this is because we are moved by > despair... :-) > > I like Python, but I begin to resent Guido, who did this to us. Take heart, Fran?ois: I've had many more Python years to resent Guido than you've gotten so for, and he actually hasn't done anything bad to me yet. Don't convict him of murder before he kills. if-he-were-any-good-at-public-relations-python-would-have- swamped-perl-five-years-ago-ly y'rs - tim From jkraska1 at san.rr.com Tue May 23 03:07:41 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 23 May 2000 07:07:41 GMT Subject: Python performance notes... Message-ID: <392A2ED5.6A35B754@san.rr.com> I did a simple for loop and tested it, trying a variety of length loops. It took a bit of time to get this right, as for smaller loops, the test was biased by the relative high cost of function invocation. When it settled out, a for-loop in python is about 100 times slower in python than the equivalent in ANSI C. Irrespective of function invocation overhead, the decision to go native pays off almost immediately, with time differences in python versus native code being noticeable with as low as 100,000 simple iterations. Writing native methods in python is, fortunately, quite easy. TO WIT: PyObject* Test ( PyObject* self, PyObject* args ) { int i; for(i=0;i<100000;i++); return Py_None; } static PyMethodDef embedxmethods[]= { {"Test", Test, METH_VARARGS}, {NULL, NULL } }; void _declspec(dllexport) initembedx () { Py_InitModule("embedx", embedxmethods); } When you realize that the last two groups are basically cookie cutter, this becomes not bad at all. C/ From sabren at manifestation.com Sat May 20 13:06:44 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sat, 20 May 2000 13:06:44 -0400 (EDT) Subject: CGI Authentication form passthrough question In-Reply-To: <3925E44A.33B90279@bigfoot.com> Message-ID: On Fri, 19 May 2000, David Rock wrote: > I am trying to write a CGI script to check authentication for a > website, but I have a problem. [snip] > 2. Write a file with a random key value that gets passed along as a > hidden item in a form. When the form runs the next cgi script, it > looks for the key value in the file and compares the two. Since > this would be a date-based seed, the key would always be different > (but how do you know when to get rid of the key file? The process > would be dead as soon as the HTML is generated) Hey David, What you want is true session support. Create a random value once for the session and either a) set a cookie, or b) put it as a parameter in every single URL on the site, so that no matter what people click on, it passes the value along. The benefit of a) is that you can remember who's logged in even if they leave the site and come back... The benefit of b) is that not all people allow cookies. The best approach may be a hybrid: use cookies, but if they don't have it, fall back on sticking the session ID in the URL.. BTW: it lets the keys pile up (in a file, or dbm or relational database), and then eventually deletes the old ones. It just so happens that there's a package that does all this for you.. It's called weblib. http://weblib.sourceforge.net/ .. Grab the CVS version, because the docs and snapshot are a few weeks out of date. If it looks like something you want, I'll be happy to answer any questions you might have. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From thomas at xs4all.net Wed May 17 08:51:10 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 17 May 2000 14:51:10 +0200 Subject: Q? Calling nearest inherited method In-Reply-To: ; from phd@phd.russ.ru on Wed, May 17, 2000 at 11:54:53AM +0000 References: <392286f1.3796291238@news.u-psud.fr> Message-ID: <20000517145110.A13281@xs4all.nl> On Wed, May 17, 2000 at 11:54:53AM +0000, Oleg Broytmann wrote: > On Wed, 17 May 2000, Laurent POINTAL wrote: > > Given a class hierarchy like this: > > A > > B inherits A > > C inherits B > > > > A define dothis method. > > C define dothis method. > > > > In the C.dothis, I wants to call my nearest parent class dothis > > method. That is, call B.dothis if it is defined, or A.dothis if it is > > defined... > I think B.dothis() will do it just right, no? Yes, but dont forget to manually pass 'self' (or whatever you call the first argument in your method.) class C(B): def dothis(self, x): # your code here B.dothis(self, x) # more code here If you aren't sure if B has a 'dothis' method (either from itself or inherited) wrap the call in a try/except. And if you dont want to hard-code the name of the parent class in more than one place (the class line), use self.__class__.__bases__. This is a tuple containing the base classes for that class. If you want to call all possible dothis() methods, in all parents, you could do something like this: def dothis(self, *args, **kwargs): for parent in self.__class__.__bases__: try: method = parent.dothis except AttributeError: continue apply(method, (self,)+args, kwargs) or if you just want to call the first one you find, either change the last line to 'return apply ...' or add a 'break' after the 'apply'. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From dalcolmo at mediaone.net Fri May 5 08:44:59 2000 From: dalcolmo at mediaone.net (Josef Dalcolmo) Date: Fri, 05 May 2000 12:44:59 GMT Subject: COM + reload() Message-ID: I am using Python as a COM client and server for Excel. E.g. I have a couple of buttons in Excel calling some methods in Python, which in turn use COM to read from and write to Excel. Everything works fine, but when I make a change in the Python program, no matter in which module, the change is never reflected in the call started by Excel, until I restart the program. Even when reloading the top level module on every call from Excel, and making the changes only in that top level module, the program called by Excel never changes, until I restart Excel. Does anyone know how I can change this behavior, e.g. how I can force the changes to take effect? - Josef From phd at phd.russ.ru Wed May 17 09:29:07 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 13:29:07 +0000 (GMT) Subject: Q? Calling nearest inherited method In-Reply-To: <392295a8.3800058174@news.u-psud.fr> Message-ID: On Wed, 17 May 2000, Laurent POINTAL wrote: > >: I think B.dothis() will do it just right, no? > > I was afraid it resolve in a single (B) method search... but it search > also in B parents (even when prefixed explicitely with B). It's standard object-oriented approach. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From bjorn at roguewave.com Fri May 5 14:23:10 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 05 May 2000 12:23:10 -0600 Subject: How to get terminal width? References: <3912434E.B894368A@roguewave.com> <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <8epl60$1b42$1@nntp6.u.washington.edu> <8es8fr$rjm$1@nntp6.u.washington.edu> <8etdaq$7992e$1@fido.engr.sgi.com Message-ID: <3913118E.10084844@roguewave.com> Donn Cave wrote: > > Quoth Bjorn Pettersen : > | Paul Jackson wrote: > | > > | > "stty size" isn't defined on my Irix box, but: > | > > | > tput cols > | > > | > works on each of my Irix, SuSE and TurboLinux boxes, > | > issuing simply the number of columns. > | > | Well, we're getting closer :-) > | > | The above doesn't work on: > | > | SunOS 4.1.4 (not present) > | SunOS 5.4 (wrong result) > | > | But does work on: > | > | RedHat 6.0 > | Solaris 2.6, 2.7 (7), 8 > | HPUX 10.20, 11 > | AIX 4.2, 4.3 > | IRIX64 6.2, 6.5 > | Dec 3.2 > > And it works on > FreeBSD 4.0, and > BeOS 4.5 and 5.0 > > However - "tput" is really mainly about terminal-specific information > retrieved from termcap/terminfo, and that shows in a couple of ways. > On BeOS, and I bet a few other platforms, I get "80" regardless of > my actual window size. It can get the information from the terminal > description, and that's probably legitimate if not ideal. Tput also > fails when the terminal type is unknown (a marginal problem, but could > be worse than you might think, if the platform suffers from the all > too common terminfo vs. termcap split.) All this goes back to the > dark ages when we had real terminals, with more or less fixed screen sizes. I also got 80 on SunOS 5.4, but I got the correct result on all the others. Probably means that if you get back 80, you really can't tell if it's real or not though... -- bjorn From niels at endea.demon.nl Wed May 31 16:31:39 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Wed, 31 May 2000 22:31:39 +0200 Subject: *blink* That's neat. References: Message-ID: <393576AB.1B10F9D8@endea.demon.nl> John Schmitt schreef: > > I take it then that there is a paper I can read the observations that lead > to the conclusion that students had a problem with case sensitivity? Where > might it be found? A quick peek on alice.org did not reveal it. The one I know of is here: http://www.alice.org/advancedtutorial/#dissertation -- Niels Diepeveen Endea automatisering From g2 at seebelow.org Fri May 12 17:35:58 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 22:35:58 +0100 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <20000511091621.A24253@corrada.com> Message-ID: <391C793E.B28@seebelow.org> andres at corrada.com wrote: > > On Thu, May 11, 2000 at 12:09:07AM -0500, James Felix Black wrote: > > > Two big ones come to mind: using complex data structures, and > > > modularizing your code. Both are much easier in python. > > > > I won't dispute your second point, but I don't understand your first. > > > > I'm not sure exactly what you mean: > > > > %friends = { Bob => [ ], Jane => [ "Lisa", "Mabel", "Freddy" ], > > Lisa => [ "Mabel" ] }; > > > > for $name (keys %friends) { > > print "$name has these friends:\n"; > > for $f (@{ $friends{ $name } }) { > > print " ", $f; > > } > > print "\n"; > > } > > > > Sure looks similar, doesn't it? Of course, the de-referencing of the > > array reference looks bizarre, and perl doesn't have the wonderful REPL > > loop, but the assignment is almost completely identical to the python > > syntax. > > > > C'mon, let's be reasonable about this. Only die-hard Perl programmers can > love the syntax of that language when it comes to complicated data > structures. I quote from "Programming Perl", pg 243, emphasis mine: > > "For both practical and philosophical reasons, Perl has ALWAYS been biased > in favor of flat, linear data structures." > > One of the main reasons I came to Python was that I got tired of coding > complex data structures in Perl and getting them wrong. Unless you are > constantly creating these structures, you forget Perl's convoluted syntax. Or in my case, never completely learn it. I had forgotten about that as a major shortcoming of Perl. The system Perl uses is flexible, but undeniably awkward. It stands in stark contrast to some of Perl's other very brief, very handy constructs. I consider Perl's argument passing system to be a step backward compared to C. In comparison, Python's approach is a step _forward_ compared to C and even C++, with its support of keyword arguments. perl's-inconsistency-is-its-most-consistent-feature--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From glyph at twistedmatrix.com Wed May 10 12:59:39 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 10 May 2000 11:59:39 -0500 Subject: Why should I switch to Python? In-Reply-To: Russell Turpin's message of "Wed, 10 May 2000 09:41:14 -0500" References: <3919D30A.74DE@seebelow.org> <3919750A.22E2300E@do.not.use> Message-ID: Russell Turpin writes: > In Perl, someone once observed, there are seven good > ways to do anything. I think that should be amended to, "In Perl, there are seven apparently good but subtly wrong ways to do anything.". > For this reason, I prefer Python. Just to add my drop of gasoline to the fire ;) Poorly written python code will get you a code savings of 30% from other languages (less for perl, obviously); just for leaving out the braces, the variable declarations, and the punctuation, and it will probably repeat itself a little less. (argument-passing symantics are so wacky in perl I have often found myself copying and pasting whole blocks of code rather than writing a subroutine and tracking down where I forgot to use a 'my'). *Well* written python code, that uses all the twists and turns and odd little corners and cool features of the language, will probably end up being (no kidding) 80% shorter than the equivalent (let's say) java program. I am willing to bet that it would be about 40% shorter than the equivalent Perl script; but more importantly, it will be better designed. The savings are *especially* apparent as the program scales, as python has a very simple way of reusing code: just import another .py file! "module" declarations, header files ... they all go away. There are more terse ways to express everything in perl, but perl's syntax is dense enough that sometimes it's easier to just "do it the hard way". (especially if one of your goals is maintainability). This requires conscious effort; whereas in python, it's all natural. Python has opened up paradigms about programming to me that were previously cut off. Things that, in other languages, are either simply impossible (__getattr__ and __setattr__ are my friends) or merely fragile (python is the only language where I have seriously considered using a hash of function pointers). I never understood why LISP was a good idea until I started playing with python: now much of the wisdom of the "old guard" of programming makes sense to me, as well as many newfangled ideas about testing, "extreme programming", etcetera. It is so easy for me to understand that when I work on a hard problem in java, I implement the algorythm in Python first, because things are becoming easier for me to implement in python than to describe in english. This is all hearsay, of course, but I would be willing to place a gentleman's bet that if you use python for a moderately large project, you will find it harder and harder to go back to perl afterwards. In other languages, I begin with a concept in english, and then obfuscate the concept with code to arrive at an implementation. In python, I begin with a concept in python, and the implementation becomes implicit. All that is necessary is for me to improve it. guido-is-our-god-and-the-timbot-his-prophet--ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From PClaerhout at CREO.BE Mon May 8 07:25:10 2000 From: PClaerhout at CREO.BE (Pieter Claerhout) Date: Mon, 8 May 2000 13:25:10 +0200 Subject: Iterating over items in the registry Message-ID: <2B1262E83448D211AE4B00A0C9D61B03BA7335@msgeuro1.creo.be> Hello all, is there a way to iterate over keys in the registry? I want to scan the contents of the key HKLM\HARDWARE\DEVICEMAP\Scsi to find info about all connected scsi hardware. I want to use this under NT. Is this the proper way to do it, or does anyone has a module who accomplish this for me? Kind regards, Pieter Pieter Claerhout Application Support - CreoScitex Europe From alvaro at ocse.infonegocio.com Tue May 9 10:53:29 2000 From: alvaro at ocse.infonegocio.com (AMR) Date: Tue, 9 May 2000 16:53:29 +0200 Subject: Converting a Binary Message-ID: <8f98bk$a6c28@esiami.tsai.es> Good afternoon, What module I need to convert a number to binary?, I can't find a function in Python build 126 Thank you, -- Alvaro Mart?nez Optichrome Computer Systems Espa?a, S.A. Tel. (+34) 917 242 670 Fax. (+34) 917 130 360 alvaro at ocse.infonegocio.com http://www.optichrome.com From tismer at tismer.com Sat May 6 17:57:09 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 06 May 2000 23:57:09 +0200 Subject: BAD starship.python.net news! References: <38FC852A.9B11F458@concentric.net> <38FCBD77.A5925D65@darwin.in-berlin.de> <38FD8FC1.EC5DDCD7@tismer.com> <6oQHOYGsk3CUxVh00LNjwelELGrD@4ax.com> Message-ID: <39149535.7D8C47BB@tismer.com> Bill Hunter wrote: > > Many ISP's, at least if they are over some threshold of > professionalism, run backup tapes on a schedule and save archival > copies at intervals. While they might be unsympathetic to putting in > a lot of work to recover something for an individual, they might be > persuaded that this is important to an entire global community - which > it is. > > My two cents worth. You are right, and your two cents are worthy. Unfortunally this is all what we get. I know them for a long time, and I know that what they've thrown away once is lost forever. lots-a-perl-scripts-instead-o-professionalism-is-why-I-left-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From effbot at telia.com Tue May 16 14:23:12 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 16 May 2000 18:23:12 GMT Subject: TypeError: attribute-less object (assign or del) References: Message-ID: Sam Corder wrote: > I'm using the windows script control to allow scripting in a VB project that > I am working on. My app exposes a website object which users can script > different things like clicking a link or looking for text (feedback). It > works fine using VBScript but I want to use a more feature full language > like Python. The problem is I keep getting a "TypeError: attribute-less > object (assign or del)" error when trying to assign a value to an input text > box. Does anybody have any clues? the error message means that you're trying to assign to (or remove) an attribute, but the target variable doesn't have any attributes, e.g: >>> a = None >>> a.foo = 10 TypeError: attribute-less object (assign or del) >>> del a.foo TypeError: attribute-less object (assign or del) From jkraska1 at san.rr.com Sun May 7 02:16:44 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 07 May 2000 06:16:44 GMT Subject: GC... Message-ID: <39150B0E.F17C1621@san.rr.com> If two python objects mutally refer to eachother, but aren't referred to globally in any current namespace, will they be garbage collected? C/ From senn at maya.com Wed May 17 09:11:09 2000 From: senn at maya.com (Jeff Senn) Date: 17 May 2000 09:11:09 -0400 Subject: Stackless/microthreads merge news In-Reply-To: Christian Tismer's message of "Tue, 16 May 2000 21:29:00 +0200" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <3921A17C.F995CEFB@tismer.com> Message-ID: Christian Tismer writes: > > In fact, he commented that making C itself stackless would be too hard > > to really consider seriously and nobody in the community would > > appreciate it at all. > > Yes. It would be hard to make portable. > Instead, I'm trying to get rid of C and want > to use a language where I can control stacks > more easily. The last barrier in Stackless Python is > to make a couple of internal functions stackless as well, > but it is so hard in C that I need another bytecode > interpreter to do that. > Well, guess what that should be. Hm -- I've been trying to find a way to explain the "stackless zen". It seems that we all (people who write high level software) take the program stack, as a method of flow control and messaging between function invocation, as a given. Really the stack is just another data/object type -- not any more special than a queue or a heap... Given our usually math notation, methods of functional composition and early compiler/OS development I'm not surprised that the stack is viewed so. (Consider as a counter example how asynchronous circuit design is done and microcode is developed) IMHO this dependence on making the stack of higher importance has made the implementation of multi-"threaded" operating systems complex and limited the ways in which alternative approaches could reduce the difficulty of implementation of async/parallel systems. Anyway I hope this stimulates some thought... -- -Jas Jeff Senn MAYA Design -- Taming Complexity From dan at netrics.com Thu May 11 16:24:42 2000 From: dan at netrics.com (Dan Gindikin) Date: Thu, 11 May 2000 20:24:42 GMT Subject: Problem w/Cookies Module? References: <8feh8j$3g5$1@nnrp1.deja.com> Message-ID: <8ff4tn$r4g$1@nnrp1.deja.com> I don't know if this problem is what you are seeing, but there is A known problem with the cookie module. Well, not with the cookie module, but with the cPickle module that it uses. On unix it resulted in a segfault, I don't know what the effect would be in windows. An easy way to check if this is what you are seeing, is to edit your cookie.py file, and make it import Pickle instead of cPickle. Dan Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Sun May 21 21:45:20 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 May 2000 01:45:20 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: <39289130$0$148@wodc7nh7.news.uu.net> Neel Krishnaswami wrote: >Suspicions are most easily dispelled/confirmed via evidence, and >taking the trouble to do this has the pleasant side-effect that you >can either cease expending effort worrying, or move directly to taking >positive action to correct the problem. What? You would eviscerate Usenet? Sheesh! - Gordon From mwh21 at cam.ac.uk Thu May 11 13:25:47 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 May 2000 18:25:47 +0100 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> <8feioj$fei$1@nyheter.chalmers.se> <8feld6$8h8$1@nnrp1.deja.com> Message-ID: Andrew Cooke writes: > In article <8feioj$fei$1 at nyheter.chalmers.se>, > d98aron at dtek.chalmers.se (Fredrik Aronsson) wrote: > > Well, using Haskells syntax, I would suggest > > map((\a,b,c -> a+b+c), p,q,r) > > what's that funny backslash for? It's the closest character in shape to lambda in ASCII. Insufferably cute? Yes, but that's Haskell for you... Cheers, M. -- I saw `cout' being shifted "Hello world" times to the left and stopped right there. -- Steve Gonedes From offer at sgi.com Mon May 8 11:05:02 2000 From: offer at sgi.com (Nhi Vanye) Date: 8 May 2000 15:05:02 GMT Subject: PyBalsa? References: <4CCD34DC434D6019.93763A3431326470.47F9322EA18914C1@lp.airnews.net> Message-ID: <8f6l2u$8m0mo$1@fido.engr.sgi.com> $ from roman at speeder.org -#89334 | sed "1,$s/^/> /" > > > >Well - I don't know anything about balsa but pmail is a gtk based >mailer written in python that works well. It's still pretty early in >its life - but it doesn't crash. > >http://www.scottbender.net/pmail > >You might also look at mahogany. Its a wxGTK based mailer written in >C++, but extensible in python. It is in alpha and does crash >sometimes, but it is amazing in how many features it has and how nice >it looks. It also runs on windows: > >http://www.wxwindows.org/Mahogany/ > I dislike both UIs, and also I need a text only mode for when I log in remotely (by text I mean line not curses based). [Yes I know about IMAP, but I have my reasons for not wanting to go that route.] I started working on a python binding to the UoW C-Client library, but.... >^Roman richard. -- Richard Offer Widget FAQ --> http://reality.sgi.com/widgetFAQ MTS-Core Design (Motif) ___________________________________________http://reality.sgi.com/offer From akuchlin at mems-exchange.org Tue May 23 13:11:04 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 23 May 2000 13:11:04 -0400 Subject: Python 1.6a2 -- patch for urllib https POST support References: <20000523012329.2798.qmail@web119.yahoomail.com> Message-ID: <3dln11xkd3.fsf@amarok.cnri.reston.va.us> Paul Schreiber writes: > I was futzing with urllib and noticed it supported POST and GET for http but only > GET for https. So I added support. :-) I assume this is against 1.6a2? A similar fix was checked in to the CVS a little while ago, so it should be OK in 1.6a3. (You may want to check your code against the CVS version; perhaps there's some oversight in the CVS version that needs to be fixed.) --amk From dworkin at ccs.neu.edu Wed May 3 13:15:05 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 03 May 2000 13:15:05 -0400 Subject: Best way to convert a list to a dictionary In-Reply-To: "Lars Lundstedt"'s message of "Wed, 03 May 2000 17:12:35 GMT" References: <76ZP4.2558$wYl.196706304@newsb.telia.net> Message-ID: "Lars Lundstedt" writes: > I have a list where each element is another list with two elements. > What is the best way to convert this to a dictionary? Something like this would probably be simplest: d = {} for k, v in your_list: d[k] = v -Justin From jkraska1 at san.rr.com Sat May 27 13:58:56 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 27 May 2000 17:58:56 GMT Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <8goufe$17n$1@newsg4.svr.pol.co.uk> <39300308.69576FD@mit.edu> <8gp0fh$2g4$1@newsg4.svr.pol.co.uk> <39300B6B.C0789ECF@mit.edu> Message-ID: <39300D76.A62C38A6@san.rr.com> > in all of those cases C was ~100 times faster than Python You need to write an external C module and compare its performance to an equivalently coded python algorithm. I'll be publishing results on heap sort, just for grins, sometime in the next few weeks. C/ From jraven at psu.edu Thu May 18 12:56:24 2000 From: jraven at psu.edu (Jeff Raven) Date: 18 May 2000 16:56:24 GMT Subject: Decimals to fraction strings References: <8fu1e3$3h4$1@news.wrc.xerox.com> Message-ID: On 17 May 2000 11:56:51 GMT, Mark Jackson wrote: >=?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: >> mjackson at wc.eso.mc.xerox.com (Mark Jackson) writes: >> >> > > Yet your suggestion is straightforward, it might not always yield the >> > > "best" answer, because of the constraint put on the denominator to >> > > initially be an exponent of 10. >> >> > >> > Is not this same constraint applied by the problem itself, which starts >> > with a [finite length] decimal representation? >> > >> >> Not necessarily. 0.6667 is well approximated by 1:3, for example, while >> if you force the denominator to be an exponent of 10, you will obtain a >> fraction which is not only uglier, but less precise. > >It's only less precise if the intended result was 1/3 rather than >6667/10000, but if "0.6667" is what you're given there's no way to >tell. One could introduce an arbitrary tolerance within which a >"simpler" rational fraction is accepted (as I see you have in the >renamed thread) but in the end what you've shown is that the original >poster's approach doesn't always yield the "best" answer to a >*different* problem. > Well, in keeping with the comp.lang.python tradition of drifting off-topic, there actually is a sense, due to Dirichlet, in which 1/3 is a better approximation to 0.6667. Call an approximation p/q to a number alpha 'good' if |p/q - alpha| < 1 / q^2 In simple terms, we don't just want to get close to alpha, but we'd like to do it using as small a denominator as is reasonable. Classically this makes a lot of sense, since the main reason you wanted the fraction was to do calculations, and although you can get as accurate a fraction as you'd like, there's a point where larger fractions just make the calculations more difficult, even if they would be more precise. Dirichlet proved that given any number alpha and integer N, there is always a 'good' approximation p/q such that q < N. This fraction can be calculated directly using a rather clever argument, but the method of continued fractions ought to give you the same thing. Incidentally, under this approach, until you make N rather large, Dirichlet's algorithm will consistently give 22/7 as the best good approximation to pi. Mathematics-is-just-a-matter-of-defining-good-ly, Jeff Raven From tim_one at email.msn.com Wed May 31 00:47:49 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 31 May 2000 00:47:49 -0400 Subject: Python for project planning tool In-Reply-To: <3933C0D0.63B8731A@NOSPAM.philips.com> Message-ID: <000101bfcabb$5f5eb2c0$2d2d153f@tim> [Jeroen Lamain] > We are trying to develop a project managment tool like MS Project 98. > > Previously we were developing using c++ and gtk. Yesterday I > tried Python and the GNOME binding. I was very impressed by > the ease of development. (this was my first experience with Python) > > Is python ok for developing such a tool ? I mean... is it usable > for a such a kind of project. Will I have enough performance > when writing everything in Python (UI, task scheduler) ? Depends on how crappy your algorithms are . Seriously, unless you've written complete project management systems before, and are expert in scheduling algorithms, you're going to make a lot of changes in internal data structures and algorithms before this is over. Even if Python were 1000x slower than C++ (it isn't), and you have to throw all your Python code away in the end and reimplement in C++, your development time will *still* be slashed by developing in Python first: rapid and/or massive rewrites generally go much quicker in Python. You've already got a taste for why that might be true, so follow that hunch without thinking about it too much . I *expect* you'll find Python fast enough for this project. Simple critical-path scheduling is linear-time in the sum of the number of activities and sequencing constraints, and is more involved with chasing data structures than with flat-out computation. The first half of that ("linear time") means it's not all that demanding a task, and the second half means C++'s relative speed advantage is likely not crushing. If you move on to fancier scheduling gimmicks (like load balancing, resource leveling, and/or auto-split of long tasks), clever algorithms are crucial regardless of language (e.g., a quadratic-time algorithm will kill the usefulness of your tool for very large projects even if you code it in hand-optimized assembler). by-the-time-you-finish-this-machines-will-be-twice-as-fast-anyway-ly y'rs - tim From godzilla at netmeg.net Fri May 26 12:15:46 2000 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 26 May 2000 16:15:46 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> Message-ID: two different comments from different posters: > to complain that it's all a question of possible IPO money seems > remarkably mean-spirited. i didnt say __all__. but i am definitely wondering if its a factor, concious or otherwise. and that won't change (much) even if someone tells me GvR is the most kindest gentlest Christian on Earth. Why? Because i hadn't intended to make a statement about GvR personal only to him (and aoplogize if it was taken that way). you will note also i never used the word greedy in my post, on purpose. > I think you're right, frankly. Speculative character assassination > from the point of view of ignorance and from the security of > relative anonymity is disgusting. first off, how is the post i made in any way anonymous? You have my email address. I am not famous in the Python community, thats true. Is that what is important to you? I agree that my conjecture was speculative, and i thought that was pretty clear from my use of the word 'absurd', twice. I dont agree that it was character assassination. I didn't mean to single out anyone (though i can ses now it could be taken that way). I was making a general comment that large sums of money (more generally, the material basis of a society) can affect the ways things happen. You evidently think there is some critical error in logic here. But Courageous, I am not the first person on the planet to suggest that why we do things has numerous and sometimes unknown-to-us causes. Sometimes we get to them by speculating first, and then testing out the speculation second. Newton's "hypothesis non fingo" is considered outdated in physics by the way. the fact is, the three of you that got yourselves in an uproar over my supposed character assassination have not dealt at all with the (at least intended) substance of my post, which is that a large (to me) change in Python was being put forward by its author for published reasons which struck me as absurd on its face. So absurd, one could not but speculate on the deeper causes for such a situation. I understand this is debateable, that some of you think its a rational change to remove case sensitivity. Others of us disagree. Some of those disagreements and analysis will come out of left fields, so to speak, in the sense that some of the terms of the debate will appear mysteriously shifted from center stage. C'est la vie... les schaffer -----and now for something (kinda) completely different----- from http://www.sexuality.org/l/activism/logic.html#cumhoc Cum hoc ergo propter hoc This fallacy is similar to post hoc ergo propter hoc. The fallacy is to assert that because two events occur together, they must be causally related. It's a fallacy because it ignores other factors that may be the cause(s) of the events. "Literacy rates have steadily declined since the advent of television. Clearly television viewing impedes learning." This fallacy is a special case of the more general non causa pro causa. --- NI!!! --- I never used the term "Clearly" in my original post, on purpose. I never said that IPO money was the ONLY cause. From embed at geocities.com Fri May 12 10:21:28 2000 From: embed at geocities.com (Warren Postma) Date: Fri, 12 May 2000 10:21:28 -0400 Subject: pkzip-like utility script for python that uses zlib? (embedded python) Message-ID: I have an embedded controller running Python, and I can compile zlib into the application. What I'm wondering is, is there a pre-written script that will provide either a tar+gz or PkZip like functionality on top of ZLIB? I want to be able to zip up and unzip the contents of my embedded system, to provide a backup and restore of embedded system's contents. I can't spawn external executables, as the main program is the only thing that can run in this system, so if I can't use a Python script (with zlib) to do this, I will be Out of Luck. A standard file format like .tgz or .zip would be preferred. Any ideas? Warren Postma From dalke at acm.org Sun May 14 00:41:01 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 13 May 2000 22:41:01 -0600 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> Message-ID: <8flaj9$7bs$1@slb0.atl.mindspring.net> andres at corrada.com wrote: >Physicists also use "i" and "I" for current and yet still use "i" for >imaginary numbers also. The use of "j" is unfortunate given that most >of the scientific/mathematical world uses "i". Just scanned through one of my E&M books. Can't find "i" used for current. Found "I", and dQ/dt. Also found J used for volumn current density. Lower case "i" is used for imaginary numbers and i^ (that's i-with-caret) for unit vector along the x axis. Can't ever recall using "i" for current. Andrew dalke at acm.org From pinard at iro.umontreal.ca Mon May 8 13:43:32 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 08 May 2000 13:43:32 -0400 Subject: OT [Way OT]: Unicode Unification Objections In-Reply-To: Kevin Russell's message of "Sun, 07 May 2000 19:48:07 GMT" References: <3915C869.1B387972@videon.home.com> Message-ID: Kevin Russell writes: > "Dennis E. Hamilton" wrote: > > In Japanese texts, when a borrowed or employed Korean word is used, > > a desired practice is to render the Korean characters as different, > > even though some or all of them involve "the same character" common to > > both languages. However, the iconography (or calligraphy) is commonly > > different. > The entire point of markup is that distinctions like this *shouldn't* > be preserved in simple text. It depends. English and French use the same, or quite similar calligraphy for letters, and using common fonts is not at all a problem. However, we do not use the same calligraphy for quotes, so English quotes and French quotes are different, and Unicode keep them different. If by tradition, the same English and French letter were using different calligraphy, I would not like to write French using English letters, and you would object to be forced using French letters to write English, despite the letters would be recognisable and we could read each other. If we were using a common international character set, it would be important that I could mix English and French in a same text, using different characters (because we both know they are different, despite similar and recognisable), and without having to resort to typographical annotations. Any stranger, writing French and having strong opinions (because he studied French in school or travelling, or after s/he had a love affair in France), who would dare spelling my own needs for French, would be rather unwelcome. If many Japanese and Chinese feel the strong need of distinguishing their characters in a common character set, they just know better than me, however competent I may feel in Asian matters, and regardless of my great urge to spare one more bit. > A similar situation holds in almost every written language. We often > dump Latin or French words into English text. Even though they may be > written in the same alphabet, we usually want them to *look* different > from ordinary English words. The situation is just not similar. I do not have a strong, perpetual need that the look be different, and the truth is that as a French reader, I honestly do not mind much if we use the same characters. All the contrary, it is quite convenient, and not shocking at all. (Not everybody is so lucky. For example, when Unicode decided that `y-diaresis' could be used to replace the Finnish `ij' ligature, Finnish people were not very happy.[1]) Agreed that Japanese people are themselves on this. Some are ready to accept Han unification together with Microsoft Windows, if they really have to be bundled together, they just don't care. Others do. We have the same in French. Some people are very ready to drop diacritic marks while using computers. They never got it right at school anyway, and diacritics create technical problems they are too happy to recognise as intractable if they can be. Why not drop proper spelling on the same blow? More than one said: "We did not choose literature, anyway!". ASCII is more than enough for them. Please don't read that ASCII is enough for French. I'm not saying that Japanese are right or wrong about unification. This is their problem and their decision. One sure thing is that _we_ are wrong when we are haughty enough to have a strong opinion about what they should do. Granted that Python supports Unicode. There is a danger that, because we love Python, and because Unicode is well supported, that we start blindly loving Unicode. What I'm trying to tell is that we should keep a clear mind, and happily use Unicode while keeping in mind that this it not the final word of everything about charsets. Don't become Unicode fanatics. -------------------- [1] If I remember correctly. This was years ago. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pj at sgi.com Tue May 23 18:05:09 2000 From: pj at sgi.com (Paul Jackson) Date: 23 May 2000 22:05:09 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <3929D1F5.DC00DBC9@prescod.net> Message-ID: <8geval$e6igp$1@fido.engr.sgi.com> richard_chamberlain wrote: > When we teach our children to write we teach them case sensitivity, Ah - but we teach them that case is partially context sensitive. Formal names are always capitalized, but most words are only capitalized at the start of a sentence. Can you imagine it being that "light" meant of little weight, whereas a "LIGHT" was a photon emitter, "LIghT" a stream of photons, and to "liGHt" something was to set fire to it? -- Still, I would caution Guido against making too much of the Alice work. At least in my couple of attempts to introduce myself and my son to it, it was not particularly compelling (in contrast to, say, Pokemon), nor intuitive, nor (at least on my Windows system) stable (that is, it kept crashing). Granted, I sometimes joke that I dream in 'C', and have to translate to English for my shrink (which is to say I'm an old hacker). But in my view there is a difference between coding programs in an editor, and working in an end user environment. Perhaps there is someway to enable case INsensitive frontends to Python 3000, while still working with the current case sensitivity "under the covers". Sort of like the difference between having a (mostly) case INsensitive WYSIWYG structured document composer frontend, over a (somewhat more) case sensitive XML. -- That is, instead of thinking of this as a problem of how to make case INsensitivity palatable to the hackers, rather think of this as a problem of how to _present_ case sensitivity to the End User, in a way that is sensitive their natural language (e.g., English) sensibilities. ... I sense that I should shut up now ... -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From tomega at earthlink.net Tue May 16 23:54:16 2000 From: tomega at earthlink.net (Simon) Date: Wed, 17 May 2000 03:54:16 GMT Subject: Network statistics program References: Message-ID: <392218F4.1245481@earthlink.net> The time module has a sleep function. Put time.sleep(60) at the end of a cycle and it will wait 60 seconds before starting the cycle. --S. Greg Fortune wrote: > I'm currently working on a program that will run some network statistics > for me over the span of months. I want to send a ping every minute, collect > the results, and then store that information in a database. I think I can > get everything working, but the issue of the one minute interval is killing > me. How do I make my program just sit there and do nothing until the system > clock says it has been a minute? Never before have I *tried* to make a > program do nothing :). > I consider a while loop with a pass statement or a time check, but that > seems like it would take up processor cycles for little reason. > I also considered letting ping handle the interval and just use ping as > the piped input. Although this may be the simplest solution for me at this > time, I really want to learn how to implement delay. > > Any help is greatly appreciated, > > Greg Fortune From jblaine at shell2.shore.net Thu May 18 16:19:07 2000 From: jblaine at shell2.shore.net (Jeff Blaine) Date: Thu, 18 May 2000 20:19:07 GMT Subject: Thread Question References: Message-ID: From: http://www.python.org/doc/current/lib/module-threading.html "Python's Thread class supports a subset of the behavior of Java's Thread class; currently, there are no priorities, no thread groups, and threads cannot be destroyed, stopped, suspended, resumed, or interrupted...." On Thu, 18 May 2000 04:07:37 GMT, Karl Lewin wrote: >Is there a way to "kill" a thread that is currently asleep. > >Example: > >thread t1 is currently executing "time.sleep(60)", is it possible to >kill/delete/destroy the thread object before it finishes sleeping? > >If this isn't clear, I can post a better example tomorrow. > > > > From jsolbrig at my-deja.com Wed May 10 22:55:45 2000 From: jsolbrig at my-deja.com (jsolbrig at my-deja.com) Date: Thu, 11 May 2000 02:55:45 GMT Subject: Python Websites: References: <391a27e8.2952935@news.prodigy.net> Message-ID: <8fd7fb$m8j$1@nnrp1.deja.com> In article <391a27e8.2952935 at news.prodigy.net>, xion at inorbit.com wrote: > > I'm looking for some cool Python fansites. Anyone have/know of any? > We got: > Vaults of Parnassus, Python.org, Starship, Programming Pub. That's all > I know of. Well, wxWindows. Any others? > There's also www.pythonware.com and the links from there. But altogether, it seems like the python sites seem to be become somewhat moribund. Perhaps it's a sign of success. The language no longer needs our help - its success is guarenteed. Sent via Deja.com http://www.deja.com/ Before you buy. From sollie at saint-etienne.no Mon May 29 10:51:29 2000 From: sollie at saint-etienne.no (=?iso-8859-1?q?P=E5l?= Sollie) Date: Mon, 29 May 2000 14:51:29 GMT Subject: Walking recursivly through a directory-structure Message-ID: I've been looking at os.path.walk for this, but I'm not sure how to implement it. Anyone able to point me in the rigth direction? -- P?l Sollie sparkz at ikke.no sollie at bitemyshinymetalass.com From rupole at compaq.net Mon May 22 22:01:19 2000 From: rupole at compaq.net (Roger Upole) Date: Tue, 23 May 2000 02:01:19 GMT Subject: win32net.NetServerEnum resume handle Message-ID: I can't get this function to return anything other than 0 as the resume handle, even when the buffer size is set low enough that only 2 machines are returned. The initial handle passed is 0. Is there some constant I should be passing on the first call ? Anybody else having the same problem? Roger Upole From embed at geocities.com Tue May 2 09:27:45 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 2 May 2000 09:27:45 -0400 Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> Message-ID: > OK, I'm going to piggyback on Rick's question. > > My son's school district has asked me to teach an introductory > programming class to some of the talented and gifted students this > summer. They want me to teach for eight days. 1.25 hours a day for 1-2 > graders, 1.25 hours a day for 3-6 graders. > > I want to use Python, but have no experience with Python on the Mac, > which is what the school district uses. > > First question: what do I need to be careful of, if anything when using > Python on Mac? I think the bigger issues than using a Mac are how to teach programming to young kids. Has anyone got books on this? I remember Logo, but I don't know how much work has been done since then on these things. I remember one of the first programs I found compelling as a kid was "Hunt the Wumpus". At 8 years old, I used to get this book out of the library just because I liked to dream that someday I might own a computer upon which I would hunt for wumpii. (Maybe thats why I have a basement full of Commodore 64s now.) Is anyone else interested in designing a Python-based Game for Kids, to teach programming? What would be great is if it could be extended by small kid-written objects that are small enough to write in class, but which leaves some room for open-endedness, and collaboration between kids. First they'll type in some basic types of programs, and experiment with changing them around a bit. Then, perhaps intuition will take flight, and they'll come up with new ideas. Once they "grok" python, watch out! ;-) One possible idea is a combination of the "Battling Robots" simulation game, and the ancient Electronic Arts classic "Mail Order Monsters". Perhaps the kids could build little software-based robots/monsters/etc that either battle, or search, or explore, or do some other useful competitive and/or cooperative things with each other. A simple 2d bitmap layer would suffice for showing the robots on their playing field, and May The Best Algorithm Win. Other stops along this road could include classic simulations like the LIFE simulator, and simple artificial-intelligence toys like the "What kind of animal are you?" game, or Eliza. What really captivated me as a kid was how much it seemed that computers, mere circuits, where alive, once you programmed them with an interesting program. That hasn't changed much. Thoughts? Warren Postma From mikem at wetafx.co.nz Fri May 19 04:11:32 2000 From: mikem at wetafx.co.nz (Mike Morasky) Date: Fri, 19 May 2000 20:11:32 +1200 Subject: PyRun_String Message-ID: <3924F734.7FA2668F@wetafx.co.nz> Embedded in a simple c++ program, I've defined a global dictionary and then: PyObject *resultObj = PyRun_String(script, Py_file_input, globalDict, globalDict); if( !resultObj ) { PyErr_Print(); } else { PyObject_Print(resultObj, stdout, 1); Py_DECREF(resultObj); } Anyway, it appears to execute just fine and the errors all print exactly what you'd expect but the non-error rusults always print "None". I suspect the int arg to PyObject_Print is wrong. I found reference to Py_Print_RAW, which I tried but is undefined as a constant. Anyone have any pointers? From bjorn at roguewave.com Mon May 22 16:40:52 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 22 May 2000 14:40:52 -0600 Subject: append to a file References: Message-ID: <39299B54.EB63551F@roguewave.com> Open the file for appending: f = open('file', 'a') -- bjorn Scott Hathaway wrote: > > How do I append to a file instead of overwriting it? I searched on the > python website and got a hit, but the link was bad. > > Thanks, > Scott > > -- > http://www.python.org/mailman/listinfo/python-list From ralf.claus at t-online.de Sat May 27 03:48:32 2000 From: ralf.claus at t-online.de (Ralf Claus) Date: Sat, 27 May 2000 09:48:32 +0200 Subject: TkMessageBox Message-ID: <8gnulo$7br$14$1@news.t-online.com> Hi, i try to create a Tkinter MessageBox with the MessageBox - option "YESNOCANCEL" But what ever i try, it does not work. In my opinion the syntax must look like this: import tkMessageBox tkMessageBox.askquestion("equal","even better", icon=QESTION, type=YESNOCANCEL) The error message here is: NameError: QUESTION but why ? Ralf From ivanlan at home.com Sun May 7 23:50:19 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Sun, 07 May 2000 21:50:19 -0600 Subject: RH6.1 coredump: float("10.01") References: <3915ECBB.C9A780B6@rubic.com> Message-ID: <3916397B.FBDBE334@home.com> Jeff Bauer wrote: > > I recently discovered a problem using the built-in > float() function on a client's RedHat 6.1 server. > > >>> float("10.01") > Segmentation fault (core dumped) > > If I use float() or string.atof() against any string > whose absolute value is greater than "10.0", I get > a core dump. > > I've duplicated this problem in C (egcs-2.91.66) > on this particular machine, so it's not a problem > with the Python interpreter. No problem on various > SuSE Linuxes using egcs-2.91.66. > > The tim-bot will say it's my just desserts for even > considering using floats in my code. > > If anyone can confirm this problem on RedHat 6.1 > (and even better, point me to a solution), please > email me privately -- or post to this list, if you > think it's relevant. Thanks. > [0 /home/ivanlan] 2 python Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs - on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> float("10.01") 10.01 >>> That was on Redhat 6.1, which is what's running my webserver, na-tzul.pauahtun.org ("big dog"). Looks pretty good to me, although I wasn't willing to do it in C. ... > god-created-integers,-we-should-have-had-enough- > sense-to-stop-there-ly y'rs, > -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From bawolk at ucdavis.edu Tue May 16 20:54:57 2000 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Tue, 16 May 2000 17:54:57 -0700 Subject: BLT & Python Megawidgets on linux Message-ID: <3921EDE1.ED274B87@ucdavis.edu> I have installed BLT on my linux machine, but my Pmw programs don't run anymore. They can't seem to find the BLT files. Is anyone running BLT on linux and if so, where did you put the various directories? Bruce From g2 at seebelow.org Fri May 12 17:50:08 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 22:50:08 +0100 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391AED9E.30C70EF@yahoo.com> Message-ID: <391C7C90.2C0@seebelow.org> Paul Winkler wrote: > ... > Yes, it does. :) More to the point, I got too frustrated with > staring at man perldsc and man perllol trying to understand it. Can > you explain the meaning of each bit of punctuation on that line? > Faced with something I thought should be simple, but took up 1200 > lines in the perl man pages, I gave up. I got to like perl because > it was easy; I gave up on it because I needed complex data > structures and they were driving me crazy. I'm really honestly > impressed that you can do it with no trouble, but I think a lot of > people who need scripting languages will have a similar reaction to > mine: "This is too hard!" If there were some overall benefit to it, it might be worth it. But Python shows us that all that junk isn't necessary. (then-again-neither-was-this-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From aa8vb at yahoo.com Mon May 15 09:34:36 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 15 May 2000 09:34:36 -0400 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) In-Reply-To: <8fh9ki$51h$1@slb3.atl.mindspring.net>; from aahz@netcom.com on Fri, May 12, 2000 at 03:57:06PM +0000 References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> Message-ID: <20000515093436.B1303573@vislab.epa.gov> Aahz Maruch: |In article , |Ben Wolfson wrote: |> |>', '.join(['foo', 'bar', 'baz']) | |This only works in Python 1.6, which is only released as an alpha at |this point. I suggest rather strongly that we avoid 1.6-specific idioms |until 1.6 gets released, particularly in relation to FAQ-type questions. That's disgusting anyway. I just can't wait until we see more expressions like that. 1.+(2,3).*4 Are we calling 1's + method with 2 and 3 as arguments, or is that a floating point number we have there added to a tuple. Watch out! Python is morphing into Perl. ([scratch, scratch] Now WHAT does THAT code do!?!) -- Randall Hopper aa8vb at yahoo.com From db3l at fitlinxx.com Wed May 31 20:49:51 2000 From: db3l at fitlinxx.com (David Bolen) Date: 31 May 2000 20:49:51 -0400 Subject: *blink* That's neat. References: <3fMY4.28915$WS3.322429@typhoon.we.rr.com> Message-ID: Michael Hudson writes: > The situation is much worse in C, especially when using the bitwise > operators. Does "var & 1 == 0" do what *anyone* would expect on first > reading? (Hint: no). A bit off-python-topic, but while I don't know about anyone else, the above is why I more or less gave up with all but the most obvious C precedence rules at some point for all but the simplest expressions. Getting bit once or twice by stuff like that (and yes, my "first reading" of that statement nowadays screams "bug") was enough. Parentheses became my friends. -- -- 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 buzzard at contactbox.co.uk Wed May 10 02:27:17 2000 From: buzzard at contactbox.co.uk (Duncan Smith) Date: Wed, 10 May 2000 06:27:17 GMT Subject: Trouble installing numpy - newbie References: <3918B795.7AFE8386@world.std.com> Message-ID: <39191022.0@news2.cluster1.telinco.net> I had exactly the same problem a few days ago. If you download the zip from the following link it should install O.K. without needing to run or compile anything. Just unzip it to your python directory. http://sourceforge.net/project/?group_id=1369 From pinard at iro.umontreal.ca Thu May 25 10:51:47 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 25 May 2000 10:51:47 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Les Schaffer's message of "Thu, 25 May 2000 14:27:27 GMT" References: <8g7t5c$1i7i$1@thoth.cts.com> Message-ID: Les Schaffer writes: > Anyway, thats as absurd as I can get. I just can't think of any other > reason why the language and newsgroup has to waste its time with a > discussion on case-sensitivity. We live in the terror of the damage to come. If we loose our precious time into these discussions, this is because we are moved by despair... :-) I like Python, but I begin to resent Guido, who did this to us. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From shogan at iel.ie Tue May 23 09:39:39 2000 From: shogan at iel.ie (Shaun) Date: Tue, 23 May 2000 14:39:39 +0100 Subject: how to find index of int in a string? exceptions? Message-ID: <03af01bfc4bc$57a09260$2801000a@iel.ie> ok, i have variables ,id ,subId, nvSeqStr a message will be passed in like...(some code & pseudo code below) forgive me im still a newbie and i cant grasp this stuff at all.... class message: import string def __init__(self, id, subId, nvSequence): self.id=id self.subId=subId self.nvSequence=nvSequence() #overloaded constructor 1 #sets up member vars id and subId subId of type int def __init__(self, id, subId, nvSequence=None): self.id = id self.subId = subId self.nvSequence = nvSequence def Message(StringMsg): # what i want to do is, 1) find the index of the first integer in the string StringMsg 2) #on an error throw a format exception 3) save int in var id 4) find the index of the second integer in the string StringMsg #on an error throw a format exception save int in var subId 5) keep the rest of the string in var nvSeqStr 6) if nvSeqStr is not empty 7) try decode it #on an error throw a format exception 8) else set nvSeqStr to null #on an error throw a format exception ===================== Shaun Hogan Interactive Enterprise Ltd. alt. E-mail : shaun_hogan at yahoo.com Phone: +353 86 8342529 The University of Limerick Rollerhockey Club URL: http://rollerhockey.csn.ul.ie From chibaA at TinterlogD.Tcom Tue May 16 10:41:01 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Tue, 16 May 2000 14:41:01 GMT Subject: pyApache install References: Message-ID: <39215d4d.306703205@news1.on.sympatico.ca> The only error that I receive (when using apachectl start) is: /usr/local/apache/bin/apachectl start: httpd could not be started [root at linux apache_1.3.12]# If I just try it as ./httpd, then I get "Segmentation Fault". I figured the defaults would at least allow me to compile correctly (compile for make, and make install work fine - with no errors; it just makes a faulty executable!?!) -- but I guess not. Re: could gcc be too new? Maybe I suppose. But would RH distribute a gcc that would be incompatible with compiling something as standard as apache? (6.2 I believe is the newest, I have RH6.1). I'd imagine more people would have problems doing simple things as I - if that were the case. Actually, I remember I had to copy some .h files into my include directories (WAY back..). Is there anyway to reinstall all of the GCC files & includes? (ie. where might I find the package to do so? Thanks for all your help, kc On Tue, 16 May 2000 08:21:10 +0000 (GMT), Oleg Broytmann wrote: >On Tue, 16 May 2000 chibaA at TinterlogD.Tcom wrote: >> I'm having problems figuring out how to install pyApache. Actually, >> the root of it might have something to do with problems getting the >> compiled apache server to run. If anyone has successfully recompiled >> apache with pyapache (or.. even recompiled apache), could you lend me >> a hand here? > > I did it many times, pretty successfully. > >> Basically, if I try and run ./configure, everything goes well (and >> seemingly imports modules & stuff fine), the installation finishes, >> and the apache directory & executables are all there. I go to run >> apachectl start - and it gives me an unable to start message. If I >> just try running ./httpd, it just says segmentation fault. > > Any more details? Any error message? > >> Any ideas? I'm running RH6.1, I have the rpm version of apache >> 1.3.9-4 running already (but I killed the process while trying the >> rebuilt one). I compiled (with and without pyapache) using apache >> 1.3.9 (and for kicks, tried 1.3.12 as well) - but the same problem >> each time (segmentation fault). When I type gcc -v, it returns gcc >> version egcs-2.91.66 (which I assume is new enough - came with RH6.1). > > May be it is TOO new? I use gcc-2.7.2.3 and 2.8.1... > >Oleg. (All opinions are mine and not of my employer) >---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > From genesis7 at my-deja.com Mon May 8 23:24:33 2000 From: genesis7 at my-deja.com (genesis7 at my-deja.com) Date: Tue, 09 May 2000 03:24:33 GMT Subject: zlib in python 1.5.2 missing? Message-ID: <8f80d2$ruh$1@nnrp1.deja.com> Hi Python Expert out there... I have a quick question regarding zlib module in python 1.5.2. Is any one using it? If you are where can I find it. I tried building it from both 1.5.2 source and from their CVS tree. No luck! It seems to be missing zlib.h file. This file doesn't seem to exist anywhere in their source tree. If you have a solution, that would be great. Thanks, --sc Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Sat May 6 13:12:41 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 06 May 2000 17:12:41 GMT Subject: My Server supports Python? References: <391305A4.98430BB0@swt.edu> Message-ID: <39145347.59330549@san.rr.com> Will Ware wrote: > > Shah, Navneet (navneet at swt.edu) wrote: > > I need to add some python programming on my website. > > How do I check whether my server supports python programming? > > If you have a shell account, try typing "python" at the command > line. If you get back a version number, copyright notice, and > ">>>" prompt, your ISP has Python. % find / -name "python*" -print This would be a bit more authoratative, albeit take a long while. :) C/ From glyph at twistedmatrix.com Sun May 7 19:14:57 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 07 May 2000 18:14:57 -0500 Subject: Future of the Python Linux Distribution In-Reply-To: Vetle Roeim's message of "07 May 2000 23:19:09 +0200" References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: Vetle Roeim writes: > - age. the other "P" language[0] has been around a little longer.. right? I hear this tossed around a lot. How *much* longer? > - forced intentation. a friend of mine once said that he > categorically dislikes languages that forces that kind of > limitations on the programmer. what language does this guy use? I imagine that it forces him to treat stack frames as implicit... possibly even to use an imperative syntax. Or infix notation. Anyone who believes that the language they use doesn't impose restrictions and enforce a paradigm on them is deluding themselves (and not well, at that). > this aspect of Python *is* a litle weird. but all languages have > their weirdness.. many people judge are scared of new things. I was scared of python for this very reason for *ever*. We need a publicized, annoying, LOUD defense of this feature of the language. Every time I look at python code these days, I feel like slamming my head into the wall; to THINK that I missed out on this for a YEAR because I was dumb enough to think that enforced whitespace was not only a big deal, but a BAD thing!! > let's just hope it doesn't get a reputation like Lisp (and > derivatives)[1]. Lisp has several reputations; part of it is from the insidiousness of the Lisp "industry". Luckily, the PSA can never do this, thanks to the existance of a free implementation of python in the first place (and I *seriously* doubt anyone would want to) > - books. I may be very wrong about this, but are there more books > about the other "P" language? It requires more documentation. I can't make it 5 lines through a perl script without 25 consultations of the Camel Book. I bought two python books from o'reilly on principle, but I haven't really needed them. This is a *GOOD THING*. We need more python books that cover higher-level concepts. Learning Python isn't about "learning python"... it's about unobscuring good programming. Learning Perl is about learning perl. Capitalization important there: uppercase-P is the language, lowercase-p is the interpreter. If you don't know the in-and-outs of the perl interpreter, and the quirks it has, you can't do anything. Now, python has some nifty quirks too (my code is riddled with __setattr__ and __getattr__. I LOVE them!) but I seriously doubt there will ever be a JPerl. > - not hackish enough. Python code is nice to look at. code written in > the othet "P" language looks cooler.. to me (I'm an academic) it > just looks ugly. code should be beautiful. > but some people see that Python is all nice and tidy, and so they > dislike it because they can't write ugly, unmaintainable code[2] Stupid, stupid, stupid, stupid... First of all, this is NOT an admirable goal as an engineer, and it's a problem with the software industry at large, not with Python... Secondly; def hash_coerce(l): d={} map(lambda x,d=d: apply(lambda k,v,d=d:d.update({k:v}), string.split(x,'.')), l) return d map, lambda, apply, filter. Obfuscation at your fingertips. :-) Using {}.update(), I believe it's possible to write programs that use only expressions; no statements. > - bad PR-agency[3]. until a year ago, I hadn't heard about Python. > now I use it all the time. We need more cybernetic time-travelling marketing executives from the year 2038 to subdue perl and java proponents with their psychic freeze-rays. Failing that, a "banner campaign", where everybody who has a web page that uses python advertises it incessantly (this would hopefully include every Zope site too) might do some good... Unfortunately, one of the best features of the python community is that it seems to have a sane group of people in it who know multiple languages and will choose appropriate ones for the appropriate task. We need more rabid, unabashed evangelists. :-) > [0]: no, I'm not referring to Pascal.. or Prolog. you know what I'm > referring to, you little weasel Perhaps you mean you little *camel* > [1]: I like Lisp, but it *does* have a PR-problem. Lisp *IS* a PR-problem. Lisp needs to change its name and shed some syntax before it's ever going to get 'mainstream' acceptance; the ideas in lisp are good, but too many cs students have been tortured with it ... > [2]: some of you may think I'm being sarcastic here. I wish I thought you were ... I really wish ... > [3]: I know there's no PR-agency. it's a joke. laugh. If there's no PR-agency, where are we going to get our nuclear-powered psychic cyborg executives? Do you think microsoft has any extra? -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From jraddockNOjrSPAM at hotmail.com.invalid Tue May 16 16:43:35 2000 From: jraddockNOjrSPAM at hotmail.com.invalid (JRHoldem) Date: Tue, 16 May 2000 13:43:35 -0700 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <3921A17C.F995CEFB@tismer.com> Message-ID: <043ee7d0.5c606b3d@usw-ex0101-008.remarq.com> I'm new to this board but you're right - Glyph is a programming god and he's 100% on target with his Java rants. I say this not only as a business partner and friend of his but also as a Java programmer who has faced several of these issues myself. And yes, any language which has attracted the attention of the Cobol community probably is the work of Satan. Stay cool, JrHoldem aka JR aka the-super-rounding-poker-playing-computer- programming-evil-evil man * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From akuchlin at mems-exchange.org Mon May 22 18:24:30 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 22 May 2000 17:24:30 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (May 22) Message-ID: <8B4B18AC5D343888.65E03E67E4106364.DEBE8E21D2760B6D@lp.airnews.net> Words to live by: "the registry sucks, but ... a global environment sucks even more!" http://x44.deja.com/getdoc.xp?AN=623411718 http://x44.deja.com/getdoc.xp?AN=623726469 Jeff Kunce installs Python for network sharing http://starship.python.net/crew/jjkunce/netinstall/python_network_setup.html GvR announces that the Python CVS tree has been moved to SourceForge. This makes it possible to give external developers checkin privileges. http://www.python.org/pipermail/python-list/2000-May/058080.html A page on using Python from Delphi: http://www.multimania.com/marat/delphi/python.htm Peter Milliken announces Python support for ELSE, which adds language-specific templates to Emacs: http://members.xoom.com/pmilliken Francois Pinard postes interesting code snippets. He calculates the fraction closest to a decimal number: http://www.python.org/pipermail/python-list/2000-May/057402.html and converts nsgmls output to an in-memory tree: http://www.python.org/pipermail/python-list/2000-May/057442.html Speculation about Python 3000, and the mooted possibility of introducing case-insensitivity, lead to a lengthy discussion. (Since this is comp.lang.python, it's a discussion and not a flamewar.) You can start following the thread from the following posting: http://www.python.org/pipermail/python-list/2000-May/057876.html A few noteworthy posts in the thread: GvR, on the rationale for the potential change: http://www.python.org/pipermail/python-list/2000-May/057990.html Fredrik Lundh, on the Alice work that gave rise to the idea: http://www.python.org/pipermail/python-list/2000-May/058031.html Francois Pinard explains his disagreement: http://www.python.org/pipermail/python-list/2000-May/058044.html "3 years is a long time", by A.M. Kuchling: http://www.python.org/pipermail/python-list/2000-May/058053.html ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org eff-bot's complements this digest with his daily python url http://hem.passagen.se/eff/url.htm Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py 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 Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 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 res031mu at gte.net Fri May 5 07:42:02 2000 From: res031mu at gte.net (Jim Callahan) Date: Fri, 05 May 2000 11:42:02 GMT Subject: IDLE 0.5 won't die (bug??) Message-ID: <3912B392.F00D7D66@gte.net> When I run the code from the Frames in TK message (code after error) as a script in IDLE 0.5 (using ctrl-F5) , and close the resulting window, IDLE won't do anything else, and I have to run a script which does a print "Howdy" or something of the sort to get my prompt back. IDLE the reports this Traceback: Hello World! Traceback (innermost last): File "C:\Program Files\Python\Tools\idle-0.5\printHi.py", line 1, in ? print "Hello World!" File "C:\PROGRA~1\PYTHON\TOOLS\IDLE-0.5\PyShell.py", line 637, in write self.shell.write(s, self.tags) File "C:\PROGRA~1\PYTHON\TOOLS\IDLE-0.5\PyShell.py", line 628, in write raise KeyboardInterrupt KeyboardInterrupt: ****the code that kills my IDLE********************************** from Tkinter import * def create_frames(master): # relief and borderwidth arguments make frames visible frame1 = Frame(master, relief='sunken', borderwidth=2) frame2 = Frame(master, relief='sunken', borderwidth=2) frame1.place(relx=0, rely=0, relwidth=1, relheight=0.65) frame2.place(relx=0, rely=0.65, relwidth=1, relheight=0.35) # put something in the frames label1 = Label(frame1, text="Hello") label1.grid(row=0, column=0) label2 = Label(frame2, text="World!") label2.grid(row=0, column=0) root = Tk() create_frames(root) root.mainloop() -- Jim Callahan cobol4ever at altavista.net From guido at python.org Tue May 30 15:05:43 2000 From: guido at python.org (Guido van Rossum) Date: Tue, 30 May 2000 14:05:43 -0500 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com Message-ID: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> To all Python users and developers: Python is growing rapidly. In order to take it to the next level, I've moved with my core development group to a new employer, BeOpen.com. BeOpen.com is a startup company with a focus on open source communities, and an interest in facilitating next generation application development. It is a natural fit for Python. At BeOpen.com I am the director of a new development team named PythonLabs. The team includes three of my former colleagues at CNRI: Fred Drake, Jeremy Hylton, and Barry Warsaw. Another familiar face will joins us shortly: Tim Peters. We have our own website (www.pythonlabs.com) where you can read more about us, our plans and our activities. We've also posted a FAQ there specifically about PythonLabs, our transition to BeOpen.com, and what it means for the Python community. What will change, and what will stay the same? First of all, Python will remain Open Source. In fact, everything we produce at PythonLabs will be released with an Open Source license. Also, www.python.org will remain the number one website for the Python community. CNRI will continue to host it, and we'll maintain it as a community project. What changes is how much time we have for Python. Previously, Python was a hobby or side project, which had to compete with our day jobs; at BeOpen.com we will be focused full time on Python development! This means that we'll be able to spend much more time on exciting new projects like Python 3000. We'll also get support for website management from BeOpen.com's professional web developers, and we'll work with their marketing department. Marketing for Python, you ask? Sure, why not! We want to grow the size of the Python user and developer community at an even faster pace than today. This should benefit everyone: the larger the community, the more resources will be available to all, and the easier it will be to find Python expertise when you need it. We're also planning to make commercial offerings (within the Open Source guidelines!) to help Python find its way into the hands of more programmers, especially in large enterprises where adoption is still lagging. There's one piece of bad news: Python 1.6 won't be released by June 1st. There's simply too much left to be done. We promise that we'll get it out of the door as soon as possible. By the way, Python 1.6 will be the last release from CNRI; after that, we'll issue Python releases from BeOpen.com. Oh, and to top it all off, I'm going on vacation. I'm getting married and will be relaxing on my honeymoon. For all questions about PythonLabs, write to pythonlabs-info at beopen.com. --Guido van Rossum (home page: http://www.python.org/~guido/) From rkiendl at gmx.net Thu May 25 11:38:08 2000 From: rkiendl at gmx.net (Robert Kiendl) Date: Thu, 25 May 2000 17:38:08 +0200 Subject: Embedding Pythonwin: Thread State Problems with Nested Calls Message-ID: <392D48E0.8D66CB46@gmx.net> I've got just one thread - for app and pythonwin. When win messages are routed to the pythonwin part of my application, execution flows through a CEnterLeavePython/PyEval_AcquireThread (inside CVirtualHelper, glue/Python_OnCmdMsg, ...) Also direct calls of python code out of the app source appears. Such stuff must also be sourrounded by CEnterLeavePython (i think this is rigth?) Sometimes such CEnterLeavePython-sourrounded direct python calls run back into windows functions which directly send messages (SetWindowPos, DoModal's, ....) When such Messages run through the above path, PyEval_AcquireThread ist called a second time inside pythonwin - and bang! What would be a correct treatment for those problems? Finding all win-reentries in my swig-ed code and doing y_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS would be tedious and apparently unnecessary. Experiments with glue.bShouldAbandonThreadState=false were fruitless. Is that thread state handling of Pythonwin already in a ripe state or is this a current topic? I hate trying to compile pythonwin with PYCOM_USE_FREE_THREAD or such stuff. Would this at all be a makeshift? Or am i completly wrong? robert From Christopher.Vogel at wpafb.af.mil Wed May 3 12:45:49 2000 From: Christopher.Vogel at wpafb.af.mil (Vogel Christopher N Contr AFRL/SNAA) Date: Wed, 3 May 2000 12:45:49 -0400 Subject: numpyio code Message-ID: <9F17D7A52AA1D311988500104B2444E0674904@FSZHTV44> To whom it may concern, I am in need of Travis Oliphant's numpyio code, and it is currently unavailable to download from the www. If anyone out there has a copy of it, could you please e-mail it to me, or put it on an ftp site? I would greatly appreciate it. Thank you very much, Chris V. _____________________________________________________ Christopher N. Vogel Engineer Sverdrup Technology, Inc. 4200 Colonel Glenn Highway, Suite 500 Beavercreek, OH 45431-1663 Phone (office): (937) 255-5668 x4150 Phone (ARC lab): (937) 255-4310 Fax: (937) 255-1122 E-mail: Christopher.Vogel at wpafb.af.mil From effbot at telia.com Thu May 11 09:53:06 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 13:53:06 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: <6XyS4.6757$Za1.105942@newsc.telia.net> tony summerfelt wrote: > > we cannot read perl, and we cannot read your mind... > > > but I can try (reading your mind, that is). > > where's this coming from? is this what i can expect in answers to any > python questions i have? oh, you only want answers from people who can read perl and/or figure out what you mean even if you say something else? I suppose that can be arranged. From tim_one at email.msn.com Tue May 9 02:55:19 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 9 May 2000 02:55:19 -0400 Subject: Copyright and License In-Reply-To: Message-ID: <000601bfb983$89dbc900$592d153f@tim> [Tim] > Once copyright status is lost, it can't be regained: the decision > to put something in the public domain is irrevocable. That means > nobody-- not even me! --can ever assert copyright on something I > release to the public domain. [Cliff Crawford] > I've actually heard the opposite said by people defending the GPL. > Supposedly if you release something as PD, or even with a BSD or other > license, then a Big Corporation can take your code, assert copyright on > it without even making any modifications or anything, and then sue you > for distributing "their" code. So that's why everyone should use the > GPL. At least, that's how their argument goes.. You certainly haven't heard Richard Stallman make that argument. If Andrew's example of the King James Bible didn't sway you, use any old search engine and look for any old copyright FAQ -- they all cover this point about public domain. The Big Corp can copyright it after they make some changes, but the copyright applies only to their changes, and even then only to their particular *expression* of their changes (not to the ideas behind them). > I don't really have the time or the legal expertise to sit down and > read copyright laws, and there's so many different interpretations of > the GPL that I'm wary of using that too. I've never been able to stay awake thru the whole thing. But it's what you want if your project embraces the GNU philosophy (mine usually don't; the Emacs pymode was an exception). > So I just slap a BSD license onv everything and hope for the best :) I > think I'll look more into PD though, it sounds like it's not as dangerous > as I thought it was. There's no danger that you'll get ripped off in a serious way. GNU is pushing a particular ideology for software, but short of that most everyone just wants to avoid getting sued. So far, programmers have mostly avoided getting nailed for what in other engineering disciplines would almost certainly be judged criminal negligence, and we've enjoyed this charmed life regardless of license. I stick stuff in the public domain peppered with a one-liner full of buzzwords like "no warranty", "as-is", "use at your own risk". Does that give me legal protection? Frankly, I'd be kinda sad if it did -- reciting that crap is more in the nature of a comforting social ritual that we tell each other keeps the wolves away <0.1 wink>. for-reliable-legal-advice-nothing-beats-usenet-ly y'rs - tim From vasvir at iit.demokritos.gr Fri May 26 13:34:35 2000 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Fri, 26 May 2000 20:34:35 +0300 Subject: capturing stdout and stderr of system() Message-ID: <392EB5AB.3AA7AD59@iit.demokritos.gr> Halo, I would like to capture both the output of stdout and stderr of system() in two distinct strings in a portable way. I can do it if I use fork() instead of system() but I would like to maintain source compatibility with win32 as much as possible. I searched the FAQ and howtos and I looked at popen2 code but it uses fork, so if anyone can enlighten me I would be grateful. I hope this is the right place for asking this kind of questions... .Bill From paul at prescod.net Wed May 10 18:10:41 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 10 May 2000 15:10:41 -0700 Subject: jpython References: <5auR4.19049$uJ1.40115@nntpserver.swip.net> Message-ID: <3919DE61.E1FA68E5@prescod.net> No. But Microsoft has Java "extensions" that allow access to the win32 API and you could probably use those extensions as long as you are using Microsoft's JVM. I think it is called "JDirect" or something. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Art is always at peril in universities, where there are so many people, young and old, who love art less than argument, and dote upon a text that provides the nutritious pemmican on which scholars love to chew. -- Robertson Davies in "The Cunning Man" From francis at robinton.demon.co.uk Mon May 8 15:43:17 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Mon, 8 May 2000 20:43:17 +0100 Subject: Copyright and License References: <000801bfb8b9$f0fc7280$b12d153f@tim> Message-ID: <2SB4YzAVjxF5EwDn@robinton.demon.co.uk> In article , Cliff Crawford writes >I don't really have the time or the legal expertise to sit down and read >copyright laws, and there's so many different interpretations of the GPL >that I'm wary of using that too. So I just slap a BSD license on >everything and hope for the best :) I think I'll look more into PD >though, it sounds like it's not as dangerous as I thought it was. And it wouldn't really help because they are not universal. Actually, I believe that in the US you cannot give away your copyright, you can sell it, and if you work for a company ownership of the copyright on your work may belong to the company as part of your work contract. Intellectual property belongs to the creator unless they sell it in some way. Patents are even worse (I believe that owing to the differences between the US and Europe that two unrelated people can hold the sole patent to a product, one in Europe and one in the US - the US gives preference to the first to file while Europe uses a different criterion) Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From rogerha at ifi.uio.no Tue May 16 08:11:34 2000 From: rogerha at ifi.uio.no (Roger Hansen) Date: 16 May 2000 14:11:34 +0200 Subject: import c-library into python References: <291a7886.96e46737@usw-ex0107-055.remarq.com> <39212867.22E7CA52@tammura.at> Message-ID: * Tamer Fahmy > > Haegges wrote: > > > > Hello, > > I have a library (and the source) written in c. How can I import > > these lib into python? So, that I can access the c-functions, if > > possible without changing many c-code! > > Hi! > > There are actually 2 possibilities I know of: > 1. write a wrapper Python module to your C library. > The document on http://www.python.org/doc/current/ext/ext.html > should provide you with information how to do this. This is a good solution if you only have to wrap a few functions. However if it's a library I would suggest SWIG since wrapping lots of functions are boring and error-prone. But you should look at the "Extending ..." document above to get the feeling of things. HTH, Roger From mjhand at concentric.net Mon May 8 15:34:55 2000 From: mjhand at concentric.net (Manus Hand) Date: Mon, 08 May 2000 13:34:55 -0600 Subject: import modules at runtime References: <8f6jd5$7mg$1@nnrp1.deja.com> Message-ID: <391716DF.CECEE2A5@concentric.net> I regularly do the following, after dynamically realizing that "object" should be an instance of a particular "className" found in a certain "moduleName": code = __import__(moduleName) object = code.__dict__[className](initParam1, initParam2, etc.) Works like a charm. Manus From sreekant at uklinux.net Wed May 17 13:17:57 2000 From: sreekant at uklinux.net (Sreekant Kodela) Date: Wed, 17 May 2000 17:17:57 GMT Subject: Python / CGI / E-mail problem References: <3920E594.F3F2E4CD@uklinux.net> <3921C3C8.90A5E7C9@uklinux.net> <1oiU4.47074$z%.50348@afrodite.telenet-ops.be> Message-ID: <39231953.3F156977@uklinux.net> ben at co.and.co wrote: > Sreekant Kodela wrote: > > Hi there > > > > I tried using the MimeWriter but failed. Do you have any simple exampe by > > any chance. > > > > thanks > > sreekant > > I've never used smtplib nor MimeWriter, and it appears MimeWriter > isn't necessary at all. Try this one, as a test (fill in the obvious > ones): > > ---------------------------------------------------------------------- > #!/usr/bin/python > > import smtplib > > your_email_address = '____' > your_server = '127.0.0.1' > > test_message = '''From: %s\r > To: %s\r > Subject: ILOVEYOU\r > MIME-Version: 1.0\r > Content-Type: text/html; charset=iso-8859-1\r > Content-Transfer-Encoding: 8bit\r > Content-Disposition: inline\r > \r > \r > \r > \r >

Hello %s

\r > \r > \r > ''' % (your_email_address, your_email_address, your_email_address) > > con = smtplib.SMTP(your_server) > con.sendmail('From: %s' % your_email_address, > 'To: %s' % your_email_address, > test_message) > con.quit() > --------------------------------------------------------------------- > > Greetings, > -- > ben . de . rydt at pandora . be ------------------ your comments > http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora Hi there I followed exactly as you said and it still seems to come as text. Did it work for you! If so I am going to send a few mails to my self across the net and read the mail from various clients and see. Thanks sreekant From paul at prescod.net Wed May 31 12:24:45 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 31 May 2000 11:24:45 -0500 Subject: What's that sound? Message-ID: <39353CCD.1F3E9A0B@prescod.net> ActiveState announces four new Python-related projects (PythonDirect, Komodo, Visual Python, ActivePython). PythonLabs announces four planet-sized-brains are going to be working on the Python implementation full time. PythonWare announces PythonWorks. Is that the sound of pieces falling into place or of a rumbling avalanche "warming up" before obliterating everything in its path? -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "I want to give beauty pageants the respectability they deserve." - Brooke Ross, Miss Canada International From robin at jessikat.demon.co.uk Thu May 18 03:18:03 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 18 May 2000 08:18:03 +0100 Subject: Auto-insert of colons in Emacs References: <8fvl63$seb9@news1.gtech.com> Message-ID: In article <8fvl63$seb9 at news1.gtech.com>, Peter Milliken writes >Hi John, > >To quote a famous recent email "Why hobble your mind with a detail the >computer can figure out for itself?" :-) > >Have a look at true language sensitive editing using Emacs at >http://members.xoom.com/pmilliken > >I have just updated the minor mode (you will see it if you haunt >gnu.emacs.sources) and added a new template language for Python :-) So, now >you can get the computer to generate all of the syntax and you just supply >the variable names :-) This mode works with any major mode, not just Python, >there are language templates for C, Ada, Emacs-Lisp etc WOW! Does this mean I can install emacs and go home? If only the variable names are missing can't we just get emacs to generate random ones? I know emacs is big, but!! :) >I have only just started learning Python, so I don't claim the templates are >perfect but I have been using them for a couple of days now without >problems. If there is something you don't like let me know and I will fix it >(full instructions on how the templates work and how to modify them are >included in the 45+ page user manual :-)). > >Any questions, please don't hesitate to call :-) > >Peter -- Robin Becker From yohamed at concentric.net Tue May 2 19:23:26 2000 From: yohamed at concentric.net (Moe Hendawi) Date: 02 May 2000 19:23:26 EDT Subject: Error importing MySQLdb when embedding python Message-ID: <8eno1e$5iu@chronicle.concentric.net> Hi there, I am trying to embed python in a C++ application. Here is the gist of the C++: Py_Initialize(); PyRun_SimpleFile(fh, "handler.py"); Py_Finalize(); handler.py is as follows: import sys import MySQLdb print "Hello" When I do this, I get the following error: moe: embed [19]>./embedpython Traceback (innermost last): File "test2.py", line 3, in ? import MySQLdb File "/usr/local/packages/Python-1.5.2/lib/python1.5/site-packages/MySQLdb.py", line 19, in ? import _mysql ImportError: /usr/local/packages/Python-1.5.2/lib/python1.5/site-packages/_mysqlmodule.so : undefined symbol: PyType_Type If I take out the "import MySQLdb" line, the problem goes away (duh). If I run handler.py directly from the command-line it works fine so MySQLdb is set up properly (I have written more complicated scripts that demonstrate it working). I'm not really sure what the error message is telling me about PyType_Type. Does anyone have any ideas what is going on? This is my first real attempt at using Python so I may be attempting a bit much at first, but I have a need for embedding and I would prefer to take this opportunity to learn Python (as opposed to doing it in Perl which I know cold). Thanks for any help! -Moe (please cc: yohamed AT concentric DOT net) From digitome at iol.ie Wed May 3 14:56:33 2000 From: digitome at iol.ie (Sean Mc Grath) Date: Wed, 03 May 2000 18:56:33 GMT Subject: RAX Website Message-ID: <39107127.87004195@news.iol.ie> RAX is an API for processing record oriented XML. The reference implementation of RAX is in Python. It can be downloaded from http://www.digitome.com/rax.html. regards, Sean McGrath From paul at prescod.net Wed May 31 13:10:58 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 31 May 2000 12:10:58 -0500 Subject: [Python-Dev] What's that sound? References: <39353CCD.1F3E9A0B@prescod.net> <14645.17611.318538.986772@anthem.python.org> Message-ID: <393547A2.30CB7113@prescod.net> "Barry A. Warsaw" wrote: > > Or a big foot hurtling its way earthward? The question is, what's > that thing under the shadow of the big toe? I can only vaguely make > out the first of four letters, and I think it's a `P'. Look closer, big-egoed-four-stringed-guitar-playing-one. It could just as easily be a J. And you know what you get when you put P and J together? -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "I want to give beauty pageants the respectability they deserve." - Brooke Ross, Miss Canada International From tismer at tismer.com Tue May 9 20:20:34 2000 From: tismer at tismer.com (Christian Tismer) Date: Wed, 10 May 2000 02:20:34 +0200 Subject: Help: Starship administrator's email? References: <39187C68.DD1FA22D@bioreason.com> Message-ID: <3918AB52.DAF34599@tismer.com> Mitch Chapman wrote: > > Does anybody know whom to contact regarding restoration of telnet > access to the Starship? The main page says "If you need telnet > access, please contact Starship's administrators," but it does > not give an email address. And I can't find the URL for the > old main page which did provide such an email address. > > I have tried to login using ssh, but always receive a > "protocol version not supported" error. (This result predates the > crash, and has much to do with my laziness and little to do w. anything > else. But it is my excuse for needing telnet access.) Please use a SSH 1.5 compliant client. We do not support SH 2.0 . If you'd like to get telnet access, contact me privately (since our lists are still broke (and webmaster is one)) or remember how you got your ticket last time. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From olipt at mayo.edu Tue May 30 10:19:24 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 30 May 2000 09:19:24 -0500 Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) In-Reply-To: <393326D3.400AA248@cosc.canterbury.ac.nz> References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> <393326D3.400AA248@cosc.canterbury.ac.nz> Message-ID: > You're failing to take the dynamicness of Python into account. > The problem isn't with writing 1/2 and forgetting what it means; the > problem is with writing a/b when you can't be sure until run time > what type a and b are. > > Most of the time in Python it doesn't matter if you leave a number > as an integer until such time as it needs to become a float, whereupon > conversion is automatic. This is very convenient -- until you want > to do real division, at which point it all falls apart. Either you > explicitly convert to floats at every division, which clutters up > the code, or you have to take care to convert all numbers which > you might conceivably want to divide to floats on input. Either > approach is error prone in the worst possible way, i.e. mistakes > lead to bugs which are hard to trace. > > I assume that no-one would disagree with the following statements: > > 1. Integer division and real (or rational, if you prefer) division > are different operations. > > 2. Whenever you write a division operation into your code, you > always know which one you want. > > Currently, Python provides no way for you to directly specify > which one you want -- instead, it uses a heuristic based on the > run-time types of the arguments. This clearly violates the principle > of not trying to guess what the programmer meant. Therefore, it > is un-Pythonic. QED. > Thank you for this clear explanation. I agree with this statement. I have been bit several times by this problem of being able to specify which kind of division I want and having it depend on input types. -Travis From richard_chamberlain at ntlworld.com Fri May 5 05:00:43 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Fri, 5 May 2000 10:00:43 +0100 Subject: Learning Python References: Message-ID: Hi Alan, I think the best place to start is the tutorial in the Python Documentation which is at http://www.python.org/doc/current/tut/tut.html I bought the Learning Python book which is very good and fills in some of the gaps the tutorial leaves, unfortunately I haven't a copy of the Quick Python book so I cannot comment. The great thing about Python is the prompt. You can learn so much in realtime, without having to write a long script. Have fun, Richard Alan Wu wrote in message news:B538BAD2.C19%alanwu at bigpond.com... > Hi, > This may not be the best place to ask, but I was wondering if you people > here could help me out with my attempt to learn how to program with Python. > By all accounts, Python seems to be a learn-able language that one can do > useful stuff with. I haven't had much experience with programming (except > for a course in Visual Basic I did a year ago in Year 10), so I'm a bit > hesitant as to how to go about learning a programming language. I was > thinking of buying a book, either Learning Python by O'Reilly or The Quick > Python Book by Manning - does that sound wise? Which book would be best for > a newcomer to programming? > > Any help would be appreciated. > > Alan > From eric_mean at hotmail.com Sun May 21 13:08:48 2000 From: eric_mean at hotmail.com (eric_mean at hotmail.com) Date: Sun, 21 May 2000 17:08:48 GMT Subject: Tired of spam! Message-ID: Never use your main e-mail when you surf the newsgroups: You might get spammed. I receive at least 10 unsollicited e-mails a day! Do you? To address this issue, You might want to check this out: http://clicks.firstname.com/showfree.hmx?siteid=641041676&BAN=1 Sincerely, James P.S. If you know about a software that could help me filter my e-mail (by keywords, subject, etc.) could you please let me know? From akuchlin at mems-exchange.org Fri May 26 13:25:15 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 26 May 2000 13:25:15 -0400 Subject: Buffer overflows? References: <392A348E.7E31DD58@stroeder.com> <8gm2d1$tck$1@slb7.atl.mindspring.net> Message-ID: <3d8zwx9qbo.fsf@amarok.cnri.reston.va.us> aahz at netcom.com (Aahz Maruch) quoted Michael Str?der: > >Well, it's obvious that there are no problems with string buffers > >(like strcpy() in C) within pure Python code. But many modules (e.g. > >socket) are wrapping C code. How about these modules? Are there any > >security reviews of the C code of the Python library? Not as far as I know. I went on a search-and-destroy mission for unchecked sprintf("%s",...) calls a long time ago (pre-1.5, I think), but I don't really know anything about security auditing. It would be nice to know if anyone has carefully audited Python, or if anyone is willing to do so. Wasn't there a linux-audit mailing list where people would volunteer to audit stuff? Or maybe the OpenBSD group has looked at Python? -- A.M. Kuchling http://starship.python.net/crew/amk/ Perl is worse than Python because people wanted it worse. -- Larry Wall, 14 Oct 1998 From nascheme at enme.ucalgary.ca Tue May 30 02:22:07 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Tue, 30 May 2000 06:22:07 GMT Subject: destructors -- when are they called? References: <393351D2.3533AEFF@san.rr.com> Message-ID: Courageous wrote: >When writing a C language extension, is it guaranteed that the >moment your object's reference count is reduced to zero it's >destructor will be called? (I have a situation in which this >may matter). Yes. Neil -- "I can't believe I put pants on for this." --Homer Simpson From frankn=nuws at cs.vu.nl Tue May 9 17:43:13 2000 From: frankn=nuws at cs.vu.nl (Frank Niessink) Date: Tue, 9 May 2000 21:43:13 GMT Subject: Any module or library for full-text indexing? References: <391854D9.89285A9B@do.not.use> Message-ID: <8fa0ph$cs4@cs.vu.nl> Russell Turpin wrote: > I'm looking for a Python module that does full text > indexing, ie, that extracts a set of significant words > from a text document, and searches for a candidate word > in a list of words so extracted. The module should > solve the following problems: [snip] > If there is no C package, I'll consider anything that > can run on a Linux box. I don't know of any python module or package, but I have successfully used glimpse for this purpose (http://webglimpse.org/). I think it will fulfill most of your requirements. Cheers, Frank -- "Ha!" snapped Marvin. "Ha!" he repeated. "What do you know of always? You say `always' to me, who, because of the silly little errands your organic lifeforms keep on sending me through time on, am now thirty-seven times older than the Universe itself?" -- Douglas Adams, 'So long, and thanks for all the fish' From alleshohlNOalSPAM at gmx.de.invalid Tue May 16 03:25:47 2000 From: alleshohlNOalSPAM at gmx.de.invalid (Haegges) Date: Tue, 16 May 2000 00:25:47 -0700 Subject: import c-library into python Message-ID: <291a7886.96e46737@usw-ex0107-055.remarq.com> Hello, I have a library (and the source) written in c. How can I import these lib into python? So, that I can access the c-functions, if possible without changing many c-code! * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From mwh21 at cam.ac.uk Thu May 4 08:30:39 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 May 2000 13:30:39 +0100 Subject: Deleting objects in Python 1.6 References: <39116805.86326A69@python.net> Message-ID: "Thomas A. Bryan" writes: > Michael Hudson wrote: > > > > Try this: > > > > >>> l=[[]] > > >>> m=l[0] > > >>> for i in range(100000): > > ... m.append([]) > > ... m = m[0] > > ... > > >>> del l > > > > (hint: it segfaults on my machine, unless I use a v. new Python) > > Interesting. I caused Python to segfault once on Solaris. I wonder > whether this problem was the cause. There are easier ways of crashing Python 1.5.2; >>> l=[] >>> m=[] >>> l.append(l) >>> m.append(m) >>> l==m Segmentation fault (core dumped) is probably the simplest (and also won't work on 1.6). >>> import marshal >>> l=[] >>> l.append(l) >>> marshal.dumps(l) Segmentation fault (core dumped) is another... any C code that traverses structure "deeply" is at risk from recursive structures. > Then again, your code works on > my little Linux box... Tried it again. Still crashes. Gotta love computers, no? I guess you have to grow the stack until it stomps on something else, which might depend on all sorts of factors, like how many modules you have loaded, total memory size, versions of the kernel, phase of the moon, that kind of thing. Have you tried increasing the depth of the structure? Cheers, M. -- 93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From jkraska1 at san.rr.com Sat May 27 14:44:32 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 27 May 2000 18:44:32 GMT Subject: ob_refcnt INCREF and so on... Message-ID: <39301826.91D0E17D@san.rr.com> import deque class Class: pass o=Class() deque.checkref(o) ------- I'm currently working on a deque implementation, and I believe I now understand python reference counts. However, one small little thing puzzles me which I'd like resolved before I can say "I grok this." In my efforts to grok references, I wrote a function to print the ob_refcnt of python objects so I could test my understanding of the reference system. Here's where I'm a bit sketchy: In the above code fragment, checkref(o) prints "2". The object "o" has two references to it, and I'm not sure why. The closest thing I have to a theory is that at the point of creating the argument, "o" is assigned to a temporary tuple which grabs a reference count to "o" (I based this theory on the knowledge that I have to parse a tuple in the C extension code). Can someone confirm or deny this, and if I'm mistaken, explain why the refcnt of the object is 2 at the point where I print it?????? If correct, is there a predictable time when the temporary will lose it's reference hold on the object? Thanks much, C/ From shogan at iel.ie Thu May 4 09:47:11 2000 From: shogan at iel.ie (Shaun) Date: Thu, 4 May 2000 14:47:11 +0100 Subject: assigning a value to input data (scanf-ish)???? Message-ID: <013d01bfb5cf$3f3726e0$2801000a@iel.ie> right, what i wanna do is... print to the screen: ('please enter yer name:') here i want to take the name the user entered and assign a value, say 'name' to it ('please enter yer number') here i want to take the name the user entered and assign a value, say 'num' to it ('please enter yer email:') same ('please enter yer address:') same ('please enter the cost:') same then using the xdrlib module i want to pack all the info together to make a single byte data stream....like.... import xdrlib p=xdrlib.Packer() p.pack_string(name) p.pack_int(num) p.pack_string(email) p.pack_string(add) p.pack_float(cost) so how do i keep the value entered by the user in the memory with the value name, num ect.... assigned to it and will the way i have this structured work? thanks Shaun ===================== Shaun Hogan Interactive Enterprise Ltd. alt. E-mail : shaun_hogan at yahoo.com +353 86 8342529 From dana at mmi.oz.net Fri May 19 11:05:26 2000 From: dana at mmi.oz.net (Dana Booth) Date: 19 May 2000 15:05:26 GMT Subject: Java vs Python References: Message-ID: <8g3l7m$mpi$0@216.39.141.36> Brent Fulgham wrote: BF: I have to say that the works BF: shown on "Masterpiece Theatre" generally have something important BF: to say about society, life, etc., and are worth seeing. None of that pussy stuff even comes close to the social value of WWF Smackdown. -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From darrell at dorb.com Sun May 21 20:50:40 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 21 May 2000 17:50:40 -0700 Subject: Bit length of int or long? References: <000201bfc066$85951380$872d153f@tim><000b01bfc14d$7c7ef1c0$6401a8c0@home> <87zopl50o1.fsf@psyche.evansnet> Message-ID: <03c201bfc387$c1898640$6401a8c0@home> "Carey Evans" > I found when rewriting crypt() in Python that nearly all the right > shifts were by constants, so I could write something like > > ((t >> 18) & 0x3fff) > > to trim off the sign bits. Yeah, but... >>> x=0xffffffff >>> x -1 >>> hex((x>>18)&0x3fffffff) '0x3fffffff' >>> hex((x>>2)&0x3fffffff) '0x3fffffff' >>> hex((x>>5)&0x3fffffff) '0x3fffffff' >>> You inspired me to write :) import sys, string, re class BitMath: def __init__(self, negOne=-1): self._maskCache={} self._negOne=negOne # Just in case word sizes want to change. self._wordSize=self.bitLen(negOne) self._signBitMask= 1 << (self._wordSize-1) self._signBitMaskRightOne= 1 << (self._wordSize-2) def test(self): pat=re.compile("test.") dic=self.__class__.__dict__ for n in dic.keys(): if pat.match(n): dic[n](self) def getMask(self, sz): """ Return a mask of binary ones of len sz """ if self._maskCache.has_key(sz): return self._maskCache[sz] rm = sz%4 dic={0:'', 1:'1', 2:'3', 3:'7'} res=['0x',dic[rm]] for x in range(sz/4): res.append('f') val=eval(string.join(res,'')) self._maskCache[sz]=val return val def testGetMask(self): for c in range(33): val=self.getMask(c) assert(val==self.shift(-1,-(32-c))) def bitLen(self, x, wordLen=32): """ From Guido's post. Fixed to handle unsigned numbers Doesn't work with negative longs >>> hex(0xfL ^ 0x80000000) '-0x7FFFFFF1L' >>> hex(0xf ^ 0x80000000) '0x8000000f' """ global signBitMask n = 0 if x > 0: while x: n = n+1 x = x>>1 elif x == -1: assert(type(x) != type(1L)) n= wordLen else: assert(type(x) != type(1L)) n= self.bitLen(x ^ self._signBitMask)+1 return n def testBitLen(self): assert(self.bitLen(-1)==32) assert(self.bitLen(0xf)==4) assert(self.bitLen(999999999999999L)==50) def shift(self, x, cnt): """ shift right if cnt > 0 shift left if cnt < 0 Right shift fills with zeros """ if cnt==0: return x y=x if x > 0 or cnt > 0: if cnt < 0: y = x >> -cnt elif cnt > 0: y = x << cnt else: x = x ^ self._signBitMask y = x >> 1 y = y | self._signBitMaskRightOne y = y >> (-cnt-1) return y def testShift(self): assert(self.shift(-1, -2) == 0x3fffffff) assert(self.shift(-1, -32) == 0) assert(self.shift(0xf, 4) == 0xf0) assert(self.shift(0xa5000000, -8) == 0xa50000) def showShift(self): """ Demo shift """ def show(start, func): for c in range(10): res=func(start, c) print "%-4d%08x%15d"%(c, res, res) print "*"*50 show(-1, self.shift) show(sys.maxint, self.shift) def rotate(self, x, cnt): """ rotate bits by cnt Bits are recirculated to the opposite end """ if cnt==0: return x bitLx = self.bitLen(x) cnt1= (cnt % self._wordSize) temp1= self.shift(x, -(self._wordSize - cnt1)) temp2= self.shift(x, cnt1) return temp2 | temp1 def testRotate(self): last=1 for c in range(10): if 0: print "%08x"%self.rotate(0xa5000000,-c*4) print "%08x"%self.rotate(0xa5000000,c*4) print '-----------' temp=self.rotate(1,c*4) if temp > last: assert(temp == last * 16) else: assert(temp==1) last=temp bitMath=BitMath() bitMath.test() bitMath.showShift() From slay3241 at bright.net Tue May 23 09:27:33 2000 From: slay3241 at bright.net (bill slaybaugh) Date: Tue, 23 May 2000 09:27:33 -0400 Subject: test post Message-ID: <392A8745.50559882@bright.net> I am a python user, lurking on this newsgroup. This is a test cause I don't think my service connection lets me post - - just look. If this gets through - SORRY. From jae at ilk.de Sun May 21 22:50:32 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Mon, 22 May 2000 04:50:32 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> <91egis4v9spsp8iteg0p4ok4bimlv4mr5t@4ax.com> Message-ID: <22052000.2@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Remco" == Remco Gerlich writes: [...] Remco> And there would be similar style guides for programming Remco> too. Still, words don't usually mean different things Remco> because of their capitalization. You Still Understand What Remco> This Means. Given that your dutch you might know enough German to know the difference between "Dort haben sie etwas hingelegt" and "Dort haben Sie etwas hingelegt" One is "There they've put something down" and the other is "There you've put something down." Okay, so it's the only word in German that I'm aware of that changes meaning with capitalization... but nontheless it proves there *are* words that mean different things because of their capitalization. Just wanted to mention this, Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard SPACE: Above And Beyond (http://www.planetx.com/space:aab) pros do it for money -- amateurs out of love. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjkooHYACgkQN0B+CS56qs01HwCghaE23+O+q9L7me1eRNn2/xz3 +/oAoJvwFWea+ddv9W4QdbjPChl+6L6e =4c6j -----END PGP SIGNATURE----- From darrell at dorb.com Mon May 22 00:46:18 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 21 May 2000 21:46:18 -0700 Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <0d37ff5e.3baea24d@usw-ex0101-008.remarq.com> <009101bfc154$02d4fe30$6401a8c0@home> <8g9lb5$qcn$1@nnrp1.deja.com> Message-ID: <03e401bfc3a8$ac43cdb0$6401a8c0@home> "Andrew Cooke" wrote: > This implies that you have a large project in Python? What is it? Rules based text processing. It can do things like fix a broken SGML document. The best part is it works and they still use it. > How big? >Do you have any metrics to compare the two cases (C++ and Python)? Only my impressions, here comes a testimonial. Don't know how many lines of code and don't work there anymore. Maybe some of the regular employees who read this list will chime in with some numbers. Besides as the code got better the number of lines went down. Refactoring at work. With a peak of about 4-6 developers, we delivered once cut down to three developers did a rewrite for a second release all in about 1.5 years. The second pass included a lot of refactoring, leaving the customer with what I hope is maintainable code. I'd guess that the same effort in C++ would require more developers, which would push out the schedule while they all talk to each other. The schedule would also be extended because it just takes at least 2-4 times as long to write C++ applications. Using C++ the project would have run out of money, and half the team would be ready to kill the other. I'm currently helping an embedded C++ project get a handle on testing. (This is fun because I get to write tools that I dream up) A clean build of the code for one processor takes 10-15 minutes. Maybe if someone had read "Large Scale C++ ..." by Lakos the build times and a few other things would be nicer. Along with "Effective C++", "More Effective C++", bla, bla. The story with C++ is " This is very hard, watch out! DANGER! " Most people won't devote the time required to be good at it, and certainly won't enjoy it as much as Python. Python lets you focus more so on the final product. The benefit of a very high level language. --Darrell Gallion From roman at speeder.org Mon May 15 03:47:06 2000 From: roman at speeder.org (Roman Milner) Date: 15 May 2000 02:47:06 -0500 Subject: Java vs Python References: Message-ID: <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F@lp.airnews.net> >>>>> "HD" == Huy Do writes: HD> Hi, I would just like to know how serious python is taken in HD> the IT industry and how it compares to something like Java. HD> 3 Which is faster eg. Java servlets or Python CGI with HD> mod_python ? Don't know about that - but there is some strong evidence that Zope (python based application server) is faster than servelets: http://www.zope.org/Members/BwanaZulia/zope_benchmarks/tomcat1.html HD> Please do not interpret this message as an excuse to discredit HD> java or python. I am about to start a major web project using HD> Java but have been referred to python as an alternative so I HD> am investigating this option. I think any major web project should consider Zope. It has transformaed the way I think of web development. FWIW, I work at a moderate sized telco and we do all of our web sites in Zope. More on Zope at: http://www.zope.org ^Roman From mwh21 at cam.ac.uk Tue May 30 11:04:54 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 May 2000 16:04:54 +0100 Subject: *blink* That's neat. References: <3fMY4.28915$WS3.322429@typhoon.we.rr.com> Message-ID: "John W. Baxter" writes: > In article <3fMY4.28915$WS3.322429 at typhoon.we.rr.com>, "Stephen Hansen" > wrote: > > > I'm tired. That's about the only thing I can say in response after > > actually READING what I posted and then shaking my head in shame :) What I > > actually wanted was: > > > > if (case != 0) and (case != 1): > > Hmmm...my years around these beasts (starting in the 1950s) suggest that > *any* time I use "not" with "and" or "or" (or other spellings of not, > and, or), I had better slow down and make very sure that I'm writing > what I mean. So much debug time is thus saved. The situation is much worse in C, especially when using the bitwise operators. Does "var & 1 == 0" do what *anyone* would expect on first reading? (Hint: no). time-wasting-ly y'rs M. -- (Of course SML does have its weaknesses, but by comparison, a discussion of C++'s strengths and flaws always sounds like an argument about whether one should face north or east when one is sacrificing one's goat to the rain god.) -- Thant Tessman From jkraska1 at san.rr.com Thu May 11 22:06:19 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 12 May 2000 02:06:19 GMT Subject: A REALLY COOL PYTHON FEATURE: References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <391B1414.875F0894@tismer.com> Message-ID: <391B67FF.9BB89B01@san.rr.com> > > It's actually pretty easy in Python, too. :) (you think all this > > reducing and lambda-ing is *easy*?) Well, yeah. Albeit, I already learned lambda from lisp, ya know. :) One of the reasons that I like Python is that it is lisp like in the capabilities it offers, but blissfully child like in its syntax. While map/reduce/lambda are obviously obscure forms, as long as we have relatively *few* of these, then I think everyone will be pretty happy. C/ From erik.wilsher at iname.com Wed May 24 07:12:47 2000 From: erik.wilsher at iname.com (Erik Wilsher) Date: Wed, 24 May 2000 11:12:47 -0000 Subject: Python / Visual Basic mathematical comparison In-Reply-To: <47smis4m1e93nlq5smoskg8h5l46par5r5@4ax.com> Message-ID: <8ggdff+s8d3@eGroups.com> > if anyone can offer up opinions based on experience. > > Specifically, I am interested in where either language is more > comprehensive in built-in elements used for prototyping or developing > financial or mathematical programs. I have been programming in both (although I stopped with VB after I discovered Python:-), so here is a short summary. If we look at the bare facts we have: Py VB Int*2 N Y Int*4 Y[1] Y Long[2] Y N Real*4 N Y Real*8 Y Y Currency N Y Array arith. Y[3] N[4] Callbacks Y[5] Y Modules Y Well, sort of Dynamic YES N Interactive Y Not very good 1: Can be Int*8 on 64 bit machines 2: Long is abitary precision integer values 3: Through NumPy 4: Not that I know of 5: From within python only Looking at the above, it can appear that the two languages are running head-to head. But you should also consider: 1) You probably don't need real*4, real*8 is just as fast 2) You don't need int*2 3) VB makes some things extremly tedious. Compare py>>> FiltConst = [1., 2., 1.5, 3.2, 6.2, 4.3] VB: Dim FiltConst(6) as Double FiltConst(1) = 1. FiltConst(2) = 2. etc.... 4) The prototyping offered through an interactive environment (=Python) speeds up developement quite a lot. The fact that you can include test code in your modules for easy testing lets you develop your application in a modular fashion and test each part before "assembly". 5) The speed issue is difficult: a) If you run lots of matrix math you can use NumPy, and it is *fast*. There is no alternative to NumPy in VB (to my knowledge) b) If you on the other hand run lots of "itty nitty" numeric calculations VB is approx 15x faster than Python (highly informal test). The question you need to ask yourselves on speed is "how fast is fast enough". At present Python is (unfortunatly) not fast enough for our line of work (real time calculation of large ODE's), but the speed is sufficent for most other tasks. If you find that Python is fast enough (execution speed), it offers great advantages in development speed!! From mwh21 at cam.ac.uk Mon May 1 09:35:43 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 May 2000 14:35:43 +0100 Subject: plain text python source -> HTML syntax highlighted source References: <390D86D8.C2B85A45@mindspring.com> Message-ID: Chuck Esterbrook writes: > I know there's a program out there that reads python source and > spits out an HTML version with syntax highlighting. However, I don't > remember where I saw it and my searching and skimming on Parnassus > missed it. > > Does anyone know where I can get this? Start here http://starship.python.net/crew/lemburg/ and look for py2html.py. The demo seems to be broken at the moment (probably due to the recent starship crash). HTH, Michael -- 81. In computing, turning the obvious into the useful is a living definition of the word "frustration". -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From effbot at telia.com Sun May 14 03:48:07 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 14 May 2000 07:48:07 GMT Subject: [Q] Cannot find _tkinter? References: <8flget$sqi$1@news2.isis.unc.edu> Message-ID: Daehyok Shin wrote: > I thought I installed python 1.6a2 in solaris 5 succefully, but cannot find > _tkinter. import Tkinter compliain it cannot find _tkinter. see the troubleshooting guide at: http://www.python.org/topics/tkinter (and if necessary, check the downloading/installing instructions again; you might have missed some important detail) From mmiller3 at iupui.edu Mon May 22 21:42:12 2000 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 22 May 2000 20:42:12 -0500 Subject: NumPy and FFT References: Message-ID: <87zopioxe3.fsf@lumen.med.iupui.edu> If your data is in an array y, a FFT can be calculated like this: import FFT fft = FFT.fft(y) A fast FT doesn't care at all what the sampling rate is, so you'll have to calculate your own frequencies. If your sample rate is f_sample, you could do something like this: import Numeric delta = 1 / f_sample f = Numeric.array(range(len(fft))) / delta / len(fft) N = len(f) for i in range(N/2): f[N/2+i] = - result[N/2-i] Mike P.S. More NumPy savvy folks can probably point out a much more efficient way of calculating the negative frequencies... From dworkin at ccs.neu.edu Tue May 9 12:47:39 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 09 May 2000 12:47:39 -0400 Subject: General question re: print statement In-Reply-To: chibaA@TinterlogD.Tcom's message of "Tue, 09 May 2000 16:34:00 GMT" References: <39183e03.333330824@news1.on.sympatico.ca> Message-ID: chibaA at TinterlogD.Tcom writes: > The basic point of this code above - is the print<<"(WHATEVER)"; part > of it --> whatever is between the (WHATEVER)s, can be free form text > which will just be outputted as is (with the spaces, new lines, etc). > And I don't have to use escape characters to output reserved > characters. > > Does anyone know if this is possible - or how to do this in Python? Use triple quotes. >>> print """spam ... eggs ... spam ... more spam ... """ spam eggs spam more spam >>> -Justin From aahz at netcom.com Mon May 1 16:03:00 2000 From: aahz at netcom.com (Aahz Maruch) Date: 1 May 2000 20:03:00 GMT Subject: python.announce: what the h*ck? References: <8ekmqg$cck$1@news1.xs4all.nl> Message-ID: <8ekntk$kk9$1@slb2.atl.mindspring.net> In article <8ekmqg$cck$1 at news1.xs4all.nl>, Irmen de Jong wrote: > >What's up with c.l.python.announce? >I haven't received any messages in that group for over two months now... >Is it dead? It is currently dead. I believe there are some behind-the-scenes efforts to resurrect it. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From nascheme at enme.ucalgary.ca Mon May 8 04:07:53 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 May 2000 08:07:53 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <391645E3.3B850279@san.rr.com> <39165663.666406EB@san.rr.com> <3916731B.D5BFFB4D@san.rr.com> Message-ID: Courageous wrote: >So, it would appear that the limit would be uneval'd >strings, potentially taken from the user or a file. Yes: >>> a = "a" >>> b = raw_input() a >>> a is b 0 >>> a == b 1 >>> b = intern(b) >>> a is b 1 Trying to figure out when Python shares immutable objects can be a lot of fun: >>> a = 1 >>> b = 1 >>> a is b 1 >>> a = 1000 >>> b = 1000 >>> a is b 0 >>> 1000 is 1000 1 >This isn't something c or c++ can do for you, either. No. I think the idea comes from Lisp. I don't think Guido is a big Lisp user so the idea may have come from somewhere else. Lisp has a function called intern though so the connection seems pretty strong. Neil -- The short in SHARE_SHORTS_STRINGS is pretty short otherwise things would be even more fun. From amitp at Xenon.Stanford.EDU Sun May 28 19:38:03 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 28 May 2000 23:38:03 GMT Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> <39311C09.75F70C54@tismer.com> Message-ID: <8gsakr$827$1@nntp.Stanford.EDU> Christian Tismer wrote: | | | > * Assignment to __parent__: | > | > So far I've been assuming that __parent__ is something set by Python | > for internal use. For objects, it's set when you call a class | > constructor. For classes, it's set when you declare the class using | > the "class" construct. For namespaces, it's set when you call a | > function. | > | > But really, the cool stuff is really when the user can assign to | > __parent__! | | Please drop that. The __parent__ should always be true. | A function instance's parent namespace is always its caller. | BTW, in Stackless, the caller can of course be assigned, but then | it is consistent that __parent__ always walks that way. Actually what I'm envisioning is that the __parent__ is not the caller, but the namespace of the function that defined the current function: def foo(): x = 5 def spam(): print "my __parent__ is foo's namespace, and x is", x return spam foo_spam = foo() def zap(): x = 9 foo_spam() Here, the caller of spam() is zap, which has set x=9. However, in lexical scope you'd print 5. So I was suggesting that __parent__ was set to foo, not zap. For namespaces, it's of dubious value to assign to the parent, but it'd be useful to assign to the __parent__ of objects that aren't representing the local namespace. For example, you could change your object's class, or you can insert new classes into an existin hierarchy. You can also reparent an object if you're using environmental acquisition, when the widget is moved. - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From moshez at math.huji.ac.il Sat May 20 11:55:19 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 20 May 2000 18:55:19 +0300 (IDT) Subject: Python3k extended grammar In-Reply-To: <8g6bae$977$16$1@news.t-online.com> Message-ID: On Sat, 20 May 2000, Thomas Malik wrote: > 1. case insensitivity sounds like complete nonsense to me. Who needs it, > actually ? The "E" in CP4E, according to quite a few usability studies. > 2. promoting integer divisions to float sounds quite stupid to me: > (x/y) * y + x % y == x should always hold true in any sane language Ummmm.... 1/2 == 0 Seems sane to you? Where were you when they taught about fractions in math class? The only thing which looks sane to me is 1/2 is 1/2. And 1/3. And 367/573. > about the optional(!) static typing, good idea. But no new interpunctuation > or keywords, please! Please join the type-sig, and make your voice heard over there, where the real work is done. (Well, the real debating about the design, anyway) -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From phd at phd.russ.ru Fri May 19 07:52:00 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 19 May 2000 11:52:00 +0000 (GMT) Subject: no tupelunpacking In-Reply-To: <392525A4.4E56FEAD@muc.das-werk.de> Message-ID: On Fri, 19 May 2000, Thomas Thiele wrote: > f1(f2(...)) apply(f1, f2(...)) apply(A.__init__, ...) Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From yawyi at gmx.de Mon May 29 17:41:16 2000 From: yawyi at gmx.de (Johannes Stezenbach) Date: Mon, 29 May 2000 23:41:16 +0200 Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> Message-ID: <3932e628$0$6681@personalnews.de.uu.net> Fredrik Lundh wrote: >now, would your modified version be a great improvement over the >current 1.6 release? that pretty much depends on your answers to >these two questions: > >-- does "join" really make sense on things that are not strings? > (hint: does "+" always mean concatenation? does "join" make > sense if it doesn't? should join([1, 2, 3], 10) really return 36?) The overloaded meaning of '+' makes non-sensical use of join() possible, but this is not the fault of the join() definition. It might be useful if join([[1], [2], [3]], [10]) returned [1, 10, 2, 10, 3]. User defined classes can define their own __add__ which could make sense with join() (e.g. join a list of HTML paragraph objects with a separator of type
, ,
  • etc.) You might argue that this is somewhat contrived, and in those rare cases where one needs to join non-strings an explicit loop would be easy to write. OTOH, the definition of join as "concatenating the elements of a sequence with an interspersed separator" is IMHO simple, elegant and useful, regardless of the type of the separator and sequence elements. >-- does it really matter if the implementation hook happens to be > called "join"? No. But wait: If what you mean by "implementation hook" is that Python programmers should keep using string.join() exclusively and never use "".join() directly, then please rename "".join to "".__join__ to make this clear. Otherwise keep on reading, please. >in the current release, the answers are "no" (hypergeneralization) >and "no" (no matter what it's called, people will find it and use it). > >if you have better answers, please motivate. Well, generalization of join() was not my goal, it was just the vehicle I used to try to convince you to make join() a method of sequences instead of strings. IIRC your point was: "There's more that one string type, each of which needs it't own join() -> it makes most sense to make join() a method of the string types." So why the hell do I want to convince you to change this? Because I think that this strategy is good for the implementor of stringmodule.c and unicodemodule.c only, but unconvenient for Python programmers. In my very humble opinion words = ["foo", "bar", "baz"] print words.join(" ") looks right and print " ".join(words) looks wrong. It will confuse people and provoke programming errors. It's not a nice thing to have in a CP4E language. (Not that it is that difficult to get used to -- humans can adapt to hostile environments like case-insensitive languages or even Perl . Mastering "".join() should be a piece of cake...) Since Python doesn't have a tangible Sequence base class and by its dynamically typed nature no list-of-strings (etc.) class, there is no natural place to stick the string-join implementation in. But as Eric Jacobs showed, it is easy to define a generalized sequence.join(), except that this would have bad performance for the common case of joining sequences of strings. So I say: Implement the easy generalized join() and fiddle the optimization for the string-join in. Python programmers won't mind some hidden ugliness in the C code if they are rewarded with better looking Python code. Two possible implementations for the join() with the "right" look-and-feel would be (of course in C, to be repeated for each sequence type): def join(self, separator): if type(separator) == type(""): # insert efficient implementation of " ".join elif type(separator) == type(u""): # insert efficient implementation of u" ".join else: result = self[:1] for x in self[1:]: result = result + separator + x return result or more general but a little less efficient: def join(self, separator): if hasattr(separator, "__join__"): # join() implementation stays in the string/unicode type return separator.__join__(self) else: result = self[:1] for x in self[1:]: result = result + separator + x return result Johannes From tismer at tismer.com Sat May 6 10:17:05 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 06 May 2000 16:17:05 +0200 Subject: Py_BuildValue - return large array References: <39133A5A.AD145915@sec.noaa.gov> <%IUQ4.20$w%.2158@news.shore.net> Message-ID: <39142961.806D4A10@tismer.com> Howdy, thanks for your good advice. But I suggest to never leave the error checking code, since that teaches sloppy style to newcomers. Added error checking: "Michael P. Reilly" wrote: > > j vickroy wrote: > : Hello all, > > : How should one return a (handle to?) "large" C-array to Python? > > : It seems that Py_BuildValue ("[...]", ..., ...) is only usable for > : "small" arrays where one can explicitly enumerate each element in the > : array. > > : Thanks for your time. > > You probably don't want to use Py_BuildValue(). For one, if you have a > large array, then you might have problems enumerating the values in the > function call (as seperate arguments). > > I would suggest creating a Python list object explicitly and populating > it that way. For example, > > PyObject *Convert_Big_Array(long array[], int length) > { PyObject *pylist, *item; > int i; > pylist = PyList_New(length); > for (i=0; i item = PyInt_FromLong(array[i]); > PyList_SetItem(pylist, i, item); > } > return pylist; > } Here the same routine, using an error check, plus the (somewhat faster) PyList_SET_ITEM macro. PyObject *Convert_Big_Array(long array[], int length) { PyObject *pylist, *item; int i; pylist = PyList_New(length); if (pylist != NULL) { for (i=0; i Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From ghf at mailandnews.com Thu May 25 23:21:51 2000 From: ghf at mailandnews.com (Glenn Farrow) Date: Fri, 26 May 2000 03:21:51 GMT Subject: Out parameters to COM objects Message-ID: <8F3FD1F1Bbillybobhotmailcom@166.93.207.145> No problem instantiating COM objects and calling their methods in Python, works great. But how do I call a function that requires a an OUT parameter as opposed to returning a value. (e.g.) >>> import win32com.client >>> ns = >>> win32com.client.Dispatch('Netscape.Network.1') >>> print ns >>> bVal = ns.Open('www.cnn.com', 0, '', <0, '') >>> print bVal 1 Now I want to call "ns.Read(BSTR* pBuffer, short iAmount)", where this method is expecting a BSTR pointing to a pre-allocated buffer of size 'iAmount'. How do I do this? >>> sBuf = '' >>> iRead = ns.Read(sBuf, 4096) Traceback (innermost last): File "", line 1, in ? File "", line 2, in Read com_error: (-2147352571, 'Type mismatch.', None, 1) From thiele at muc.das-werk.de Tue May 30 14:15:59 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 30 May 2000 20:15:59 +0200 Subject: installation (linux) Message-ID: <3934055F.3EBCDEBC@muc.das-werk.de> At the moment I'm trying to install python on linux(Suse). ./configure --prefix=/usr/local/python/ make make test make install All worked fine but I have no module thread so I tried it once again. typing: ./configure --prefix=/usr/local/python/ --with-threads printed lines with "thread": checking for thread.h... (cached) no checking for --with-dec-threads... no checking for --with-threads... yes checking for --with-thread... yes checking for mach/cthreads.h... (cached) no checking for pthread_detach... (cached) no checking for kernel/OS.h... (cached) no checking for pthread_create in -lpthreads... (cached) no checking for pthread_create in -lpthread... (cached) yes checking for usconfig in -lmpc... (cached) no checking for thr_create in -lthread... (cached) no make says at the end: gcc -Xlinker -export-dynamic python.o \ ../libpython1.5.a -lieee -ldl -lpthread -lm -o python ../libpython1.5.a(threadmodule.o): In function `t_bootstrap': /usr/local/python/Python-1.5.2/Modules/./threadmodule.c:223: undefined reference to `PyEval_AcquireThread' /usr/local/python/Python-1.5.2/Modules/./threadmodule.c:241: undefined reference to `PyEval_ReleaseThread' ../libpython1.5.a(threadmodule.o): In function `thread_PyThread_start_new_thread': /usr/local/python/Python-1.5.2/Modules/./threadmodule.c:281: undefined reference to `PyEval_InitThreads' collect2: ld returned 1 exit status make[1]: *** [link] Error 1 make[1]: Leaving directory `/usr/local/python/Python-1.5.2/Modules' make: *** [python] Error 2 threadmodule.o exists. What can be wrong? What have I to do? Thanks Thomas From mwh21 at cam.ac.uk Wed May 17 02:52:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 May 2000 07:52:25 +0100 Subject: Python to be Renamed! References: Message-ID: Gaetan Corneau writes: > Good one :) > > What about this one: > http://www.segfault.org/story.phtml?mode=3D2&id=3D3905b40e-05c0a760 > Warning: PostgresSQL query failed: ERROR: id_in: 3D3905b40e-05c0a760 not in id format in /home/segfault/htdocs/story.phtml on line 30 Story Error The selected story does not appear to exist. ? Cheers, M. -- Some people say that a monkey would bang out the complete works of Shakespeare on a typewriter give an unlimited amount of time. In the meantime, what they would probably produce is a valid sendmail configuration file. -- Nicholas Petreley From embed at geocities.com Wed May 17 15:57:30 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 17 May 2000 15:57:30 -0400 Subject: range(0.0,100.0,0.1) Message-ID: how do you do this: for i in range(0.0, 100.0, 0.1): print i range doesn't like a non-integer step and won't produce a list of floats instead of integers. Warren From sbender at harmony-ds.com Wed May 31 17:59:54 2000 From: sbender at harmony-ds.com (Scott Bender) Date: Wed, 31 May 2000 17:59:54 -0400 Subject: MacOS / MPW & Command line arguments? Message-ID: I need to be able to run the python interpreter from a script in MPW and the python program needs arguments. When I try to do this from MPW I get the following: PythonInterpreter some_argument ### MPW Shell - Unable to create the finder parameter list for this application. ### MPW Shell - Unable to get information on "". # File not found (OS error -43) Is there any way to make this work? thanks, - Scott From m.faassen at vet.uu.nl Tue May 30 17:09:30 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 21:09:30 GMT Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> Message-ID: <8h1ama$nd8$1@newshost.accu.uu.nl> Paul Magwene wrote: > < news of the impending move to PythonLabs snipped> > Oddly enough, I found the most exciting part of this announcement (other > than the news that Guido et al. will be devoting their full efforts to > Python) to be the fact that I can now put a face to the name "Tim > Peters" (see http://www.pythonlabs.com/team.html ). Me too. I wanted to post this! A face for Tim Peters! Yay! > That photo isn't a fake, is it? Of course it's a fake. You didn't see any mention of the PSU in that FAQ either, did you? This is all going exactly according to plan. We need to be prepared for the Whitespace Invasion in 2010. And-what-about-Gordon-McMillan-hm?-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Tue May 2 16:25:29 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 May 2000 20:25:29 GMT Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F31A5.6452D256@tismer.com> Message-ID: <8endjp$7fi$1@newshost.accu.uu.nl> Christian Tismer wrote: > Will Ware wrote: [snip] >> If a stackless version of Kaffe could be developed, it might be >> possible to convince Kaffe's maintainer (Tom Wilkinson, owner of >> the transvirtual.com site) to fold the changes into its official >> distribution. It would give him an advantage over Sun, so before >> too long, they might follow suit. > Hey, this is just an incredible idea. > Java with first class continuations, let that > drop through your brains. 90 percent of java threads > would be replaced by microthreads. > I will read the Kaffe source and think how this must be. > It can become quite a revolution for Java. > bye-bye-Python-I-have-no-time-for-your-for-quite-a-long-time-ly y'rs - chris Oh no! Please don't let that be true! Will, what have you done!? :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From garabik at center.fmph.uniba.sk.spam Sat May 13 03:51:54 2000 From: garabik at center.fmph.uniba.sk.spam (Radovan Garabik) Date: 13 May 2000 07:51:54 GMT Subject: really silly nit: why 3+5j instead of 3+5i? References: Message-ID: <8fj1iq$n84$1@sunnews.cern.ch> Jeff Petkau wrote: : Can anyone tell me why Python uses 'j' instead of 'i' for imaginary : numbers? I know this is really minor, but every bloody time I : use complex numbers I forget and type i's, and have to go back : and change them all to j's. My fingers just won't learn. you can always use something like this: i = 1j a = 2+3*i : [History of imaginary number notation, according to Google: Euler : invented the things, and he used 'i'. Gauss made 'em famous, and Wasn't Tatraglia(sp?) the first one to use square roots of negative numbers? (though he did not consider them numbers, just a clever trick of computing the roots of cubic equations) : he used 'i'. Everyone since then has used 'i' except for electrical : engineers, and they probably just changed it to cause trouble. So they changed it because i conflicted with the letter used for current, I. (oh.. wait a minute... it is uppercase)... ok, _alternate_ current is denoted with lowercase i, and unfortunately complex numbers in electrical engineering are almost exclusively used to describe _alternate_ currents.... : why does Python use 'j'?] G. knows :-) -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik | | __..--^^^--..__ garabik @ fmph . uniba . sk | ----------------------------------------------------------- From gmcm at hypernet.com Wed May 31 16:02:35 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 31 May 2000 20:02:35 GMT Subject: SQL: don't use bind variables (was Re: Using strings with ' in them in SQL-queries) References: <39342055.1301760@news.c2i.net> <393510AB.D62AE9A5@infercor.no> <8h38ak$s1f$1@slb6.atl.mindspring.net> Message-ID: <39356fdb$0$12276@wodc7nh6.news.uu.net> Aahz Maruch wrote: >Paul Boddie wrote: >> >>As the ideal solution, though, I would recommend using bind variables >>(placeholders) if your database module supports it: >I've been keeping silent for a while, but I'm now going to start >speaking forcefully against this style. It's a real PITA to maintain >when you have complex queries, because you can't use dicts and named >parameters. Many DB servers cache compiled queries with SQL text as key and parsed statement as value. If an SQL statement is *exactly* identical, it can skip the compile step. Some DB servers (Oracle, in particular) are very bad about managing their cache. Eventually it eats up all memory, and the server has to be brought down to clear it. So, at least in some circumstances, your advice is a recipe for disaster ;-). Personally, I go one step further and use prepared statements. All of them get compiled at the start of the app. Unfortunately, the Python DB API doesn't expose this capability. (Yes, it's a PITA, but so is the impedance mismatch between SQL and the host language). - Gordon From sifu at atnet.at Mon May 8 03:39:18 2000 From: sifu at atnet.at (Siegmund Fuhringer) Date: Mon, 8 May 2000 09:39:18 +0200 Subject: snmplib? Message-ID: <20000508093918.D15702@debian.atnet.at> hi! i was unable to find a snmplib! is there anywhere a snmplib available? bye... sifu From jones2lan at aol.com Sat May 20 00:31:57 2000 From: jones2lan at aol.com (Jones2lan) Date: 20 May 2000 04:31:57 GMT Subject: Problems with string.rjust() Message-ID: <20000520003157.15888.00000338@ng-fl1.aol.com> it gives me an error every time i try to use the function rjust. it is a typeerror but no by me it says. the interpreter says it is in the library? can this be right? From robin at jessikat.demon.co.uk Tue May 23 09:55:01 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 23 May 2000 14:55:01 +0100 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8g7t5c$1i7i$1@thoth.cts.com> Message-ID: In article , Blake Winton writes .... > >Well, there we go. Perhaps we can have something which is neither >case-sensitive, nor case-insensitive, based on the following principles. >1) Your variables can be named anything you want. >2) Any variable which differs from a preceeding one only by case > generates an error. ... I want to maintain full case sensitivity; algebra is taught that way, English is taught that way; why not Python? I explicitly want to code stuff like for s in S: .... foo = Foo() initial = INITIAL I never regarded case insensitivity or otherwise as being anything to do with the style or otherwise of how variables are named. It's a convenience that initialValue is slightly more readable than initialvalue. The whole argument that, for a short term gain in popularity amongst toddlers or whatever, you should dumb down a good programming language seems pretty flawed to me. Give them a dumbed down language and leave the standard language to be used by more advanced users. Others have already mentioned the studies on what the correct 'style' of programming language should be (oo or otherwise). I started writing with non joined up letters and progressed to cursive non capitals etc etc. If Python is the CP4E language, just what is the lower IQ level for inclusion in E? -- Robin Becker From breiter at usf.Uni-Osnabrueck.DE Fri May 12 08:47:57 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 12 May 2000 12:47:57 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> <8feepm$csg$3@newsserver.rrzn.uni-hannover.de> <6PNrfgBp7sG5EwLW@robinton.demon.co.uk> Message-ID: <8fguht$25n$3@newsserver.rrzn.uni-hannover.de> In article <6PNrfgBp7sG5EwLW at robinton.demon.co.uk>, Francis Glassborow writes: > In article <8feepm$csg$3 at newsserver.rrzn.uni-hannover.de>, Bernhard > Reiter writes >>I justed wanted to explain why the GPL is so popular. And what the >>differences to other licenses are. > > However, note that there is nothing that prevents the copyright holders > from negotiating a commercial licence as well (though that is more > complicated where the commercial organisation wants to use heavily > derived code with many contributors. > > Now perhaps we should be negotiating with industry to release all their > patents in exchange for a release to use GPL software ;-) This idea was seriously discussion on gnu.misc.discuss a while ago I think. :) -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From parker at gol.com Thu May 25 06:32:45 2000 From: parker at gol.com (Ian Parker) Date: Thu, 25 May 2000 10:32:45 GMT Subject: case sensitivity and XML References: <20000523113250.A2150232@vislab.epa.gov> <7LxW4.9151$Za1.142121@newsc.telia.net> <392B40F0.324E0189@cosc.canterbury.ac.nz> Message-ID: In article <392B40F0.324E0189 at cosc.canterbury.ac.nz>, Greg Ewing writes >Fredrik Lundh wrote: >> >> so why not enforce these rules, just like we're enforcing the >> indentation rules: >> >> >>> class foo: >> SyntaxError: Class name should be Foo > >There are some precedents for this. Smalltalk requires >global variable names to start with a capital. HUGS >distinguishes type names from other names by whether >they start with a capital. Some Eiffel compilers chide >you if you don't spell class names in ALLUPPERCASE and >other names in alllowercase. > I don't think I could return to programming in a language that _required_ capitalisation or uppercase to indicate the purpose or function of some name. I'm reminded of old Basic where a string was indicated with a $ or somesuch. Isn't that a little like Perl. Almost Hungarian. -- Ian Parker From robin at jessikat.demon.co.uk Sun May 21 05:46:44 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 21 May 2000 10:46:44 +0100 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: In article , Guido van Rossum writes .... > >Yet, here are some of the reasons why I am considering making Python >case-insensitive: > >(1) Randy Pausch, a professor at CMU, found, when teaching Python to >non-CS students in the context of Alice (www.alice.org), that the >number one problem his students were having was to remember that case >matters in Python. (The number two problem was 1/2 == 0; there was no >significalt number three problem.) > >(2) I've met many people who are experienced and accomplished Python >programmers but who still, when referring to Python modules or >functions in an informal context (e.g. email), make up their own case >conventions. E.g. people will write me about the String module or >about FTPLib. > This argument is like saying that we should bias the language(s) of mathematics so first steps in algebra can be more easily taught to non- mathematicians. I really want to be able to write stuff like for s in S: doSomething(s) it's often a direct translation of the underlying algorithm. Please don't take case-sensitivity away. In addition I would also like 1/2 to remain integer divide. If the students have problems with 1/2 = 0 aren't they likely to have as much trouble with the fact that 1/2. == 0.5 is valid float, but 1/3. isn't ie 3*(1/3.) isn't exactly representable even though in Python we get 1.0-3*(1/3.)-->0.0 ie allegedly better fp from python16 says that 3*0.33333333333333331 == 1.0 The fact is that a lot of simple things are difficult and I think it foolish to throw away the practice of years in a vain attempt to make them easy. -- Robin Becker From dalke at acm.org Thu May 25 11:21:25 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 25 May 2000 09:21:25 -0600 Subject: What's in a name? References: <392c17d3$0$17863@wodc7nh7.news.uu.net> <392C3738.58C41202@muc.das-werk.de> <392CB840.1E5E5B06@teleatlas.com> <392CBAB5.37BFCE21@san.rr.com> Message-ID: <8gji5u$2hl$1@slb1.atl.mindspring.net> Courageous wrote: >In plain English, case appears to be optional for the most part, >only assisting readers in reading, I think. Can you name some situations >in reading and writing english (heh) where case is essential to being >understood? Elsewhere in this forest of capitalization threads, I posted some examples. Here's they are again: Where is the polish container? Where is the Polish container? The first is where you might keep shoe shine, and the second is a container made in Poland. Unlike the rest of these examples, the two words are even pronounced differently! Here's another: Do you like china? -- asking about ceramic preferences Do you like China? -- asking about country preferences Stretching some, That is my french toast. -- bread dunked in a mixture of eggs and milk, then toasted on the stove top That is my French toast. -- toast from France, or a congratulatory remark to be made in French. Switching to names of people instead of countries: If it weren't for Faith ... -- person named Faith helped out If it weren't for faith ... -- belief helped out And corporate names: What was next? -- curious about ordering What was NeXT? -- curious about the company Jobs started after leaving Apple. Andrew dalke at acm.org From neelk at brick.cswv.com Wed May 31 20:31:44 2000 From: neelk at brick.cswv.com (It's neelk!) Date: 1 Jun 2000 00:31:44 GMT Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934A8F5.520B858C@prescod.net> Message-ID: Paul Prescod wrote: > Martijn Faassen wrote: >> But if certain HCI people produce research that shows 'and' and >> 'or' are about the worst names for these operators, then I'd indeed >> question that research and those particular HCI people. There isn't >> actually such research, is there, though, I assume? > > Well, speaking anecdotally, I remember years ago when I was learning > to program and I had trouble with those operators. I admit that I > can't remember exactly what the trouble was now, but for some reason > I often got them reversed. Obviously, the problem is that you must have been thinking of the isomorphism between the booleans and the Galois field of order 2, and thus using unfamiliar operators like "xor" and "and" in the place of "+" and "*" was what confused you. Fortunately, this is easily remedied. I also asked grabbed the handiest four-year old to find out if integer division was confusing to people unfamiliar with computers, and her response was "Siwwy Gwido! Integer if a ring, not a field!" She then demanded a plush Pikachu doll, and held her breath until I gave in. I didn't feel bad, though, because no price is too high for science. Neel From jajs at NOSPAMretemail.es Sat May 20 13:04:20 2000 From: jajs at NOSPAMretemail.es (Juanjo =?iso-8859-1?Q?=C1lvarez?=) Date: Sat, 20 May 2000 17:04:20 GMT Subject: OT: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> Message-ID: Grant Griffin dijo sobre OT: why tar is strange (was: The REALLY bad thing about Python lists ..), en fecha: Sat, 20 May 2000 08:40:54 +0100 |With all due respect to the Windows-bashers of the world, I personally |think that trading flexibility for convenience is a very good tradeoff: |it makes me productive. While you launch and use winzip I can type 5 times "tar zxvf" (or "unzip") on my xterm (with the command completion, of course). In fact, there are GUIs for gzip and tar on Unix, for example, KArchiver. But very few use them once they learn to do "tar zxvf". Its simply faster. Force a Unix lover to use Windows... the first thing he probably does is to install the GNUtils. Force a Windows lover to use a (even with the GUI tools) Unix... after a short time he probably will be using the magic "tar zxvf" anyway. And I see that constantly on my job, were we have Windows NT and Linux boxes (err... computers). don't-underrate-the-power-and-speed-of-a-good-CLI'ly y's Juanjo From sbrunning at trisystems.co.uk Fri May 19 09:43:05 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 19 May 2000 14:43:05 +0100 Subject: HTML search engine written in Python - is there one? References: <34575A892FF6D1118F5800600846864D2F0636@intrepid> <8g3c7m$nf4$1@supernews.com> Message-ID: <34575A892FF6D1118F5800600846864D2F24A0@intrepid> Dale Strickland-Clark wrote in message <8g3c7m$nf4$1 at supernews.com>... >If you're running it on NT, there's a free search engine you can tap into >that comes as part of the NT 4.0 option pack. No, I'm on Win9x. Besides, I'll want to tinker with it! Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From claird at starbase.neosoft.com Tue May 16 10:09:05 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 16 May 2000 09:09:05 -0500 Subject: Sharpening comparative concepts (was: Java vs Python) References: Message-ID: <18CD0C3E9F8D621D.066D4CC984A07877.88E0A688930DFD0D@lp.airnews.net> In article , Glyph Lefkowitz wrote: . . . >Not to mention the fact that everything is a first-class object in >python, so you don't end up worrying about how the heck you're going >to write your code to deal with int/long/double/float without >incurring extra overhead both in syntax and in memory: you can just >treat everything as a number in python. (As if it were object >oriented or something!) > >Compare the following to snippets: > >class Foo: > def __init__(self,x=15): > self.x=x > def bar(self, a, b): > return self.x+a+b > >... > >public class Foo { > int x; > public Foo(int x) { > this.x=x; > } > public int bar(a,b) { > return x+a+b; > } >} > >The java version looks slightly more complex, but they appear to be >approximately the same: until you realize that Java is operating on >integers, and Python is operating on *anything which can be added*! Python has genericity built-in--right? Is that exactly the point here, or is there some- thing more or less to it? . . . >your platform *probably already exist*. Java shoehorns you into ONE >API, ONE loosely-defined standard implemented shoddily by Sun, ONE way >to write GUI's, no ability to do multiplexing (all I/O is blocking and >in threads) ... all in all, the poor performance and poor scalability >of Java's standard library damn the language more thoroughly than any >other feature of it. After all, java "scales" because it has true I've been thinking about I/O. Is Java *wrong* (in the sense that, say, inter-module communi- cation through FORTRAN common blocks is an unacceptable hazard), or just different, in this regard? Myself, I much prefer event-ori- ented programming, and think that threads are generally dangerous in the hands of amateurs; on the other hand, I find Java's I/O just a *different* programming model, one not inher- ently inferior. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From wware at world.std.com Mon May 22 13:01:17 2000 From: wware at world.std.com (Will Ware) Date: Mon, 22 May 2000 17:01:17 GMT Subject: Programs run SLOW References: <39294515.824760893@news1.on.sympatico.ca> Message-ID: chibaA at TinterlogD.Tcom wrote: > I was just wondering if there would be any reason why a python script > would run REALLY slow (from the command prompt, and elsewhere). This might help: http://www.python.org/doc/current/lib/profile-instant.html -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From claird at starbase.neosoft.com Fri May 12 11:18:18 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 12 May 2000 10:18:18 -0500 Subject: correct round of reals? References: <391BE774.95B2C26D@stud.ntnu.no> <006701bfbc05$04bfcbc0$0500a8c0@secret.pythonware.com> <391C0EF9.6646EF7A@stud.ntnu.no> Message-ID: <61BBF44AF9A134E1.AF6E92C7121304C0.BBE2A0970733887B@lp.airnews.net> In article , Fredrik Lundh wrote: >Peter Schneider-Kamp wrote: >> Thanks. Do you know if e.g. VC++ uses IEEE doubles? > >most modern platforms use IEEE, but I'm sure there are >exceptions (OpenVMS?) . . . OpenVMS can do IEEE, but it's not the default. Most developers are aware of this as a compile- time switch. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From info at animationallsorts.com Fri May 26 11:15:47 2000 From: info at animationallsorts.com (info at animationallsorts.com) Date: Sat, 27 May 2000 01:15:47 +1000 Subject: Open Mind Message-ID: <200005261515.BAA14056@buffy.tpgi.com.au> I have discovered your webside on the Internet and find it really interesting.I do believe that you or your clients may benefit from the information we are offering. There are a lot of people trying to get rich quick, without any interest in another human being whatsoever. Well, I doubt that they will succeed. There is a law in success like there is a law in physics. You may not believe in gravity or not know about it, but it still works. The Law of Success says: If you help enough people to get what they want, You will get what You want. Therefore, if you think, that you may gain and discover a benefit for yourself, click on: http://www.animationallsorts.com/00-Main-Journey.htm or you can have a look at our Newsletter to find out if you can benefit from it: http://www.animationallsorts.com/NEWSLETER/April-00/NLetter-index.htm Don't hesitate to forward a copy of this newsletter to friends and associates, but please ask for permission before reproducing the content in any form -- we would like to know who you are. Pavel Kyral Director Animation Allsorts - Open Mind 105/3 Bruce Street, Crows Nest, NSW, 2065, Australia Phone: 612 9955 7990 | Fax: 612 9955 0076 Copyright ? 1990-2000 All Rights Reserved If you think, that you will not benefit from this corespondence, send an email to: remove at animationallsorts.com Subject:Remove gravity From moshez at math.huji.ac.il Thu May 4 00:38:43 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 4 May 2000 07:38:43 +0300 (IDT) Subject: houston python users In-Reply-To: <074C8D12C3163164.5E3EC1EAB58F6489.E8B525BEDFE31E20@lp.airnews.net> Message-ID: On Wed, 3 May 2000, technology wrote: > Are there any houston python programmers out there. I can just imagine it: "Houston, we have a metaclasses problem" python-3000-the-movie-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From pete at visionart.com Mon May 22 13:11:26 2000 From: pete at visionart.com (Pete Shinners) Date: Mon, 22 May 2000 10:11:26 -0700 Subject: PyOpengl... gone forever? References: <5hcW4.5291$wYl.211543552@newsb.telia.net> Message-ID: <39296A3E.B44D1578@visionart.com> Fredrik Lundh wrote: > > my top spies have informed me that pyopengl lives on > > the starship at http://starship.python.net:9673/crew/da > > > > this site has been inactive for too long now. > > fwiw, that URL works just fine from here... yes, it does work now! go starship From fiona at sitegnome.com Fri May 12 11:20:50 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sat, 13 May 2000 01:20:50 +1000 Subject: [FAQTS] Python Knowledge Base Update -- May 10th, 2000 References: Message-ID: <391C2152.F2CCAFFC@sitegnome.com> Mikael Olofsson wrote: > > On 12-May-00 LUK ShunTim wrote: > > I think what Fiona compile is very useful, especially to one like me who > > is quite new to python. > > and its nature IMO is for information more than for discussion, hence > > the idea of another list. > > I don't mean not to send it to the python list; it's certainly a good > > thing that people who post knows that their posting is being summarized, > > as Fiona pointed out. What I'd like to see is a _second_ option where > > people who may not want ~130 messages _more_ a day can get it without > > being on the python list. I may turn to the digest if I find the number > > of messages to much for me. > > I didn't think of that. It's a splendid idea. Since I've just begun doing the summaries I think it might be a little premature to set up an additional mailing list; currently it is only a partial daily summary. Give me a few weeks to get into the swing of things, if it's going well we can think again about setting up a new mailing list... Sound reasonable? Fiona Czuczman From ehagemann at home.com Sun May 14 10:36:54 2000 From: ehagemann at home.com (Eric Hagemann) Date: Sun, 14 May 2000 14:36:54 GMT Subject: help with COM and Excel References: <391EB172.10E13B22@tismer.com> Message-ID: Christian, Many Thanks ! It make a bit more sense now Cheers eric "Christian Tismer" wrote in message news:391EB172.10E13B22 at tismer.com... > > > Eric Hagemann wrote: > > > > Anybody done much with Excel and COM? > > > > I am trying to get some COM stuff working -- specifically to generate a > > chart > > > > I have been able to open excel, create a workbook and push data into it. > > Further I can create a charts but now I am stuck on how to add data to the > > chart. > > > > I know I need to add a 'SeriesCollection' Object but when I try > > > > .....chart.SeriesCollection.Add > > > > I get an 'attribute error'. In this context SeriesCollection referes to a > > function to select _which_ series collection you want (As far as I can tell) > > and not an object (which is what I need to attach data to). I can find the > > SeriesCollection Object initself and indeed it has an Add method. But I > > cannot seem to get to or add the object to the Chart Object. > > > > Anybody tried this already ? > > No, but I just tried it for you: > > PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) > >>> import win32com.client > >>> e=win32com.client.Dispatch("excel.application") > >>> e.Visible = 1 > >>> b=e.Workbooks.Add() > >>> c=e.Charts.Add() > >>> c > > >>> e.ActiveChart > > >>> e.ActiveSheet > > >>> e.Sheets(2) > > >>> e.Worksheets > > >>> e.Worksheets(1) > > >>> e.Worksheets(1).Range("a1","b3") > > >>> c.SeriesCollection().Add(Source=e.Worksheets(1).Range("a1","b3")) > > >>> > > The problem seems to be how you obtain your chart variable. > e.ActiveChart yields just a coclass, while via ActiveSheet > I get at the real _Chart thing. > > Well, and c.SeriesCollection is a method of a chart instance, > so it must be called, and then it has an Add method. > > hope this helps - ciao - chris > > -- > Christian Tismer :^) > Applied Biometrics GmbH : Have a break! Take a ride on Python's > Kaunstr. 26 : *Starship* http://starship.python.net > 14163 Berlin : PGP key -> http://wwwkeys.pgp.net > PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF > where do you want to jump today? http://www.stackless.com > From sabren at manifestation.com Mon May 29 08:04:53 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Mon, 29 May 2000 08:04:53 -0400 (EDT) Subject: python logical objects? Message-ID: Hey all, I've been thinking about how objects relate to one another, and it occurred to me that there's a use for "ad hoc" rules. SPAM AND EGGS ------------- For example, suppose you maintain an online grocery store, and the manager comes to you and says she wants to offer a sale: buy two eggs and get a free can of spam. How do you code it? Is it a method of a Product or Cart or Spam or Egg class? Does it go in a Specials class? Some kind of Coupon mechanism? What if its a temporary sale, and next week you get one free egg with every can of spam? Or do you just tell the client that the software isn't designed for that kind of thing, and they'll have to handle it manually, or not at all? This kind of ad-hoc rule seems to be the bread and butter of logical languages like Prolog. For example: price(spam, 0) :- bought(eggs,2), !. price(spam, 1). Which roughly means: "The price of spam is 0 if you bought 2 eggs. Otherwise, the price of spam is 1". (I'm only vaguely familiar with prolog, so this might not be the "best" way to do this, but it works.) In an object-oriented language, I'd usually want to have a .getPrice() method on a Product class... But this spam-and-eggs situation isn't so simple. If we leave getPrice attached to Product, we'll have to pass it some kind of context-representing object, perhaps a reference to a shopping cart. Not only that, Spam would have to be a subclass of Product, or contain some kind of PricingStrategy object. Neither option is really as elegant as the two line prolog script. It almost doesn't seem worth it to code a temporary rule like this. GAMES ----- I *wish* I could see the source for PySol while I'm writing this, but the actual home page seems to be down at the moment. From what I understand, PySol (see:http://www.vex.net/parnassus/apyllo.py?i=57203352) is a card game program that can play many different sets of games. I'm curious how the author represents rules for all those games. I would guess that he's created a Card class (or perhaps a Deck class) and then he somehow represents the rules of a game as an object, but I won't know until I track down the source. I wonder if it would be useful to have the rules stored in a prolog-style rule base. I suspect that it would be a little more concise than doing it with objects. I also suspect this kind of rules-on-top-of-objects thinking would simplify the task of writing "collect stuff and solve puzzle" adventure games. Game objects could have still have their own attributes and behaviors (descriptions, point values, etc) but the relationships between the objects could be summed up in a tidy rulebase. I haven't thought much further than this, so the idea may have no merit whatsoever in practice... But, I'd like to try it out. I've found PyLog (see: http://www.vex.net/parnassus/apyllo.py?i=78923594), which connects to a prolog interpreter over a socket. Has anyone else done anything prolog-ish with Python? Better yet: is anyone else interested in doing something prolog-ish with python? Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From g2 at seebelow.org Fri May 5 13:42:14 2000 From: g2 at seebelow.org (Grant Griffin) Date: 5 May 2000 10:42:14 -0700 Subject: HTMLParser tag contents References: Message-ID: <8ev15m$17sj@drn.newsguy.com> In article , Oleg says... > >On Sat, 6 May 2000, Grant Griffin wrote: >> I've been trying to figure out how to use HTMLParser. My immediate need >> is to extract the entire of a file. (I could do that with 're', >> but I'm trying to learn HTMLParser.) Sure, HTMLParser will returns a >> tag's _attributes_, but I can't figure out how to get to the tag's >> _contents_. Can it do that? > > Do not use HTMLParser - use SGMLParser. HTMLParser is for different >parsing - more for HTML-to-text conversions... Perhaps I misspoke. I agree that the solution would probably have to occur at the level of SGMLParser, but I guess my question remains: can it do that? if so, how? In looking at the SGMLParser source code, it doesn't appear to have any mechanism to capture the contents of a tag. I'm kindda new to Python, so am I missing something here? If not, it seems like the thing to do is to keep a little stack of tag begin/end indices into its "rawdata" array, then provide a routine to extract the data using the tag's begin/end indices. (even-though-i'm-new-i-already-figured-out-how-to-write-these -silly-salutations,-which-lately-i've-been-been-subjecting -the-poor-comp.dsp-newsgroup-to-)-ly =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From sanner at scripps.edu Fri May 19 14:38:49 2000 From: sanner at scripps.edu (Michel Sanner) Date: Fri, 19 May 2000 11:38:49 -0700 Subject: Wrapping C++ under windows Message-ID: <1000519113849.ZM178800@noah.scripps.edu> Hello, I have wrapped a C++ library that contains some static global objects with constructors and I am trying to build a .pyd file under Window98 using Visual Studio 6.0. The shared library I get dumps the core when it is used and I suspect that this happens because the constructor of these shared objects is not called when the shared object is loaded. In the unix world (IRIX and linux) it works fine. If I link The windows library against a C++ main under windows it works fine too. So my first question is: has the windows Python1.5.2 binary I got from Mark hammond's download site been compiled and linked using a C++ compiler ? I am also wondering what type of DLL project I should use in VS6.0 ? I usually use and "empty DLL" for Python extension. Might this be the problem ? Do I have to explicitly write a explicite DllMain ? Thanks for any help -Michel -- ----------------------------------------------------------------------- >>>>>>>>>> AREA CODE CHANGE <<<<<<<<< we are now 858 !!!!!!! Michel F. Sanner Ph.D. The Scripps Research Institute Assistant Professor Department of Molecular Biology 10550 North Torrey Pines Road Tel. (858) 784-2341 La Jolla, CA 92037 Fax. (858) 784-2860 sanner at scripps.edu http://www.scripps.edu/sanner ----------------------------------------------------------------------- From jkraska1 at san.rr.com Sat May 13 02:45:04 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 06:45:04 GMT Subject: python book recommendations? References: <8fgsqq$kuo@news.or.intel.com> <8fit16$dc3$0@216.39.141.21> Message-ID: <391CFA86.8BAC0014@san.rr.com> Dana Booth wrote: > > Firehawk343 wrote: > F: I'm new to Pyhton and would appreciate advice on what book(s) will help me > F: ramp up the fastest. > > If you already program, David Beasly's "Python Essential Reference" is very > good. Another plus is that the book is high quality. My O'Reilly books > always seem to fall apart quickly. I just got that book today, and have looked over most of it. Very good book. After Beazely's book, it will be web pages, grepping through html, and searching all the way (to wit: you will have outgrown normal learning channels). C/ From jerry_spicklemire at my-deja.com Thu May 11 10:49:37 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Thu, 11 May 2000 14:49:37 GMT Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: <8feh9q$3gn$1@nnrp1.deja.com> Hi Python Fans, This may be the last time that I know _the_answer_ to a question that shows up here, so I'd better make the most of it. Michael Hudson wrote: > Glyph Lefkowitz writes: > > > Vetle Roeim writes: > > Unfortunately, one of the best features of the python community is > > that it seems to have a sane group of people in it who know multiple > > languages and will choose appropriate ones for the appropriate task. > > We need more rabid, unabashed evangelists. :-) > > Why? Yeah, that's the one. The reason I can tell you why evangelists are needed, oh exalted gurus and wizards ("We're not worthy!"), is that I am most certainly not. You may all have binary chromosomes, but the grim truth is most bitheads are more like me. We are just lucky to be able to do anything that folks pay money for at the start of the twentyfirst century, however poorly. We are the subsistence farmers of the Web Wide World. That's why Python is even more important, and absolutely essential to me. I NEED Python very badly, and so does the seemingly endless throng of mediocre coders. Most of us will never transcend our own feeble limits, but Guido gave us a tool that let's us get stuff done anyhow. It's really just as simple as that. You guys are glad to have found another great language, one among many, and know exactly when and how to use it. The rest of us are struggling through CS101 with C++, Java, and the rest. That's right, Pascal is dead, Basic is an historical footnote. These days they start kids out with C++ and Java because students want to learn "job skills". It's no accident that Visual Basic is so popular, in the real world of workaday programming! The reason Python needs more rabid evangelists is because so many still don't know it exists. "Never heard of it", that's what thay say every time I mention Python to a newbie. They don't even know had much they need it, and that's a crying shame. Don't hold your breath for any mind blowing code to emerge from this corner, but you can bet your last billion that I'll keep touting Python to anyone who betrays the faintest glimmer of interest, and even some who don't! Say Hallelujah! Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From frankc at colconsulting.com Thu May 11 08:50:43 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Thu, 11 May 2000 08:50:43 -0400 Subject: Python style. References: <200005102207.IAA20656@envy.fulcrum.com.au> Message-ID: <391AACA3.EB4AE23F@colconsulting.com> Richard Jones wrote: > > [Johann Hibschman] > > What you really want is something like: > > > > for item1, item2 in transpose((list1, list2)): > > > > to go from a tuple of two lists to a list of many tuples. That's what > > that awful map None does. > > And, because I haven't had a chance to write any Python for far too long, > here's an implementation of transpose() :) > > Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 > (egcs-1.1.1 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> class transpose: > ... def __init__(self, l1, l2): > ... self.l1, self.l2 = l1, l2 > ... def __len__(self): > ... return min(len(self.l1), len(self.l2)) > ... def __getitem__(self, i): > ... return self.l1[i], self.l2[i] > ... > >>> list1 = [1,2,3] > >>> list2 = ['a','b','c'] > >>> for item1, item2 in transpose(list1, list2): > ... print item1, item2 > ... > 1 a > 2 b > 3 c > >>> > > Note the slightly different syntax in the call to transpose(). Extending the > transpose class to N lists and re-writing it in C is left as an exercise to the > reader. > > Richard > > ps. god-damn I have to get myself a job writing Python. Have to love a language > that allows me to - in one shot - interactively crank up the interpreter, write > a quick-n-dirty class I just thought up and test it out. Maybe you'll consider becoming a team member for open development a new project I started. As an seasoned OO and C++ monkey, I am quickly taking to jumping into the python pit, but alas lack the experience and "style" that time and understanding provides. I have posted a job opening (remember these are not paying jobs) for a team lead/guru/wizard (whatever the appropriate term to mean kick-ass Python pro) Have a look at http://PythPat.sourceforge.net -- Frank V. Castellucci http://PythPat.sourceforge.net Pythons Pattern Package From "dbroadwell" at spam.mindspring.com Tue May 30 05:40:08 2000 From: "dbroadwell" at spam.mindspring.com (David Broadwell (remove spam.)) Date: Tue, 30 May 2000 05:40:08 -0400 Subject: groking about dynamic type languages. Message-ID: <8h021f$c0t$2@slb6.atl.mindspring.net> am i correct tht only a dynamic langugage would be capable of the follwing assosiation without a TON of code to specifically define the behaviours? for example, i have a number of predefined classes that instanceinto 'tool' objects. (tool objects work on other ojects only). let us uas i also have another object, a light switch (wall mount), wrapped in a 'wall mount plate wrapper' that requires a screwdriver tool object to unwrap. (screw are of a unstated type) in a dynamic language i just pick up the screwdriver and let the 'dynmaic' type bindings choose whych screwdriver tip to use on the screws of the plate. (if we have the appropriate type) ~Right~? (this happens to me.. and i have to say this is a extention of my brocling that led to understanding OO proper.. much like what happened to understand electrons and electronics MANY years ago) From mhammond at skippinet.com.au Tue May 23 08:40:02 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 23 May 2000 12:40:02 GMT Subject: win32net.NetServerEnum resume handle References: Message-ID: This appears to be a bug. I just checked a fix into CVS. Mark. "Roger Upole" wrote in message news:PDlW4.72073$H8.5026150 at news.easynews.com... > I can't get this function to return anything other than 0 > as the resume handle, even when the buffer size is set > low enough that only 2 machines are returned. > The initial handle passed is 0. Is there some constant I > should be passing on the first call ? > Anybody else having the same problem? > Roger Upole > > From case at ironwater.com Tue May 9 01:10:34 2000 From: case at ironwater.com (Case Van Horsen) Date: Mon, 08 May 2000 22:10:34 -0700 Subject: snmplib? References: <20000508093918.D15702@debian.atnet.at> Message-ID: <39179DCA.2EE4E9C8@ironwater.com> There is a simple toolkit written entirely in Python at ftp://ftp.glas.net/users/ilya/tools/pysnmp/. cvh Siegmund Fuhringer wrote: > hi! > > i was unable to find a snmplib! is there anywhere a snmplib available? > > bye... sifu From mattes at rfhsm.ac.uk Tue May 23 08:03:50 2000 From: mattes at rfhsm.ac.uk (Frank Mattes) Date: Tue, 23 May 2000 12:03:50 GMT Subject: help with PYTHONHOME / unix Message-ID: <20000523.12035000@rfhsun1.rfhsm> Hi all, I'm new in this group and my question might be silly for most of us, however I could't find the answer on the net. I'm compiling a program "pybliographer-1.0.0" which needs python 1.5.2. I have installed python from the binaries on my hp-ux, which has a slightly different install tree. Python is installed in /opt/python with /opt/python/bin <------ the program /opt/python/lib/python1.5 <------ the lib files /opt/python/include/python1.5 <------ the include files the "configure" script gives the following error: checking for python... /opt/python/bin/python checking python version... Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 1.5 checking python devel... Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] found However I don't know how to set-up the variable. Can anybody help me. I appreciate any help Frank Department of Virology Royal Free Hospital, London From scarblac-spamtrap at pino.selwerd.nl Tue May 9 12:07:40 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 9 May 2000 16:07:40 GMT Subject: Load Arbitrary Script as Module? References: <8f9bs3$b9u$1@nnrp1.deja.com> Message-ID: rgb122 at my-deja.com wrote in comp.lang.python: > Is there a way to load a module given a full filepath? Something like: > > driver = LoadModule("C:\\Stuff\\sample.py") > driver.someFunction() driver = __import__("C:\\Stuff\\sample") -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "I sense... golden arches": In Original D&D, some swords had the ability to 'detect meal and what kind.' From neilh at scintilla.org Mon May 1 06:42:26 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 01 May 2000 10:42:26 GMT Subject: [Python-Dev] Re: Python 1.6a2 Unicode bug (was Re: comparing strings and ints) References: <39072F0C.5214E339@lemburg.com> <45919986@data.franken.de> <048501bfb0b4$c793d760$4add3fcb@neil> <45919991@data.franken.de> <390d3d72.74901005@news.nikoma.de> Message-ID: > > Well, depends on how far you stretch 'more or less'. UTF-16 has room to > >encode about 900,000 characters by using two 16 bit elements. > > Is this the "surrogate" thingies? Yes. The surrogates use a pair of 16 bit numbers to represent a character. The first number is in the range 0xD800 to 0xDBFF and the second in the range 0xDC00 to 0xDFFF so you get 0x400 * 0x400 = 0x100000 = 1048576 characters although some must not be allowed as one reference says only 917,504 are possible. http://www.unicode.org/unicode/standard/principles.html http://www.unicode.org/unicode/faq/ Neil From effbot at telia.com Wed May 31 15:13:01 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 31 May 2000 19:13:01 GMT Subject: Perl chop equivalent in Python? References: <8f7ih8$cj2$1@nntp6.u.washington.edu> <8g1b86$rpm$1@nntp6.u.washington.edu> <8h3l78$iv5$1@nnrp1.deja.com> Message-ID: <1vdZ4.6355$wYl.229560320@newsb.telia.net> pem at my-deja.com> wrote: > Is there an equivalent command to chop (the perl command) in Python? If > not, is there some easy way to use existing commands to do this simple > task? I need to do it frequently and would like to have a readily > available command that does not require much programming. Thanks in > advance. www.python.org => search => newsgroup search for "chop" => a whole bunch of hits, including this one by Fran?ois Pinard: http://www.deja.com/=dnc/getdoc.xp?AN=583863832 ... To chop (even if line is truly empty): line = line[:-1] To chomp: if line and line[-1] == '\n': line = line[:-1] ... From rwcitek at uci.edu Tue May 16 15:08:41 2000 From: rwcitek at uci.edu (Robert Citek) Date: Tue, 16 May 2000 14:08:41 -0500 Subject: A REALLY COOL PYTHON FEATURE: In-Reply-To: References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <3.0.5.32.20000516030210.007ad100@earthlink.net> Message-ID: <3.0.5.32.20000516140841.007d74c0@earthlink.net> At 12:13 PM 5/16/00 -0400, Fran?ois Pinard wrote: >Robert Citek writes: > >> The join method is fine for converting lists to strings, but doesn't work >> for converting lists to tuples. However, lambda works nicely here: > >> reduce(lambda x, y: x + (y,), somenames, ()) > >Why not just tuple(somenames) ? > >-- >Fran?ois Pinard http://www.iro.umontreal.ca/~pinard Because it was late and my brain works in weird ways sometimes. Or maybe I was just pleased with myself thinking that I could actually create something with reduce and lambda and that it worked. :-) Thanks for pointing out the obvious and helping me write better code. - Robert From mfletch at tpresence.com Tue May 23 20:47:19 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 23 May 2000 20:47:19 -0400 Subject: Micro-Threads: uthreadsleep.py -- scheduling of uthreads to conti nue processing after given seconds Message-ID: While playing with making a uthreads-based server, I have found the lack of a real-world-time sleeping function somewhat disconcerting (relying on number of time slices when the system could vary from a cycle per millisecond through a cycle every 10 seconds (on very heavily loaded simulations) isn't very useful). Accordingly, I created a module which provides for "sleeping" uthreads. Unfortunately, because you cannot properly "suspend" a uthread (i.e. declare that it is inactive until time x), there is no noticeable processor load reduction when you have only waiting threads :( . This is a demo, not a production piece of code. It is released into the public domain for whatever it's worth. To do processor load reduction, you would likely need to have a far more involved run mechanism. It should be possible to do something such as, on the first cycle where there is no non-waiting thread, use time.sleep() to wait until the first waiting thread should be restarted. This would seem to work with the current micro-threads philosophy (i.e. a single python thread running all the micro-threads), as you would be able to declare that there is no further work to do in the python thread until the timer wakes up. In a multi-threaded scenario, that could not be guaranteed (unless you force the issue by preventing threads from adding to other thread's micro-thread collection)? The ability to use almost no processing power when not active is somewhat of a requirement for many systems. Incidentally, continuations/uthreads is, without a doubt, one of the coolest things in Pythonica :) . One question, why does the micro-threads library use non-thread-safe mechanisms (global lists etc.)? It limits the use of the micro-threads to a single python thread. Enjoy yourselves, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch -------------- next part -------------- A non-text attachment was scrubbed... Name: uthreadsleep.py Type: application/octet-stream Size: 1801 bytes Desc: not available URL: From moshez at math.huji.ac.il Tue May 30 02:03:56 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 30 May 2000 09:03:56 +0300 (IDT) Subject: destructors -- when are they called? In-Reply-To: <393351D2.3533AEFF@san.rr.com> Message-ID: On Tue, 30 May 2000, Courageous wrote: > When writing a C language extension, is it guaranteed that the > moment your object's reference count is reduced to zero it's > destructor will be called? (I have a situation in which this > may matter). It is true in the current implementation. The *language* makes no gurrantees about when it calls destructors, if at all. If you need to release resources in a timely fashion, use try: .... finally: # release resources In your Python code. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From effbot at telia.com Mon May 1 19:46:29 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 01 May 2000 23:46:29 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> <20000430170952.A502@datapro.co.za> <8ehrb9$mm5$1@ites.inria.fr> <8el305$h77$1@ites.inria.fr> Message-ID: Cedric Adjih wrote: > > Hungarian notation as used by Microsoft is by far NOT the only way to use > > it. > > No but the very name "Hungarian notation" comes from its (incorrect) use > at Microsoft. really? I suggest reading the original paper: http://msdn.microsoft.com/library/techart/hunganotat.htm iirc, Charles Simonyi invented this notation in the early seventies. he has worked for Microsoft since 1981. From erno at iki.fi Tue May 16 17:47:35 2000 From: erno at iki.fi (Erno Kuusela) Date: 17 May 2000 00:47:35 +0300 Subject: Java vs Python References: <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F@lp.airnews.net> <8foh8i$31m$1@newshost.accu.uu.nl> <8fpnua$o8u$2@newshost.accu.uu.nl> Message-ID: >>>>> "Martijn" == Martijn Faassen writes: >> imprecise terms i guess - i meant cgi in the narrow sense of >> the word, as opposed to something like mod_python. Martijn> He did ask about mod_python. :) doh :) -- erno From akuchlin at mems-exchange.org Fri May 5 13:16:35 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 05 May 2000 13:16:35 -0400 Subject: ftp return format References: <3912E462.2E296390@cyberus.ca> Message-ID: <3dvh0szzm4.fsf@amarok.cnri.reston.va.us> blues-l at cyberus.ca writes: > Okay, probably a dumb question but could it be that the transfer should be set > to binary mode and is using the default ascii mode? Or vice versa, having done something similar in a past life. If the FTP server is an AS/400, I assume it uses EBCDIC. If the file transfer is done in ASCII mode, it's the FTP server's responsibility to translate to EBCDIC (the relevant RFC says transfers are in ASCII, with no provision for different character sets); if it's in binary mode, you'll get the original EBCDIC data which will be difficult to deal with on a PC/Unix system. So, maybe you're *not* in ASCII mode. -- A.M. Kuchling http://starship.python.net/crew/amk/ Destiny is the oldest of the Endless; in the beginning was the Word, and it was traced by hand on the first page of his book, before ever it was spoken aloud. -- From SANDMAN: "Season of Mists", episode 0 From buzzard at contactbox.co.uk Wed May 3 18:36:28 2000 From: buzzard at contactbox.co.uk (Duncan Smith) Date: Wed, 03 May 2000 22:36:28 GMT Subject: Installing numpy Message-ID: <3910b8e1.0@news2.cluster1.telinco.net> I'm trying to install Numerical-15.2 after successfully installing Distutils-0.1.3. But I get the following: >>> running install running build running build_py not copying Lib\ArrayPrinter.py (output up-to-date) not copying Lib\FFT.py (output up-to-date) not copying Lib\LinearAlgebra.py (output up-to-date) not copying Lib\MLab.py (output up-to-date) not copying Lib\Matrix.py (output up-to-date) not copying Lib\Numeric.py (output up-to-date) not copying Lib\Precision.py (output up-to-date) not copying Lib\RandomArray.py (output up-to-date) not copying Lib\UserArray.py (output up-to-date) running build_ext cl.exe /nologo /Ox /MD -IC:\PROGRAM FILES\PYTHON\include\python1.5 -IC:\PROGRAM FILES\PYTHON\include -IInclude /c /FoSrc/_numpymodule.obj /TcSrc/_numpymodule.c Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files\Python\Numerical-15.2\setup.py", line 58, in ? ext_modules = [('_numpy', File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 97, in setup dist.run_commands () File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 526, in run_commands self.run_command (cmd) File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 575, in run_command cmd_obj.run () File "C:\Program Files\Python\Numerical-15.2\setup.py", line 41, in run install.Install.run (self) File "C:\PROGRAM FILES\PYTHON\distutils\command\install.py", line 282, in run self.run_peer ('build') File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 886, in run_peer self.distribution.run_command (command) File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 575, in run_command cmd_obj.run () File "C:\PROGRAM FILES\PYTHON\distutils\command\build.py", line 54, in run self.run_peer ('build_ext') File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 886, in run_peer self.distribution.run_command (command) File "C:\PROGRAM FILES\PYTHON\distutils\core.py", line 575, in run_command cmd_obj.run () File "C:\PROGRAM FILES\PYTHON\distutils\command\build_ext.py", line 150, in run self.build_extensions (self.extensions) File "C:\PROGRAM FILES\PYTHON\distutils\command\build_ext.py", line 213, in build_extensions include_dirs=include_dirs) File "C:\PROGRAM FILES\PYTHON\distutils\msvccompiler.py", line 103, in compile self.spawn ([self.cc] + cc_args) File "C:\PROGRAM FILES\PYTHON\distutils\ccompiler.py", line 431, in spawn spawn (cmd, verbose=self.verbose, dry_run=self.dry_run) File "C:\PROGRAM FILES\PYTHON\distutils\spawn.py", line 37, in spawn _spawn_nt (cmd, search_path, verbose, dry_run) File "C:\PROGRAM FILES\PYTHON\distutils\spawn.py", line 70, in _spawn_nt raise DistutilsExecError, \ DistutilsExecError: command 'cl.exe' failed: No such file or directory Anyone know where I'm going wrong? Cheers. From itdcgb at its.hants.gov.uk Wed May 17 09:25:02 2000 From: itdcgb at its.hants.gov.uk (Graham Bleach) Date: Wed, 17 May 2000 14:25:02 +0100 Subject: DCOracle and handling of package OUT parameters broken ?! References: <20000517135941.A23544@sz-sb.de> Message-ID: <8fu6b3$qj3$1@news.hants.gov.uk> > oci.error: (6502, 'ORA-06502: PL/SQL: numeric or value error: character string buffer too small\012ORA-06512: at "AJUNG.SELECT_LOB", line 22\012ORA-06512: at line 2\012') Hmm, this looks like the buffer mentioned above is the OCI buffer used/created by DCOracle. I'm not familiar with DCOracle (not enough time). Is there anything that's specifically designed to handle CLOBs being returned from Oracle? > When I reduce the size of the output string (substr()) to less than about 2000 I receive > the data correctly. > Is this DCOracle related or a problem of Oracle ?! > Our environment: Oracle 8.16 EE, Solaris 2.7, Python 1.5.2, DCOracle 1.3 As a workaround could you use UTL_FILE in PL/SQL to write the CLOB to a file and then read the file in python to do whatever you wanted to do? G From g2 at seebelow.org Fri May 12 03:20:36 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 08:20:36 +0100 Subject: python idioms: (was: a really cool python feature) References: <391A3FD4.25C87CB4@san.rr.com> <8fdfp8$ho0$1@slb0.atl.mindspring.net> Message-ID: <391BB0C4.398E@seebelow.org> Andrew Dalke wrote: > > Courageous wrote: > >>>> somenames = ["fred", "barney", "wilma", "betty"] > >>>> reallycool = reduce ( lambda x, y: x+", "+y, somenames ) > >>>> reallycool > >'fred, barney, wilma, betty' > >>>> > > > >Check that out. Do you know what a royal pain in the ass > >it is in most languages to do this? > > BTW, the usual way to do that is > > string.join(somenames, ", ") > Forgive a possible newbie FAQ, but is there a page of Python idoms like this? sorry-for-not-searching-in-advance-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From mlauer at trollinger-fe.rz.uni-frankfurt.de Mon May 29 09:27:57 2000 From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de) Date: 29 May 2000 15:27:57 +0200 Subject: bz2 support in Python? References: <3929327D.1F09D8BB@anfdata.cz> <20000522081621.A69716@dsl-only.net> Message-ID: <3932705d@nntp.server.uni-frankfurt.de> eito (eito at cs.pdx.edu) wrote: > On Mon, May 22, 2000 at 03:13:33PM +0200, Xavier Outhier wrote: > > Is there in Python any bz2 tool? bz2 is the 2nd version > > of bzip. A compression algo. > I wrote a module based on version 0.9.5. The module has only two > functions, compress and decompress. I am planning to add object > support like zlib module. I can send the code if you would like. Sounds good. can you put it on a website for download ? Greetings, M: -- -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From glyph at twistedmatrix.com Mon May 8 14:38:45 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 08 May 2000 13:38:45 -0500 Subject: Future of the Python Linux Distribution In-Reply-To: akuchlin@mems-exchange.org's message of "08 May 2000 11:05:20 -0400" References: <20000507193526.B6654@owl.rhein-zeitung.de> <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> <3dr9bdhykv.fsf@amarok.cnri.reston.va.us> Message-ID: akuchlin at mems-exchange.org (Andrew M. Kuchling) writes: > (Or Skaller's accomplishment of a from-scratch reimplementation in > OCaML, for that matter.) 1) is there a free OCaML? 2) is OCaML-Python free? 3) Where can I get a copy of it? 4) Why don't we hear more about this? What is all this jpython hype about? ;-) -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From mwh21 at cam.ac.uk Tue May 23 05:03:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 May 2000 10:03:25 +0100 Subject: Is it just Syntactic Sugar ? References: <3929E47E.993727CF@roguewave.com> Message-ID: Bjorn Pettersen writes: > ps: yes, Python will recompute the indices since the [] operator is only > a call to __getitem__ which is free to do anything, including changing > the array. My recently posted patch only computed indices and the target of the array ops once. My patch is insufficient because it is inefficient, and because it doesn't allow classes to override += and friends. I haven't redone it because (a) I'm not really sure which way one should proceed and (b) my finals start two weeks yesterday. Cheers, M. -- 59. In English every word can be verbed. Would that it were so in our programming languages. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From fwang2 at yahoo.com Tue May 2 16:02:53 2000 From: fwang2 at yahoo.com (oliver) Date: Tue, 2 May 2000 16:02:53 -0400 Subject: ConfigParser question Message-ID: hi, here is a beginner question, I am testing out ConfigPaser module, and run into error when I create the object instance, can anyone kindly point out why? >>> import ConfigParser >>> x = ConfigParser() Traceback (innermost last): File "", line 1, in ? TypeError: call of non-function (type module) oliver From xkliang at cpsc.ucalgary.ca Fri May 5 17:05:20 2000 From: xkliang at cpsc.ucalgary.ca (Kevin X. Liang) Date: Fri, 05 May 2000 15:05:20 -0600 Subject: Help! Message-ID: <39133790.8D4D8275@cpsc.ucalgary.ca> I am a newbie with Python 1.5 on Linux (RH-6.1). I have a problem with importing modules. When I tried to import a module 'pyjbt', defined myself, I got the following error message: ImportError: /home/grads/xkliang/research/Linux/jsp/jpy/modules/pyjbtmodule.so: undefined symbol: PyType_Type It seems to me that the system could not find the external module defining PyType_Type used in Python include file object.h. I am wondering what is the proper setup for PYTHONPATH in order to load all the necessary modules and libraries and get rid of the above import probelm. My currect PYTHONPATH is ['', '/home/grads/xkliang/research/Linux/jsp/jpy/modules', '/home/grads/xkliang/lib/Linux', '/usr/lib/python1.5/config', '/usr/lib/python1.5/', '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload', '/usr/lib/python1.5/site-packages'] where '/home/grads/xkliang/research/Linux/jsp/jpy/modules' contains my own modules. I appreciate very much any help from the Python experts in this group. Kevin From jkraska1 at san.rr.com Tue May 30 00:46:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 30 May 2000 04:46:43 GMT Subject: deque vs list: performance notes Message-ID: <3933484B.B471017A@san.rr.com> A C-native bidirectionally linked list (deque) was tested versus the performance of native python lists as a LIFO. Items were appended to the end of each data structure, but always removed from the beginning. Sets of 10, 100, 1,000, 10,000, and 100,000 objects were tested and timed against each data structure. In both cases, each datastructure was iteratively appended until the test count was reached, and then iteratively popped from the head until empty. Each test run was performed within a function which was then invoked by the profile module; tottime for function invocation was recorded: Results: # deque(tottime) list(tottime) 10 .004 .004 100 .004 .004 1,000 .10 .24 10,000 .12 1.18 100,000 1.14 129.01 Conclusions: For FIFO datastructures involving smaller sets of objects (10-100), which are, in all likelihood typical container size for average programs, execution times were dominated by function call, loop control, and python interpreter overhead (inferred). Because pyton lists are implemented as dynamic resizeable arrays, python lists guarantee O(1)+k complexity for append and delete from the tail, but provide O(n)+k overhead for inserting/removing at the head. In contrast, the deque implementation guarantees O(1)+k complexity for add/delete operations at both head and tail. The cost, therefore of removing all n members from a deque is O(n), while the cost of removing all n members from a python list is O(n!). As a matter of practice, however, the theoretical mathematical limits of these algorithms are not the limiting factors for smaller/average-sized containers of these types. It should be noted that this author deliberately selected a practical problem in which he knew python lists would perform poorly, and yet for everyday programming problems, this turned out not to matter much. Joe Kraska San Diego Ca From mikael at isy.liu.se Tue May 23 06:33:18 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 23 May 2000 12:33:18 +0200 (MET DST) Subject: Case sensitivity (Was: Re: NumPy and FFT) In-Reply-To: <1gqW4.9107$Za1.141269@newsc.telia.net> Message-ID: On 23-May-00 Fredrik Lundh wrote: > oh, you mean scientists cannot use languages like Fortran and Lisp? ;-) No, not me anyway... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-May-00 Time: 12:32:57 This message was sent by XF-Mail. ----------------------------------------------------------------------- From tismer at tismer.com Tue May 9 13:39:45 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 09 May 2000 19:39:45 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> <39144E9E.4928C7E2@tismer.com> Message-ID: <39184D61.453BDD09@tismer.com> Glyph Lefkowitz wrote: ... > Also; the hype that's used here is all about the "enterprise" > (whatever that is) and how Java is basically the new COBOL. > Continuations are a LISPish feature, and won't be appreciated, as far > as I can tell, by the ex-COBOL community now coming into Java. This argument has hit me right between the eyes. I may be changing targets again, not so sure, but see Jeff Senn's post and my reply. Rebuilding Python as a very tiny, scalable engine for microcontrollers could be what we need, soon. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From slhath at flash.net Mon May 8 11:31:56 2000 From: slhath at flash.net (Scott Hathaway) Date: Mon, 08 May 2000 15:31:56 GMT Subject: control kids' game plays References: <8evnq6$5hp$1@nnrp1.deja.com> <391664E3.8662CC8B@kraken.itc.gu.edu.au> Message-ID: Yes, you could do it easily in Win95. Have a python script running in the background that monitors the names of various windows when then pop up. Have it close the window after a period of time or simply log the window. This is done is the Windows API. I am too new to Python to tell you how to do it with it, but I could write a simple VB program to accomplish what you want in about 2 hours. Scott "Joal Heagney" wrote in message news:391664E3.8662CC8B at kraken.itc.gu.edu.au... > benpark at my-deja.com wrote: > > > My kids play games on our home windows95 computer all the time. I would > > like to control the times and durations of their playing. Is there any > > way to do it with python? > > > > Ben > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > I don't think you could really stop them playing the games on win95. Any > type of program wrapper you could build out of python, they could still > execute the original game programs. Somebody may be able to create a > program logger, one that records in a log when a particular program is > running, and how long it runs for, but there's nothing in the win95 os > that stops the kids from opening up the log and editing it, or stopping > the program logger. (And believe me, if they're half-way intelligent, and > dedicated gamers, they're going to at least try how to overcome the > program. Outwitting Dad would be too much of an enjoyable challenge.) > > At the very best, to stop the kids from turning the logger on and off, you > could set up the program to write a special note in the log whenever the > program is started up, or a periodic write to log. (And check the log > yourself for any suspicious lengths of program down time.) You'll probably > want to implement a daily log clean/mailing, or it'll swamp the disk after > a few days. > > To prevent them mucking around with the log file, you could implement the > following tamper testing every time the program writes to the log: > > Read the last access time of the file, BEFORE opening or editing the file. > > Open the file, read from the file the time of the last logging message. > If last access time and last logging message time don't match, see red > *smiles*. > If last access time and last logging message time do match, write next > logging message and logging time. You may have to release the log file > after each message so that the interpreter doesn't screw up the last > access time of the file. (Check with the more advanced users in the > group.) > > Despite all these measures, you're still going to have to read the log > (You may be able to get python to email the logs to you if your children > and you use a different machine.), and employ parental sanctions if they > go outside the agreed upon gaming times. > If they play around with the log files or the program logger, you're going > to have to employ stiffer sanctions. (Such as forcing them to wipe all > computer games off their machine for one week. That should hurt. *grins*) > Mind you, if they get really inventive and actually rewrite the logger, > I'd be tempted to let them think they've gotten away with it for a week. > At least their gaming addiction has forced them to learn some valuble > python programming, but at the end of the week, I'd sit them down, tell > them very sternly that they HAVEN'T gotten away with it, that you knew > about it (Giving specific dates from when you did know always shakes them > up.) and that you hope they realise in the real world, doing similar > things would get them arrested. > > Anycase, I hope I've been of some help. I'm afraid I don't know enough > about python to be able to help you write the logger though. I'm still > trying to learn enough wxPython to write a chemical structure editor. I > may give up and just use the TK toolkit. > > Joal Heagney/AncientHart > From ben at co.and.co Fri May 19 12:40:49 2000 From: ben at co.and.co (ben at co.and.co) Date: Fri, 19 May 2000 16:40:49 GMT Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <8g1as4$p9q$2@newshost.accu.uu.nl> <39245386.B350E309@sage.att.com> <3926363A.B1F@seebelow.org> <3925640f$0$28525@wodc7nh1.news.uu.net> Message-ID: Gordon McMillan wrote: > You might as well ask why the Windows way does it backwards: > zipping a tar will almost always yield better compression than > tarring a bunch of zips (more redundancy to work with). (Yes, it's > easier to extract one file from the latter, but that's not the common > usage.) Indeed: $ ls -lh tartest/ total 40k -rw-rw-r-- 1 ben ben 1.0k May 19 18:35 test.1 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.10 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.2 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.3 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.4 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.5 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.6 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.7 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.8 -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.9 $ tar zcf tar.gz tartest/ $ zip -r tar tartest/ $ ls -lh tar.* -rw-rw-r-- 1 ben ben 272 May 19 18:36 tar.gz -rw-rw-r-- 1 ben ben 1.6k May 19 18:42 tar.zip Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From pshinners at mediaone.net Sun May 14 19:36:28 2000 From: pshinners at mediaone.net (Pete Shinners) Date: Sun, 14 May 2000 23:36:28 GMT Subject: Can't Extend Message-ID: <0MGT4.7890$WS3.61292@typhoon.we.rr.com> i'm finding i cannot create my own C extensions for python. (this time checking with the FAQ) i'm stuck. using Visual C 6 i am consistently getting this error. ImportError: dynamic module does not define init function (initincr) as far as i can see, this is incorrect. there is a simple initincr function. i'm assuming there is some sort of name mangling going on during the compile/link anyone have a secret set of visual c flags that gets me a good clean extension PYD file? here is my sample code (if that helps) solutions welcome! ----------------------------------------- #include static PyObject* incr_func(PyObject* self, PyObject* args); static PyObject* decr_func(PyObject* self, PyObject* args); static PyMethodDef IncrMethods[] = { {"incr", incr_func, METH_VARARGS}, {"decr", decr_func, METH_VARARGS}, {NULL, NULL} }; void initincr() { Py_InitModule("incr", IncrMethods); } static PyObject* incr_func(PyObject* self, PyObject* args) { int val; if (!PyArg_ParseTuple(args, "i", &val)) return NULL; ++val; return Py_BuildValue("i", val); } static PyObject* decr_func(PyObject* self, PyObject* args) { int val; if (!PyArg_ParseTuple(args, "i", &val)) return NULL; --val; return Py_BuildValue("i", val); } From fdrake at acm.org Wed May 31 10:47:47 2000 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 31 May 2000 10:47:47 -0400 (EDT) Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com In-Reply-To: <20000531094101.A18889@corrada.com> References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <8h1ama$nd8$1@newshost.accu.uu.nl> <20000531094101.A18889@corrada.com> Message-ID: <14645.9747.688320.660801@cj42289-a.reston1.va.home.com> andres at corrada.com writes: > How does this announcement relate to the news that the Python CVS tree moved > to sourceforge.net? That is, will pythonlabs host the CVS tree eventually? We moved the CVS repository to SourceForge as a part of the move to BeOpen. It is possible that the repository may move to PythonLabs or BeOpen in the future, but we're pretty happy with SourceForge. -Fred -- Fred L. Drake, Jr. PythonLabs at BeOpen.com From aahz at netcom.com Tue May 2 16:24:03 2000 From: aahz at netcom.com (Aahz Maruch) Date: 2 May 2000 20:24:03 GMT Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390F674F.9C5C9F1E@exceptionalminds.com> <390F2FBE.B01C882F@asme.org> Message-ID: <8endh3$q7i$1@slb1.atl.mindspring.net> In article <390F2FBE.B01C882F at asme.org>, Jeffrey P. Sandys wrote: > >From my experience I would not teach Python (or Logo) to first and >second graders, they will become frustrated from the syntax rules and >spelling problems. Fourth graders are ready for programming in Logo. > [...] >I thought of teaching python to a group of 6-7th graders this year. I >decided to stick with Logo (LISP without parenthesis). I think the >python syntax and concepts might be more difficult for this age group >to grasp. I learned BASIC in summer school after third grade. I see no reason why Python couldn't be used in grade four and higher. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From mhammond at skippinet.com.au Wed May 24 20:37:21 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 May 2000 00:37:21 GMT Subject: flock on windowsnt References: <392B9607.7250A905@yahoo.co.jp> <392BE285.BF287B56@cfdrc.com> Message-ID: <5B_W4.2863$bZ3.18971@news-server.bigpond.net.au> "Lyle Johnson" wrote in message news:392BE285.BF287B56 at cfdrc.com... > There is a function _locking() which I haven't used, but which sounds > like it does the same thing as flock() under Unix. The prototype is: > > _locking(int handle, int mode, long nbytes) > > Look it up in the MSDN documentation for more details. It does not > appear to have been wrapped into any of the standard Python modules (at > least not for Python 1.5.2). Actually, you will find it in the builtin msvcrt module... Mark. From bwarsaw at python.org Mon May 22 16:45:44 2000 From: bwarsaw at python.org (Barry A. Warsaw) Date: Mon, 22 May 2000 13:45:44 -0700 (PDT) Subject: ANNOUNCE: Python CVS tree moved to SourceForge References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> Message-ID: <14633.40056.874353.41941@localhost.localdomain> >>>>> "BR" == Bernhard Reiter writes: BR> Hmm I am not really happy about it. The concentration of Free BR> Software Projects on SourceForge is a little bit dangerous. BR> See http://lwn.net/2000/0210/devel.phtml for some BR> considerations. They raise some good points, and we'll be working on ways to mitigate these in the future. For now, SF provides a robust way to jump start a more open development process. For example, it was just impossible to allow non-CNRI employees write access to the CVS tree. Now we can manage that much more easily through SF. And I hope to soon put in place some nightly cron jobs to suck down the cvsroot for Python for archival purposes. -Barry From tseaver at starbase.neosoft.com Tue May 9 22:54:25 2000 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 9 May 2000 21:54:25 -0500 Subject: Python/Zope References: Message-ID: <3DDBDA594E55C9EC.E425C32F683DAB41.92F6E57858733657@lp.airnews.net> In article , Charlie Derr wrote: >|Does anybody know a newsgroup about Zope? >|I have searched on comp. and didn't find anything. :o/ > >Are you aware of the e-list? The address is zope at zope.org (more info at >www.zope.org). It's a pretty active list. See http://www.zope.org/Resources for links to the signup and archives pages for the Zope mailing lists. Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at digicool.com http://www.zope.org Digital Creations From thiele at muc.das-werk.de Fri May 19 04:52:03 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Fri, 19 May 2000 10:52:03 +0200 Subject: GUI (Tkinter) and "cancel" Message-ID: <392500B2.D467C8EB@muc.das-werk.de> Hallo! I have a simple graphical user interface written with Tkinter. This allows a user to call a function by pressing on a button (or something like this). The function works for some minutes, somtimes up to an hour. How can I implement a "cancel"-button that allows the user to cancel the time-intensive function. At first I thought on creating another thread, but it must be simpler. How? Thanks Thomas From borlak at home.com Wed May 31 23:49:31 2000 From: borlak at home.com (Michael Morrison) Date: Thu, 01 Jun 2000 03:49:31 GMT Subject: Dictionary size/speed limit? Message-ID: I'm comtemplating a new program I'll be creating, and I plan on having a dictionary with around 20000-50000 entries. This dictionary will be searched many thousands of times itself, all at once. ie. read a file with 20000 keys, find value in dictionary for each key. (The dictionary size and file size have no relationship, and actually, the file size will probably be larger than the dictionary in some cases) So, is using the regular Python dictionary just an insane idea? :) Should I create something in C to do this for me, or are there modules to do this sort of thing? Thanks, borlak From grisha at ispol.com Sat May 13 12:18:59 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Sat, 13 May 2000 12:18:59 -0400 (EDT) Subject: mod_python - testers needed! In-Reply-To: Message-ID: On Sat, 13 May 2000, Oleg Broytmann wrote: > Hi! > > On Sat, 13 May 2000, Gregory Trubetskoy wrote: > > The very first version of mod_python is available at > > http://www.modpython.org/ > > > > Gregory (Grisha) Trubetskoy > > grisha at ispol.com > > Your name suggested the module is formerly httpdapy? Great Renaming? :) Yes - it's mentioned in the documentation. This is a complete rewrite and there is next to nothing left of httpdapy in the code (although there is an httpdapi module that allows migration from httpdapy). Grisha From scarblac-spamtrap at pino.selwerd.nl Tue May 16 19:23:09 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 16 May 2000 23:23:09 GMT Subject: Decimals -> Fraction strings, my solution References: Message-ID: Scott wrote in comp.lang.python: > Hi all, > > I've come up with one solution to my problem. Its probably quite > inefficient, but it does what I need for now. Feel free to > tear it apart and/or give any advice on how to better implement it. > This code will take either a number or a string (ie '0.5') and return > a string of the fraction (ie '1/2'). Here it is: I had been playing with it too. Your method for finding the gcd is very slow. To find the gcd of two numbers a and b, you substract the lower from the higher one, until they are equal. My solution is this, but it only works for 0 < x < 1. For negative numbers, integers, and bigger numbers you have some more string formatting to do. def makefract(x): assert type(x) == type(1.0) and 0.0 < x < 1 # These lines may count as a hack, but it works sx = str(x) digits = len(sx)-2 value = long(sx[2:]) # The fractional representation is "value/(10**digits)". # A better representation divides both by the gcd. a, b = value, 10L**digits GCD = gcd(a,b) return "%s/%s" % (a/GCD, b/GCD) def gcd(a,b): while a != b: if a < b: b = b - a else: a = a - b return a -- Remco Gerlich, scarblac at pino.selwerd.nl 1:22am up 71 days, 13:36, 7 users, load average: 0.04, 0.11, 0.06 From cut_me_out at hotmail.com Wed May 10 15:19:36 2000 From: cut_me_out at hotmail.com (Alex) Date: 10 May 2000 15:19:36 -0400 Subject: No not a one time job. References: <8f9jr7$kk1$1@nnrp1.deja.com> <8fa1be$4k6$1@nnrp1.deja.com> <8fak9e$plg$1@nnrp1.deja.com> <8fc97c$jvg$1@nnrp1.deja.com> Message-ID: > No not a one time job. I'd strongly recommend Zope, then. Alex. From eye at niksula.hut.fi Tue May 9 12:09:15 2000 From: eye at niksula.hut.fi (Petri Mikael Kuittinen) Date: 09 May 2000 19:09:15 +0300 Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: tsummerfelt1 at myspleenhome.com (tony summerfelt) writes: > and i think the following is hard to beat in tcl/tk: > #!/usr/bin/wish > button .b -text "Exit" -command {exit} > pack .b > > to fire up a window with a button on it. > > how does python compare for those two programs? The following is bad Python code, but should do the same as above: #!/usr/bin/python from Tkinter import * root=Tk() Button(root, text="Exit", command=root.quit).pack() root.mainloop() > think i'll actually pick up the `24 hour python book'...i'm pretty sure i'll > grok it in less though... I recommend that you first get "Learning Python" or "Quick Python" and if you already know TCL/TK and want to learn the Python way to do it get "Python and Tkinter Programming". They are all excellent books. /eye -- <(O)> Petri Kuittinen, also known as Eye, Dj Eye or Peku <(O)> <(O)> ADDRESS: Timpurinkuja 1 C 39, FIN-02600 Espoo, Finland <(O)> <(O)> EMAIL: eye at iki.fi WWW: http://www.iki.fi/~eye/ PHONE: 09-5472380 <(O)> ~You only live once but, if you live right, once is enough. From dgoodger at bigfoot.com Sat May 27 23:02:33 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 27 May 2000 23:02:33 -0400 Subject: global name space and importing In-Reply-To: <39306CB7.B5419219@bioeng.ucsd.edu> References: <39306CB7.B5419219@bioeng.ucsd.edu> Message-ID: on 2000-05-27 20:47, Curtis Jensen (cjensen at bioeng.ucsd.edu) wrote: > How come the global declaration works when I define it from withing the > interpreter, but not from within a file that I import? Because global means "global at the module level". There is no sharing of globals between modules (if there were, what chaos that would create!). When you're working in the interactive interpreter, you are actually in the "__main__" module's namespace. When you import a module (regardless of whether you use "import x" or "from x import *"; the latter just copies all of x's names into the current namespace), you create a new namespace for that module. Any global variables created by that module are global within that module's namespace. For example, assume file mytest.py contains: def spam(i): global x x = i So "x" will be global in mytest's namespace, rather than just local to the spam() function. Now let's test it: >>> from mytest import * >>> spam(5) >>> x Traceback (innermost last): File "", line 1, in ? NameError: x This is as you saw. Now, let's "import sys". "sys.modules" is a dictionary contining all imported modules, indexed by name: >>> import sys >>> sys.modules["mytest"] >>> sys.modules["mytest"].x 5 So x *was* changed, in mytest's global namespace, but not __main__'s. When you define a function in the interpreter: >>> def eggs(i): ... global z ... z = i >>> eggs(5) >>> z 5 The function "eggs()" is defined in the "__main__" module, in __main__'s namespace, therefore "global z" makes z a global variable in __main__'s namespace. Get it? :-) -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From jkraska1 at san.rr.com Sat May 6 17:15:05 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 06 May 2000 21:15:05 GMT Subject: My Server supports Python? References: <391305A4.98430BB0@swt.edu> <39145347.59330549@san.rr.com> Message-ID: <39148C19.59B715BD@san.rr.com> Will Ware wrote: > > Courageous (jkraska1 at san.rr.com) wrote: > > % find / -name "python*" -print > > He could also just do: > > which python > > though "find" and "which" both assume a Unix system. Assuming his > path is set up correctly,... Yeah. I was assuming since the word "server" was used and a command line was mentioned, it just about had to be unix. The advantage to the find, of course, is that it will find python even if he hasn't had it put into his path (which is a possibility). C/ From krussell4 at videon.home.com Sun May 7 16:07:28 2000 From: krussell4 at videon.home.com (Kevin Russell) Date: Sun, 07 May 2000 15:07:28 -0500 Subject: OT [Way OT]: Unicode Unification Objections References: Message-ID: <3915CD00.C73DA43B@videon.home.com> "Dennis E. Hamilton" wrote: > Consider the following. In Japanese texts, when a borrowed or employed > Korean word is used, a desired practice is to render the Korean > characters as different, even though some or all of them involve "the > same character" common to both languages. However, the iconography (or > calligraphy) is commonly different. This loses the ability to > distinguish the linguistic use of the character, forcing material to be > font-distinguished some how (e.g., give me the ones that look Korean, > not the ones that look Japanese). This means that the distinction can't > be preserved in simple text. The entire point of markup is that distinctions like this *shouldn't* be preserved in simple text. How a particular character should *look* is a question for presentation glyphs, not for character encoding. What kind of language a character is used to represent (emphasis, quotations, foreign borrowings, titles, proper names, sarcasm, etc.) is a question for markup, not for character encoding. A similar situation holds in almost every written language. We often dump Latin or French words into English text. Even though they may be written in the same alphabet, we usually want them to *look* different from ordinary English words. But nobody uses that fact to argue that Unicode should have handed out a separate code number to italic "e" than to plain "e" -- or even that entirely disjoint sets of codes should be used for writing Latin, French, and English words. (Actually, there probably were people who argued these, but they were rightly ignored.) Once you start mixing up glyph questions (what a character should look like) and markup questions (what kind of language is the character being used for) with character encoding questions, there's no logical place to stop. Soon the Unicode Consortium would be fielding requests like "I want to be able to distinguish the Yamato pronunciation of the 'sun' character whispered with a Hokkaido accent and a lisp from the Yamato pronunciation of the 'sun' character as muttered inaudibly by someone from Okinawa who has a head-cold. And I want to do it with a character that looks like it was finger-painted in drippy chartreuse water-colours by a five-year-old. And it should be 23-point bold, 'cause it will be in a title. I suggest you assign me character xDE4A921B." > > Unfortunately, the Greek alphabet and the APL alphabet (and apparently > some other math symbol alphabets) *were* unified. That is, a number of > Greek-letter symbols were removed from any distinct APL character set, > and only some APL-unique made-up symbols having Greek letters in them > were retained as separate. Unfortunately, the iconography of the Greek > alphabet in Greek text is often enough different that those codes don't > render appropriately with the other APL symbols when used in APL texts. > Borrowing epsilon (for member) from the Greek character set in Unicode > is not always what one wants to do when writing membership propositions > in APL (and borrowing the alternative MEMBER OF symbol may not get you > what you want either). It's even more fun if you want to write APL > programs and use Greek-language identifiers. Something a CP4E teacher > in a Greek school might strongly desire to do. Get it? > What kind of sadist would try to teach a CP4E course using APL?! (And I say this fondly as someone who learned APL as my first computer language in high school.) Actually, this is a very good point. But the problem is more with APL than with Unicode. Every computer language needs a way to distinguish characters used in literals from characters used in operators from characters used as raw data (e.g., strings), and so on. Usually the decisions made during syntax design will limit to programmer's freedom to make up literal names. (Or to quote what I said at 90 decibels at 2 a.m. two nights ago: "Why the **** can't I call that variable 'class' if I want to call it 'class'!) Iverson's decisions during APL's syntax design must have made perfect sense in 1960, but in hindsight they turned out to be extremely inconvenient. If you want to extend APL to make it less inconvenient for your Greek teacher, you're either going to have to redesign the language syntax from scratch (as Iverson did for J) or you could take the problematic APL characters and assign your own codes to them from Unicode's private use blocks. That's what the private use blocks are for -- they let you and the four other people in the universe who are going to use your Greek APL interpreter do what you need to do, without bogging down the entire character standard. -- Kevin Russell From famvandenberg at home.com Wed May 10 22:13:44 2000 From: famvandenberg at home.com (bo Vandenberg) Date: Thu, 11 May 2000 02:13:44 GMT Subject: python and Novell Message-ID: <391A17EB.58D177CC@home.com> I'm wonderring if anyone has used Python on a Novell 4.x or 5 network??? I want to find the logical way that I can begin to play with it. Can I just put the python install the network and have all the clients call it as a search drive? Are there any issues that demand that it be installed on all the clients? Anyone with Novell success stories? I'd really like to hear some. bo From rhicks at rma.edu Thu May 18 22:42:24 2000 From: rhicks at rma.edu (Robert) Date: Fri, 19 May 2000 02:42:24 GMT Subject: Python3k extended grammar References: Message-ID: uggh...keep "return"...out with "->"...nuff said! As a newbie..."return" makes it much easier read and understand Bob Roy Katz wrote in message news:Pine.GSO.4.21.0005181437530.2583-100000 at z.glue.umd.edu... > Hi! > > (apologies in advance as to the applicability of this message to such a > general group) > > > I checked out the TYPE-SIG material.. It's really interesting. > I agree that grammars which take into account the type of an object are > in quite demand in Python; however, as a (practical) programmer I take > offense at the creation of (yet) more keywords and operators. For > example, take the function declaration grammar: > > def func( x: Integer, y: Integer ) -> Integer: > > what's the rational behind using the -> operator, rather than sticking to > 'return'? > > def func( x, y ) return Integer: > > IMHO it's just another operator or keyword to bloat my language. > Same thing with the proposed 'decl' operator. Why another keyword? > What's wrong with the following: > > > > int = Integer > def add( (int) x, (int) y ) # specifies type of the parameter > return int; # specifies the return type > raise exGenException: # specifies the exceptions thrown > > z = x + y # body > return z # exit. > > > No added keywords there. I understand that the above is more verbose, > however, I believe this approach is vastly more consistent with the > traditional grammar. Then again, this is only my personal preference. > > Another question: to whoever proposed the following notation: > > x: [ Integer ] > > what happens when we have a list of list of strings? > > x: [[ StringType ]] > > am I correct here? > > > As I see it, we have a grammar spectrum with Pascal and Java on one side, > (which places the burden on the programmer to declare, detail and > categorize every little nuance), and perl on the other -- a language > which IMHO is reconfigurable ad nauseum. (what kind of situation > necessates changing the starting array index from 0, anyway?). > > > > Roey Katz > Jewish Programmer. > Oy. > From effbot at telia.com Wed May 31 17:56:44 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 31 May 2000 21:56:44 GMT Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934242B.ECFDBAAE@endea.demon.nl> <8h1k0q$h04$2@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote: > > I'm not sure Alice has much of a "result" to offer on the subject. As > > far as I can tell from the paper I have read, doing away with case > > sensitivity was just the nearest hack available, not a decision based on > > scientific analysis of the whole interface problem. > > True; I don't think there was done any double-blind research into this > phenomenon. I'm probably just dense, but how would you design such a double-blind test? > It was just an anecdotal observation, perhaps in a more controlled setting > than ours, but probably still doesn't weigh much more strongly than our own > anecdotal observations. As far as I understand, the Alice researchers observed that errors caused by case *mismatches* are a real and important problem. They don't claim that there are no better *technical* solutions than the one they implemented. (iirc, alice just casefolds everything in the "reader". Which reminds me of some recent private mail, which boldly claimed that if you implement things in that way, your language is not really case sensitive at all...) From jkraska1 at san.rr.com Mon May 15 13:26:06 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 May 2000 17:26:06 GMT Subject: Java vs Python References: Message-ID: <392033D6.373CE543@san.rr.com> > > 1. Which is more maintainable ? > > Python. Python can do just about anything in fewer lines of code, and > is vastly more readable to boot (not to mention having lovely > space-saving features like function and method objects and > module-global variables.) I don't think i've *ever* found a language > more maintainable than python, I agree with this. And I've used a lot of languages. Python's the most succinct and maintainable by far. C/ From m.faassen at vet.uu.nl Tue May 23 06:08:05 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 10:08:05 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> <8gcoij$60n$1@news-int.gatech.edu> Message-ID: <8gdla5$nju$3@newshost.accu.uu.nl> Andrew Henshaw wrote: > Ben Cornett wrote: >> >>this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". >> > ...snip... > The interesting thing about this is that I could read it. A case-insensitive > compiler couldn't handle a single case flip. That's why I don't understand > the argument that (English-speaking) humans are case sensitive. In general > we're not. We prefer that everyone follow case-usage rules, but we don't > require it. In my opinion, that's the way programming should work. I would > like to read a program that followed case usage for readability; but, I > don't want an interpreter to barf when case is ignored. if 1: print "This is " print "incorrectly indented" print "code" Now let's paraphrase: "The interesting this about this is that I could read it. A indentation based compiler couldn't handle a single indentation misalignment. That's why I don't understand the argument that humans are indentation sensitive. In general we're not. We prefer that everyone follow indentation-usage rules, but we don't require it. In my opinion, that's the way programming should work. I would like to read a program that followed indentation usage for readability; but, I do'nt want an interpreter to barf when indentation is ignored." Do you, or do you not, think about Python's indentation system this way? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rumjuggler at cryptarchy.org Sun May 21 13:56:49 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 21 May 2000 17:56:49 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> <3927FA67.94D85CAF@elite.org> Message-ID: <349gisk5q40o7n9h8m03e7sr4bbed8tigo@4ax.com> On Sun, 21 May 2000 14:40:54 GMT, "Fredrik Lundh" wrote: >The problem with your argument is that the Alice environment is a single >system. In a case-sensitive environment, people will waste time typing >"case-incorrect tokens into their programs for a short period", for every >new Python library. Huh? I've been following the case threads, and this is the first time I absolutely don't understand an argument. Surely the *same* people won't waste time for each new python library. -- Barnabas T. Rumjuggler An infant is a seed. Is it an oak seed or a cabbage seed? Who knows? All mothers think their children are oaks, but the world never lacks for cabbages. -- Robertson Davies, _World of Wonders_ From jkraska1 at san.rr.com Sun May 7 02:17:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 07 May 2000 06:17:34 GMT Subject: print... okay, howabout sprintf? Message-ID: <39150B40.A5BA5A5C@san.rr.com> Okay, I've noticed that python print supports printf style format notation, and that's cool. But how do you do the same thing with strings. i.e., what's the equivalent of sprintf()? C/ From olipt at mayo.edu Wed May 24 09:57:59 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Wed, 24 May 2000 08:57:59 -0500 Subject: Python / Visual Basic mathematical comparison In-Reply-To: <8ggdff+s8d3@eGroups.com> References: <8ggdff+s8d3@eGroups.com> Message-ID: > I have been programming in both (although I stopped with VB after I > discovered Python:-), so here is a short summary. > > If we look at the bare facts we have: > > Py VB > Int*2 N Y > Int*4 Y[1] Y > Long[2] Y N > Real*4 N Y > Real*8 Y Y > Currency N Y > > Array arith. Y[3] N[4] > > Callbacks Y[5] Y > Modules Y Well, sort of > Dynamic YES N > Interactive Y Not very good > > 1: Can be Int*8 on 64 bit machines > 2: Long is abitary precision integer values > 3: Through NumPy > 4: Not that I know of > 5: From within python only Thanks for this comparison. A couple of things are not stated, however: Types: Through NumPy you have Int*2, and Real*4. Several people have posted example currency classes. Callbacks: I don't understand what you mean by "From within Python only." You can callback into Python from C-code and vice-versa, so I'm not sure what you were trying to communicate with this restriction. > 5) The speed issue is difficult: > a) If you run lots of matrix math you can use NumPy, and it is > *fast*. There is no alternative to NumPy in VB (to my knowledge) You can use NumPy for lots of things besides just "matrix" math. You can store large amounts of data in a small space and do rapid operations on that data as well. As a result, image processing can be done very well using the NumPy object. > The question you need to ask yourselves on speed is "how fast is fast > enough". At present Python is (unfortunatly) not fast enough for our > line of work (real time calculation of large ODE's), Have you tried multipack? It contains a module that links the FORTRAN integration routines in ODEPACK. It is rather fast, but because it calls a Python function at each step it is not "as fast as machinely possible." Still, a combination of Python/(C,FORTRAN) is very fast. -Travis From moshez at math.huji.ac.il Tue May 23 00:57:09 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 23 May 2000 07:57:09 +0300 (IDT) Subject: bz2 support in Python? In-Reply-To: <3929327D.1F09D8BB@anfdata.cz> Message-ID: On Mon, 22 May 2000, Xavier Outhier wrote: > Is there in Python any bz2 tool? bz2 is the 2nd version > of bzip. A compression algo. > > I have search in FAQ, DejaNews and I have found nothing. I believe there is, but I was always for the much simpler: os.popen("bzip2 ...."), or os.popen2 if you don't need a file at either end. Of course, you should abstract it away with a class if it's large enough. Then, you'd be able to change bzip2 to bzip3 (when it comes out), without waiting for a Python interface. all-this-doesn't-apply-on-win32-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From kuncej at mail.conservation.state.mo.us Mon May 15 11:56:11 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Mon, 15 May 2000 10:56:11 -0500 Subject: Python Plans from ActiveState References: <51rthscplh93iuktpbn87lihguqo1rq5s8@4ax.com> Message-ID: Despite the technical quibbling, Robin has a good point about network installation. As python penetrates more into corporate and government environments, I think a network install option is becoming a neccessity. I have my own hack to do this: http://starship.python.net/crew/jjkunce/netinstall/python_network_setup.html But we really need an installer-savvy person to add: "Install to network" "Install client - run from network" options to the official python installation program --Jeff From sreekant at uklinux.net Tue May 16 13:00:43 2000 From: sreekant at uklinux.net (Sreekant Kodela) Date: Tue, 16 May 2000 17:00:43 GMT Subject: Python / CGI / E-mail problem References: <3920E594.F3F2E4CD@uklinux.net> Message-ID: <3921C3C8.90A5E7C9@uklinux.net> Hi there I tried using the MimeWriter but failed. Do you have any simple exampe by any chance. thanks sreekant ben at co.and.co wrote: > Sreekant Kodela wrote: > > Hi there > > > > I am trying to send automated emails to the people who joined the > > mailing list. I am using the smtplib and sending the mail but my users > > came back to me that they can see the code. I tried to mail it to my > > self and hotmail was ok but pop/kmail was showing the code. I am using > > the following method. Is there anything stupid I'm doing!! > > > > hdr='From: xxxxx'+smtplib.CRLF+'SUBJECT: xxxxxx'+smtplib.CRLF > > hdr2='StokZilla > For anything else than a plain text message, you need to pack the body > in MIME-headers, telling the MUA how to render the content. > In your case, you need to tell the MUA its a HTML-message. > The headers should contain > Content-Type: text/html; charset=iso-8859-1 > > Take a look at the MimeWriter-module. > > Greetings, > -- > ben . de . rydt at pandora . be ------------------ your comments > http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From James_Pannozzi at aon.com Fri May 5 12:13:10 2000 From: James_Pannozzi at aon.com (James Pannozzi) Date: Fri, 5 May 2000 12:13:10 -0400 Subject: Python Front End to Dos Progrrams? Message-ID: <8eurti$2dt$1@ssauraab-i-1.production.compuserve.com> We have a bunch of DOS legacy apps that drive everyone crazy. They run in a dos box on our W95 computers and we don't have time to re-write them as Windows 95 apps just yet. One app uses the F4 key to do something, another one uses alt-tab combo, another uses F2 and then an keypress. Most of these apps are provided to us by different companies (no source available). Some are written in old versions of Visual Basic. Has anyone ever written a Python front-end to DOS based programs in which the user clicks on a menu and then the Python program generates the correct set of goofy dos app keypresses and sends it to the dos app? Is this do-able? Thanks Jim From chris*SPAM*h at pobox.com.invalid Mon May 15 09:46:39 2000 From: chris*SPAM*h at pobox.com.invalid (Chris Herborth) Date: Mon, 15 May 2000 13:46:39 GMT Subject: Compiling Python for BeOS 5 References: Message-ID: <3dTT4.83457$VR.1660305@news5.giganews.com> According to Jerome Chan : > I've managed to compile it but under make test it just hangs on > test_p_open2.py. AFAIK this is a common problem (and doesn't mean anything is wrong with your build of Python). > Once I remove that file from the testing sequence seems > to go into an infinite loop after test_threading. Also the struct module > test failed as well. This is odd; both of these should work. > Does anyone have any hints in configuring Python for BeOS? Just follow the directions? :-) I haven't had time to keep up with the changes in the Python source. Both threading and struct should work fine... -- ----------========================================================---------- Chris Herborth, DNRC Holder of Past Knowledge Arcane Dragon -==(UDIC)==- BeOS hacker, Catharon Productions, Inc. http://www.catharon.com/ CTO, Next Generation Entertainment http://www.ngent.com/ From jkraska1 at san.rr.com Sat May 20 21:29:35 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 21 May 2000 01:29:35 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <39260037.146C3467@san.rr.com> <39260B99.86CBF73C@san.rr.com> Message-ID: <39273CBE.3ACC0D94@san.rr.com> > Well, you're right. Being rude doesn't help. But being a pushover > doesn't help either -- I know, I've tried it. That's true enough. I suppose the real essence of my point is that as long as he controls the keys of python, he does. Announcing it won't make it any more so. If anything, that will turn people off, IMO. C/ From deirdre at deirdre.net Wed May 10 18:50:34 2000 From: deirdre at deirdre.net (Deirdre Saoirse) Date: Wed, 10 May 2000 15:50:34 -0700 (PDT) Subject: OT [Way OT]: Unicode Unification Objections In-Reply-To: <3918E331.C179670A@home.com> Message-ID: On Tue, 9 May 2000, Ivan Van Laningham wrote: > Fredrik Lundh wrote: > > don't worry -- the most dangerous weapon I own is > > an old water pistol. > > -ly y'rs, > Ivan;-) Perfume is expensive. He probably filled it with fresh Durian. Much cheaper and smells much worse. ;) -- _Deirdre * http://www.sfknit.org * http://www.deirdre.net "Linux means never having to delete your love mail." -- Don Marti From m.faassen at vet.uu.nl Thu May 18 21:03:18 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 May 2000 01:03:18 GMT Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newshost.accu.uu.nl> Message-ID: <8g23sm$pe0$1@newshost.accu.uu.nl> Glyph Lefkowitz wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: >> I sit on the chair > . >> chair.sit() > Hmm. This is not the way I think of it. I would never say > chair.sit() ... more like, > "Bob, sit on the chair." > bob.sit(chair) > After all, who's doing the work here; bob, or the chair? Depends on how you're modelling. In many muds for instance, the world objects determine what's possible with them, not the players. The player issues some commands and the player object knows just enough to be able to pipe it to the world objects (which then can query the player. So more like: chair.sit(bob) Though that does look a bit odd. :) chair.be_sat_on_by(bob) >> Similarly: >> >> I append to the list > I tend not to think of things as so person-focused ;-). *I* will > append nothing to the list; I am merely telling the list what it shall > do. I plan to be somewhere else entirely when this program is > running. You're just as person-focused as I am. I just happend to be in a first-person mood while you're in a third-person mood. I frequently think things like: 'here I am adding these two numbers but the output is wrong..weird' when really the computer is doing the adding. >> list.append() > So what "list.append(element)" says to me is, "List, append > element. (to yourself, of course)" Sure, perhaps I should rewrite 'I append to the list' to something like: I tell the list to append another element to it. >> I draw on a paper with a blue color >> >> paper.draw(color='blue') > This doesn't make sense either. For me it would be: > pen.paper=paper > pen.draw(color='blue') > "Pen, you're going to be drawing on that piece of paper. Draw in > blue." Depends on how you're modelling. Let's do this then: display.fill(color='blue') The 'pen' metaphor does often work better if you're going to draw lines and such. >> In the case of 'foo'.join() this stops making sense: >> >> I join the list of strings with spaces. >> >> ' '.join(list) >> In this case, it feels obvious to us that the *list* is the big target, >> and the space is what we're joining with. We don't think: > [snip] > Finally, this makes sense to me, becuase what I'm saying is; > "' ' (which we all know to be a string), join list together". Being a > programming language, "tell me what the result is" is implicit =). Interesting. Would you like the arguments to string.join() to be reversed as well then? As usually we map the first argument in functions to 'self' in objects. In Python this is extremely explicit. The string.join() function therefore feels like it should be translated to something like list.join(), as the first argument is a list. i.e.: list, join yourself together (with a space) The equivalent in your pen example would seem to be: blue.draw(paper) and that doesn't seem to be encountered often. Though this is more common: pen = Pen(color=blue) pen.draw(paper) >> lots-of-instinctive-language-analysis-ly yours, > my-intuition-is-nonintuitive-ly y'rs, I suppose it all has to do with refactoring; on which object we should place our methods, and so on. In programming we sometimes tend to move methods around a bit until they settle; we change our minds about what the central actors are and what are just arguments. In the list example, some people just don't seem to feel that the string is being the central actor. I think there's also the tension with .split(), i.e: "foo bar baz".split(" ") Which would be: string, split yourself (on spaces) Or is it this in 1.6? " ".split("foo bar baz") That would be the equivalent with the join() case, right? space, split this string. downloads-tarball-compiles-tests-no-its-the-former-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From darcy at vex.net Wed May 17 06:43:18 2000 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 17 May 2000 10:43:18 GMT Subject: python web hosting References: <8fsh2i$796$1@nnrp1.deja.com> Message-ID: <8ftt46$mvq$1@news.tht.net> sh1232 at my-deja.com wrote: > I've searched this forum but could not find a good list of web hosting > company that support python. If your web hosting company (or know of one) > supports python cgi, please post it to this thread. Thank you very much in > advance. http://www.vex.net/ fully supports Python. It is what we use for our billing system, the owner (me) is the current maintainer for PyGreSQL and the Vaults of Parnassus are served from here so you can be sure that it's an integral part of our system and will continue to be maintained and updated.. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From Gonk_ at spamspamhotmail.com Fri May 19 09:22:28 2000 From: Gonk_ at spamspamhotmail.com (Bart Holthuijsen) Date: Fri, 19 May 2000 15:22:28 +0200 Subject: Newbie: opening files. Message-ID: <39254013.C5B3834A@spamspamhotmail.com> hi Python enthousiasts! I'm having a problem with the opening of files under Python... I've seen code which makes it seem easy, just a call like: file = open(filename, 'r') doesn't seem to hard, now does it? now this is what I try to do: ------------------------- from sys import * from os import * from string import * def main(): chdir('c:\stage\Xalan') f = open('Yearend.xml','r') print "file opened" ------------------------- The following error message appears: C:\Stage\xalan>python open.py Traceback (innermost last): File "open.py", line 25, in ? if __name__=='__main__': main() File "open.py", line 13, in main f = open('Yearend.xml','r') TypeError: illegal argument type for built-in operation What am I doing wrong? TIA, Bart Holthuijsen. From neelk at brick.cswv.com Tue May 23 18:23:05 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 23 May 2000 22:23:05 GMT Subject: case sensitivity and XML References: <20000523113250.A2150232@vislab.epa.gov> <7LxW4.9151$Za1.142121@newsc.telia.net> Message-ID: Fredrik Lundh wrote: > Randall Hopper wrote: > > Reading BASIC and Pascal code for several years taught me (among other > > things) that case insensitivity isn't the better way. > > > > whY do WE Have RULES fOR capiTALIZation IN lANGUAGES? Because it makes > > them easier to read and comprehend. > > so why not enforce these rules, just like we're enforcing the > indentation rules: > > >>> class foo: > SyntaxError: Class name should be Foo > > (if not else, that should make martijn happy, right? ;-) Actually, this is exactly what Haskell does; type names *must* begin with a capital letter and variables *can't* begin with a capital letter. (For the curious: partitioning type and regular variables into different namespaces makes life easier for the language designers, who then doesn't have to worry about what it means when a type name is shadowed by a value binding, since Haskell types only have meaning at compile time.) Neel From moshez at math.huji.ac.il Sat May 13 02:40:19 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 13 May 2000 09:40:19 +0300 (IDT) Subject: python improvements (Was: Re: New Language) In-Reply-To: Message-ID: On 12 May 2000, Neel Krishnaswami wrote: > If you can declare that a variable is a machine integer or float, and > arrays of the same, you have enough information to get about 80% of > the speed benefit that static typing can win you. What about array-based member lookup, vs. dict-based? I.e., if we can optimize foo.bar to be either a 1) compile-time error or 2) an index to the member array, it will speed up quite a lot of code. > Before static typing for speed is tried (with its complicating effects > on implementation), I think it's better to go for the factor of 2 > improvement that can be won via easy tricks like method caches, > variable lookup optimization, and reducing function call > overhead. (Look at Squeak Smalltalk for an example.) Can you give some kind of reference, beside the Squeak Smalltalk source code? How easy are the tricks? > Note also that it can be hard to declare 'machine integer' as a type, > if type-class unification becomes reality and you can subclass > Integer. Not if we have a type system which will allow you to say "an int, and nothing else. Not a subclass". I'm very much in favour of such a type-system, but I'm a minority -- this seems an OPT-based target, and most type-sig people are ERR people. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From jvickroy at sec.noaa.gov Fri May 5 17:17:14 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Fri, 05 May 2000 15:17:14 -0600 Subject: Py_BuildValue - return large array Message-ID: <39133A5A.AD145915@sec.noaa.gov> Hello all, How should one return a (handle to?) "large" C-array to Python? It seems that Py_BuildValue ("[...]", ..., ...) is only usable for "small" arrays where one can explicitly enumerate each element in the array. Thanks for your time. -- jv From dsavitsk at e-coli.net Wed May 31 20:11:53 2000 From: dsavitsk at e-coli.net (dsavitsk) Date: Thu, 01 Jun 2000 00:11:53 GMT Subject: Calling Function in DLL on Windows Message-ID: i need to call a DLL from within a python program. in VB i would declare the function like... Declare Function LoadSFW Lib "Sfwlnk32" (ByVal strPath As String, ByVal strConfig As String) As Long then use it later like... intErrorCode = LoadSFW("C:\SFW", 6) i don't know how to do this in Python, so any quick explanation would be helpful. doug From ivanlan at home.com Fri May 26 00:03:19 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Thu, 25 May 2000 22:03:19 -0600 Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> Message-ID: <392DF787.6658FCE1@home.com> Hi All-- Alan Daniels wrote: > > On 25 May 2000 08:56:38 GMT, Remco Gerlich > wrote: > > [snip...] > >Why the problem with multiple lines and an extra variable here and there? > > Yes, but the short version reminds me very much of one of my favorite > python idioms: > > lines = open("some_file", "rt").readlines() > If you don't want the newlines, you can do this: alist=open("some_file","rt").read().split() in 1.6. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org/ http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From wtanksle at dolphin.openprojects.net Mon May 29 16:16:45 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 29 May 2000 20:16:45 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> Message-ID: On Sun, 28 May 2000 20:14:46 +0200, Thomas Malik wrote: >Late answer, but here i go: And a late reply on my part :-). >1. By bringing the department of our bank into argument, i was saying, that >even very conservative - thinking organizations are starting to use your (as >it is) quite innovative programming language, because of the advantages it >has. A quick comment: Python has very little in the way of innovation. It brings together many tried-and-true mechanisms in a very elegant manner. Not even indentation is a true innovation; it was pioneered by ABC before Python was born. >For a bank, one of the most important points is reliability in the IT >systems, which, amongst others, can be achieved by a quite strict set of >programming rules. If these rules completely break with some new programming >language, or even with a new version of the language, it will have to be >reconsidered it the language is going to be used. This is a very good argument. At the same time, there are already enough plans to make Py3K a very different language in this sense; new policies will have to be written before its use will be accepted anyhow. So I agree with you, but I don't think you see that this point is already lost. >If the language itself provides for possibilities to write unreadable code >(which case-insensitivity does, see below), it will be extremely difficult >to share code with external programmers (we work a lot together with >external consultants), i can assure you of this fact from experience. We'll see about your contentions for unreadability, but as to the general tendancy here -- well, I'm not at all impressed. Can you even IMAGINE a language which does NOT allow possibilities to write unreadable code? The concept boggles my mind. >3. Removing case - sensitivity wouldn't reduce errors in any way, in >contrary, it will add a new and more difficult class of errors: those where >one uses the same identifier (possibly written with different case ...) with >two different meanings. For example, one uses a class 'Error' from library >a, and the function 'error' from library b, case-insensitivity will be a >great source of annoayance here. You are trading syntax errors (easy to cope >with) for possible semantic errors (extremely difficult to cope with) NO! You're not just wrong here; you're 180 degrees wrong. In a case _sensitive_ language it's possible to have two different identifiers with the same spelling but different cases; if you include both, and then try to use one but mispell it as the other, you'll get no error, but your program won't work. If you try that trick on a case insensitive system, you'll get an error as soon as you import the second module. Case sensitivity WILL reduce this class of error by replacing a runtime error with a compiletime one. >4. the point, that bothers me most about case insensitivity, is, that >consistency in the spelling of identifiers will be lost. That means, because >case doesn't count any more, why should a programmer enforce any kind of >rules in the use of type case ? Why should one even consider using the same >case for the same identifier in different places ? What would the right >typing be anyway, if Python doesn't check it anymore ? Your rhetorical questions answer themselves. Why should a programmer enforce these things? Because it's stupid to NOT enforce them. So enforce them already! >5. there are quite a lot of cases, where i would have to invent 'unnatural' >names for identifiers, just because the word i want to use is already used >by a class name, for instance. GOOD. Excellent. Now we don't have variables which differ only in case -- which is the problem you spend so much energy exponding against on point 4. >On the other point, that has been discussed in the list, about promoting >integer divisions to float or something other: >I don't get the point here. I mean, during my college time, we have been >bored with stuff about groups and rings, just to see in the later courses, >that that kind of stuff can be quite useful. So, why should a division >between integers leave the set of integer numbers, but no so a muliplication >? Ok, it's more 'natural' to say 'ok, 1/3 is 1/3, a rational number, that is >(note that it's NOT the floating point representation 0.3333..., that's only >an approximation). You seem to understand the reasoning behind this -- I have no idea why you're asking the question. >The point is, again, that a programming language is NOT a >natural language (COBOL tried this already and failed laughable), but used >for programming. And in programming, i will need an integer division all >around, it were annoying if i would have to use some other >function/operator, whatever. Why should it be more or less annoying to use a 'rational' division than to use an integer division? They're both a pain; the difference is that the rational division preserves certain properties of the integers, while the integer division doesn't. >And then, i mean, once told, one shouldn't forget that 1/2 == 0. A person >forgetting that all the time should propably learn something else. Such as, for example, Py3K? >CP4E, to be honest, i have my vague doubts about that. In some way you are >postulating the same level of intellectual potential for everyone, but >that's another question you might have investigated for a longer time >already. I doubt it. They're only postulating enough to get _something_ done by people who are not currently being reached. It's a fair experiment, and it _is_ being investigated. >The strong point about C is, that it succeeded with an absolutely minimum >set of language features to be capable of everything a programmer needs. Or so you've been told. Did you consider the C library as part of the language? You can't do anything important without the library, and it's clunky junk. >The syntax, to a beginner, looks extremely crude. Hmm. I thought it was rather nice. So much more elegantly terse than Pascal, yet familiar in a way that Forth wasn't (at the time). The library, though, was barely adequate, and later experience has only strengthened that hostile conclusion. >Thomas -- -William "Billy" Tanksley From andrew at andrewcooke.free-online.co.uk Mon May 8 13:33:17 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Mon, 08 May 2000 17:33:17 GMT Subject: __len__ and boolean values - small language change References: <8f6qm0$glb$1@nnrp1.deja.com> Message-ID: <8f6tos$k9a$1@nnrp1.deja.com> In article , Michael Hudson wrote: > Andrew Cooke writes: > > [snip] > > Is there a special method that I can override to provide boolean values > > in tests, or is __len__ called directly? > > You want __nonzero__: excellent. thanks v much. on a meta-level it's also demonstrated to me that the module index doesn't include entries for the language reference ;-) sorry... andrew Sent via Deja.com http://www.deja.com/ Before you buy. From traversx.l.kiley at intel.com Tue May 16 19:04:10 2000 From: traversx.l.kiley at intel.com (traversx.l.kiley at intel.com) Date: Tue, 16 May 2000 23:04:10 GMT Subject: Win32file newline character Message-ID: <8fsk4v$air$1@nnrp1.deja.com> Hello, I'm creating a win32file object to write different strings and i'm having trouble figuring out how to start a new line in the file. I've tried "\n" and "\012" and "\0" and nothing seems to work. Does anyone know how to place a newline into the win32file.WriteFile (wHandle, string) method? Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sun May 14 08:39:32 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 14 May 2000 08:39:32 -0400 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: <391E9E84.D1A0D74A@prescod.net> Lloyd Zusman wrote: > > ... > > Or would this change somehow go against one or more core principles of > Python architecture? Alternate forms and syntaxes increase the possibility of one programmer knowing one subset ("dialect") of the language and another knowing another subset/dialect. Still, there are no unbreakable rules in Python development and I bet many programmers are unaware of complex as it is. I would vote for an "i" in Py3K. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Art is always at peril in universities, where there are so many people, young and old, who love art less than argument, and dote upon a text that provides the nutritious pemmican on which scholars love to chew. -- Robertson Davies in "The Cunning Man" From jad at altern.org Sun May 21 19:09:11 2000 From: jad at altern.org (MrBlue) Date: Sun, 21 May 2000 23:09:11 GMT Subject: NumPy and FFT Message-ID: Hi, I installed NumPy to use the FFT function. I have a 1D array (say a) which contains real data (of wind velocity v(t)) taken at a fixed sampling rate (5 Hz) i.e I have a file which contains 1 measurement per line and I'd like to take the FT of these data, i.e having a 2D array (say b) which would contain omega in one column and the complex value (FT(v(t)))(omega) in another column for different values of omega. which function do i have to use in order to get b = FT(a) ? The fft function gives a 1D array as an output Any insight would be strongly appreciated. Jad Courbage Physics Department McGill University Montreal Canada From jkraska1 at san.rr.com Sun May 14 20:03:50 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 May 2000 00:03:50 GMT Subject: Can not remove file in windows because of "permission denied" References: <8fmo5k$e5u$1@news.uni-paderborn.de> <391f2eba$0$20207@wodc7nh6.news.uu.net> Message-ID: <391F3F89.6A1B024@san.rr.com> Gordon McMillan wrote: > > Chr. Ullenboom wrote: > > >I want to remove a file (an rename) but I cannot. There is a > permission > >denied under Windows 2000, but it is my own file. What can I do? > > You (or a close facsimile thereof) probably have the file open. Yes, albeit you might be surprised at how some windows programs can "hold on" to your file, even when they don't apparently have it. I have this problem with Win CVS, occasionally. When it pops up, I terminate Win CVS, and all is well. C/ From phd at phd.russ.ru Fri May 5 04:41:07 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 5 May 2000 08:41:07 +0000 (GMT) Subject: python help for webpages ? In-Reply-To: <39124E00.13CC8723@swt.edu> Message-ID: On Thu, 4 May 2000, Shah, Navneet wrote: > How do Python helps in developing webpages? Can anyone explore in this > area? http://www.python.org/topics/web/ Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tismer at tismer.com Tue May 16 15:16:11 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 16 May 2000 21:16:11 +0200 Subject: Stackless/microthreads merge news References: Message-ID: <39219E7B.364C6EA6@tismer.com> Moshe Zadka wrote: > > On Tue, 16 May 2000, Courageous wrote: > > > But I think you'd have to write a full fledged compiler for this [making > > C stackless] and that *is* a lot of work. > > Making C *anything* would be a lot of work...but please note that making > C stackless doesn't buy you a lot -- I mean, it just means you'll use some > other pointer instead of the stack-pointer, and move it to a linked-list > from a resizable array. And we already talked about linked-list vs. > resizable arrays Not quite. It would buy you everything. This doesn't mean to use linked lists all over the place. No that would e a mess. But to be able to do it at all, with compiler support, that would be everything I need. > it's-just-like-making-forth-stackless-ly y'rs, Z. Making Forth stackless means to add a word that is able to switch stacks, and use that in places where it makes sense: Where we want to be able to grab a continuation. While we are at it: How would you name such a Forth-word? wondering-how-they-always-guess-my-pet-projects-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From mwh21 at cam.ac.uk Wed May 17 05:49:10 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 May 2000 10:49:10 +0100 Subject: Decimals -> Fraction strings, my solution References: Message-ID: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: > kain at cableadmin.com (Scott) writes: > > > I've come up with one solution to my problem. Its probably quite > > inefficient, but it does what I need for now. Feel free to > > tear it apart and/or give any advice on how to better implement it. > > OK, taken! As a kind of rest, I tried to do it as well, as I was teased > by the fact your solution limits the denominator to be 2**N * 5**M. You have the right approach (continued fractions), but you're implementation is more complex than it needs to be. As it happens, I've just handed in a computer project on continued fractions so, after a bit of translation (I originally wrote this stuff in lisp), here it is. # copied from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include/float.h epsilon = 2.2204460492503131e-16 def cfrac(x,err=0.0): result = [] err = err + epsilon while 1: a,b = divmod(x, 1.0) result.append( int(a) ) if not b: return result err = err / (b * (b + err)) if err > b: return result x = 1 / b def converge(partials): p_1, q_1, p, q = 0, 1, 1, 0 result = [] for a in partials: p_1, q_1, p, q = p,q, a*p+p_1, a*q+q_1 result.append( (p,q) ) return result Justifying all that requires significant time with a pencil, so I'll leave that as an excercise for the reader. However: >>> cfrac.converge(cfrac.cfrac(math.pi)) [(3, 1), (22, 7), (333, 106), (355, 113), (103993, 33102), (104348, 33215), (208341, 66317), (312689, 99532), (833719, 265381), (1146408, 364913), (4272943, 1360120), (5419351, 1725033)] Same numbers as before, but rather less effort to get them, I think. Also: >>> cfrac.converge(cfrac.cfrac(float("0.3333333333333333333333"))) [(0, 1), (1, 3)] continued-fractions-are-almost-like-magic-ly y'rs Michael -- 81. In computing, turning the obvious into the useful is a living definition of the word "frustration". -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From wlfraed at ix.netcom.com Sat May 13 23:56:28 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sat, 13 May 2000 20:56:28 -0700 Subject: really silly nit: why 3+5j instead of 3+5i? References: <391EF59E.2F6B@seebelow.org> Message-ID: On Sun, 14 May 2000 19:51:10 +0100, Grant Griffin declaimed the following in comp.lang.python: > Or at least that's the party line. In truth, we use 'j' to represent > sqrt(-1) for exactly the same reason we use a convention for the > direction of current which is exactly the opposite of the direction the > electrons actually travel: because it drives physicists crazy. (And if Have pity... Just because ol' Ben Franklin thought current flowed in the direction opposite to actual electron movement... And if you use the semiconductor concept of "holes", then current DOES flow positive to negative -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From jkraska1 at san.rr.com Fri May 12 03:22:51 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 12 May 2000 07:22:51 GMT Subject: Seeds References: <65118AEEFF5AD3118E8300508B1248774CB2E2@ALTNET> Message-ID: <391BB230.E7B27A5D@san.rr.com> > >Depending on how serious you are about randomness, you may want to use a > >hardware source (e.g., an audio input device). See 8.7 in the following > >document: Depending on how serious he his about randomness, he may also be concerned whether or not the random number generator is likely to generator numbers like the kind that one might encounter if those numbers had been generated under natural circumstances (i.e., is there a distribution, and if so what?) C/ From g2 at seebelow.org Fri May 12 03:42:02 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 08:42:02 +0100 Subject: Why should I switch to Python? References: <000401bfbaf5$877f8b60$2aa0143f@tim> Message-ID: <391BB5CA.3640@seebelow.org> Tim Peters wrote: > > [Grant Griffin] > > Speaking of C, I find myself missing the "x=" operators, and "++". > > However, I understand and endorse the reasons Python omits them. > > While ++ makes little sense in a language with immutable numbers, += (& > friends) can make good sense. There's more on this in the FAQ and the ToDo > list. Guido isn't opposed to augmented assignment. > > and-i'm-in-favor-so-that's-that-ly y'rs - tim Forgive me, Tim, but as a Python newbie, I had inferred that part of Python's design philosophy was to minimize redundant constructs, to encourage regularity in Python code. Likewise, another design philosophy I had inferred was to minimize "hyroglyphics" (tm), to make the language easy to learn and read; the aforementioned operators definity contribute to C's distinct "gobbledygook" look to the uninitiated. My beloved '+=' (and friends) fail on both these counts. However, perhaps I have inferred the philosophy wrongly. I know that you (or maybe he) have written numerous posts that touch on Python's design philosophy, but do you know if Guido has ever formalized Python's design philosophy on a web page or something? I read something wise a few months ago from you (or maybe him) that one succeeds in the programming language design business by choosing a design philosophy and sticking to it. Of course, one would not want to get too "anal" about that, but perhaps a formal statement would help us Uninitiated understand. anality-is-the-only-alternative-to-'occassional-irregularity' --ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From g2 at seebelow.org Thu May 11 03:28:59 2000 From: g2 at seebelow.org (Grant Griffin) Date: Thu, 11 May 2000 08:28:59 +0100 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <8fateo$5h1$1@216.39.141.21> Message-ID: <391A613B.2154@seebelow.org> Dana Booth wrote: > > Grant Griffin wrote: > > GG: Like you, I have been doing Perl for about 3 years. It's a wonderful > GG: thing for what it is, but having discovered Python, I now consider > GG: myself a "Perl Refugee". Python is like Perl--except without so much > GG: "Perl". What could be better?! > > I'm a fan of any scripting language that's easy to learn. :) Hence, I love > Perl, Python, and TCL. One of the things I really dig about Python is that > it seems like such a perfect mix of traditional C style coding, and the ease > of high level languages like Perl and TCL. Speaking of C, I find myself missing the "x=" operators, and "++". However, I understand and endorse the reasons Python omits them. I have recently been doing some C, and I've found myself not declaring variables, and leaving ";" off. So switching between the two seems problematic, but with more practice, I hope to one day do that as easily as I switch between treble and bass clef on the piano. (C-with-indents-instead-of-braces-would-help)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From greg at cosc.canterbury.ac.nz Thu May 4 22:13:05 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 05 May 2000 14:13:05 +1200 Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> Message-ID: <39122E31.AFB74291@cosc.canterbury.ac.nz> Will Ware wrote: > > Ancient civilizations like > the Phonecians (sp?) and Babylonians had records relating to trade, No, that was the Phoenicians. The Phonecians developed a primitive form of communication using small clay pots linked together with long pieces of string. Archaeologists have unearthed the ruins of a building that was located at the centre of a village, with the rotting remains of strings leading from it to many of the dwellings. It is thought to have been an early form of telephone exchange, in which teams of clerks switched calls by rapidly tying and untying pieces of string. The word Tal'ee-kom was inscribed over the door in ancient Phonecian letters, which translates roughly to "thoughts flying like the wind". -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From francis at robinton.demon.co.uk Thu May 18 07:59:57 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Thu, 18 May 2000 12:59:57 +0100 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> <3923444A.ABD7182@san.rr.com> Message-ID: <5e27ryA9s9I5EwLG@robinton.demon.co.uk> In article <3923444A.ABD7182 at san.rr.com>, Courageous writes >> Not being able to read the code of a >> competent programmer probably indicates your own level of inadequacy. > >You should have kept this last remark to yourself; suppose to >yourself that even if you are right, sometimes right remarks >in particular are best left unspoken. Unfortunately one deficiency of the English language is difficulty with disambiguating uses of 'your'. My remark was not intended to apply to you or anyone else in particular. However if I have a piece of code that is written by someone whose expertise I respect and I cannot understand it then my first question is about my own competency. There is a phenomenal amount of badly written code in any language that gains any degree of popularity. Those who seek 'the one true language' are responsible for a fair amount of it. Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From petersc at stud.ntnu.no Sat May 27 16:21:35 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Sat, 27 May 2000 22:21:35 +0200 Subject: Draft web text re vectors, quadrays, python, spatial geometry, crystallography, peer review solicited References: Message-ID: <39302E4F.64F92691@stud.ntnu.no> Kirby Urner wrote: > Hei Kirby! I do not know what your preferences for the source code, but there is more than one way to do the example below (do I sound like some p&rl-monkey?): E.g. using map and reduce: from operator import add,mul def dot(self,v1): return reduce(add,map(mul,self.norm0(),v1.norm0())) This might look unreadable to many people, but for others (with a functional programming background) it looks clearer. So it's a matter of taste/preferences, I guess. > def dot(self,v1): > # return the dot product of self with another vector > # return a scalar > scalar = 0 > a = self.norm0() > b = v1.norm0() > for i in range(4): > scalar = scalar + a[i] * b[i] > return 0.5*scalar greeting-the-lisp-fellows-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From DOUGS at oceanic.com Wed May 3 15:07:03 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 3 May 2000 09:07:03 -1000 Subject: How to get terminal width? Message-ID: <8457258D741DD411BD3D0050DA62365907A13D@huina.oceanic.com> [cpmcda01 at shark.kitenet.net wrote:] > > | I need to write a command line script in Python that needs > to know the width > | of the terminal in characters. I've looked through several > modules and > | haven't yet found what I'm looking for. Does anyone know > where I need to > | look? [and Donn Cave replied:] > Contrary to popular belief, the COLUMNS environment variable isn't > universally available on UNIX platforms. The last time I saw it was > on an obscure platform based on System V 3.2, and you don't get it > on contemporary Berkeley or Linux platforms, ... COLUMNS is there on my just installed Mandrake 7, a new Storm install, a Red Hat 5.2, 6.1, and a Mandrake 6.x. In my world thats almost universal, although the sometimes accessed Solaris system doesn't have it. Also, if you use curses there is a stdscr.getmaxyx() function. -Doug- From pharris at crosswinds.net Thu May 25 17:45:23 2000 From: pharris at crosswinds.net (Phil) Date: Thu, 25 May 2000 22:45:23 +0100 Subject: XML to SQL or XML into Tables SomeHow References: <392e080f.1310806219@news.online.no> Message-ID: <392d9fa5@news.server.worldonline.co.uk> Couldn't you use xslt to do the transformation, since that is its purpose "Thomas Weholt" wrote in message news:392e080f.1310806219 at news.online.no... > Hi, > > I want to submit a special formattet xml, nothing more than xml based > on a specified DTD, to a module/script that "transforms" the xml data > to a valid SQL insert-statement. > > Ex. > > > > > > > > > > > > > > > > >
    >
    >
    > > I want an output like : > > # SQL-statements > > use test; > insert into person > (name, sex) > values > ("thomas", "male"); > > insert into person > (name, sex) > values > ("bill", "male"); > > insert into person > (name, sex) > values > ("jane", "female"); > > ################## > > Perhaps the entries must have a specified type like > etc. > > For simple insertion statements this shouldn`t that hard to do, but > I`m having a hard time locating the stuff to do it. > > I`ve looked at RAX, SAX, Pyxie etc. If somebody could give me a hint > on how to "transform" the example above I`d be happy to try and make a > more generic module out of it. I just need some help to get started. > > Thomas From pinard at iro.umontreal.ca Sat May 13 20:35:36 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 May 2000 20:35:36 -0400 Subject: HEAP/priority queue In-Reply-To: =?iso-8859-1?q?Fran=E7ois?= Pinard's message of "13 May 2000 18:22:21 -0400" References: <391CA714.3EB0E8B5@san.rr.com> Message-ID: Fran?ois Pinard writes: > if ((high+1 < len(array) > and compare(array[high], array[high+1]))) > 0: Of course, this should have been: > if ((high+1 < len(array) > and compare(array[high], array[high+1]) > 0)): -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Mon May 29 11:35:40 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 29 May 2000 11:35:40 -0400 Subject: Bytecode In-Reply-To: "=?iso-8859-2?q?Przemys=B3aw_G._Gawro=F1ski?="'s message of "Mon, 29 May 2000 13:51:40 +0200" References: <393259CC.EFA3DD1E@obop.com.pl> Message-ID: "Przemys?aw G. Gawro?ski" writes: > How portable is the bytecode ? Can I take pyc file to different computer > and will it run ? (ofcource having all the needed libs and moduls there) I've read somewhere that it is portable. I do not know if it is portable across Python versions, however. -- -------------- next part -------------- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From max_thomsen at my-deja.com Tue May 30 21:25:55 2000 From: max_thomsen at my-deja.com (max_thomsen at my-deja.com) Date: Wed, 31 May 2000 01:25:55 GMT Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> Message-ID: <9op8jssrecc7h0r0g61j213rda1iedtihv@4ax.com> Guido van Rossum wrote: [snip] > Oh, and to top it all off, I'm going on vacation. I'm getting married > and will be relaxing on my honeymoon. For all questions about > PythonLabs, write to pythonlabs-info at beopen.com. Ha. Good joke. Relaxing on a honeymoon. You'll be pouring the real python -- a spitting cobra v6.0, more like -- to Mrs van Rossum, which is a far cry from relaxation. I imagine you'll come back to work relaxed, though. From embed at geocities.com Thu May 18 16:27:29 2000 From: embed at geocities.com (Warren Postma) Date: Thu, 18 May 2000 16:27:29 -0400 Subject: Pointless Diversion: Volume of a partially filled cylinder lying on it's side Message-ID: Anyone ever want to know how much gasoline or oil is in a storage tank, given only the height of the gasoline or oil? Since gas storage tanks, tanker trucks, etc, are often cylinders and lying on their sides, it's a pain to calculate their volume. I found a great volume calculator (javascript) here: http://grapevine.abe.msstate.edu/~fto/tools/vol/ And I borrowed the algorithm to make this python version (cylindervolume.py). I wish I was clever enough to remember all the trig that goes into this sort of thing. Now that I've done that, it just occurred to me that the trucks that deliver gasoline to your local gas station don't have purely cylindrical tanks, but instead, are a flattened looking oval-cylinders. So what is it called when you extrude an oval into 3d? Ovoids? I'll save that for version 2.0. Oh, and what if the ends of the tanks are rounded instead of flat. At least rounded tanks are up on his web page. Warren Postma begin 666 cylindervolume.py M:6UP;W)T(&UA=&@-"@T*(R!6;VQU;64 at 17%U871I;VYS(%-O;'9E<@T*(R!0 M87)T:6%L;'D at 1FEL;&5D($-Y;&EN9&5R($QA>6EN9R!/;B!I=',@2!3+B!$+B!&:6QI<"!4;R!0:&0N(%!%#0HC#0HC M('1R86YS;&%T960 at 9G)O;2!*879A4V-R:7!T('1O(%!Y=&AO;B!B>2!787)R M96X at 4&]S=&UA(%MW<&]S=&UA0'IT6QI;F1E6QI;F1E2!I;B!D M96=R964-"B @("!A,2 ]("AA("H@;6%T:"YP:2 O("@R+C @*B Q.# N,"DI M(",@:&%L9B!A;F=L92!I;B!R860-"B @("!R(#T at 86)S*&9L;V%T*')A9&EU M6QI;F1E<@T*(" @(" @("!H M,2 ]("@R+C @*B!R("T@:"D-"B @(" @(" @ M,B J(&P-"B @(" @(" @2!R#0H@(" @2!O9B!T:&5S92!P87)A;65T97)S.B!L96YG=&@L:&5I M9VAT+'9O;"QA;F=L92QR861I=7,B#0H@(" @;VL], T*(" @(&EF('9O;#T] M3F]N93H-"@EI9B H;&5N9W1H(#P^3F]N92!A;F0@" ](&5X("L@,0T*(" @('1R>3H-"B @(" @(" @;B ] M('-O;'9E*&QE;F=T:#TQ,"XP+&AE:6=H=#TQ,"XP*2 C(&YO="!E;F]U9V at - M"B @("!E>&-E<'0 at 5F%L=65%" K(#$- M"B @("!T" ](&5X("L@,0T* M(" @(&EF("AE>" \(#,I. at T*(" @(" @("!P&-E<'0 at 5F%L=65% I want to use a function such as "flock()" on WindowsNT. On unix, it seems "fcntl" module is available. Is there any way on NT ? Thanks for reading this article. From JoeSmith at bogusaddress.com Sat May 6 20:53:11 2000 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Sun, 07 May 2000 00:53:11 GMT Subject: win32all-129-update.exe - Is it needed? Message-ID: On the starship site is says: Also download and install the patch set for build 129 - win32all-129-update.exe (663,799 bytes) Is this needed if one installs win32all-129.exe? From dale at out-think.NOSPAMco.uk Fri May 19 08:31:31 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 19 May 2000 13:31:31 +0100 Subject: HTML search engine written in Python - is there one? References: <34575A892FF6D1118F5800600846864D2F0636@intrepid> Message-ID: <8g3c7m$nf4$1@supernews.com> If you're running it on NT, there's a free search engine you can tap into that comes as part of the NT 4.0 option pack. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Simon Brunning wrote in message news:34575A892FF6D1118F5800600846864D2F0636 at intrepid... > I need something that will build an index of the text content of a > number of HTML files, and allow you to nun queries on the index. > Does anyone know of such a thing, or am I going to have to write my > own? > > -- > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > The opinions expressed are mine, and are not necessarily those of my > employer. All comments provided "as is" with no warranties of any > kind whatsoever. > > > > From paul at prescod.net Tue May 30 12:44:21 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 30 May 2000 11:44:21 -0500 Subject: Python for project planning tool References: <3933C0D0.63B8731A@NOSPAM.philips.com> Message-ID: <3933EFE5.8D7F6F93@prescod.net> Jeroen Lamain wrote: > > Hello, > >... > > Is python ok for developing such a tool ? I mean... is it usable > for a such a kind of project. Will I have enough performance > when writing everything in Python (UI, task scheduler) ? The standard answer is to try and see. If there are bottlenecks, you can recode only those bottlenecks in C and thus combine the ease of development of Python with the performance of C. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From mmorris at mindspring.com Wed May 24 01:45:39 2000 From: mmorris at mindspring.com (Mitchell Morris) Date: 24 May 2000 05:45:39 GMT Subject: Graphical User Interface application References: Message-ID: <8F3DE03A5beable@207.211.168.81> jilanik at tin.it (Jilani Khaldi) wrote in : >Hi All, >I wonder if it is possible to write graphical user interface applications >using Python, like in VB? If yes, what do I need then? > >Thanks. > >Jilani > > I see many people have answered one possible interpretation of your question, but have neglected that you may be asking something else entirely. That said, I'll step up to the plate: I am aware of no tool that does everything for Python that VB does for BASIC. That is, you can find drag-and-drop editors for GUI component layout with Python as a target language, Python-aware editors including some lovely folding ones, and there might even be "property sheet" add-ons somewhere. Unfortunately, nobody has integrated all those parts into a single unified IDE. The more I think about it, however, the more I wish I was wrong, as that would be the bee's knees. I've given this a teeny little bit of thought, and have come to the conclusion that the hardest part would be integrating the Python core into said editor so you could run your program, pause it mid-stream, edit some stuff, and resume execution. It's probably trivial for guys smarter than me (and there's plenty of those), but that's where I stumble. From aa8vb at yahoo.com Tue May 30 08:16:41 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 30 May 2000 08:16:41 -0400 Subject: Microthreads: wait( duration ) with minimal processor overhead, u In-Reply-To: <392F494E.AB935747@san.rr.com>; from jkraska1@san.rr.com on Sat, May 27, 2000 at 04:01:32AM +0000 References: <392F494E.AB935747@san.rr.com> Message-ID: <20000530081641.A3015914@vislab.epa.gov> Courageous: |Eh? These are *microthreads*. Using thousands and thousands |of "normal" threads will clobber your cpu. And yet in a very |simple test of microthreads, I was able to spawn up 10,000 of |them and watch them finish in under 3 seconds flat. Quite |remarkable. In Python, are normal threads kernel threads, and "microthreads" user-space threads? Is that the distinction? (A python.org search turned up no useful information.) Thanks, Randall -- Randall Hopper aa8vb at yahoo.com From jhe at webde-ag.de Thu May 11 08:45:21 2000 From: jhe at webde-ag.de (Juergen Hermann) Date: Thu, 11 May 2000 13:45:21 +0100 Subject: Const-Correctness of Python/C Message-ID: <20000511114535146.AAA71.378@pcfue9> Hi! Some calls in the Python/C API, namely PyObject* PyImport_ImportModule (char *name) are (I assume) not const-correct. In the above example, I figure that the "name" argument is NOT changed, but that is not advertized. This either forces you to cast away constness from parameter you pass on in your own const-correct code, or create an unnecessary duplicate. Could this be fixed within the 1.6 schedule? (I'd be happy to provide a list) Ciao, J?rgen -- J?rgen Hermann (jhe at webde-ag.de) WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe Tel.: 0721/94329-0, Fax: 0721/94329-22 From m.faassen at vet.uu.nl Mon May 22 05:52:59 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 09:52:59 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> <91egis4v9spsp8iteg0p4ok4bimlv4mr5t@4ax.com> Message-ID: <8gb01r$bhu$4@newshost.accu.uu.nl> Remco Gerlich wrote: > Ben Wolfson wrote in comp.lang.python: >> On 21 May 2000 18:22:26 GMT, scarblac-spamtrap at pino.selwerd.nl (Remco >> Gerlich) wrote: >> >> >Besides, it's apparently easier >> >to use for newbies, who have never learned that 'Friend' and 'friend' are >> >completely unrelated words. >> >> Then they should learn that they are. > Why? I don't see a lot of added benefit. If case insensitivity is both > easier to learn and easier to read, that sounds like Python to me. Python also has indentation marks block structure. You know, the lack of 'free form' blocks that's often bemoaned by people who haven't actually tried it (and some who have, of course, but few). I'd say the lack of free form casing would fit this general philosophy, and have the same type of benefit: more readable code. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jhauser at ifm.uni-kiel.de Wed May 24 03:31:20 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 24 May 2000 09:31:20 +0200 Subject: NumTut installation problems References: <392B5229.6DE604F7@irl.cri.nz> Message-ID: <87vh04jtfb.fsf@ifm.uni-kiel.de> This means that a function or class array_constructor needs to be present in the module Numeric. This looks like a version mismatch or is at least a bug which originates in a version mismatch. I append the missing function, which needs to be placed in the Numeric.py file, which sits somewhere on your disk. Probably under C:\Program Files\Python\ HTH, __Janko def array_constructor(shape, typecode, thestr, Endian=LittleEndian): x = fromstring(thestr, typecode) x.shape = shape if LittleEndian != Endian: return x.byteswapped() else: return x -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From cfsjtu at smtp.zj.cninfo.net Tue May 30 04:46:50 2000 From: cfsjtu at smtp.zj.cninfo.net (cf) Date: Tue, 30 May 2000 16:46:50 +0800 Subject: crypt on solaris2.6 Message-ID: <003901bfca13$98d5a1b0$97a665ca@dhs.org> HI : Can someone has enable crypt at solaris 2.6? thanks CF From akuchlin at mems-exchange.org Mon May 1 09:48:44 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 01 May 2000 09:48:44 -0400 Subject: ZODB troubles References: <87pur7jgtn.fsf@ethereal.dyndns.org> Message-ID: <3d7lde5qkj.fsf@amarok.cnri.reston.va.us> Nolan Darilek writes: > Test 1 works flawlessly. Test 2 runs, but in order to save the > newly-added function, I have to delete the object from the database > and re-insert it; it can't be modified live it seems. Test 3 works Your Object class has __getattr__/__setattr__ methods, and there are subtleties to writing such methods when using the ZODB, because the ZODB uses the same hooks for its own purposes. If I delete those methods, your example works fine. I thought someone documented the steps required to write a __getattr__ that works with the ZODB, but I can't find it; ask on the zope-dev mailing list. -- A.M. Kuchling http://starship.python.net/crew/amk/ Now. Take this street to New Mexico. -- ??? in DOOM PATROL #50 From Michaell.Taylor at reis.com Thu May 25 12:36:27 2000 From: Michaell.Taylor at reis.com (Michaell Taylor) Date: Thu, 25 May 2000 12:36:27 -0400 Subject: Parallel processing on the cheap? Message-ID: I have what I am sure is a simple problem to which there should be a simple answer. I have python program which processes a large number of simulations which takes a 500 mghrt machine about three weeks to get through. Therefore I want to divide this labor amongst the 8-12 machines sitting around doing nothing in the afterhours. I can do this if I have each machine write a progress statement to a common file (updated roughly every 30 minutes per machine). Each machine can reference this file to "know" what the next step of the computations should be and move to that computation. In this way, multiple instances of the same program run on various machines/platforms can sort of dynamically leapfrog each other to the finish line. I am using : loop structure progress_stamp=open('....') sys.stdout=progress_stamp print scenario progress_stamp.flush() progress_stamp.close() sys.stdout=a_different_output_file loop: compuations print results To accomplish this it seems that I must close the file (as shown), but once closed the same instance doesn't seem to write to it again even given a sys.stdout=progress_stamp command. Not closing the file means that one process dominates. I need all instances to be able to read and write to the file - not at the same time. In general, a process will need rw access to the file to write a single number before wandering off to perform roughly half an hour of computations. What am I missing? Thanks. Michaell Taylor =========================== Michaell Taylor Associate Professor, Dept. of Political Science, NTNU, Trondheim, NORWAY Senior Economist, Economics Research Group, Reis, New York City, USA Adjunct Professor, University of Durban, South Africa From aahz at netcom.com Thu May 4 11:45:10 2000 From: aahz at netcom.com (Aahz Maruch) Date: 4 May 2000 15:45:10 GMT Subject: Map lots of words to lots of integers References: <39176ae0.613278087@news.online.no> <39188472.619823849@news.online.no> Message-ID: <8es5u6$sd0$1@nntp9.atl.mindspring.net> In article <39188472.619823849 at news.online.no>, 5?HH575-UAZWKVVP-7H2H48V3 wrote: > >In my application I need to make an intersection of several lists >returned from lookups in the database, so if they`re all huge I might >run out of memory. > >I`m indexing files on cd-roms and the number of ids can be up into the >millions. Why not use a real database? That's what they're for? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From infonuovo at email.com Sun May 14 19:40:36 2000 From: infonuovo at email.com (Dennis E. Hamilton) Date: Sun, 14 May 2000 16:40:36 -0700 Subject: AI and Python - Eliza and Counseling Humans In-Reply-To: <#26g7HIv$GA.269@cpmsnbbsa04> Message-ID: The last version of Eliza that I saw was written in Basic, so this should not be a big job. I don't know if one is available in Python though. I want to move from the practicality of analyzing natural-language question responses to the possible undesirable consequences of using such technology, regardless of technology availability. Joe Weizenbaum has written at length about his distress at seeing people use Eliza, his creation, as if there were a benign human at the other end of the dialog. Also, when the accomplishment of Eliza was taken as evidence for suitability of natural-language dialog in a clinical therapeutic capacity, Joe expressed even more concern. I do not know what the current view of medical or counseling professionals is at this point, but I suggest that using a computer to interact with "kids in trouble" is not necessarily a constructive action, and needs to be examined very carefully. (These days, there are probably liability considerations, too.) I don't have a good picture of what it is you are trying to do, but I suspect that having kids speak to an attentive, trustworthy counselor or peer is far superior. Is there a support hot-line for kids in your community? Your application may well be harmless. I just didn't want to let your questions go by without making sure you are aware of the concerns that have been raised around use of Eliza-like programs in non-trivial human-interaction situations, especially ones where genuine human contact is the most important element needed. -- Dennis AIIM DMware Technical Coordinator I am traveling until June 1, 2000, and am best reached via E-mail until then. Dennis E. Hamilton ---------------------------- InfoNuovo mailto:infonuovo at email.com http://www.infonuovo.com -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of lexberezhny Sent: Friday, 12 May 2000 19:27 To: python-list at python.org Subject: Re: AI and Python Hi, I was wondering if there was a version of eliza in python? - Lex Chris Ryland wrote in message news:Yi2T4.266$mh3.4671 at news... > http://www.norvig.com/python-lisp.html > > is a good comparison of Lisp and Python (Lisp being the canonical AI > language). There's more on that web site as well. > -- > Cheers! > / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com > > "lexberezhny" wrote in message > news:OwZBsfGv$GA.306 at cpmsnbbsa04... > > I was wondering if anyone has dont any artificial inteligence with Python. > > I am writing a program for my school, which is ment to talk to kids in > > trouble, it will ask some simple questions based on the student answers, > > there is already a list of questions that we might want answered, so its > not > > really AI. But I wanted any opinions on this topic. Thanks. > > > -- http://www.python.org/mailman/listinfo/python-list From srn at fn.com.au Sun May 21 08:24:52 2000 From: srn at fn.com.au (Stephen Robert Norris) Date: Sun, 21 May 2000 12:24:52 GMT Subject: Case [in]sensitivity Message-ID: I've been reading this for a while now, and my biggest worry isn't the prospect of a case-insensitive python - after all we can just go on with 1.x and fork the user group and see who wins. No, rather my worry is about the perception of Python breaking. I'm working on a multi-million dollar project for a large bank, and we're proposing Python for the development. We have a lot of anti-Python arrayed against us, and this sort of thing would do us in - we'd be back to Java within a day or two. Sad, really, but that's the world. I guess if it lets Guido push his own CP4E barrow, good luck to him, but for those of us in the trenches it's just so much more incoming fire (and friendly fire isn't better than any other sort). Stephen From lars.lundstedt at telia.com Wed May 3 13:12:35 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Wed, 03 May 2000 17:12:35 GMT Subject: Best way to convert a list to a dictionary Message-ID: <76ZP4.2558$wYl.196706304@newsb.telia.net> I have a list where each element is another list with two elements. What is the best way to convert this to a dictionary? Any ideas? /LasseLu From Shiv at pspl.co.in Tue May 9 09:44:42 2000 From: Shiv at pspl.co.in (Shiv Shankar Ramakrishnan) Date: Tue, 9 May 2000 09:44:42 -0400 (EDT) Subject: Python on 64 bit/IA-64 ... Message-ID: Hi, Has there been any work done to make Python take advantage of a full 64 bit environment? More specifically is anyone working on an Intel IA-64 port of Python? In particular if one were to change the sources for this then which data model would one follow - LP64 or LLP64 (P64)? Which model have people used for existing 64 bit platforms if they did a port? AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited precision (emulation). Floating points are m/c dependent but mostly doubles. So this is what I think might be good for IA-64 - Pointers - All 64 bit. Int - 64 bit. Long - As it is now. Floating Point - double (As now) or should it be long double? Making floating points long double will get better precision but then the results might differ from the double based ones. Any comments? Also any general advice on doing a 64 bit port of Python. Things to watch out for? Pitfalls etc ... Please note that I am not making any promises about an IA-64 port as of now :-) Thanks, Shiv P.S. If you something significant to say please cc a copy to me by E-mail also. From urner at alumni.princeton.edu Sat May 27 15:26:59 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sat, 27 May 2000 12:26:59 -0700 Subject: Draft web text re vectors, quadrays, python, spatial geometry, crystallography, peer review solicited Message-ID: The essay below is on its way to the web, where it will be supplemented with pictures and hyperlinks. I'm posting it here with an invitation for feedback re how to improve it. Please cc: pdx4d at teleport.com if you have pertinent remarks and/or questions. Thanks in advance. Kirby Urner 4D Solutions May 27, 2000 ======================================= [NO TITLE] INTRODUCTION Quadrays may be considered a subclass of a more generic Vector class. Quadrays define four basic directions, from the center of a regular tetrahedron to its four corners, and map all other points in space relative to these four vectors, labeled (1,0,0,0)(0,1,0,0)(0,0,1,0)(0,0,0,1) -- with (0,0,0,0) their common origin. Are quadrays new? They certainly have some features in common with the barycentrics and other homogenous coordinate systems. This essay summarizes the work of various individuals without advancing anyone's claims to priority. I invite readers to provide me with feedback about prior and/or contemporaneous partially overlapping research. GEOMETRIC IMPLEMENTATION Quadrays may be scaled and added in the usual fashion when considered geometrically, i.e. a vector sum may be depicted as a series of arrows placed tip to tail. The end result is a vector from the origin to the last vector tip. Multiplication by a floating point or real number k stretches a "Qvector" if k>1 and shrinks it if 0==0, where {} means "all permutations of the enclosed members". Note also that we have no need for negative numbers in the normalized 4-tuple, given all four basis vectors are positive (or unsigned). COMPUTER LANGUAGE IMPLEMENTATION My background as a math teacher, computer literarcy text book contributor, and computer programmer, predisposes me to blend more conventional mathematics notations with a programming language. In March, 1999, FoxPro Advisor, a trade magazine for Xbase application developers, published my article about using quadrays to drive ray tracings of colorful polyhedra (see: http://advisor.com/Articles.nsf/ID/FA9903.URNEK01). Since writing that article, I've become enamoured of Python as a teaching language, because of the interactive command line environment and spare, readable syntax. And unlike Xbase, Python is free and cross-platform. The section below is a transcript of an interactive Python session, with >>> prompting user input. Computer output is flush to the left. Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.6 -- press F1 for help >>> >>> from coords import Qvector >>> v = Qvector((1,0,0,0)) # v = one of the basis quadrays >>> -v # -v still has all positive coords Qvector (0, 1, 1, 1) >>> w = Qvector((2,3,1,1)) # all 4 coords > 0 >>> w # normalized form of same Qvector Qvector (1, 2, 0, 0) >>> x = Qvector((0,1,1,1)) # compare with -v >>> y = v + x # y = v + (-v) >>> y Qvector (0.0, 0.0, 0.0, 0.0) >>> z = Qvector((3,3,3,3)) # any (d,d,d,d) = (0,0,0,0) >>> z Qvector (0, 0, 0, 0) >>> r = Qvector((-1,-2,0,4)) # use negatives when initializing >>> r # normal form has no negatives Qvector (1, 0, 2, 6) NORMALIZATION Clearly vector addition and negation are being handled according to some different (non-XYZ) rules. Specifically, to obtain the normal form of a quadray, we subtract its lowest coordinate from the other 4, an operation with no net effect because (d,d,d,d)= (0,0,0,0). Here's the algorithm: def norm(self,plist): # normalize such that 4-tuple all non-negative members # with at least one zero member return tuple( map(lambda x, y=min(plist): x-y, plist) ) The "lambda" operator is Python's way of letting us define a function "on the fly", with x, y as parameters in this case. plist is a passed 4-tuple, e.g. (-1,-2,0,4), with min(plist) putting the lowest coordinate e.g. -2 in y by default. The "map" operator then applies the rule x-min(plist) to each member of plist, i.e. x becomes each member of plist in turn. The resulting tuple is returned as the normalized form of the quadray. This method is invoked whenever a quadray is initialized, perhaps as a result of vector addition or subtraction. NOMENCLATURE Whether we use the term "quadray" is not especially critical and depends on the namespace of the author. David Chako originally introduced his 4-tuple vector algebra on Synergetics-L in December, 1996, without using this term, whereas D. Lloyd Jarmusch mentioned using "quadrays" as early as 1981 for essentially the same apparatus. Josef Hasslberger made a similar beginning under the heading of "tetra space coordinates." At one point I played with calling the six Cartesian vectors (i,j,k,-i,-j,-k) "e-rays", because they go from (0,0,0) at the center of a tetrahedron through its six mid-edges (hence "e" for edge). By extension, quadrays could be called "v-rays", because they go through the tetrahedron's four vertices, or, equivalently, "f-rays" through the face-centers (Hasslberger's depiction) -- "equivalently" because the tetrahedron is self-dual, i.e. "through the faces" is "through the vertices" of the dual, also a regular tetrahedron. More important than what they're called is how they work, and here again we have some divergence in their implementation. QUADRAYS, TETRAYS & SIMPLICIAL COORDINATES The most detailed elaboration of quadrays of which I am personally aware occured on Synergetics-L, subsequent to Chako's getting the ball rolling, and in this context the research forked into quadrays and tetrays as distinct topics, the difference being that tetrays use the identity (1,1,1,1) to tick off an additional, fifth "temporal direction". Possibly we'll end up classifying quadrays as a kind of "simplicial coordinate system", where "simplicial" derives from "simplex", another name for the tetrahedron. The differences in implementation may reduce to conventions around how we choose to normalize our 4-tuples. ALTERNATIVE NORMALIZATIONS Quadrays as originally defined by Chako used only non-negative integers, meaning {a,b,c,0} did not sum to any specific constant k = a+b+c+d. On the other hand, because (d,d,d,d) may be added to (a,b,c,d) with no net effect -- (d,d,d,d)= (0,0,0,0) -- we have the option to normalize to any integer we like. The same rules apply if we allow (a,b,c,d) to be real or floating point numbers. Tom Ace used the k=0 normalization to derive a dot product, and a more streamlined distance method, proving the importance of remaining flexible about how we normalize. def norm0(self): # normalize such that sum of 4-tuple members = 0 a,b,c,d = self.quadray() k = (a+b+c+d)/4.0 return tuple( map(lambda x,y=k: x-y, [a,b,c,d]) ) def dot(self,v1): # return the dot product of self with another vector # return a scalar scalar = 0 a = self.norm0() b = v1.norm0() for i in range(4): scalar = scalar + a[i] * b[i] return 0.5*scalar def length(self): # return this vector's length # same method as for XYZ vectors return self.dot(self) ** 0.5 MORE QUADRAY METHODS Ace also came up with a cross product method and 4x4 rotation matrices, with (1,0,0,0)...(0,0,0,1) as the axes of rotation, none of which depend on normalization to zero. Here's a cross product method: def cross(self,v1): # return the cross product of self with another vector # return a Qvector A=Qvector((1,0,0,0)) B=Qvector((0,1,0,0)) C=Qvector((0,0,1,0)) D=Qvector((0,0,0,1)) a1,b1,c1,d1 = v1.quadray() a2,b2,c2,d2 = self.quadray() k= (2.0**0.5)/4.0 sum = (A*c1*d2 - A*d1*c2 - A*b1*d2 + A*b1*c2 + A*b2*d1 - A*b2*c1 - B*c1*d2 + B*d1*c2 + b1*C*d2 - b1*D*c2 - b2*C*d1 + b2*D*c1 + a1*B*d2 - a1*B*c2 - a1*C*d2 + a1*D*c2 + a1*b2*C - a1*b2*D - a2*B*d1 + a2*B*c1 + a2*C*d1 - a2*D*c1 - a2*b1*C + a2*b1*D) return k*sum As Tom Ace explains at his website, the above is simply an expansion of the following determinant: | A B C D | | k k k k | | a1 b1 c1 d1 | | a2 b2 c2 d2 | VOLUME METHODS Ace also developed a volume method consistent with the usual equivalence in XYZ of a scalar triple product with a determinant i.e. | Ax Ay Ax | A dot (B cross C) = | Bx By Bz | (A,B,C are vectors) | Cx Cy Cz | The scalar triple product likewise gives the volume of a parallelepiped with edges ABC from a common vertex, or of a corresponding tetrahedron, if we multiply the above scalar by k=(1/6) -- plus take the absolute value if we want to eliminate a possible negative sign. The volume of tetrahedron ABCD using quadray coordinates is likewise |k*det[M]| where AB, AC, AD = quadrays (a1,b1,c1,d1),(a2,b2,c2,d2),(a3,b3,c3,d3) and M is the matrix: | 1 1 1 1 | | a1 b1 c1 d1 | | a2 b2 c2 d2 | | a3 b3 c3 d3 | If we set k=(1/4), then the volume of a regular tetrahedron with all edges 1 would be 1 (see below). An regular icosahedron consisting of 20 irregular tetrahedra, with radials of ~0.951 and outer edges = 1, would have a volume of about 18.51. >>> ico = Icosahedron() # create Icosahedron object >>> ico.vertices["O1"].length() # a center-to-vertex vector 0.95105651629515353 >>> ico.volume # compute volume 18.512295868219159 The Icosahedron's constructor method sets the starting volume using the expression: 20*vol(O1,P1,R1) where the vol method returns (1./4.)*abs(det((O1,P1,R1))). O1,P1,R1 are vectors from the icosa's center to the three vertices of one triangular facet. Vectors define direction. Any 3 non-coplanar edges of a tetrahedron, expressed as vectors, will provide sufficient information to determine the other three edges. These vectors may either share a common vertex, or define an "open triangle" zig-zag. Either way, they provide sufficient input for various vector-based volume methods. In contrast, simple edge lengths, being scalar quantities, do not define direction. To specify three non-coplanar lengths does not uniquely determine the remaining three edges. If we label a tetrahedron's six edges a,b,c,d,e,f -- a,b,c connecting a common vertex to an opposite triangle with edges d,e,f -- then we will need all six values in order to compute a specific volume. Leonhard Euler long ago solved the problem of how to express a tetrahedron's volume solely in terms of its edge lengths. Java programmer Gerald de Jong rederived the method and expressed his result in the form of a Java applet. The computation involves using "closed triangles" (edges from the same face), "open triangles" (3-edge zig-zags), and "opposite pairs" (edges with no endpoints in common). Gerald's expression is also specifically designed to return a volume of 1 when the six edges of the tetrahedron are 1. Here's a Python version of the algorithm: def vol2(edges): a2,b2,c2,d2,e2,f2 = map(lambda x: x**2, edges) open = ( f2 * a2 * b2 + d2 * a2 * c2 + a2 * b2 * e2 + c2 * b2 * d2 + e2 * c2 * a2 + f2 * c2 * b2 + e2 * d2 * a2 + b2 * d2 * f2 + b2 * e2 * f2 + d2 * e2 * c2 + a2 * f2 * e2 + d2 * f2 * c2 ) closed = ( a2 * b2 * d2 + d2 * e2 * f2 + b2 * c2 * e2 + a2 * c2 * f2 ) oppos = ( a2 * e2 * (a2 + e2) + b2 * f2 * (b2 + f2) + c2 * d2 * (c2 + d2)) return (abs(open - closed - oppos)/2.0)**0.5 This method has nothing specifically to do with quadrays, since length is an attribute of the generic Vector class. I mention it more because of its historical role in the quadray thread on Synergetics-L. David Chako conjectured that all tetrahedra with vertices at the centers of fcc spheres might have whole number volumes, provided the initial tetrahedron -- defined by four intertangent fcc spheres -- were defined as volumetric unity. Until Robert Gray developed an algebraic proof for this conjecture, de Jong's Java applet and a MathCad worksheet featuring Euler's original formula, provided an initial source of empirical evidence for its validity (i.e. failed to turn up any counter-examples). Other volume methods would have served, but this was how events actually unfolded. In terms of quadrays, fcc sphere centers may be expressed as sums of vectors with coordinates {2,1,1,0}. For example, if s were an fcc sphere center, s + (2,1,1,0) + (1,1,2,0) + (1,2,0,1) = (4,4,3,1) = (3,3,2,0) would be another fcc sphere center relative to s. I will return to quadrays in a sphere packing context in the notes on crystallography below. CONVERTING TO/FROM XYZ (ONE POSSIBLE IMPLEMENTATION) Differences in implementation may arise around how we choose to define quadrays in relation to XYZ. Perhaps the most obvious convention would be to define the length of each basis vector {1,0,0,0} as unity. However, in my own research, it's more useful and practical to apply a different "control length", such that the six edges of the "home base" tetrahedron are either 1 or 2 units. This is because my home base tetrahedron is constructed by closest- packing four equi-radius spheres, such that sphere centers define the tetrahedron's four vertices. This means the tetrahedron's edges are 2R (R=sphere radius) or 1D (1=sphere diameter). Therefore I want my four quadrays to have a length of root(6)/2 or root(6)/4 respectively. >>> v = Qvector((1,0,0,0)) >>> v.length() 0.61237243569579447 >>> 6**0.5/4.0 # compare with root(6)/4 0.61237243569579447 With these preliminaries out of the way, we have sufficient information to uniquely pair normalized (a,b,c,d) Qvectors with Cartesian (x,y,z) Vectors and vice versa: >From the Vector class: def quadray(self): # return (a,b,c,d) quadray based on current (x,y,z) x=self.xyz[0] y=self.xyz[1] z=self.xyz[2] a = (2/root2) * ((x>=0)*x + (y>=0)*y + (z>=0)*z) b = (2/root2) * ((x<0)*(-x) + (y<0)*(-y) + (z>=0)*z) c = (2/root2) * ((x<0)*(-x) + (y>=0)*y + (z<0)*(-z)) d = (2/root2) * ((x>=0)*x + (y<0)*(-y) + (z<0)*(-z)) return self.norm((a,b,c,d)) >From the Qvector subclass of Vector: def __init__(self,arg,*flag): # initialize a vector at an (a,b,c,d) tuple (= arg) # NOTE: in accompanying essay, xyz units = sphere diameter # i.e. Vector((1,0,0)).length() is 1 D, therefore quadray # inputs must be scaled by 1/2 to fit this context, i.e. # tetra edge defined by 2 basis quadrays = 1 D. if len(arg)==3: arg = Vector(arg).quadray() # if 3-tuple passed self.coords = self.norm(arg) a,b,c,d = self.coords self.xyz = ((0.5/root2) * (a - b - c + d), (0.5/root2) * (a - b + c - d), (0.5/root2) * (a + b - c - d)) Let's look at these methods in action: >>> from coords import * >>> i = Vector((1,0,0)) >>> i.xyz (1, 0, 0) >>> i.quadray() (1.4142135623730949, 0.0, 0.0, 1.4142135623730949) >>> j = Vector((-1,0,-3)) >>> q = Qvector(j.quadray()) >>> q Qvector (0.0, 1.4142135623730949, 5.6568542494923797, 4.2426406871192848) >>> q.xyz (-0.99999999999999978, 0.0, -2.9999999999999996) Note that floating point numbers lose a small amount of information as we convert back and forth between Qvectors and Cartesian Vectors (or "Cvectors"). USEFULNESS IN SPATIAL GEOMETRY "Are quadrays useful?", is the final question I should address, as I reach the close of this essay. I've found them to be so in the context of conceptualizing the relationships among polyhedra. The initial home base tetrahedron with coordinates (1,0,0,0), (0,1,0,0)(0,0,1,0)(0,0,0,1) will generate 22 other points of interest by simple vector addition (negation is not required). These 26 points A-Z are sufficient to define a tetrahedron, inverse tetrahedron, cube, octahedron, rhombic dodecahedron and cuboctahedron (David Chako supplied coordinates for the first few of these in his initial post on the topic). Furthermore, the size and orientation of these six shapes matches that given by R. Buckminster Fuller in his 'Synergetics', wherein these shapes all have whole number volumes, given the tetrahedron is Fuller's geometric model of 3rd powering (i.e. 1x1x1 = unit volume tetrahedron). So with Qvectors, we bring whole number coordinates to an initial set of shapes which already have whole number volumes. This is an aesthetically pleasing construct, and may help streamline the introduction to both spatial geometry and object-oriented programming, as per my "numeracy + computer literacy" approach (currently Python-focused). """ By Kirby Urner, Oregon Curriculum Network Ver 0.1: May 24, 2000 """ from coords import * import math #==================[ Points of Interest ]==================== """ * 26 data points A-Z define six polyhedra in the concentric hierarchy * the Jitterbug Transformation creates a basis for additional vertices Labels of Numbers of Shape Volume Vertices Vertices, Edges, Faces --------------------------------------------------------- Tetrahedron 1 A-D 4 6 4 Inv Tetra 1 E-H 4 6 4 Duo-tet Cube 3 A-H 8 12 6 Octahedron 4 I-N 6 12 8 Rh Dodecahedron 6 A-N 14 24 12 Cuboctahedron 20 O-Z 12 24 14 See: http://www.inetarena.com/~pdx4d/ocn/graphics/povlabels.gif Using the quadray apparatus (4 basis vectors to the corners of a regular tetrahedron with edges = 1 sphere diameter) See: http://www.teleport.com/~pdx4d/quadray/quadray.gif """ A = Qvector((1,0,0,0)) # center to corner of tetrahedron B = Qvector((0,1,0,0)) # " C = Qvector((0,0,1,0)) # " D = Qvector((0,0,0,1)) # " # tetrahedron's dual (also a tetrahedron i.e. inverted tet) E,F,G,H = B+C+D, A+C+D, A+B+D, A+B+C # tetrahedron + dual (inverted tet) = duo-tet cube # octahedron vertices from pairs of tetrahedron radials I,J,K,L,M,N = A+B, A+C, A+D, B+C, B+D, C+D # octahedron + dual (cube) = rhombic dodecahedron # cuboctahedron vertices from pairs of octahedron radials O,P,Q,R,S,T = I+J, I+K, I+L, I+M, N+J, N+K U,V,W,X,Y,Z = N+L, N+M, J+L, L+M, M+K, K+J ... APPLICATIONS TO CRYSTALLOGRAPHY Quadrays take to a sphere packing context like fish to water and so might serve some streamlining role in crystallography. Scott Childs has researched this possiblity. Russell Chu's investigations are also relevant in this connection. The 12 quadrays {2,1,1,0} define the vertices of a cuboctahedron relative to the origin (0,0,0,0). This arrangement, with 12 nearest neighbors at the corners of a cuboctahedron, is the face centered cubic lattice (fcc). Quadrays with integer coordinates define the centers of fcc spheres, as well as the centers of all tetrahedral and octahedral voids between these spheres. Given the volume expression (1/4)|k*det[M]|, we know that any non-coplanar arrangement of any four such vertices (i.e. with integer coordinates) will define a tetrahedral volume evenly divisible by 1/4. Those tetrahedra with all vertices in the same fcc lattice will have whole number volumes (a sufficient, but not a necessary condition). Selectively illuminated, these all-integer, quadray defined vertices may present face centered, body centered, hexagonally close packed, or simple cubic arrangements of points. We may also sort all these vertices into four interpenetrating fcc lattices, using the rhombic dodecahedron for guidance. Rhombic dodecahedra fill space in an fcc pattern, with the spheres inscribed and intertangent through the rhombic face centers. The corners of the rhombic dodecahedron occur at the centers of the voids surrounding each fcc sphere. The rhombic dodecahedron has 8 points at the opposite ends of short face diagonals, in a cubic arrangement -- this is the cube of volume 3, relative to the dodeca's volume of 6. This cube defines two interpenetrating unit-volume tetrahedra, A-D and E-H, as per the above labeling scheme (see 26 points of interest). To each tetrahedron, there corresponds a unique fcc lattice. In addition, the remaining 6 vertices of the rhombic dodecahedron, which occur at opposite ends of long face diagonals, define an octahedral arrangement. The corresponding vectors, I-N, define yet another fcc lattice. The sphere at the center of our rhombic dodecahedron, at (0,0,0,0), has 12 nearest neighbors O-Z. This is the original lattice. So we may identify the four lattices as follows: {(1:'O-Z'),(2:'I-N'),(3:'A-D'),(4:'E-H')}. Vertices from 1+2, or 3+4, will define a simple cubic lattice. All 4 lattices taken together will define a body cubic centered lattice. The hcp arrangement cannot be expressed as a sum of whole fcc lattices, but its vertices will nevertheless have all integer quadray coordinates. From claird at starbase.neosoft.com Thu May 25 13:57:50 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 May 2000 12:57:50 -0500 Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> <3dwvkiac4w.fsf@amarok.cnri.reston.va.us> <8gjive$bed$1@slb6.atl.mindspring.net> Message-ID: In article <8gjive$bed$1 at slb6.atl.mindspring.net>, Aahz Maruch wrote: . . . >Who is Robin Friedrich? . . . Local host for the IPC-before-last, and more: -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From petersc at stud.ntnu.no Wed May 17 14:17:28 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 17 May 2000 20:17:28 +0200 Subject: Decimals -> Fraction strings, my solution References: <3922bbbb.59529999@client.ce.news.psi.net> Message-ID: <3922E238.29CEDE3B@stud.ntnu.no> Dave Hansen wrote: > > A very nice implementation of Euclid's algorithm. I would suggest a > couple small changes to make it more robust. Shouldn't hurt the > efficiency significantly... > > > > >def gcd(a, b): > a = abs(a) > b = abs(b) Probably a good idea given Python's implementation of modulo. > if b > a: > a, b = b, a This is IMHO absolutely unneccessary and just bloats the code. Why do you want to check when in the case that b is greater than a the first step just reverses the arguments? So in case b is greater than a you trade in a division against a comparison and more code. In the case that a is already greater than b you gain nothing and pay a comparision and more code. Ha det bra Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From jsolbrig at my-deja.com Fri May 5 14:04:20 2000 From: jsolbrig at my-deja.com (jsolbrig at my-deja.com) Date: Fri, 05 May 2000 18:04:20 GMT Subject: comp.lang.python-announce Message-ID: <8ev2en$d85$1@nnrp1.deja.com> Hi, I don't have direct access usenet and I have not been able to find a way to either read or post to comp.lang.python-announce. Both eGroups and deja don't give anything. I sent email to python-announce at python.org and it bounced. This seems to have to do with python-starship having crashed. Anyone have any idea when things will be up and running again? I noticed that the news on python.org is about a month out of date, so does comp.lang.python-announce even exist anymore? I already announced my open-source release here but I suspect it's well burried. Thanks In Advance Joe Solbrig jsolbrig at webcom.com Visit: www.crucialquestions.com (Python-based BBS system and hypertext language -alpha release) Emailing any replies to jsolbrig at webcom.com would be appreciated Sent via Deja.com http://www.deja.com/ Before you buy. From hpasanen at my-deja.com Mon May 15 05:46:19 2000 From: hpasanen at my-deja.com (hpasanen at my-deja.com) Date: Mon, 15 May 2000 09:46:19 GMT Subject: Python 1.6 and OpenSSL version required? Message-ID: <8foh19$mhb$1@nnrp1.deja.com> I'm having some problems using the OpenSSL module in Python 1.6a2 Testing using the httplib.py, the HTTP request goes through ok, but at the end I get. python1.6 /usr/local/lib/python1.6/httplib.py . . . testing HTTPS... Traceback (most recent call last): File "/usr/local/lib/python1.6/httplib.py", line 272, in ? test() File "/usr/local/lib/python1.6/httplib.py", line 258, in test h.connect(host) File "/usr/local/lib/python1.6/httplib.py", line 213, in connect ssl = socket.ssl(sock, self.key_file, self.cert_file) socket.sslerror: SSL_connect error This is on Solaris 2.7, OpenSSL 0.9.5a 1 Apr 2000, Python 1.6a2, gcc 2.95.2 Any glues? Harri Sent via Deja.com http://www.deja.com/ Before you buy. From g_will at cyberus.ca Fri May 5 15:09:12 2000 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 05 May 2000 19:09:12 GMT Subject: [ANN] Creating Python Extensions Using Borland's Free Compiler Message-ID: <01bfb6c5$7ec33c80$4041c3d1@Cyberus> *** Creating Python Extensions Using Borland's Free Compiler *** I am pleased to announce a set of step-by-step instructions and examples to create extensions using the free Borland Command Line Compiler. This information can be found at http://www.cyberus.ca/~g_will/pyExtenDL.shtml . ********************************************************************** ABSTRACT This paper describes the method used to create Python Extensions using the Borland 5.5 C++ Compiler (BCC). This command line compiler is available free from http://www.borland.com/bcppbuilder/freecompiler/. I describe the steps that are necessary to produce the extension from the C source code and how to set up the associated files for the compiler and linker. These extensions work with the standard Windows distribution of Python. The process used to produce the extension is very easy and consists of running a simple batch file that I provide as part of this package. I also have some examples and a short reference section at the end of this paper that may be helpful. Gordon Williams g_will at cyberus.ca From digitig at cix.co.uk Sat May 27 18:32:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Sat, 27 May 2000 23:32 +0100 (BST) Subject: Beginners' Question -- Assigning variables in a lambda References: Message-ID: In article , mwh21 at cam.ac.uk (Michael Hudson) wrote: Thanks. I'm not really comfortable with either, though. In my version, handler will have quite a few keys but two or three actual handlers. Your first solution assumes that all keys are handled in essentially the same way (sorry, I may have wrongly implied that when I said what get_number() does). The second solution involves writing a separate handler for each key (ok, so does my failed lambda solution, but it's more compact!) What I really want to do is assign one of the few handlers to each key. All the handlers will assign to a variable which I would really like to be in the local scope of the call, but global scope would do, but they will derive the variable in different ways. For example, the one I've shown interprets the parameter as a string representation of a number and converts it to a numerical representation; another will force the parameter into string form. By the way, I don't mind you asserting on user data. Just so long as you catch the resulting AssertError before it gets to the top! (I hadn't even noticed Python had assert -- I see it's new in 1.5, but it doesn't seem to get much attention in the documentation. Still, another reason Python is fast becoming my favourite scripting language!) > digitig at cix.co.uk (Tim Rowe) writes: > > > Are beginners' questions ok here? (if not, where?) > > Yes. You might want to try python-help or tutor at python.org, though. > > > After I've done my getopt (or maybe instead, if I can get this to > > work) I want to avoid the if/elif/else from hell by having a > > dictionary of parameter names and functions, something like: > > > > handler = { > > # Doesn't work! > > "b": lambda x: eval("bandwidth = get_number(" + x + ")") > > # , ... more here ... > > } > > > > (get_number is essentially string.atof with some special handling) > > then later on do, for example: > > handler["b"]("0.23") > > > > and I'd like to call eval("bandwidth = get_number(0.23)") (it seems > > to get that far) and so assign 0.23 to bandwidth (it won't do that > > bit!) > > > > I suspect my problem is that I need to exec("bandwidth = get_number(" > > + x + ")"), but lambda won't take exec. > > > > Is there a sensible way to do what I'm tying to do? > > Not directly, but there are almost certainly sensible ways of > acheiving your goal. > > One attempt might look like this: > > option2attr = { > "b":"bandwidth", > ... > } > > class Settings: > def __init__(self): > self.bandwith = 9600 > ... > def handle_option(self,opt,val) > setattr(self,option2attr[opt],eval(val,{"__builtins__":{}})) > > settings = Settings() > > for k,v in get_options(): > settings.handle_option(k,v) > > Or similar, but a bit fancier: > > class Settings: > option2meth = { > "b":"set_bandwidth", > ... > } > > def __init__(self): > self.bandwith = 9600 > ... > def handle_option(self,opt,val) > > getattr(self,self.option2meth[opt])(eval(val,{"__builtins__":{}})) > def set_bandwidth(self,val): > assert 300 < val < 100000 # hmm, you shouldn't assert on > # user data, but I'm too lazy to > # change it now... > self.bandwidth = val > ... > > settings = Settings() > > for k,v in get_options(): > settings.handle_option(k,v) > > HTH, > Michael > > -- > There are 'infinite' number of developed artifacts and one cannot > develop appreciation for them all. It would be all right to not > understand something, but it would be imbecilic to put judgements > on things one don't understand. -- Xah, comp.lang.lisp > From sabren at manifestation.com Sun May 21 16:07:23 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sun, 21 May 2000 16:07:23 -0400 (EDT) Subject: case sensitivity and XML In-Reply-To: Message-ID: On Sun, 21 May 2000, Fredrik Lundh wrote: > Michal Wallace (sabren) wrote: > > 11. Given the above, a case-insensitive python cannot parse all > > XML documents. > > Q: does __dict__ has to be the same kind of dictionary as you use to > store XML attributes? Q: does all *existing* Python implementations > use the same dictionary type for namespaces and user dictionaries? I don't know. For sure, you could create some case sensitive dicts and some case insensitive dicts. In fact, a case insensitive dict is trivial: >>> import UserDict, string >>> >>> class CaseInsensitiveDict(UserDict.UserDict): >>> def __setattr__(self, name, value): >>> self.data[string.lower(name)] = value >>> >>> def __getattr__(self, name): >>> return self.data[string.lower(name)] But again, consider JPython importing a module from Java. Java is case sensitive, so javaobject.A has to be different from javaobject.a .. This is similar to a current behavior in JPython. Suppose I take this class: public class Case { public int main; public int main2; public static void main(String[] args) { System.out.println("hi"); } } and import it into JPython: JPython 1.1beta4 on java1.2.2 (JIT: symcjit) Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> import Case >>> dir(Case) ['main', 'main2'] >>> Any guesses what Case.main returns? >>> Case.main That poor little int is lost and gone forever... Probably not a big deal, since it's common practice to use accessor methods.. But what about subclasses versus instances? In java, you could have a nested class, A... and an instance attribute: public A a = A(); A case insensitive Jpython would lose the ability to distinguish the two. > > Does anyone disagree with the conclusion in line 4? Can we have a case > > insensitive Python without case-insensitive string comparisons? > > Q: does *namespace* lookups have to use the standard string comparision > operator? I say it does, for JPython's sake. > > Another argument has to do with Java. In java, X and x are different. What > > does that mean for a case insensitive JPython? That we can only script > > SOME java objects reliably? > > Q: can you think of any *other* environment that has the same problem? > Q: how does Visual Basic talk to Java or C++ components over COM? Q: how > does PythonWin talk to Visual Basic components? Q: how does SAMBA solve > the problem with a case-sensitive server and case-insensitive clients? etc. I don't know about SAMBA. Visual Basic doesn't have the same issue. In VB (at least in VBScript) I create a COM instance like so: Set x = Server.CreateObject("My.Favorite.Component") Is x.ATTRIBUTE the same as x.attribute? Well, actually, I believe they are. This has never caused a problem for me. But the difference is that in VB*, x.A == x.a does not imply that "A"=="a", whereas in python, it does. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From effbot at telia.com Tue May 30 04:29:38 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 30 May 2000 08:29:38 GMT Subject: *blink* That's neat. References: Message-ID: Stephen Hansen wrote: > While writing a function, I curiousely typed this into the Interpreter: > > >>> if Case is not 0 or 1: > .... > > etc..and it worked.. This was rather surprising to me :) "worked" as in "did not give you a syntax error", you mean? ;-) unless guido has abused his time machine again, your interpreter treats this as: if (Case is not 0) or 1: .... which probably isn't what you really wanted to do. or maybe you really wanted to do this? > if Case is not 0 or Case is not 1: > if Case != 1 or Case != 0 same thing here -- unless Case is a really strange object, it cannot be 0 and 1 at the same time, so one side of the "or" is always true. assuming that you really meant "and", how about: if Case not in (0, 1): ... otherwise, if 1: is probably more efficient ;-) also note that "is" compares object identity, not object value. afaik, the language specification doesn't guarantee that all integers having the value "1" also have the same object identity. btw, usability research has shown that "and" and "or" are about the worst names you can use for these operators. how about renaming them in Py3K? ;-) From dale at out-think.NOSPAMco.uk Wed May 24 16:07:17 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 24 May 2000 21:07:17 +0100 Subject: Pass by reference? Message-ID: <8ghcq1$opl$1@supernews.com> How do I pass a value by reference so the called routine can update it? Here's an extract from a routine that uses ADO on NT to access a database. ADO will return the number of records deleted in the second parameter but it's not working like this. DBCon.Execute("delete from parts where path='%s' and drive='%s'" % (drive, path), delcnt) Thanks -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From teemu.keskinarkaus at ramk.fi Mon May 8 04:49:17 2000 From: teemu.keskinarkaus at ramk.fi (Teemu Keskinarkaus) Date: Mon, 08 May 2000 08:49:17 GMT Subject: Week and days Message-ID: <39167ea7.366149144@news.ramk.fi> Hi.. I have project where I need years weeks and week's begin and endday something like this: "Week 19 (8.5. - 14.5.)" I tried to do time tuple and that way to do it but I couldn't get working version. Is there an (easy) way to do it or have someone already done that?? TK From peter at norvig.com Wed May 17 17:13:10 2000 From: peter at norvig.com (Peter Norvig) Date: Wed, 17 May 2000 14:13:10 -0700 Subject: AI and Python References: Message-ID: <39230B65.EB54DC2B@norvig.com> You make a good observation that AI and operations research have a large overlap in the problems they address: basically, what is the right program or policy to decide what to do in a complex, uncertain environment? It is a crime that the fields developed independently with little interaction, but in the last five or ten years this has changed, and AI now encompasses OR techniques, and is much better suited for dealing with real-world programs. -Peter Fran?ois Pinard wrote: > > "lexberezhny" writes: > > > I was wondering if anyone has dont any artificial inteligence with Python. > > I once followed some AI courses in theoretical computer science, and later > worked for years in a few local AI laboratories. The overall impression > that remained from the whole adventure is a lot of fuss, and many buzzwords > wrapping not that many results. :-) > > Later in my life, I returned to university and took operation research. > In many occasions, we were using almost the same "AI" algorithms as before > to solve equivalent problems, without ever using "AI" in our discussions > and without any kind of fuss, just calmly seeking some results among other > sets of results. I felt much more comfortable in that humble efficiency. > > ... From wlfraed at ix.netcom.com Tue May 16 23:17:58 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 16 May 2000 20:17:58 -0700 Subject: IDEs, ID or EGO? (was: Decimals -> Fraction strings, my solution References: <3921D4C6.91B2090F@acm.org> Message-ID: On Wed, 17 May 2000 08:07:50 +0900, Gregory Tucker declaimed the following in comp.lang.python: > nothing but a standard text editor (GVIM). Languages like Java or C++ > typically require one to open an IDE, create a project, drag a few buttons, > insert code, save, compile, etc. > They do? Strange... And here I've been using an archaic editor (EDT) for coding and even for maintenance of makefiles (MMS) for over a decade... Just because M$ doesn't want to reveal all the command line options to work from outside of their "visual" environment doesn't mean the language requires it The only IDEs I work with are on my home computer -- and I don't really develop on that machine (VBA, GNAT/AdaGIDE, Fujitsu COBOL starter pack, PythonWin, ObjectREXX). My real job doesn't have anything so modern... -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From pinard at iro.umontreal.ca Mon May 29 11:30:16 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 29 May 2000 11:30:16 -0400 Subject: Walking recursivly through a directory-structure In-Reply-To: "=?iso-8859-1?q?P=E5l?= Sollie"'s message of "Mon, 29 May 2000 14:51:29 GMT" References: Message-ID: "P?l Sollie" ?crit: > I've been looking at os.path.walk for this, but I'm not sure how to > implement it. Anyone able to point me in the rigth direction? I'm sure examples abound. I have a few on-line, here and there, like: http://www.iro.umontreal.ca/contrib/recode/lib/distroweb.py Just look for occurrences of the `walk' or `walker' strings. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From johngrayson at home.com Thu May 18 06:57:15 2000 From: johngrayson at home.com (John Grayson) Date: Thu, 18 May 2000 10:57:15 GMT Subject: newbie - tkinter - how to do button rollover References: <8fva74$caa$1@nnrp1.deja.com> Message-ID: <8g0ia5$nu9$1@nnrp1.deja.com> In article <8fva74$caa$1 at nnrp1.deja.com>, leapinglemur00 at my-deja.com wrote: > > > I seem to be missing something -- I'd like to do > a "rollover" sort of effect with the image on a > button changing as the mouse goes over it. I > know how to respond to the mouse event, but how > do you change the image? Is there a method on > the Button class to set the image? Is there some > place in the documentation where I could find > this? > > Thanks a lot... > Here is a minimal example. Choose your own images... from Tkinter import * class ActiveButton(Button): def __init__(self, master, inimage=None, outimage=None, activate=None): self.master = master self.inI = PhotoImage(file='icons/%s' % inimage) self.outI = PhotoImage(file='icons/%s' % outimage) Button.__init__(self, master, command=activate, image=self.outI) self.bind('', lambda e, state=1, s=self: s.change(e, state)) self.bind('', lambda e, state=0, s=self: s.change(e, state)) def change(self, event, state): if state: self.configure(image=self.inI) else: self.configure(image=self.outI) if __name__ == '__main__': root = Tk() button = ActiveButton(root, inimage='smooth.gif', outimage='tline1.gif', activate=root.destroy) button.pack() root.mainloop() Sent via Deja.com http://www.deja.com/ Before you buy. From jae at ilk.de Thu May 4 18:53:42 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Fri, 05 May 2000 00:53:42 +0200 Subject: Do I always have to write "self." ? In-Reply-To: <8esoev$oad$1@slb7.atl.mindspring.net> (dalke@acm.org) References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil><20000430170952.A502@datapro.co.za> <8enie0$9n8$1@slb7.atl.mindspring.net> <3911D84D.427382D3@earthlink.net> <8esoev$oad$1@slb7.atl.mindspring.net> Message-ID: <05052000.2@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Andrew" == Andrew Dalke writes: [...] Andrew> h bar isn't not unitless; it's 1.0546 ? 10-34 Joule*sec. ^^^^^^^^^^^^^^^^^^ Uhm, Andrew, you're sure this is what you wanted to say? ;-) *grin* (actually, rather LOL...) Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard Electronic Frontier Foundation (http://www.eff.org) "No matter how cynical I get, I can't keep up." -- Bruce Schneier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjkR/3QACgkQN0B+CS56qs2SlQCeJA+U+zGYcQwgvLQsWOa+Gps4 Pu8An2TtDxzRFZj7+K3DJ0vb3quth0zB =Nysw -----END PGP SIGNATURE----- From amitp at Xenon.Stanford.EDU Tue May 30 14:32:18 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 30 May 2000 18:32:18 GMT Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> <8h0to8$nvr$1@news.udel.edu> Message-ID: <8h11fi$t4t$1@nntp.Stanford.EDU> Terry Reedy wrote: | | "Amit Patel" wrote > * Methods on objects: | > | > We have to resolve the issue of "self" being a magic argument. | | 'self' isn't. The first arg, whatever named, is. Your proposal would | mandate that this | arg be named 'self', which is not the case now. I usually just use 's'. Oops, sorry, I may have mixed things up. I wasn't referring to the name "self" but rather the first arg. I was still imagining that you define m(self, args). However, by saying classes and objects are the "same", we have to distinguish between unbound and bound methods: obj.foo = lambda self,x: self.foo(x) is what you do in a "class", vs. obj.foo = lambda x: x+3 is what you do in an "object". You can call obj.foo(5) either way, but in one case the system adds obj as the magic first argument and in the other case it doesn't. See, there's no syntax for distinguishing the two, because we use "def" for both functions and methods, and in Python 1 we use the context to decide what is defined. If we want to unify classes and objects (and I admit, I'm probably the only one who wants this), then we may need a way to say "I'm defining an unbound method" vs. "I'm defining a plain old function". - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From sliang at oregon-lnx.cc.gatech.edu Wed May 24 16:01:57 2000 From: sliang at oregon-lnx.cc.gatech.edu (Shengquan Liang) Date: 24 May 2000 20:01:57 GMT Subject: Path Question Again Message-ID: <8ghcfl$hgt$1@solaria.cc.gatech.edu> How do I specify the path of the file to write in a Python script running on a web server. Say the script is running in /usr/local/apache/cgi-bin (with alias /cgi-bin) and wants to write a file to /usr/local/apache/htdocs (with alias /) how do i specify the path in the script? thanks a lot From andrew.henshaw at gtri.gatech.edu Sat May 27 02:21:47 2000 From: andrew.henshaw at gtri.gatech.edu (Andrew Henshaw) Date: Sat, 27 May 2000 02:21:47 -0400 Subject: Help! SMTPlib References: <8gmti4$sf5$1@nnrp1.deja.com> Message-ID: <8gnbip$282$1@news-int.gatech.edu> sjoshi at ingr.com wrote: >Hello > I'm trying to use the smtplib for sending mail, and I keep getting >error: (10061, 'winsock error') when I try just to connect to the >localhost. > I'm guessing that your code looks something like: import smtplib server=smtplib.SMTP('localhost') server.connect() If so, then your problem is that the server.connect() function was already called when you instantiated "server". The connection is automatically made when you provide the hostname as a parameter to SMTP. I believe that the SMTP example in the library documentation is in error, in this regard. Andrew Henshaw From moshez at math.huji.ac.il Sun May 28 01:00:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 28 May 2000 08:00:03 +0300 (IDT) Subject: coverting numbers to strings In-Reply-To: <8gpnqb$ki7$1@bob.news.rcn.net> Message-ID: On Sat, 27 May 2000, Z 3 Penguin wrote: > i want to convert an integer to a string contaning the bytes for that value, Have a look at the "struct" module. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From psxunderground at cjb.net Wed May 3 15:37:56 2000 From: psxunderground at cjb.net (psxunderground at cjb.net) Date: Wed, 03 May 2000 19:37:56 GMT Subject: The Real Playstation Underground 1958 Message-ID: The Real PSX Underground check us out online @ http://psxunderground.cjb.net Hello fellow PSX owners and Fans Ive just setup the coolest new Hideout, here you can Buy, Sell and Trade Playstation games as well as the latest PSX addons like Modchips, VcD cards and so on. You can even get plans on how to build you own ModChip Burner to make your own modchips from parts from RadioShack, we have all the plans and software you will need to make them for -FREE- although we also sell them. We also got the plans and software to make your Own DreamCast ModChips which is very cool. and for a limited time we are Giving away a Free System of your Choice from DreamCast, Playstation, N64 or even the Jap PSX2 ... we sell everything that deals with Modifying or Backing-up games. We also have DVD Players with No Country Lock or Copy protection as low as $400 Canadian check us out online @ http://psxunderground.cjb.net From nospam.newton at gmx.li Sat May 6 03:47:03 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Sat, 06 May 2000 07:47:03 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> Message-ID: <3913cd02.357020248@news.nikoma.de> On Thu, 04 May 2000 21:50:41 GMT, "Don Tuttle" wrote: >Check out this major resource the Perl community has - http://www.cpan.org >This site is mirrored on many servers around the world. Think of the >disruption the Starship crash caused. That could not have happen to CPAN. Well, depends. Since we were just talking about ActiveState, Win32 Perl hackers depend heavily on ActiveState's repository of pre-compiled Perl extensions (database, image manipulation, etc. etc.) -- if their server were to go belly-up, a whole lot of people would cry, since AS's repository isn't completely mirrored anywhere AFAIK, and there are only a handful of public repositories for pre-compiled Win32 modules (Dave Roth, Jenda, dto.rk). CPAN doesn't help those Win32 users who haven't got a compiler but need a non-pure-Perl extension. >(Then again, the anacronym works for Python too. Maybe one of you hackers >could just graft us a tree onto CPAN. Don't think they'd notice do you? >;-) Probably not, actually :-). Just request a CPAN / PAUSE ID and upload stuff to your directory. I suppose cpan-testers (who AFAIK receive notices of newly uploaded stuff) would by a bit mystified, though .... Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From jraven at psu.edu Fri May 5 09:28:02 2000 From: jraven at psu.edu (Jeff Raven) Date: 5 May 2000 13:28:02 GMT Subject: string.replace References: <15115.957531909@www8.gmx.net> Message-ID: On Fri, 5 May 2000 15:05:09 +0200 (MEST), rei05 at gmx.de wrote: >hi there, >i have a string s and i need to replace the substring "'" (i.e. the >symbol with ascii 146) with the substring "\'"; so i tried >string.replace(s,"'","\'"), but this doesn`t work. anyone any >better idea? >thanx, rei > Well, there are two possible problems : 1. Try printing the string "\'" -- I don't think it's what you want it to be. Use r"\'" or "\\'" instead. 2. Strings are immutable, so s itself is not changed. So all together, new_s = string.replace(s, "'", r"\'") should do the trick. [I'm not sure if ' is the actual symbol you're interested in, since that's ascii 39 for me, but this should work with whatever you want in place of '.] Jeff Raven From * at spam.ruud.org Thu May 18 15:56:02 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 18 May 2000 21:56:02 +0200 Subject: Nested Dictionaries References: <392446c9@wwwproxy3.westgroup.com> Message-ID: <87em6zskdp.fsf@hobbes.home.ruud.org> "Chris Lada" writes: > Is there some where of directly accessing information in a dictionary which > occurs as part of another dictionary i.e.: > > inner = {'city':'This City','state':'This State'} > outer = {'12345':inner} > > In order to access the 'city' information in the 12345 dictionary entry, I > do the following: > > temp = outer['12345'] # yields the outer dictionary entry with the key > '12345' > > tempCity = temp['city'] # yields the city value of the inner dictionary of > the > # outer dictionary entry with the key > '12345' > > Is there an easier or more direct way of doing this ? outer['12345']['city'] - Ruud de Rooij. -- ruud de rooij | *@spam.ruud.org | http://ruud.org From neelk at brick.cswv.com Fri May 12 19:39:43 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 12 May 2000 23:39:43 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote: > > Ooh, lots of us would! Join the types-SIG. :) > > This is not a small project, and has many consequences, though the > run-time variety would be easier to do than the static-type checking > variety. (which would report type errors during compile-time). > > We have OPT, ERR and DOC reasons for doing type checking: > > OPT -- the interpreter/compiler uses the type declarations to make our > code run faster. The more static the type checking, the better. I think this is a bit of a myth. If you can declare that a variable is a machine integer or float, and arrays of the same, you have enough information to get about 80% of the speed benefit that static typing can win you. Beyond that there isn't much you can do without fairly exotic techniques, all of which have the common feature that they a) are very hard to implement correctly, and b) make interfacing with foreign C code much harder. Before static typing for speed is tried (with its complicating effects on implementation), I think it's better to go for the factor of 2 improvement that can be won via easy tricks like method caches, variable lookup optimization, and reducing function call overhead. (Look at Squeak Smalltalk for an example.) Strong typing can also *cost* you speed, if you decide expressiveness is important and you let your type system include allow parametric types. For example, accessing and modifying an array with type [Foo] (meaning a list of instances of Foo) will be slower than accessing a list of arbitrary objects, because you need to add checks to confirm that all additions to the list are of class Foo, rather than blindly adding objects to the list. Note also that it can be hard to declare 'machine integer' as a type, if type-class unification becomes reality and you can subclass Integer. > ERR -- we get more robust code as the types are checked. It's nice when > this happens during compile-time, though run-time can also be > helpful. With an interactive read-eval-print loop, run-time is just as good as compile-time, IMO, because you can test your system incrementally, as you build it. > DOC -- we get more readable code as we can see which types go into a > function. These two are the real reason to go for type declarations, IMO. Neel From jkraska1 at san.rr.com Mon May 29 18:55:00 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 22:55:00 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> Message-ID: <3932F5DC.E00C1642@san.rr.com> > > words = ["foo", "bar", "baz"] > > print words.join(" ") > print ( "foo", "bar" ).join(" ") I've thought about this for a bit, and it's quite clear to me that these idoms are the natural representation for this. Whether or not their implementation in python is easily/optimally acheived is another issue altogether, but this representation is natural and, IMO, right one. C/ From jkraska1 at san.rr.com Mon May 8 22:03:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 09 May 2000 02:03:34 GMT Subject: Block comments? References: <391653B7.2F38A7F2@san.rr.com> <8f754o$flg$1@sunnews.cern.ch> Message-ID: <391772C6.69096697@san.rr.com> Radovan Garabik wrote: > > Courageous wrote: > > : Okay, it's not like I'm not looking in my documentation or anything, > : but if this is available, it's not obvious. How do you express > : python block comments? > > comment = 0 > > . > . > . > > if comment: > you block comment > goes here Well, the """ """ works most of the time (a use for strings that I hadn't thought of), but of course what I want is to disable arbitrary elements of code without reformatting and the like. It seems that there isn't really a full block comment notation, given when you CAN'T use strings. C/ From thiele at muc.das-werk.de Thu May 25 11:50:52 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Thu, 25 May 2000 17:50:52 +0200 Subject: intersection Message-ID: <392D4BDC.6F339367@muc.das-werk.de> Hallo! Is there a function returning the intersectin of two lists. Example: l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] l3 should be [4,5] It' s not diffucult to program it, but I couldn't find a build-in-fucnction. Or I'm blind? From buster2642 at my-deja.com Wed May 31 17:00:34 2000 From: buster2642 at my-deja.com (buster2642 at my-deja.com) Date: Wed, 31 May 2000 21:00:34 GMT Subject: numpy for linux(ppc)? References: <8gedo6$o6q$1@nnrp1.deja.com> Message-ID: <8h3uhd$pca$1@nnrp1.deja.com> Alert ----- Newbie Help Request ----- Alert I see that I need Distutils to allow numpy installation. If my installation is python 1.5.1, without numpy installed, what's the smartest thing for me to do, upgrade to python 1.5.2 first, then install Distutils, then build numpy? If so, in what order do install RPMs for python-1.5.2 python-devel python-docs python-tkinter Distutils to get my upgrade to 1.5.2, and latest numpy build, to work smoothly? Thanks! Chuck In article , Travis Oliphant wrote: > > > > Where's the best place to get linux RPMs for Numpy? > > > > src.rpm's are distributed at the SourceForge site: > > http://numpy.sourceforge.net > > RPM binaries for i386 are also available. > > -Travis > > Sent via Deja.com http://www.deja.com/ Before you buy. From hsauer at marnie.teuto.de Tue May 23 09:34:32 2000 From: hsauer at marnie.teuto.de (Henning Sauer) Date: 23 May 2000 15:34:32 +0200 Subject: Python interface for Video4Linux ? Message-ID: Hello, is their a Python interface to the Linux Video4Linux API available somewhere ? Bye, Henning From mwh21 at cam.ac.uk Wed May 10 15:00:01 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 May 2000 20:00:01 +0100 Subject: Passing by value instead of reference References: Message-ID: "Jeff Massung" writes: > >Then what would you expect your "test" function to do? > > > >Cheers, > >M. > > Just print a different address. If test was: > > def text(x): > x=1 > > test(z) > print z > > I would want this to print the original value of z (5), not 1. It will. I don't think you understand assigment yet... Cheers, M. -- 112. Computer Science is embarrassed by the computer. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From dgoodger at bigfoot.com Sat May 27 23:17:13 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 27 May 2000 23:17:13 -0400 Subject: Getting Variables from a file In-Reply-To: <39305B84.A06745E9@bioeng.ucsd.edu> References: <39305B84.A06745E9@bioeng.ucsd.edu> Message-ID: on 2000-05-27 19:34, Curtis Jensen (cjensen at bioeng.ucsd.edu) wrote: > I have a text file of the form: > > (var = integer) I assume that the above line is part of the description, not the file itself. > dof = 8 > elements = 10 > mesh_dof = 300 > . > . > . > . > > I want to read the file from within Python and then create a variable in > python of the same name as what is in the text file, and holding the > assigned value. Assuming I don't already know the names of the > varialbes; how do I do this? I can do the file I/O, but how do I change > a character string into a variable name? Thanks. If your variables text file conforms to Python syntax, use execfile("filename"). But beware! Huge potential for abuse here! -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From claird at starbase.neosoft.com Thu May 4 13:55:10 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 4 May 2000 12:55:10 -0500 Subject: houston python users References: <074C8D12C3163164.5E3EC1EAB58F6489.E8B525BEDFE31E20@lp.airnews.net> Message-ID: In article <074C8D12C3163164.5E3EC1EAB58F6489.E8B525BEDFE31E20 at lp.airnews.net>, technology wrote: >Are there any houston python programmers out there. . . . In fact a few of the stars of Pythonia, including Robin Friedrich , live in Houston. As it happens, broadly-experienced Tres Seaver left town just a few hours ago, headed for full-time East Coast Python employment. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From thomas at xs4all.net Mon May 22 08:15:41 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 22 May 2000 14:15:41 +0200 Subject: Damnation! In-Reply-To: ; from pinard@iro.umontreal.ca on Mon, May 22, 2000 at 07:05:59AM -0400 References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8gaui8$bhu$2@newshost.accu.uu.nl> Message-ID: <20000522141541.S13281@xs4all.nl> On Mon, May 22, 2000 at 07:05:59AM -0400, Fran?ois Pinard wrote: > P.S. - Do you read this message in the list? I got two rejects with: > : Command time limit exceeded: > "/home/mailman/mail/wrapper post python-list" This is a known problem with the list... (that is, I talked with Barry about it, and he rewrote parts of Mailman in response to some discussion we had, and it hasn't helped :-) It's my belief now that it isn't Mailman-specific, just that the list is so incredibly large that sending all messages out takes longer than Postfix is prepared to wait. The message is probably archived properly, is probably posted to the newsgroup properly, and even sent to a fair number of the lists recipients, but maybe (probably) not everyone. The problem is probably related to a cron job on the machine, or some such, as it always happens at CET mornings, which is like 2 AM for the machine in question ;) So, if you usually catch up on the newsgroups while enjoying a cup of coffe or a bit of breakfast, before heading to work, like me, you can expect a couple of these bounces ;-P I imagine Barry has been insanely busy the last few weeks aranging the move to sourceforge of Python and Mailman, among other things, but I hope he'll be able to tune those Postfix timing parameters sometime soon... I'm purposely avoiding postings before noon localtime to avoid the bounces ;-P -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From johann at physics.berkeley.edu Tue May 30 16:12:53 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 30 May 2000 13:12:53 -0700 Subject: Is it just Syntactic Sugar ? References: <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> <20000530213957.E469@xs4all.nl> Message-ID: Thomas Wouters writes: > No, I have more faith in the idea that += is an *in place* add, for mutable > types. But then it loses its most basic utility, namely working with integers. An integer is not a mutable type. A simple rewrite is the only way to make sense of i += 1 -> i = i + 1 if i is an integer, given the existing python variable semantics. -- Johann Hibschman johann at physics.berkeley.edu From pinard at IRO.UMontreal.CA Sun May 14 23:33:13 2000 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 14 May 2000 23:33:13 -0400 Subject: A TYPICAL NEWBIE MISTAKE? In-Reply-To: Courageous's message of "Mon, 15 May 2000 02:57:37 GMT" References: <391F513B.CEA12592@san.rr.com> <391F6844.E473FC2E@san.rr.com> Message-ID: Courageous writes: > Sometimes colons seem syntactically unnecessary. Granted, but it is always good for a language to have a bit of redundant information. When properly thought, such redundancy prevents various mistakes from programmers (once they are used to it, of course :-), and often increase overall legibility. I much like the redundant colons in Python! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From thiele at muc.das-werk.de Tue May 30 16:41:01 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 30 May 2000 22:41:01 +0200 Subject: installation (linux) References: <3934055F.3EBCDEBC@muc.das-werk.de> <20000530220840.F469@xs4all.nl> Message-ID: <3934275D.4F2520B4@muc.das-werk.de> > > > You have to clean up leftover cruft after the reconfigure. Try > > make clean > make Yes, this was the problem. Thanks. I thought the sources are wrong, but I could't believe it. From mhammond at skippinet.com.au Sun May 7 18:49:41 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 07 May 2000 22:49:41 GMT Subject: win32all-129-update.exe - Is it needed? References: <8f30cp$g5m$1@nnrp1.deja.com> Message-ID: <9qmR4.13929$v85.91649@news-server.bigpond.net.au> I will update the web page to hopefully clear up some of this confusion: * win32all-129 was released to registered users quite some time ago (registered users now have build 132 (for 1.5.2) available * There were bugs, and instead of releasing a complete new build, I released the update. It only changes files installed by 129. * Therefore, you should install win32all-129, then win32all-129-update. * If you have any earlier builds (eg, 128) already installed, the installation of 129 will suggest and offer to uninstall the previous versions. Mark. "Joe Smith" wrote in message news:YhjR4.44823$k5.1318845 at news1.frmt1.sfba.home.com... > > This was supposed to be installed before I install 129? > > wrote in message news:8f30cp$g5m$1 at nnrp1.deja.com... > > Good question! With 663K of patches presumably to the core Python > > 1.5.2 distribution, I would hesitate to install win32all129 without it. > > > > Version 128 mentioned only a single patch as far as I know (pyclbr.py). > > > > The download site is > > http://starship.python.net/crew/mhammond/win32/Downloads.html > > > > -Alan > > > > In article , > > "Joe Smith" wrote: > > > On the starship site is says: > > > Also download and install the patch set for build 129 - > > > win32all-129-update.exe (663,799 bytes) > > > > > > Is this needed if one installs win32all-129.exe? > > > From m.faassen at vet.uu.nl Sat May 13 08:25:16 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 May 2000 12:25:16 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: <8fjhjc$l6k$3@newshost.accu.uu.nl> Neel Krishnaswami wrote: > Martijn Faassen wrote: >> >> Ooh, lots of us would! Join the types-SIG. :) >> >> This is not a small project, and has many consequences, though the >> run-time variety would be easier to do than the static-type checking >> variety. (which would report type errors during compile-time). >> >> We have OPT, ERR and DOC reasons for doing type checking: >> >> OPT -- the interpreter/compiler uses the type declarations to make our >> code run faster. The more static the type checking, the better. > I think this is a bit of a myth. Perhaps so, but.. > If you can declare that a variable is a machine integer or float, and > arrays of the same, you have enough information to get about 80% of > the speed benefit that static typing can win you. What about classes and methods though? If you want to optimize some of the dispatching it may be pretty helpful to have static typing. Similarly, in a dynamic system you'd *lose* your nice declarations as soon as you pass them into some function that doesn't have them (barring type inferencing, which is about as non-easy as static typing, if not more :). > Beyond that there isn't much you can do without fairly exotic > techniques, all of which have the common feature that they a) are very > hard to implement correctly, and b) make interfacing with foreign C > code much harder. > Before static typing for speed is tried (with its complicating effects > on implementation), I think it's better to go for the factor of 2 > improvement that can be won via easy tricks like method caches, > variable lookup optimization, and reducing function call > overhead. (Look at Squeak Smalltalk for an example.) Definitely agreed. (method caching may not always be that easy, though, given __getattr__ and friends..) > Strong typing can also *cost* you speed, if you decide expressiveness > is important and you let your type system include allow parametric > types. For example, accessing and modifying an array with type [Foo] > (meaning a list of instances of Foo) will be slower than accessing a > list of arbitrary objects, because you need to add checks to confirm > that all additions to the list are of class Foo, rather than blindly > adding objects to the list. Yes, as noted on the types-SIG, too. > Note also that it can be hard to declare 'machine integer' as a type, > if type-class unification becomes reality and you can subclass > Integer. >> ERR -- we get more robust code as the types are checked. It's nice when >> this happens during compile-time, though run-time can also be >> helpful. > With an interactive read-eval-print loop, run-time is just as good as > compile-time, IMO, because you can test your system incrementally, as > you build it. Not all people agree on this. I think some interface conformance checking at compile-time would for instance be nice. But I definitely agree that the ERR component of static type checking is overrated. >> DOC -- we get more readable code as we can see which types go into a >> function. > These two are the real reason to go for type declarations, IMO. The idea of these notations is that everybody gets to pick their favorites. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cobrien at Radix.Net Wed May 31 21:32:14 2000 From: cobrien at Radix.Net (Cary O'Brien) Date: 31 May 2000 21:32:14 -0400 Subject: Using python (or Tcl) on the web References: Message-ID: <8h4eeu$bpg$1@saltmine.radix.net> In article , J.M. Ivler wrote: >In comp.infosystems.www.misc amphgobb wrote: >> There is a reason for that and I question whether the CGI naysayers >> were ever wrong. The arrival of mod_perl and mod_php provide two >> distinct development platforms which do not need to fork a new >> process for each instance of the script execution. > >And what about TCL users? > Well, they've got mod_dtcl and aolserver. Python has got mod_python and pyapache. Look, this is mature technology. Can't everyone just get along? (Plus you forgot embedded perl - embperl). -- cary From jmassung at magpiesystems.com Wed May 24 11:22:50 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Wed, 24 May 2000 09:22:50 -0600 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <8gf3ms$jce$2@newshost.accu.uu.nl> <392b1f96$0$2624@news01.syd.optusnet.com.au> Message-ID: Arnold de Vos wrote in message <392b1f96$0$2624 at news01.syd.optusnet.com.au>... >Yep. As pointed out on this group from time to time, import from * can be >harmful. I'm new to Python - I'm understand why it is harmful (finally ;) - but was wondering, if it is that harmful, why have it to being with (what good can come from using it)? Also, what would be the harm in removing "passed down importing" (that's the only way I could think of to state it)? If y imports z and z imports y, why not have z have to import x to get the functionality of x, too? Jeff (still learning) From JoeSmith at bogusaddress.com Fri May 19 03:24:46 2000 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Fri, 19 May 2000 07:24:46 GMT Subject: Python multiplexing is too hard (was: Network statistics program) References: <8ftqtk$25a$1@ites.inria.fr> <70473664761982E0.213BD232030AF5BF.3DC75D82647B8DFC@lp.airnews.net> Message-ID: <3924ECF0.577B0DD8@bogusaddress.com> An HTML attachment was scrubbed... URL: From cjc26 at nospam.cornell.edu Sat May 13 22:40:55 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 14 May 2000 02:40:55 GMT Subject: GUIs References: <7ACS4.5039$ur1.107262@news6-win.server.ntlworld.com> <391cb04a.62616489@news.telus.net> Message-ID: * David menulis: | | Certainly [wxPython] has become much more powerful over the past year. | Rather remarkable, some of the things it can do now. Grids, especially... Does it have anything like the Tk Text widget? -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "One man's nirvana is another man's map." icq 68165166 From claird at starbase.neosoft.com Mon May 29 09:28:17 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 29 May 2000 08:28:17 -0500 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <393004FA.846A54BF@mit.edu> <8gtn29$s8u$1@ites.inria.fr> Message-ID: In article <8gtn29$s8u$1 at ites.inria.fr>, Cedric Adjih wrote: . . . > You're right, Python is slow. That is fast to program with, but slow >to run. For many cases, it is fast enough. >For other cases, its speed is an issue, but programmer time is deemed >more important. >For other cases, one can profile, and write a C module (with the >extension API, SWIG, CXX or SCXX), for the bottlenecks, when possible. > >If you need more speed than Python has (but not top speed), and something >more clean than C++, you can try something in between, such >as Java or Eiffel. > >-- Cedric ... and sometimes even then, especially with Java, you'll find meaningful applications are *slower* when you try languages other than Python. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From andy at reportlab.com Tue May 23 08:37:17 2000 From: andy at reportlab.com (Andy Robinson) Date: Tue, 23 May 2000 12:37:17 GMT Subject: Microsoft-style format strings References: Message-ID: <392b7aca.17408456@news.demon.co.uk> Thanks to all who replied. I know the Pythonic way to do it, I just repeatedly get people asking for a VB-compatible formatting function since that's the notation they know. And frankly, even after years of Python I find the VB format more readable. I'll try to write one. - Andy From pinard at iro.umontreal.ca Tue May 16 12:13:31 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 16 May 2000 12:13:31 -0400 Subject: A REALLY COOL PYTHON FEATURE: In-Reply-To: Robert Citek's message of "Tue, 16 May 2000 03:02:10 -0500" References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <3.0.5.32.20000516030210.007ad100@earthlink.net> Message-ID: Robert Citek writes: > The join method is fine for converting lists to strings, but doesn't work > for converting lists to tuples. However, lambda works nicely here: > reduce(lambda x, y: x + (y,), somenames, ()) Why not just tuple(somenames) ? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mikael at isy.liu.se Tue May 23 02:50:47 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 23 May 2000 08:50:47 +0200 (MET DST) Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <3929D3F6.DE9CCCBC@prescod.net> Message-ID: On 23-May-00 Paul Prescod wrote: > The most honest arguments are "case sensitivity feels cleaner" and that > it "is more popular with existing programmers." CP4EEP - CP4E except programmers... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-May-00 Time: 08:49:23 This message was sent by XF-Mail. ----------------------------------------------------------------------- From neilh at scintilla.org Sun May 14 09:18:49 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 14 May 2000 13:18:49 GMT Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: > I'm quite a newbie (read very), but it seems that there is a precedent > in strings which can be either ' or " but ' is used for printing. Is > this now considered to have been a mistake or a special case? Allowing i instead of j does not make any task significantly easier nor the resulting code clearer. Having two forms of quote makes manipulation of strings that contain quotes much easier. A lot of my Python code generates HTML with embedded JavaScript so there is stuff like: out = out + "" % (itemName, visibility) print "item = new Item(%s,'%s');\n" % (did, dispatch['itemID']) or when you have to use layers of quotes there are Python's triple quotes: itemstart="""
    %s""" Using backslash quoting instead is very tedious and prone to mistakes. However I see no need for python to have both single triple quotes and double triple quotes. Maybe its just the symmetry. Neil From wlfraed at ix.netcom.com Fri May 12 23:38:09 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 12 May 2000 20:38:09 -0700 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> <5v+rnIBnysG5Ewoc@robinton.demon.co.uk> <391C7B1D.2D3D@seebelow.org> <8fga08$vgj$1@slb0.atl.mindspring.net> Message-ID: On Fri, 12 May 2000 01:00:08 -0600, "Andrew Dalke" declaimed the following in comp.lang.python: > I assume VB has similar syntax? Then explaining declarations Usage of %, #, and $ (integer, double, and string as I recall) is deprecated in VB(A). Instead, the old "DIM" (originally only used to "dimension" arrays) is now used for type declarations, not just array... >From the help system: Dim [WithEvents] varname[([subscripts])] [As [New] type] [, [WithEvents] varname[([subscripts])] [As [New] type]] . . . type Optional. Data type of the variable; may be Byte, Boolean, Integer, Long, Currency, Single, Double, Decimal (not currently supported), Date, String (for variable-length strings), String * length (for fixed-length strings), Object, Variant, a user-defined type, or an object type. Use a separate As type clause for each variable you declare. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From debl.nospamm at world.std.com Sat May 13 23:28:38 2000 From: debl.nospamm at world.std.com (David Lees) Date: Sun, 14 May 2000 03:28:38 GMT Subject: How to use .show in PIL under Win95? Message-ID: <391E1D5D.134AA359@world.std.com> I now have PIL installed and am running through the tutorial for the Image module. No problem reading, writing and rotating images, but the .show method does not seem to work on my Win95 system. I am using PythonWin, Python 1.5.2, tkinter is installed. I do not get any errors, something flashes (does not look like an image though) and then I am back at the command prompt. The command is im.show() or im.rotate(45).show() I even wrote the results of a rotate out from Python and looked at it with an external viewer. I would like to view directly in Python. David Lees From mjackson at wc.eso.mc.xerox.com Tue May 16 14:31:43 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 16 May 2000 18:31:43 GMT Subject: Decimals to fraction strings References: Message-ID: <8fs46f$ijd$1@news.wrc.xerox.com> =?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: > "Stuart D. Gathman" writes: > > > Scott wrote: > > > > Does anyone know of a way to convert decimal numbers to a string > > > representation of the fractional value? For example: > > > 0.5 = "1/2" > > > or > > > 1.125 = "1 1/8" > > > 1) Convert to a fraction by counting places after the decimal: > > 2) Divide top and bottom by their GCD (greatest common divisor): > > 3) If desired (I don't), convert to mixed notation when num > den by > > finding quotient and remainder of num / den: > > Yet your suggestion is straightforward, it might not always yield the "best" > answer, because of the constraint put on the denominator to initially be > an exponent of 10. Is not this same constraint applied by the problem itself, which starts with a [finite length] decimal representation? -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson In judging others, folks will work overtime for no pay. - Charles Carruthers From johann at physics.berkeley.edu Thu May 11 01:16:36 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 10 May 2000 22:16:36 -0700 Subject: lambda versus "mlambda"... References: <391A301B.D59F070F@san.rr.com> <391A344D.DD52DD23@san.rr.com> Message-ID: Courageous writes: >> I think what you want is spelled thusly: >> >> lambda , self=self: > Oh, cool! So! Is the portion of the expression where you > say "self=self" a more general way of introducing a sort > of closure into the lambda expression? The python documentation > on lambda doesn't seem to be very detailed in this respect... Yes, exactly. Do that enough, and you get used to it. It's part of why there isn't all that much clamoring for full closures. -- Johann Hibschman johann at physics.berkeley.edu From dhansen at cyberoptics.com Wed May 17 11:24:49 2000 From: dhansen at cyberoptics.com (Dave Hansen) Date: Wed, 17 May 2000 15:24:49 GMT Subject: Decimals to fraction strings References: <8fs46f$ijd$1@news.wrc.xerox.com> Message-ID: <3922b690.58207117@client.ce.news.psi.net> On 16 May 2000 22:49:54 -0400, =?ISO-8859-1?Q?Fran=E7ois_Pinard?= wrote: >mjackson at wc.eso.mc.xerox.com (Mark Jackson) writes: [...] >> >> Is not this same constraint applied by the problem itself, which starts >> with a [finite length] decimal representation? >> > >Not necessarily. 0.6667 is well approximated by 1:3, for example, while ITYM 2/3. >if you force the denominator to be an exponent of 10, you will obtain a >fraction which is not only uglier, but less precise. Uglier, perhaps. But 6667/10000 is a somewhat more precise approximation of .6667 than is 2/3. Regards, -=Dave -- The opinions expressed in this post are my own and do not represent the views of CyberOptics Corporation. Change is inevitable. Except from a vending machine. From gansevle at cs.utwente.nl Mon May 8 10:46:09 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Mon, 08 May 2000 14:46:09 GMT Subject: Iterating over items in the registry References: <2B1262E83448D211AE4B00A0C9D61B03BA7335@msgeuro1.creo.be> Message-ID: <8f6jvc$8d8$1@nnrp1.deja.com> In article <2B1262E83448D211AE4B00A0C9D61B03BA7335 at msgeuro1.creo.be>, Pieter Claerhout wrote: > Hello all, > > is there a way to iterate over keys in the registry? I want to scan the > contents of the key HKLM\HARDWARE\DEVICEMAP\Scsi to find info > about all connected scsi hardware. I want to use this under NT. Is this > the proper way to do it, or does anyone has a module who accomplish > this for me? > Here is the code of a function that returns the SID of the currentely loggedin user. This function ius part of a bigger program, so probably it won't on your system but it gives you an idea how to iterate over Registrey Keys. def get_sid (): hkey = RegOpenKey (HKEY_LOCAL_MACHINE, ProfileList) sid = None i = 0 while i >= 0: try: sid = RegEnumKey (hkey, i) key = RegOpenKey (hkey, sid) path, kind = RegQueryValueEx (key, "ProfileImagePath") RegCloseKey (key) if ExpandEnvironmentStrings (path) == USERPROFILE: i = -1 else: i = i + 1 except error, why: log ('Searching for sid:', str(why)) i = -1 RegCloseKey (hkey) return sid > Kind regards, > > Pieter > > Pieter Claerhout > Application Support - CreoScitex Europe > > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From glyph at twistedmatrix.com Sat May 6 01:06:00 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 06 May 2000 00:06:00 -0500 Subject: Deleting objects in Python 1.6 In-Reply-To: Michael Hudson's message of "04 May 2000 13:30:39 +0100" References: <39116805.86326A69@python.net> Message-ID: Michael Hudson writes: > There are easier ways of crashing Python 1.5.2; > > >>> l=[] > >>> m=[] > >>> l.append(l) > >>> m.append(m) > >>> l==m > Segmentation fault (core dumped) > >>> import marshal > >>> l=[] > >>> l.append(l) > >>> marshal.dumps(l) > Segmentation fault (core dumped) > This is slightly unnerving ... (good to know, though) ... I want to write long-running programs in python that run user-supplied code. I take it all of these well-known problems will be fixed in python 1.6? -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From paterno at fnal.gov Fri May 5 10:31:47 2000 From: paterno at fnal.gov (Marc Paterno) Date: Fri, 5 May 2000 09:31:47 -0500 Subject: Problem with "COM Browser" in PythonWin 1.5.2 Message-ID: <8eum0h$gj$1@info3.fnal.gov> Hello, When trying to use the "COM Browser" tool in PythonWin 1.5.2, I encounter the following problem. I start the COM Browser from the Tools menu. If I think click on the "Registered Categories" item in the tree display, I get a trackback in the PythonWin interactive window. The entire contents of the interactive window (including the version info, printed at startup) are the following: ---------------------------------------------------------------------------- ------- PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) >>> Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line 118, in OnTreeItemExpanding self.AddSubList(itemHandle, self.GetSubList(item)) File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line 263, in GetSubList return self.DelegateCall(item.GetSubList) File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line 250, in DelegateCall return fn() File "C:\Program Files\Python\win32com\client\combrowse.py", line 101, in GetSubList for catid, lcid, desc in enum: File "C:\Program Files\Python\win32com\client\util.py", line 37, in __getitem__ return self.__GetIndex(index) File "C:\Program Files\Python\win32com\client\util.py", line 53, in __GetIndex result = self._oleobj_.Next(1) pywintypes.com_error: (-2147024882, 'Not enough storage is available to complete this operation.', None, None) win32ui: Exception in OnNotify() handler ---------------------------------------------------------------------------- ------- I am using PythonWin build 128, under Windows NT 4.0, with SP6a installed (in case that matters). I have been unable to find any relevant posting on the comp.lang.python news group, or in the "bugs list" at www.python.org. Can anyone enlighten me on how to fix this problem? thanks, Marc From c.rafferty at formulae.co.uk Sat May 6 11:49:13 2000 From: c.rafferty at formulae.co.uk (Colm Rafferty) Date: Sat, 6 May 2000 16:49:13 +0100 Subject: Dynamically inserting HTML Message-ID: <000301bfb772$a0eb6780$06469fd4@default> Dear All, I have an HTML page. I would like to dynamically insert HTML code into a part of that page as the page loads. I can do it OK with a .js file. But I would like to do it with a link to a python script in my cgi-bin. Is it possible? Thanks Colm Rafferty From phd at phd.russ.ru Fri May 5 09:30:56 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 5 May 2000 13:30:56 +0000 (GMT) Subject: string.replace In-Reply-To: <15115.957531909@www8.gmx.net> Message-ID: On Fri, 5 May 2000 rei05 at gmx.de wrote: > so i tried string.replace(s,"'","\'"), but this doesn`t work. anyone any string.replace(s,"'","\\'") :))) Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From rlw at stsci.edu Thu May 25 16:16:18 2000 From: rlw at stsci.edu (Rick White) Date: Thu, 25 May 2000 16:16:18 -0400 Subject: profile problem Message-ID: <392D8A12.A971E190@stsci.edu> I have encountered a problem with the profiler. Here's a brief demonstration: Python 1.5.2 (#2, Apr 17 1999, 11:16:17) [C] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> class Test: ... def __getattr__(self,attr): raise AttributeError ... >>> def g(): ... def f(): ... if hasattr(Test(),'x'): pass ... f() ... time.sleep(1) ... >>> import time, profile >>> profile.Profile(time.time).run('g()').print_stats() ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.992 0.992 :1(g) 1 0.992 0.992 0.992 0.992 :2(f) Profile erroneously assigns all the execution time to function f() rather than to g() where it belongs. If I replace f() with a function that does not call hasattr, but instead just tries to access the attribute and catches the AttributeError, it works correctly. The problem seems to be that the exception raised in __getattr__ (in Python) is caught by the hasattr function (in C code). As a result the profile stack gets out of sync with the real program stack, and the accounting goes awry. Things work correctly as long as the exception is both raised and caught within Python code. I looked at the profile module and was able to identify the cause (in a much more complicated program), but so far I haven't figured out how to fix it. Any suggestions? - Rick -- Richard L. White rlw at stsci.edu http://sundog.stsci.edu/rick/ Space Telescope Science Institute Baltimore, MD From bwinton at tor.dhs.org Tue May 23 08:43:37 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Tue, 23 May 2000 12:43:37 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8g7t5c$1i7i$1@thoth.cts.com> Message-ID: On 21 May 2000 05:45:16 GMT, Will Rose wrote: >Mike Fletcher wrote: >I think the problem is not case-sensitive vs. case-insensitive, it's >case-sensitive/case-preserving vs. case-insensitive/case-preserving. >I have no problem reading COBOL or early BASIC in monocase (apart >from the obvious problems of the languages). It's when one token >can have several different forms that the problems start. Well, there we go. Perhaps we can have something which is neither case-sensitive, nor case-insensitive, based on the following principles. 1) Your variables can be named anything you want. 2) Any variable which differs from a preceeding one only by case generates an error. It should be _very_ easy to tell which variable generated the error, and how to fix it, but in order to "encourage" newer programmers to think more methodically, I feel that the compiler shouldn't make the change for them. Perhaps the IDE, in beginner mode, would be nicer. I suppose that's similar to case-sensitive, but I feel it differs in two main points. Firstly, the error messages would be much nicer to users. Secondly, people wouldn't get confused by stuff like "abc=aBc", since the second form would be disallowed. >It would be nice if the language enforced reasonable default rules, Something like Java's guidelines? >I'd suggest enforcing the use of upper or lower case only, rather than >mixed case. That seems the least bad option; not much more of a >nuisance than the current whitespace rules. Speaking as someone who had to use Modula-3, Ugh! (Modula 3's largest mis-feature, for me at least, was that all keywords had to be typed in ALL-UPPERCASE. My little finger got really sore after four months of programming. :P) Move beyond the C64! Bill gave us the shift key for a reason, let's use it! ;) Later, Blake. -- 7:25am up 31 days, 11:36, 4 users, load average: 1.19, 1.06, 1.02 From jkraska1 at san.rr.com Mon May 8 00:44:25 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 08 May 2000 04:44:25 GMT Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> <39163F4E.EE88F9CF@san.rr.com> <39164561.24A711BC@udel.edu> Message-ID: <391646F2.A038644F@san.rr.com> > You are exactly right. My real question, that I didn't ask, was > how to set the various colors. I had examined the vim help > files, but hadn't figured it out. Your message, though, gave > me the right clues. You'll note that my python.vim is an upgraded version. The python.vim that came with vim5.5 was a bit weak. I added support for constants, numbers, as well as an ability to make dictionary and list notation stand out. Try both of my files to get an idea for what you can do. :) BTW, if you don't happen to understand vim syntax notation and you think something should be in there, let me know. I can do it, mon. I'm a Vim power user. :) It'd probably be pretty trivial to set up the list of popular standard python libraries as highlightable, for example. If you'd want that... C/ From aahz at netcom.com Fri May 12 11:57:06 2000 From: aahz at netcom.com (Aahz Maruch) Date: 12 May 2000 15:57:06 GMT Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> Message-ID: <8fh9ki$51h$1@slb3.atl.mindspring.net> In article , Ben Wolfson wrote: > >', '.join(['foo', 'bar', 'baz']) This only works in Python 1.6, which is only released as an alpha at this point. I suggest rather strongly that we avoid 1.6-specific idioms until 1.6 gets released, particularly in relation to FAQ-type questions. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Internet $tartup$: Arbeit ueber alles --Aahz From gmcm at hypernet.com Sun May 14 18:54:50 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 14 May 2000 22:54:50 GMT Subject: Can not remove file in windows because of "permission denied" References: <8fmo5k$e5u$1@news.uni-paderborn.de> Message-ID: <391f2eba$0$20207@wodc7nh6.news.uu.net> Chr. Ullenboom wrote: >I want to remove a file (an rename) but I cannot. There is a permission >denied under Windows 2000, but it is my own file. What can I do? You (or a close facsimile thereof) probably have the file open. - Gordon From rjroy at takingcontrol.com Fri May 19 12:34:24 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Fri, 19 May 2000 16:34:24 GMT Subject: Converting strings to hex References: <8g20r4$ru6$1@supernews.com> Message-ID: <39256bf0.305770843@news1.on.sympatico.ca> You could also use the SHA module. Gives you a 160 bit vs 128 bit strength and has a hexdigest() method. Saves having to write your own. Bob On Fri, 19 May 2000 01:11:05 +0100, "Dale Strickland-Clark" wrote: >The output from MD5.digest() is a 16 byte binary string. > >I want to convert it to hex for printing. > >The hex() function only handles integers (pah!) so I've come up with this: > >def wibble(r): > return hex(ord(r))[2:4] > >a=md5.new(data).digest() >string.join(map(wibble, list(a)), "") > >Which is ugly, at best. > >Is there a better way? > >hhmm... > >I've just discovered unpack and come up with this: > >"%4X %4X %4X %4X" % struct.unpack(">4i", a) > >which is certainly shorter! > >Is this the best I can expect? > >Thanks > >-- >Dale Strickland-Clark >Out-Think Ltd, UK > > > From nospam.mrquiz at free.fr Thu May 25 05:32:58 2000 From: nospam.mrquiz at free.fr (Dave Simons) Date: Thu, 25 May 2000 09:32:58 GMT Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> Message-ID: <8F3F72DB7davemrquizorg@212.27.32.76> We've tracked down the source of the following rumour to glyph at twistedmatrix.com (Glyph Lefkowitz) on the jeu., 18 mai 2000 20:09:02 GMT : >Marketability? Hm. The thing that makes Java marketable is >the tremendous amount of money that Sun has poured into >getting it into every trade rag that they could possibly >find. Fellow pythonistas, short of getting Guido to use the >time machine for material gain > is there any way we can effectively market Python as a >competitor to a language / platform with that kind of >agressive force behind it?... I wasn't taking too much notice at the time, so can anyone tell me how much marketing went into C to make it the biggest-selling language the world has ever known? Yours smilingly, Dave -- What was God doing all that time - before the first day? From alecdem at mit.edu Sat May 27 13:25:14 2000 From: alecdem at mit.edu (Alexander) Date: Sat, 27 May 2000 13:25:14 -0400 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> Message-ID: <393004FA.846A54BF@mit.edu> Michael Hudson wrote: > Alexander writes: > > > Hi > > > > I have implemented loop in Python > > > > for k in xrange(1,100000000): > > pass > > > > and the same one in C > > for ( i = 0 ; i < 1e8; i++ ) ; > > > > and the second one seems to be working hundreds of times faster than the > > first one > > > > Can I do anything with that. > > Well, it's an empty loop so it's pretty useless to all mankind. > > Is this /just/ a troll, or has Python's (relative) lack of speed > bothered you? Yes, C can spin empty loops faster (especially if the > optimiser removes the loop entirely...), but for doing most > significant things, the difference is much less noticeable. Actually I've created array and did something like this : for k in xrange(1,10000): for m in range(1,10000): x[m] = .... #some calculation of the value of an array's element x[m] and this work's realy slow compared to C. I don't mind it working 3 times slower, but .. Perhaps it is possible, to do something like implementing loops in C inside Python ?? (though it seems to me it will not help) From jae at ilk.de Wed May 17 21:52:13 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Thu, 18 May 2000 03:52:13 +0200 Subject: seeking volunteer position In-Reply-To: <39226352.BD7C6A34@uab.edu> (message from Shae Erisson on Wed, 17 May 2000 08:56:26 GMT) References: <3921691e.793513@news> <39226352.BD7C6A34@uab.edu> Message-ID: <18052000.1@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Shae" == Shae Erisson writes: [...] Shae> check out http://sourceforge.net, they have a long list of wanted Shae> positions. Shae> I'm am also aware of http://www.sourcexchange.net, and I Shae> know there are six or seven of these kind of websites. Please, don't confuse sourceXchange with SourceForge. sourceXchange is a commercial venture that wants to get developers together with buyers. SourceForge is a *service* that gives Free Software (they call it Open Source ;-) developers free resources for their projects (whatever they are). Bye, J PS: I agree on checking out SourceForge... there are lots of interesting projects there (like Mailman ;-). And a lot of them would be sure glad for an added hand... - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html SPACE: Above And Beyond (http://www.planetx.com/space:aab) "No matter how cynical I get, I can't keep up." -- Bruce Schneier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjkjTMsACgkQN0B+CS56qs1X9gCgqoM6j3lMDdIdi0mNBM2XkPKm EQoAn1Abua/TNJ9iHzbQn0sb/MnZfhAG =gllQ -----END PGP SIGNATURE----- From warlock at eskimo.com Wed May 3 01:39:34 2000 From: warlock at eskimo.com (Jim Richardson) Date: Wed, 03 May 2000 05:39:34 GMT Subject: plain text python source -> HTML syntax highlighted source References: <20000502043232.F187E41816@koro.off.connect.com.au> Message-ID: On Tue, 02 May 2000 14:32:31 +1000, Rod., in the persona of , brought forth the following words...: >: >Hmm, maybe in an older version. The script (syntax/2html.vim) that comes >: >with Vim 5.6 converts tabs to spaces according to your current 'tabstop' >: >setting. >: > >: >: Just when I think Vim has no more surprises for me:) >: >: (Jim, who just wishes Vim used python as a macro language.) > >you can embed python in vim (its an option when building 5.6), >and then manipulate your current edit buffer and the 'ed' comands from python >scripts from within vim. > >Ive used it a bit, and its cool... just a little slow, so you >end up doing things in vi mostly anyway :/ > >rod. > > Cool, yet another reason to get no sleep tonight... -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From tbalazs-this-must-go at netcomuk.co.uk Tue May 23 01:07:17 2000 From: tbalazs-this-must-go at netcomuk.co.uk (Tony Balazs and/or Wendy Webster) Date: Tue, 23 May 2000 05:07:17 GMT Subject: Newbie: tutorial Message-ID: <392a11d7.84245456@nntp.netcomuk.co.uk> Could someone please recommend a tutorial on Python programming in a Win95 environment for someone who's essentially a non-programmer, though I do have some Smalltalk and a tiny bit of VB? I don't find the tutorial in the main distribution very easy as a starter. Thanks for any help. Tony. From alan.gauld at gssec.bt.co.uk Thu May 4 11:55:58 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Thu, 04 May 2000 16:55:58 +0100 Subject: python's acceptance References: Message-ID: <39119D8E.C7CC047A@gssec.bt.co.uk> Speaking as an occasional Delphi programmer... Scott Hathaway wrote: > 1. In making this transition, I have had trouble because I am not used to > trying to layout gui's with pure code. It's not too bad once you get used to it - some squared paper and a pencil helps to get the initial design down then after that modify what's there, however... It took me a while to trust the layout managers to put things in the right places but once I got over that hurdle I didn't find it too bad. > If python could get a gui builder SpecTcl with the SpecPython add in works pretty well for me on both Unix and windows. Have you tried that? > platform, it could easily give VB or Delphi a run for their money. I have > recently looked at Boa Constructor that lays out wxPython code and lets you > build a gui! This is awesome. I think glade can do the same but haven't really looked or tried either - Spectcl does most of what I want. Usually i just handcraft it because I use python as a scripting tool for typing things together, thus my GUI is usually a single window front end to a commandline version of the program... > 2. It is nearly impossible for a newbie like me to build an .exe on the > Windows platform with Python. Why do you need to? Why not either distribute Python with your app (use an intelligent installer to check if its already there)? Unless you want to hide the source code from prying eyes? Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From dana at oz.net Sun May 14 15:08:40 2000 From: dana at oz.net (dana_booth) Date: 14 May 2000 19:08:40 GMT Subject: (gulp) newbie question - portablity of python References: Message-ID: <8fmtjo$3ub$0@216.39.141.21> Keygrass wrote: K: So ... my question is this: Is this really too good to be true? What I want K: to do it write the program on my Win98se (at home) and then use that .exe K: or .bat file (or whatever extension it is) at work which uses unix. TCL/TK also is very portable, and I have written several GUI front ends in TCL that call on Python for the "real" work. Both the TCL and Python scripts are written and tested on my Linux workstation. When they're ready for prime time, I move them to an OpenBSD server, where they'll reside for the Windows users. The computer that you intend to run Python on must have Python installed, that's all. If you include propriotory stuff like absolute pathnames, i.e., "c:\program files\..., etc., that's up to you, but other than that, the code is portable. K: Basically, I want a build a program that will replace words and number on K: another file. For example, if I had a file called "Outdoor_sports" that K: contained the word "baseball bat", I would want my program to change it so K: it would say "football". Really easy. Good luck! -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From jmg at ecs.soton.ac.uk Thu May 25 06:09:28 2000 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: Thu, 25 May 2000 11:09:28 +0100 Subject: Pass by reference? References: <8ghcq1$opl$1@supernews.com> <392C683E.AF7398D4@uab.edu> <8gin25$sfe$1@supernews.com> Message-ID: <392CFBD8.E5173DFD@ecs.soton.ac.uk> Dale Strickland-Clark wrote: > Also the following program proves to me that arguments are passed by value > and not by reference: No, it doesn't, but I agree that if you do not keep in mind exactly what `=' does in Python, then you are likely to think so. > def wibble(var): > var = 1 > > x = 0 > wibble(x) > print x > > It prints 0 showing that the assignment in wibble is made to a copy of x > > So - how do I pass a variable to a function/subroutine/method by reference? > > Thanks for any insight into this. The deal is approximately this: Each time you use `=', the variable on the left becomes a reference to whatever appears on the right. Function argument passing is done by the same mechanism. So, in your example, when x is passed to wibble(), wibble's var becomes a reference to x. Then, when you assign 1 to var, var becomes a reference to 1. Remeber that Python objects can be classed as mutable or immutable. Try passing a mutable object to wibble, and mutating it in place (as opposed to re-assigning it) and you will find that the argument really is passed by reference. program: =============== def wibble( mutable ): mutable[0] = 5 x = [1] print x wibble( x ) print x ================ output: [1] [5] ================= Now, change the body of wibble() to mutable = [5] and you will find that x remains unchanged. Make sense ? Jacek From pdfernhout at kurtz-fernhout.com Wed May 24 07:53:23 2000 From: pdfernhout at kurtz-fernhout.com (Paul Fernhout) Date: Wed, 24 May 2000 07:53:23 -0400 Subject: Pointrel Data Repository System for Python References: <392AA43E.B3014C3B@kurtz-fernhout.com> Message-ID: <392BC2B3.FB5DC875@kurtz-fernhout.com> Here is something I posted to the Idle development list (slightly reformatted). It may be of more general interest because the included code snippet for file versioning gives a sense of how Pointrel development feels. It's also an example of what a flexible data repository can be used for. Note the ad-hoc way you can just keep adding new types of information to it -- by using new concepts to define new relationships. [Disclaimer: In general, versioning and naming are complex topics and the included code snippet just scratches the surface.] ===== As Glyph Lefkowitz pointed out in this list on Sat, 1 April, it would be nice if Idle had an built-in version control system for files (not relying on CVS). I just released the Pointrel Data Repository System for Python (version 0.01) available at: http://www.kurtz-fernhout.com/pointrel/ The core of the system is basically a 20K Python module "PointrelRepository20000513.py" that provides a simple database-like system with some unusual properties. It is released under an X11/MIT type license so it should be Python license compatible. The wxPython-based example file viewer included in that distribution supports archiving and running of chosen versions of a Python file, but it is *very* crude. Of course, editing Python files with Idle would be much slicker than doing it in a text pane as done in that example. I looked briefly at the Idle source code a while back with an eye to adding version control. I think it might be possible with a days effort or so for someone to integrate the Idle and the Pointrel system to handle multiple versions of files. I believe most of the changes would have to be made to "IOBinding.py". Specifically, every time one saves a file to disk in Idle, a copy would go into the repository under that files complete path name. Ideally, one could also add a version name (or by default just increment a version number and include the date and time). When a file was opened from a special menu item in Idle, a dialog could pop up with alternate versions of that file that were listed in the repository under the same name. Deleted or moved files would be hard to recover with this simple interface -- you'd have to make an empty file in the right place and open it. One would need a repository file list browser dialog to find them otherwise; even in that case there are deeper issues to address. Relavant Pointrel API calls would include: #returns a unique triad associated with a name string Repository.triadForName(name) #returns a triad with the specified A, B, C slots Repository.addTriadABC(a, b, c) #same as above, but also with an associated string Repository.addTriadABCString(a, b, c, string) #same as above, but with just a string and A, B, C of 0 Repository.addTriadString(string) #returns list of Cs in triads which have the A and B Repository.searchABForAllCs(a, b) #returns list of triads which have the A and B Repository.searchABForAllCLinks(a, b) #returns the last added C triad with A and B Repository.searchABForLatestCLink(a, b) #returns string associated with this triad Repository.triadString(triadIndex) #returns unique triad representing concept with that name Repository.triadForConcept(name) Here is a code fragment that uses these calls to store and retrieve versions of a file. #So adding "C:/MyDev/foo.py" could involve something like: import PointrelRepository20000513 myRepository = PointrelRepository20000513.Repository() myRepository.openFiles() hasContentsConcept = myRepository.triadForConcept("has contents") fileNameNode = myRepository.triadForName("C:/MyDev/foo.py") fileContentsNode = myRepository.addTriadString("fileContentsOfFoo") myRepository.addTriadABC(fileNameNode, hasContentsConcept, fileContentsNode) hasVersionNameConcept = myRepository.triadForConcept("has version name") myRepository.addTriadABCString(fileContentsNode, hasVersionNameConcept, 0, "Version 0.0.1") #Retrieving all versions of a file could involve something like: hasContentsConcept = myRepository.triadForConcept("has contents") fileNameNode = myRepository.triadForName("C:/MyDev/foo.py") fileContentsNodes = myRepository.searchABForAllCs(fileNameNode, hasContentsConcept) for node in fileContentsNodes: contentsString = myRepository.triadString(node) print "Contents: ", contentsString versionInfoLinkNode = myRepository.searchABForLatestCLink(node, hasVersionNameConcept) versionString = myRepository.triadString(versionInfoLinkNode) print "Version", versionString If you ran this code three times and with a newly made repository (run "PointrelRepository20000513.py" first), you should get this output on the third run: Contents: fileContentsOfFoo Version Version 0.0.1 Contents: fileContentsOfFoo Version Version 0.0.1 Contents: fileContentsOfFoo Version Version 0.0.1 Note that for performance one might eventually want to cache the locations of the concept nodes somewhere in an Idle editor object. To get fancy, one might then add difference reporting, and another later improvement could be to group or tag versions of a files into a project versions. Would anyone on this list be interested in giving this Idle/Pointrel System integration a try? I don't have the time to do the Idle integration anytime soon myself, but I'd be happy to provide someone interested in trying it with "technical support" on using the Pointrel system (under the assumption the Idle integration results would be under a Python or compatible license). The code I provided here should be enough to get started and over the worst initial hurdles. It would help me out to get some intial feedback on the usability of what I have just released, and it might just make a nifty add-on for Idle. -Paul Fernhout Kurtz-Fernhout Software ========================================================= Developers of custom software and educational simulations Creators of the Garden with Insight(TM) garden simulator http://www.kurtz-fernhout.com From cut_me_out at hotmail.com Mon May 29 22:38:51 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 May 2000 22:38:51 -0400 Subject: Triple quote problem in Pythonwin References: <6956js4qo9jamd6i86iccch7blsct7qs6n@4ax.com> <5l86jss31e5olsrvngvpdihvrnk08o0v3a@4ax.com> Message-ID: You mean you're doing this in the shell? I don't know, then. It works for me... >>> '''Testing, testing, ... one, two, three...''' 'Testing, testing,\012one, two, three...' >>> I guess it must be a pythonwin problem, then. Sorry for the bad advice. Alex. From embed at geocities.com Fri May 26 09:42:36 2000 From: embed at geocities.com (Warren Postma) Date: Fri, 26 May 2000 09:42:36 -0400 Subject: Jpython and Forte for Java References: Message-ID: > I am embarking upon a new project that needs to run on both Win32 and > FreeBSD Unix. I am coming from a Visual Basic environment where I have > grown shallow and lazy. as such, I am interested in using an IDE that will > help me design a quick and easy interface. Perhaps the quickest way to avoid being shallow and lazy is to avoid using an IDE at all, or if you do use one, use a minimal "editor with a built in debugger but no visual form builder" type IDE such as IDLE. For the GUI use wxPython. Watch out for BoaConstructor which is up and coming full GUI IDE. To me, if you're writing your GUI in Java, just write the whole thing in Java. A mixed language application for no reason other than to use the Forte IDE seems a waste of time. Python + wxPython is probably a lot better, smaller, faster, whatever. Warren From geoff at elj.com Tue May 30 04:50:52 2000 From: geoff at elj.com (geoff at elj.com) Date: Tue, 30 May 2000 08:50:52 GMT Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <393004FA.846A54BF@mit.edu> <8gtn29$s8u$1@ites.inria.fr> Message-ID: <8gvvd9$s7m$1@nnrp1.deja.com> In article <8gtn29$s8u$1 at ites.inria.fr>, Cedric Adjih wrote: [..] > If you need more speed than Python has (but not top speed), and something > more clean than C++, you can try something in between, such > as Java or Eiffel. Some interesting reading: 1. Counting words in a text Comparison of several algorithms and languages http://mageos.ifrance.com/bouchard/ 2. the Text Processing Benchmark by F.Dominicus http://www.qss.cz/bench/ 3. The Personal Software Process: an Independent Study http://www.nyx.net/~vputz/psp_index/book1.html Chapter 15. Appendix A: Eiffel vs C++ http://www.nyx.net/~vputz/psp_index/c15426.html Geoff > -- Cedric Sent via Deja.com http://www.deja.com/ Before you buy. From andres at corrada.com Tue May 30 17:35:53 2000 From: andres at corrada.com (andres at corrada.com) Date: Tue, 30 May 2000 17:35:53 -0400 Subject: os.linesep under Windows In-Reply-To: <14644.12510.157556.765244@cj42289-a.reston1.va.home.com>; from Fred L. Drake, Jr. on Tue, May 30, 2000 at 05:21:34PM -0400 References: <14644.9070.713948.988357@cj42289-a.reston1.va.home.com> <20000530165508.A16926@corrada.com> <14644.12510.157556.765244@cj42289-a.reston1.va.home.com> Message-ID: <20000530173553.A17261@corrada.com> On Tue, May 30, 2000 at 05:21:34PM -0400, Fred L. Drake, Jr. wrote: > > The C stdio functions convert '\n' to the underlying operating > system's line separator; that's what their supposed to do. (The stdio > functions are the ones that operate on FILE* values, not file > descriptors.) So '\n' converts to '\x0D\x0A' ('\r\n') in the C > libraries, and that's what appears in the file. The '\x0D\x0A' is > converted back to '\n' when read back in. > Note that these conversions are not performed if the file is opened > in binary mode; open(..., 'wb') does not enable this conversion. > This doesn't actually have much to do with Python, but rather with > the underlying libraries. Fred, Thanks for this explanation. It reminded me of a question I have asked before but never got a clear answer. If this is due to Python's C implementation, what happens in JPython? Does Java follow the same convention? ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From m.faassen at vet.uu.nl Tue May 23 07:09:05 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 11:09:05 GMT Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> Message-ID: <8gdosh$l78$1@newshost.accu.uu.nl> Steven D. Arnold wrote: [snip] > The programmer should be able to mark certain names as > "not-for-export." The `*' set would not export such names, though if the > module user were to import the name specifically, that would override the > "not-for-export" flag. In fact, Guido used his time machine on reading this post, and it already exists: just prefix the names you don't want exported with * with an underscore. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dalke at acm.org Mon May 22 13:32:14 2000 From: dalke at acm.org (Andrew Dalke) Date: Mon, 22 May 2000 11:32:14 -0600 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> <91egis4v9spsp8iteg0p4ok4bimlv4mr5t@4ax.com> <22052000.2@sanctum.jae.ddns.org> Message-ID: <8gbs97$3lm$1@slb2.atl.mindspring.net> Juergen A. Erhard wrote: >you might know enough German to know the difference between > "Dort haben sie etwas hingelegt" >and > "Dort haben Sie etwas hingelegt" > >One is "There they've put something down" and the other is "There >you've put something down." Okay, so it's the only word in German >that I'm aware of that changes meaning with capitalization... but >nontheless it proves there *are* words that mean different things >because of their capitalization. In English, an example is: Where is the polish container? Where is the Polish container? The first is where you might keep shoe shine, and the second is a container made in Poland. Unlike the following, the two words are even pronounced differently! Here's another: Do you like china? -- asking about ceramic preferences Do you like China? -- asking about country preferences Stretching some, That is my french toast. -- bread dunked in a mixture of eggs and milk, then toasted on the stove top That is my French toast. -- toast from France, or a congratulatory remark to be made in French. Switching to names of people instead of countries: If it weren't for Faith ... -- person named Faith helped out If it weren't for faith ... -- belief helped out And corporate names: What was next? -- curious about ordering What was NeXT? -- curious about the company Jobs started after leaving Apple. Andrew dalke at acm.org From m.faassen at vet.uu.nl Sat May 27 19:03:16 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 May 2000 23:03:16 GMT Subject: OT: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <392EEEE3.2D37@seebelow.org> Message-ID: <8gpk7k$h70$3@newshost.accu.uu.nl> Grant Griffin wrote: [snip] > Well, I'm an old DOS man, so I tend to flatter myself that I have a > balanced view of the command-line-versus-GUI thing. I still use DOS for > many of my little "system administration" tasks, but I also use the GUI > stuff for a major part of it. Maybe its about a 60/40 split for me > overall. That may be because the DOS command line is such a sad miserable excuse for a command line (and *still* it's more powerful than a GUI sometimes..). A command line with filename completion (and a history, though DOS has a mode for that, and actually powerful commands) is very different from the DOS command line. And I 'grew up' with that command line too. But there's such a large difference. I imagine there are extensions for the DOS command line that make it more bearable, but the default annoys me each time I need to go back to it from Linux. And on Windows, I always use WinZip. And on Linux, I always use the command line to unpack files. Overall I'm a trifle more comfortable with the latter as I need to click less than with WinZip. Anyway, both systems have their merits. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From remove.me.wwicker at spectratechnologies.com Tue May 9 10:01:19 2000 From: remove.me.wwicker at spectratechnologies.com (William Wicker) Date: Tue, 09 May 2000 14:01:19 GMT Subject: Tkinter windows always on top in Win32 Message-ID: <391819ca.314642161@news.onlineisp.com> How can I set a Tkinter window to always be on top? I couldn't find this in the fine Tkinter book, nor in any of the examples I searched. Please help. William. From tony at lsl.co.uk Mon May 15 07:33:16 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Mon, 15 May 2000 12:33:16 +0100 Subject: Augmented assignment (ie. += and friends) for Python! In-Reply-To: Message-ID: <001201bfbe61$5cba4680$f0c809c0@lslp7o.lsl.co.uk> > Undeterred I have put a new version of the patch on starship. The > main change is to support more operators; I now support > > += -= *= /= %= &= ^= |= <<= >>= **= > > (does C have &&= and ||=? I can't remember, and Python's not getting > them anyway). Hmm. Which operators did Algol68 support? (that's about as far back as I want to go in programming history looking for validation) My references are at home, but I can look them up if you like... (I don't remember what BCPL had either) [[reluctant to do *anything* because C does it that way...] Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ Note that Python's licence is in fact the MIT X11 licence, with MIT filed off and CNRI written in its place in crayon - Andrew M Kuchling My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From chafik at nevrax.com Fri May 26 09:27:58 2000 From: chafik at nevrax.com (Sameh chafik pro) Date: Fri, 26 May 2000 15:27:58 +0200 Subject: Need help on Python/C++ Message-ID: <8gltp7$f7f$1@gw.localdomain> are there someone how know all aboute the data member of the structur PyTypeObject? Sam. From andres at corrada.com Tue May 30 22:12:50 2000 From: andres at corrada.com (andres at corrada.com) Date: Tue, 30 May 2000 22:12:50 -0400 Subject: ANNOUNCE: mod_python 2.0 - A Python module for Apache. In-Reply-To: ; from Gregory Trubetskoy on Sun, May 28, 2000 at 10:49:25AM -0400 References: <200005281316.JAA15479@saltmine.radix.net> Message-ID: <20000530221250.A17958@corrada.com> On Sun, May 28, 2000 at 10:49:25AM -0400, Gregory Trubetskoy wrote: > > > 5) I've got the bits to pull out embedded code from HTML documents and > > execute them (from a tcl based module). Interested? > > Yes and no. The idea sounds good, but this sort of thing doesn't belong in > mod_python. Some time soon I will create a section on the website for > "third party" mod_python handlers - this could be one of them. > Grisha, Does that mean that mod_python allows you to extend the Apache server the same way mod_perl does? ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From Richard.Jones at fulcrum.com.au Tue May 2 18:28:04 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Wed, 03 May 2000 08:28:04 +1000 Subject: Stackless/microthreads merge news In-Reply-To: Message from Christian Tismer of 2000-May-2 21:51:1, <390F31A5.6452D256@tismer.com> Message-ID: <200005022228.IAA03188@envy.fulcrum.com.au> [Christian Tismer] > Hey, this is just an incredible idea. > Java with first class continuations, let that > drop through your brains. 90 percent of java threads > would be replaced by microthreads. > > I will read the Kaffe source and think how this must be. Please try to modify the Blackdown JVM rather than Kaffe - it's faster and ... well ... it actually works ... and it's Sun supported ... and stuff ... > It can become quite a revolution for Java. I think it's a damn fine idea! :: Richard From bigjoe615 at my-deja.com Tue May 2 16:56:04 2000 From: bigjoe615 at my-deja.com (bigjoe615 at my-deja.com) Date: Tue, 02 May 2000 20:56:04 GMT Subject: Embedding Python in Borland C++ Application Message-ID: <8enfcr$u9d$1@nnrp1.deja.com> I have been able to compile and link a C++ (Borland C++ Builder 4.0) with Python 1.5.2. I can use the following code to evaluate simple arithmetic expressions (like 9*9): ... PyObject *s; PyObject *PyGlobal=PyDict_New(); AnsiString exp=mFormulaTextDBMemo->Text; // struct _node*pn=PyParser_SimpleParseString (exp.c_str(),Py_single_input) ; s=PyRun_String(exp.c_str (),eval_input,PyGlobal,PyGlobal); total=PyInt_AsLong(s); ShowMessage("Value of expression:"+FloatToStr (total)); ... I am trying to understand how to use built in functions like sqrt, pow, etc. PyRun_String does not seem to work. How would I do this? Sent via Deja.com http://www.deja.com/ Before you buy. From zeitlin at seth.lpthe.jussieu.fr Tue May 9 09:53:48 2000 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 9 May 2000 13:53:48 GMT Subject: PyBalsa? References: Message-ID: On 07 May 2000 11:43:43 -0700, Harry George wrote: >I like the look-and-feel of the gtk-based balsa emailer. But it has >classic C-based crashes in the current pre-release. I was wondering >if anyone knows of a python-based rendition? Hello, you might be interested in Mahogany (see http://www.wxwindows.org/Mahogany/). It is supposed to be (it is not _yet_) a cross-platform Python-friendly MUA. It is written in C++ and not in Python, but it embeds a Python interpreter and can run Python scripts when something "interesting" happens - like the program starts or a new message arrives - which should open some interesting possibilities for extending it. I'm afraid that Python support (which was initially one of the main project goals) slightly faded away recently - mainly because no real Python programmers became interested in it and we prefer working on something people really use ourselves. But if you are really interested in Python+MUA combination, why not help us to make it real? Regards, VZ From gherman at darwin.in-berlin.de Tue May 16 13:39:04 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Tue, 16 May 2000 19:39:04 +0200 Subject: Modifying JPEG compression with PIL? References: <39217EA1.E58756A0@darwin.in-berlin.de> Message-ID: <392187B8.29875BD8@darwin.in-berlin.de> Fredrik Lundh wrote: > > Dinu C. Gherman wrote: > > Sorry, but I always fail to find appropriate PIL documenta- > > tion, so forgive me when I ask if using PIL I can take a JPEG > > and increase its compression, so it will shrink in file size > > (and lose data as well)? If so, where can I read how to do > > it? > > im.save("foo.jpg", quality=50) > > http://www.pythonware.com/library/pil/handbook/image.htm > http://www.pythonware.com/library/pil/handbook/formats.htm > > > > Thanks Fredrik! I'll bookmark it right away! Dinu -- Dinu C. Gherman ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From rafferty at aol.com Wed May 3 17:31:30 2000 From: rafferty at aol.com (Rafferty) Date: 03 May 2000 21:31:30 GMT Subject: COM Sockets Message-ID: <20000503173130.22333.00002350@ng-md1.aol.com> I am trying to establish a socket from Excel using COM python code. I started with the sample code and tried enclosing it in COM but when I execute I get a socket error 10061. Any ideas I want to use COM to send data from Excel or Word to a socket server for testing. Thanks The code is below COM Part: class PythonComDemo: _public_methods_= ['COMCreateSocket', 'COMSendToPython', 'COMRecieveFromPython'] _reg_progid_ = "ICE.COMUtilities" #created via: #import pythoncom #print pythoncom.CreateGuid() _reg_clsid_ = "{11F76A51-1A10-11D4-B656-00E02941D7F1}" def COMCreateSocket(self): import socket Host = 'XXX.XXX.49.XXX' #real address used Port = 7000 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(Host, Port) s.send('Hello World') data = s.recv(1024) s.close return `data` def COMSendToPython(self, s): return "data sent" def COMRecieveFromPython(self, s): return "good" if __name__=='__main__': print "Registering COM Server..." import win32com.server.register win32com.server.register.UseCommandLine(PythonComDemo) Server Part: # Echo server program from socket import * def serverSample(): HOST = '' # Symbolic name meaning the local host PORT = 7000 # Arbitrary non-privileged server s = socket(AF_INET, SOCK_STREAM) s.bind(HOST, PORT) s.listen(1) conn, addr = s.accept() print 'Connected by', addr while 1: data = conn.recv(1024) if not data: break conn.send(data) conn.close() if __name__ == '__main__': serverSample() From ajung at sz-sb.de Tue May 2 12:19:55 2000 From: ajung at sz-sb.de (Andreas Jung) Date: Tue, 2 May 2000 18:19:55 +0200 Subject: converting word documents to html In-Reply-To: <390CA7E5.F378A910@gte.net>; from smalleys@gte.net on Sun, Apr 30, 2000 at 09:38:19PM +0000 References: <390B501C.1891CB80@uiuc.edu> <390CA7E5.F378A910@gte.net> Message-ID: <20000502181955.B22787@sz-sb.de> On Sun, Apr 30, 2000 at 09:38:19PM +0000, sue wrote: > I've used tidy for this for two years. > > http://www.w3.org/People/Raggett/tidy/ > > My only complaint is that it doesn't collapse styles. But > they're easy enough to spot. tidy does a cleanup job on HTML files but it's not a converter from Word to HTML. However it improves the the quality of the Word generated HTML code by removing unneccessary sh*t - a cool tool ! Andreas From cut_me_out at hotmail.com Wed May 10 08:27:52 2000 From: cut_me_out at hotmail.com (Alex) Date: 10 May 2000 08:27:52 -0400 Subject: Future of the Python Linux Distribution References: <3916F04F.7647B829@zipzap.ch> <391790A2.26CB9618@home.com> <391812BF.4C226C55@home.com> <3918E2C9.7F4AF974@home.com> Message-ID: > -ly y'rs, 'Fraid not. It seems to have a problem with the "M" function. Perhaps this is a standard postscript command, but it's a little hard to search for, gets too many false positives. :) Error: /undefined in M Operand stack: 70 614 Execution stack: %interp_exit () --nostringval-- --nostringval-- --nostringval-- false --nostringval-- --nostringval-- %runexec_finish --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:682/701-- --dict:0/20-- --dict:49/200-- Current allocation mode is local Current file position is 436 This is with the program /rgt { _rbar exch get } bind def /p4 { 4 { pop } repeat } bind def /ism { { rgt } forall arcto p4 } bind def /stuff { _rbar exch 3 -1 roll put } bind def /Rbbx { gsave [ 6 1 roll ] /_rbar exch def 3 rgt 1 rgt add 1 stuff 2 rgt 0 rgt add 0 stuff 2 rgt 3 rgt 4 rgt add newpath M [ [ 2 1 0 1 4 ] [ 0 1 0 3 4 ] [ 0 3 2 3 4 ] [ 2 3 2 1 4 ] ] { ism } forall gsave Sg fill grestore Sg S stroke grestore } bind def 200 200 moveto 70 614 M 2 0.5 0.82 313 136 currentpoint 9 Rbbx Alex. From shapr at uab.edu Thu May 25 10:18:45 2000 From: shapr at uab.edu (Shae Erisson) Date: Thu, 25 May 2000 14:18:45 GMT Subject: What's in a name? Case-Enforcers to the rescue! References: <392D06E1.415DFEF1@uab.edu> Message-ID: <392D3BBE.1B103FC3@uab.edu> "Edward S. Vinyard" wrote: > For example, forcing the first letter of class names to be capitalized > makes it visually clear which names are classes. I enjoy Python's lack of > block delimiters and I think I would enjoy the lack of implicitness here, > too. Someone said that earlier that the VB IDE recases typed in name to fit the declared variables... you could move that into the interpreter itself. This idea looks quite interesting... I could really go for 'case-enforced' Python. I think newbies would have a much easier time with standardized case that contains explicitly defined information. thoughts: instance vars always upper case, classes always lower case, instances always first letter caps.... hm, I dunno about that. For seriously unconvential measures you could always declare the type of something by case :) sneaking-up-on-visual-programming-ly y'rs -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius On fIre From jkraska1 at san.rr.com Tue May 16 13:19:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 16 May 2000 17:19:34 GMT Subject: java to python q's References: <001d01bfbe7f$75c78fc0$2801000a@iel.ie> <200005160216.WAA08225@tor.dhs.org> Message-ID: <392183D5.1E732B54@san.rr.com> Glyph Lefkowitz wrote: > > Blake Winton writes: > > > nvsequence = new NvSequence() > > What blake MEANT to say ;-) I'm sure, was > > nvsequence=NvSequence() Hahahah. I just love it when errors like this creep up. Stuff like that happens to me all the time. It seems like I constantly forget the necessity of self, for example. C++, Java, and their implicit this'es don'tcha know. C/ From kuncej at mail.conservation.state.mo.us Wed May 24 10:35:19 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Wed, 24 May 2000 09:35:19 -0500 Subject: flock on windowsnt References: <392B9607.7250A905@yahoo.co.jp> Message-ID: > I want to use a function such as "flock()" on WindowsNT. > On unix, it seems "fcntl" module is available. > Is there any way on NT ? I extended the posixfile file locking protocol to work on NT. I never used it in production, so test it well before using. See: ntposixfile.py at: http://starship.python.net/crew/jjkunce/python/ntposixfile.py --Jeff From mikael at isy.liu.se Tue May 30 07:09:20 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 30 May 2000 13:09:20 +0200 (MET DST) Subject: sort and delete ? In-Reply-To: <00053022342901.01027@localhost.localdomain> Message-ID: On 30-May-00 matt wrote: > Is there a more "pythonic" way to do the following, which, before I make a > mess > is, suppossed to assess whether to throw elements out of a list and then > actually do so. I use a rather strange, but database-like, list. > > a = [['egg', [1, 'ace', 3]], ['apple', [1, 'two', 3]], ['pear', [4, > 'three', > 6]], ['orange', [5, 'two', 1]]] > > x=[] > for i in a: > if i[0][1] in ('ace','three'): > x.append(i) First of all, I think you meant i[1][1] above. I am an addict under the lambda-forms, so I would do it using filter: x = filter(lambda i:i[1][1] in ('ace','three'),a) Cheers, /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 30-May-00 Time: 13:04:55 This message was sent by XF-Mail. ----------------------------------------------------------------------- From krussell4 at videon.home.com Sun May 7 15:48:07 2000 From: krussell4 at videon.home.com (Kevin Russell) Date: Sun, 07 May 2000 19:48:07 GMT Subject: OT [Way OT]: Unicode Unification Objections References: Message-ID: <3915C869.1B387972@videon.home.com> "Dennis E. Hamilton" wrote: > Consider the following. In Japanese texts, when a borrowed or employed > Korean word is used, a desired practice is to render the Korean > characters as different, even though some or all of them involve "the > same character" common to both languages. However, the iconography (or > calligraphy) is commonly different. This loses the ability to > distinguish the linguistic use of the character, forcing material to be > font-distinguished some how (e.g., give me the ones that look Korean, > not the ones that look Japanese). This means that the distinction can't > be preserved in simple text. The entire point of markup is that distinctions like this *shouldn't* be preserved in simple text. How a particular character should *look* is a question for presentation glyphs, not for character encoding. What kind of language a character is used to represent (emphasis, quotations, foreign borrowings, titles, proper names, sarcasm, etc.) is a question for markup, not for character encoding. A similar situation holds in almost every written language. We often dump Latin or French words into English text. Even though they may be written in the same alphabet, we usually want them to *look* different from ordinary English words. But nobody uses that fact to argue that Unicode should have handed out a separate code number to italic "e" than to plain "e" -- or even that entirely disjoint sets of codes should be used for writing Latin, French, and English words. (Actually, there probably were people who argued these, but they were rightly ignored.) Once you start mixing up glyph questions (what a character should look like) and markup questions (what kind of language is the character being used for) with character encoding questions, there's no logical place to stop. Soon the Unicode Consortium would be fielding requests like "I want to be able to distinguish the Yamato pronunciation of the 'sun' character whispered with a Hokkaido accent and a lisp from the Yamato pronunciation of the 'sun' character as muttered inaudibly by someone from Okinawa who has a head-cold. And I want to do it with a character that looks like it was finger-painted in drippy chartreuse water-colours by a five-year-old. And it should be 23-point bold, 'cause it will be in a title. I suggest you assign me character xDE4A921B." > > Unfortunately, the Greek alphabet and the APL alphabet (and apparently > some other math symbol alphabets) *were* unified. That is, a number of > Greek-letter symbols were removed from any distinct APL character set, > and only some APL-unique made-up symbols having Greek letters in them > were retained as separate. Unfortunately, the iconography of the Greek > alphabet in Greek text is often enough different that those codes don't > render appropriately with the other APL symbols when used in APL texts. > Borrowing epsilon (for member) from the Greek character set in Unicode > is not always what one wants to do when writing membership propositions > in APL (and borrowing the alternative MEMBER OF symbol may not get you > what you want either). It's even more fun if you want to write APL > programs and use Greek-language identifiers. Something a CP4E teacher > in a Greek school might strongly desire to do. Get it? > What kind of sadist would try to teach a CP4E course using APL?! (And I say this fondly as someone who learned APL as my first computer language in high school.) Actually, this is a very good point. But the problem is more with APL than with Unicode. Every computer language needs a way to distinguish characters used in literals from characters used in operators from characters used as raw data (e.g., strings), and so on. Usually the decisions made during syntax design will limit to programmer's freedom to make up literal names. (Or to quote what I said at 90 decibels at 2 a.m. two nights ago: "Why the **** can't I call that variable 'class' if I want to call it 'class'!) Iverson's decisions during APL's syntax design must have made perfect sense in 1960, but in hindsight they turned out to be extremely inconvenient. If you want to extend APL to make it less inconvenient for your Greek teacher, you're either going to have to redesign the language syntax from scratch (as Iverson did for J) or you could take the problematic APL characters and assign your own codes to them from Unicode's private use blocks. That's what the private use blocks are for -- they let you and the four other people in the universe who are going to use your Greek APL interpreter do what you need to do, without bogging down the entire character standard. -- Kevin Russell From mfletch at tpresence.com Fri May 26 23:20:48 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 26 May 2000 23:20:48 -0400 Subject: Microthreads: wait( duration ) with minimal processor overhea d, u Message-ID: The thing this modification allows is to "sleep" or "wait" a micro-thread for a specified (real-time) duration without requiring an active thread running constantly to unblock the client. I've not seen anything else in the micro-threads libraries that allows this. class Timer(Blockable): ... def mythread(self): import time while time.clock() < self.finish: switchContext() self.notifyAll() def start(self): new(self.mythread) Note that the Timer is actually creating a tight loop that gets a time-slice on each pass through the thread list. If you have 3000 Timers running, you've got 3000 versions of this loop gobbling up processor power. wait'ing 3000 (or however many) threads, in contrast, means you have 2 checks on each loop through the active threads. When all micro-threads are suspended, the os thread gets suspended, so you drop to ~0 processing load. In my app, using a 0.01s wait in a polling loop takes the processor load from 100% to below 5%. Regarding decoding mime files: import mimetools mimetools.decode( sourcefile, destfile, 'quoted-printable' ) Enjoy, Mike -----Original Message----- From: wware at world.std.com [mailto:wware at world.std.com] Sent: Friday, May 26, 2000 9:42 PM To: python-list at python.org Subject: Re: Microthreads: wait( duration ) with minimal processor overhead, u Mike Fletcher (mfletch at tpresence.com) wrote: > Attached find uthread6.py (modified version of Just's uthread4.py). This > adds a mechanism for putting micro-threads to sleep (with minimal processor > overhead), both when other micro-threads are running and when only sleeping > threads are present. > ... it should keep micro-threads from always pegging the processor in > low-load conditions (such as watching ports). Normal sleeping threads (for instance, a thread that has blocked while waiting for input from a queue, or waiting for a timer to finish) do not take up any processor activity until the they are reactivated by the event that wakes them. I think you may be working on an already-solved problem. > [uthread6.py] Using the Unix 'mail' program, I find that the text is full of nonsense like "3D" and "=09". I think this is an artifact of MIME encoding. Is there any way to repost it without this stuff? Or is there a filter somewhere handy for getting rid of it? -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com -- http://www.python.org/mailman/listinfo/python-list From g2 at seebelow.org Mon May 8 13:42:55 2000 From: g2 at seebelow.org (Grant Griffin) Date: 8 May 2000 10:42:55 -0700 Subject: HTMLParser tag contents References: <391544E1.6F0@seebelow.org> <39159114.BFB@seebelow.org> Message-ID: <8f6uav$8cj@drn.newsguy.com> In article , "Fredrik says... > >Grant Griffin wrote: >> I experimented with your approach and it worked, but I finally decided >> just to use 're', to preserve HTMLParser's other features. Here's what >> I came up with: > >cannot really figure out what you're trying to do, but I can assure >you that I wouldn't have done it that way... (Oops! Did is this comp.lang.perl.misc?--or does comp.lang.python also provide free newbie-mugging-service? ;-) >what exactly are those "other features" you want to preserve? Extracting the title and metas, for example. The dspGuru site currently has about 60 pages, all of which have been created manually. I now need to change the style of all the headers and footers. Also, in the future, I would like to be able to create new pages without headers and footers using a standard HTML editor. To that end, I have been planning to conscript HTMLParser and HTMLGen to build new pages from "source" pages. The title and metas of the sources will be combined with program-generated headers/footers, and the stuff inside the sources' "" tag (which HTMLGen will receive as "RawText"). The "HTMLParserEx" class I had posted was a starting point for all that. (So what's to not figure out? ;-) throwing-rocks-at-somebody's-glass-house-is-a-whole-lot-easier -than-teaching-'em-how-to-lay-bricks--ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From jkraska1 at san.rr.com Tue May 30 03:26:42 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 30 May 2000 07:26:42 GMT Subject: PyCFunction? What is it? References: <39332C24.3B34D9A@cosc.canterbury.ac.nz> Message-ID: <39336DCC.A8B64090@san.rr.com> > nope. when you're implementing methods, the first argument > is a pointer to an object instance (cast down to a PyObject). > To get the object pointer, you have to cast it back at some > point, and some programmers prefer to write: > > mymethod(MyOwnObject *self, PyObject *args) > { > ... > } > > and put the cast in the method table, than to keep writing > things like: > > mymethod(PyObject *self_, PyObject *args) > { > PyOwnObject* self = (MyOwnObject*) self_; > ... > } Ahhh. That explains it. VCC was allowing me to declare things this way without an explicit cast, but it did issue warnings. I started doing PyCFunction because I think I saw it in Guido's code maybe. C/ From teyc at bigfoot.com Sun May 28 06:52:19 2000 From: teyc at bigfoot.com (Chui Tey) Date: Sun, 28 May 2000 20:52:19 +1000 Subject: Looking for simple thread example using Events Message-ID: <8gqt4r$995$1@bunyip.cc.uq.edu.au> Hi, Are there any simple example of how Events work with threads? Thanks. Chui From akuchlin at mems-exchange.org Mon May 22 10:12:02 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 22 May 2000 10:12:02 -0400 Subject: bz2 support in Python? References: <3929327D.1F09D8BB@anfdata.cz> Message-ID: <3dsnvad68d.fsf@amarok.cnri.reston.va.us> Xavier Outhier writes: > Is there in Python any bz2 tool? bz2 is the 2nd version > of bzip. A compression algo. Not as far as I know, though it would certainly be possible to write one. Without such an extension, you'd have to run a bzip2 subprocess to handle compression or decompression. By the way, http://www.vex.net/parnassus/ is the best place to search for whether a Python module exists. -- A.M. Kuchling http://starship.python.net/crew/amk/ To my battle-scarred mind, documentation is never more than a hint. Read it once with disbelief suspended, and then again with full throttle skepticism. -- Gordon McMillan, 19 Oct 1998 From zorro at zipzap.ch Mon May 1 05:44:02 2000 From: zorro at zipzap.ch (Boris Borcic) Date: Mon, 01 May 2000 11:44:02 +0200 Subject: The Simple Economics of Open Source References: <1255272357-66924550@hypernet.com> <1255228265-1994958@hypernet.com> Message-ID: <390D51E2.70DBC685@zipzap.ch> Gordon McMillan wrote: > > Raffael Cavallaro wrote: > [...] > > You're conflating separate markets. Unique artworks (paintings, > > for example) have no real equivalent in the software world, > > because software sales are based on essentially unlimited > > identical copies. > > 'Twas your analogy. Imho, the relationship of the two cases is more subtle than that. In a sense, MS Windows functions as a unique artwork. A rather ugly one for many people with a bit of trained taste, to be sure. Ascribing the name of "artwork" to MS Windows thus finds two sorts of partial justifications : one is the relative appeal it is designed to have with totally unsophisticated users, the other is the abstract generalisation of this, e.g., saying that it captures attention just by the "virtue" of being there, that it binds people (and markets) to it as if it had a magnetic field, just like artworks. As for the matter of "essentially unlimited copies", this denies the well-known place of software licences. Open source or closed source, software comes with licences that obviously have the power to determine in principle the properties of duplication processes. Please note that calling MS Windows an "artwork" is in no way intended as an endorsement of the ways of Bill Gates. This is best illustrated by noting that a gun may be viewed as an artwork. Comparing MS Windows to guns is actually enlightening. When "networked" to a society where guns are commonplace, there is a lot of incentive to acquire one, too. BB From noemail at nowhere.hades Fri May 26 06:03:35 2000 From: noemail at nowhere.hades (Mike Cat) Date: 26 May 2000 10:03:35 GMT Subject: how can I reload 'from *' ? Message-ID: <8F407AF9Dmikecat@192.168.10.38> Hi! How can I reload things imported with 'from HUGO import *' ? Regards, Mike From effbot at telia.com Mon May 15 15:03:48 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 15 May 2000 19:03:48 GMT Subject: Serve_forever?? References: Message-ID: A[r]TA wrote: > Why doesn't this work?? > > from SocketServer import * > > class request: > print 'blah' > > TCPServer(('127.0.0.1' , 80), request) > TCPServer.serve_forever() > > Traceback (innermost last): > File "", line 1, in ? > File "C:\Program Files\Python\test.py", line 7, in ? > TCPServer.serve_forever() > TypeError: unbound method must be called with class instance 1st > argument > > I don't get it. It must be something simple, but can't figure out what. you're calling serve_forever on the class, not the instance. and the request handler must be subclassed from a RequestHandler base class. here's an example: # adapted from socketserver-example-1.py in # the eff-bot guide to the python standard library # http://www.pythonware.com/people/fredrik/librarybook.htm import SocketServer # some user-accessible port PORT = 8037 class myRequestHandler(SocketServer.StreamRequestHandler): def handle(self): self.wfile.write("blah") server = SocketServer.TCPServer(("", PORT), myRequestHandler) print "listening on port", PORT server.serve_forever() From tim_one at email.msn.com Tue May 23 01:15:42 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 23 May 2000 01:15:42 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Message-ID: <000301bfc475$f12c6720$612d153f@tim> [neelk at cswcasa.com] > ... > there are so many more fundamental changes being discussed -- > such as true garbage collection, type/class unification, lexical > scoping, rich comparisons, strong typing, a new iteration protocol -- > that I'm amazed and a little dismayed that something as relatively > trivial as case-sensitivity is dominating the discussion. It's OK to be dismayed, but not amazed: the other things involve hard technical tradeoffs, while anyone can weigh in on case-sensitivity with about as much credibility as anyone else (I've kept a complete list of the scholarly citations presented on this issue, and will embed it in the period at the end of this sentence ). > ... > there's a critical need to be able to iterate over trees and < linked-lists cleanly. This is IMO more significant than GC or > even type-class unification, Opinions vary widely on the relative importance here, of course. Depends on whether the last program you wrote leaked memory, or drove you nuts trying to iterate cleanly <0.9 wink>. > and it's the major reason I'm rooting for Stackless, since it > permits Sather-style coroutine-based iterators to be > implemented in Python. Alas, that won't sell Stackless. My read is that Guido is secretly in favor of a powerful iterator protocol, but semi-coroutines can be implemented via much simpler means than Stackless -- even in ways that will work for JPython too. Stackless needs a killer app unique to it, or to get perceived as a single solution to several problems as pressing as pleasant iterators. that-rarest-of-beasts-a-case-sensitive-windows-guy-ly y'rs - tim From dalke at acm.org Mon May 8 15:38:28 2000 From: dalke at acm.org (Andrew Dalke) Date: Mon, 8 May 2000 13:38:28 -0600 Subject: Copyright and License References: <000801bfb8b9$f0fc7280$b12d153f@tim> Message-ID: <8f750r$9qv$1@slb2.atl.mindspring.net> Cliff Crawford wrote: >I've actually heard the opposite said by people defending the GPL. >Supposedly if you release something as PD, or even with a BSD or other >license, then a Big Corporation can take your code, assert copyright on >it without even making any modifications or anything, and then sue you >for distributing "their" code. So that's why everyone should use the >GPL. At least, that's how their argument goes.. Documents produced and released by the US government are required to be released in the public domain. (There are documents which aren't released.) If the above were true, there are enough anti-government people that one of them would pick up public domain documents from the government, assert copyright, and force the government to stop distribution - just for fun. Since that hasn't/won't happen, the claim is unlikely. Another way to handwavingly disprove it. When the copyright expires, a document enters the public domain. If that claim were true, documents would enter the public domain for a fraction of a second, then a company would reclaim it. Want to claim copyright on the King James Bible? Andrew dalke at acm.org From nickm at mit.edu Tue May 23 13:18:25 2000 From: nickm at mit.edu (Nick Mathewson) Date: Tue, 23 May 2000 17:18:25 GMT Subject: [PATCH] A compromise on case Message-ID: "Everybody's always talking about the weather, but nobody seems to do anything about it." So I wanted to see how hard it would be to make Python's error messages friendlier to case-insensitive newbies, without breaking existing programs that rely on 'Guido', and 'GUIdo' being different names. I decided the best way to do this was to patch the code that raises NameError and AttrError. My rationale was this: Guido has said that he's considering case-insensitivity because beginners often run into problems. ***My hypothesis is that their problems aren't due to the language, but due to the unhelpful error messages it gives.*** After all, who could learn much from an error message like this: Traceback (innermost last): File "", line 1, in ? NameError: X So I tried to make a quick-and-dirty patch the Python interpreter to do something more reasonable. Here's a sample interaction: [tracebacks omitted, long lines wrapped] >>> def square(x): ... return X*X >>> print MAP(square, [1,2,3]) NameError: No such name as 'MAP'. Perhaps you meant 'map'? >>> print Square(3) NameError: No such name as 'Square'. Perhaps you meant 'square'? >>> print square(1) NameError: No such name as 'X'. Perhaps you meant 'x'? >>> import string, re >>> print string.JOIN(['a', 'b', 'c']) AttributeError: JOIN. Perhaps you meant 'join'? >>> x = re.compile('[Py]thon') >>> print x.CODE AttributeError: 'RegexObject' instance has no attribute 'CODE'. Perhaps you meant 'code'? >>> print x.Match('Python') AttributeError: 'RegexObject' instance has no attribute 'Match'. Perhaps you meant 'match'? With this kind of error message, newbies can learn to code better, but without Of course, our powers are not what they could be: >>> print string.combine(['a', 'b', 'c']) AttributeError: combine ===== Naturally, this patch has some problems. After all, it's only the result of a few hours hacking, by a guy who doesn't know Python's internals too well. Here are its biggest problems: * The code isn't particularly smart or clean. It's probably possible to do something simpler with a more generic framework. * It probably has a few reference leaks. If it does, they would only occur when an error is actually raised. * It's a drop in the bucket. Python's error messages need more help than this. * It only handles case errors, not other kinds of misspellings. * It requires that your system libraries have the function 'strcasecmp'. This should be true on most Unix systems IIRC, but I have no idea whether it holds true for Windows or Mac. * It's against Python 1.6a2. If you want stability, of course, you shouldn't be applying this at all. Does Guido read this newsgroup, or just the mailing list? I'm curious to know what he would think of this strategy (ignoring my wretched code). =====Begin unified diff --- Python-1.6a2/Python/ceval.c Mon Apr 10 08:45:10 2000 +++ casepy/Python/ceval.c Tue May 23 12:50:21 2000 @@ -94,6 +94,8 @@ PyObject *, PyObject *, PyObject *)); static void reset_exc_info Py_PROTO((PyThreadState *)); +static void set_name_error Py_PROTO((PyFrameObject *, PyObject *)); +static void set_attr_error Py_PROTO((PyObject *o, PyObject *attr)); /* Dynamic execution profile */ #ifdef DYNAMIC_EXECUTION_PROFILE @@ -1194,8 +1196,9 @@ "no locals"); break; } - if ((err = PyDict_DelItem(x, w)) != 0) - PyErr_SetObject(PyExc_NameError, w); + if ((err = PyDict_DelItem(x, w)) != 0) { + set_name_error(f,w); + } break; #ifdef CASE_TOO_BIG @@ -1262,6 +1265,8 @@ v = POP(); err = PyObject_SetAttr(v, w, (PyObject *)NULL); /* del v.w */ + if (err) + set_attr_error(v, w); Py_DECREF(v); break; @@ -1274,8 +1279,9 @@ case DELETE_GLOBAL: w = GETNAMEV(oparg); - if ((err = PyDict_DelItem(f->f_globals, w)) != 0) - PyErr_SetObject(PyExc_NameError, w); + if ((err = PyDict_DelItem(f->f_globals, w)) != 0) { + set_name_error(f,w); + } break; case LOAD_CONST: @@ -1297,8 +1303,7 @@ if (x == NULL) { x = PyDict_GetItem(f->f_builtins, w); if (x == NULL) { - PyErr_SetObject( - PyExc_NameError, w); + set_name_error(f,w); break; } } @@ -1313,7 +1318,7 @@ if (x == NULL) { x = PyDict_GetItem(f->f_builtins, w); if (x == NULL) { - PyErr_SetObject(PyExc_NameError, w); + set_name_error(f,w); break; } } @@ -1384,6 +1389,8 @@ w = GETNAMEV(oparg); v = POP(); x = PyObject_GetAttr(v, w); + if (x == NULL) + set_attr_error(v, w); Py_DECREF(v); PUSH(x); if (x != NULL) continue; @@ -2925,6 +2932,214 @@ return list; } +static int +name_is_similar(n1, n2) + char *n1; + char *n2; +{ +#ifdef HAVE_STRCASECMP + return n1 && n2 && strcasecmp(n1,n2) == 0; +#else + return 0; +#endif +} + +static int +name_is_similar_to_str(n1, s) + char *n1; + PyObject *s; +{ +#ifdef HAVE_STRCASECMP + char *n2 = PyString_AsString(s); + return n1 && n2 && strcasecmp(n1,n2) == 0; +#else + return 0; +#endif +} + +static PyObject* +dict_ClosestName(d, s) + PyObject *d; + char*s; +{ + int pos; + PyObject *key, *value; + + if (! d) + return NULL; + + pos = 0; + + while (PyDict_Next(d, &pos, &key, &value)) { + if (name_is_similar(PyString_AS_STRING(key), s)) { + Py_INCREF(key); + return key; + } + } + return NULL; +} + +static PyObject* +sequence_ClosestName(seq, s) + PyObject *seq; + char* s; +{ + PyObject *item; + int i; + + if (!seq) + return NULL; + + for (i = 0; ; i++) { + item = PySequence_GetItem(seq,i); + if (item == NULL) { + PyErr_Clear(); + break; + } + if (name_is_similar_to_str(s, item)) + return item; + Py_DECREF(item); + } + return NULL; +} + + +static PyObject* +object_ClosestAttr(o, s) + PyObject *o; + char *s; +{ + static char *attrlist[] = {"__members__", "__methods__", NULL}; + + PyObject *d, *cls, *lst; + PyObject *item; + int i; + char **p; + + if (!o || !s) + return NULL; + + /* Look for name in o.__dict__ */ + d = PyObject_GetAttrString(o, "__dict__"); + if (d == NULL) + PyErr_Clear(); + else { + item = dict_ClosestName(d,s); + Py_DECREF(d); + if (item) + return item; + } + /* Look for name in o.__class__.__dict__ */ + cls = PyObject_GetAttrString(o, "__class__"); + if (cls == NULL) + PyErr_Clear(); + else { + d = PyObject_GetAttrString(cls, "__dict__"); + Py_DECREF(cls); + + if (d == NULL) + PyErr_Clear(); + else { + item = dict_ClosestName(d,s); + Py_DECREF(d); + if (item) + return item; + } + } + + /* Look in o.__members__, o.__methods__ */ + for (p = attrlist; *p != NULL; p++) { + lst = PyObject_GetAttrString(o, *p); + if (lst == NULL) { + PyErr_Clear(); + break; + } + item = sequence_ClosestName(lst, s); + Py_DECREF(lst); + if (item) + return item; + } + return NULL; +} + + +static PyObject* +frame_ClosestName(f, s) + PyFrameObject* f; + PyObject* s; +{ + PyObject* closest; + char* str = PyString_AS_STRING(s); + + if (f->f_locals) { + closest = dict_ClosestName(f->f_locals, str); + if (closest != NULL) + return closest; + } else if (f->f_code && f->f_code->co_varnames) { + closest = sequence_ClosestName(f->f_code->co_varnames); + if (closest != NULL) + return closest; + } + + + closest = dict_ClosestName(f->f_globals, str); + if (closest != NULL) + return closest; + + closest = dict_ClosestName(f->f_builtins, str); + return closest; +} + +static void +set_name_error(f, name) + PyFrameObject *f; + PyObject *name; +{ + PyObject *closest = frame_ClosestName(f,name); + + if (closest) { + PyErr_Format(PyExc_NameError, + "No such name as '%s'. Perhaps you meant '%s'?", + PyString_AsString(name), + PyString_AsString(closest)); + Py_DECREF(closest); + } else { + PyErr_Format(PyExc_NameError, + "No such name as '%s'.", + PyString_AsString(name)); + } +} + +static void +set_attr_error(o, attr) + PyObject *o; + PyObject *attr; +{ + PyObject *type, *value, *traceback; + PyObject *closest, *result; + + if (! PyErr_Occurred()) + return; + + PyErr_Fetch(&type, &value, &traceback); + + closest = object_ClosestAttr(o, PyString_AsString(attr)); + + if (closest && type && value) { + result = PyString_FromString(""); + PyString_ConcatAndDel(&result, value); + PyString_ConcatAndDel(&result, + PyString_FromString(". Perhaps you meant '")); + PyString_ConcatAndDel(&result,closest); + PyString_ConcatAndDel(&result, + PyString_FromString("'?")); + + PyErr_Restore(type, result, traceback); + } else { + PyErr_Restore(type, value, traceback); + } +} + #ifdef DYNAMIC_EXECUTION_PROFILE --- Python-1.6a2/config.h.in Fri Mar 10 17:30:29 2000 +++ casepy/config.h.in Tue May 23 12:18:19 2000 @@ -414,6 +414,9 @@ /* Define if you have the strdup function. */ #undef HAVE_STRDUP +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + /* Define if you have the strerror function. */ #undef HAVE_STRERROR --- Python-1.6a2/configure.in Fri Mar 31 10:15:17 2000 +++ casepy/configure.in Mon May 22 21:44:40 2000 @@ -760,7 +760,7 @@ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname waitpid) + truncate uname waitpid strcasecmp) # check for long file support functions AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) --- Python-1.6a2/configure Fri Mar 31 10:15:16 2000 +++ casepy/configure Mon May 22 21:56:37 2000 @@ -3484,7 +3484,7 @@ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname waitpid + truncate uname waitpid strcasecmp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3491: checking for $ac_func" >&5 =====End unified diff Now-that-that's-done-lets-figure-out-the-type-class-unification-ly y'rs, -- Nick Mathewson http://www.mit.edu/~nickm/ From BgPorter at NOacmSPAM.org Thu May 25 10:28:50 2000 From: BgPorter at NOacmSPAM.org (Brett g Porter) Date: Thu, 25 May 2000 14:28:50 GMT Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: "Nick Bower" wrote in message news:392CB9B3.F5484CCB at ses.curtin.edu.au... > If one of Python's goals is to be a good teaching language, shouldn't > there be a book about OOP using Python, rather than the current books on > Python with only chapters on OOP? > > What do other people think about this? Am I wrong in thinking there is > nothing available? > > FYI - I'm thinking of picking up Bruce Eskil's "Thinking in Java" for > myself, but wish there was something comparable in Python. There are a couple of issues here -- When I decided to learn Python, my goal was to pick up a 'little language.' I had narrowed it down to a choice between the 2 P languages. A quick flip through some books at the bookstore made my choice easy. However, I was in no way expecting what I found (and continue to find) in Python. It's not a 'little' language at all (in the pejorative sense). It's dangerous to interpret GvR's 'CP4E' such that 'Everyone' only goes downward -- the language has to serve 'real' programmers/software engineers too. A serious, but accessible book covering object oriented _design_ and programming in Python could be a boon in attracting people who might otherwise dismiss Python as Just Another Scripting Language. As has already been pointed out, Python's object model is relatively free of the weird 'gotchas' that plague the other mainstream object-languages. By removing the need to cover the details of C++'s memory management issues, or virtual function dispatching, or Java's ability to inherit multiple interfaces but not multiple implementations, you're free to do more with discussing the much more subtle task of analyzing problems in terms of objects and then cleanly, quickly, and correctly implementing those objects. The clean nature of Python means that the book would be immediately useful even to non-python programmers (I love the Gang of Four 'Design Patterns' book, but hate the Smalltalk examples because I need to translate them into C++ before I can really make sense of them -- anyone can read Python code, even if they need to pretend that it's pseudocode). So, I'd rather see a book on "Object Oriented Design and Programming using Python" than a "Python book about Objects." My US$0.02. BgP From jsolbrig at my-deja.com Fri May 5 04:45:17 2000 From: jsolbrig at my-deja.com (jsolbrig at my-deja.com) Date: Fri, 05 May 2000 08:45:17 GMT Subject: [ANNOUNCE] CCQ BBS System Alpha Release 0.01 Message-ID: <8eu1mr$8pe$1@nnrp1.deja.com> Announcing the release of CCQ Bulletin Board System, application server and BBS language alpha 0.01. The CCQ System is a series of python language scripts designed to ultimately allow web-interactivity to be easily added to any web page. The CCQ system is implemented in python and should run on any web server running python 1.5. It has been tested with apache for both windows and linux. The main feature of this alpha release is a fairly full featured BBS system. It allows multiple subtopics,nests text-comments within text and has a simple and powerful administrative interface. Rather than being graphically dazzling, this board demonstrates CCQ's ability to create a wide variety of user data views (like stand-alone outline processor)- as opposed to the "normal" BBS which is generally tied to finite numbers that are initially designed into the application and can only be changed in a limited number of ways. The system is designed also to act as a web application server and thereby add automatic interactivity with an ordinary web sites. The next release should include a working system of this sort. The system is further customizable using it's own rich "very, very" high level language (If we call Python a "very high level language"). Similar to XSLT, XPath, or PIA, this language compactly and flexibly expresses interactive and hierarchical relations. It ultimately will allow an infinite variety of interactive -views to be inserted into a web site using a single tag. Rather than simply being framework for making these seperate systems easy to develop, the system is designed to ultimately unify multiple bulletin boards, calendars, interactive pages, and automated faqs into a single interactive system. Future releases may include migration of the CCQ language to XSLT or other standard server-side tagging systems, and use of the SOAP interface. The BBS is distributed as open source (essentially the same as the Zlib license). Contact jsolbrig at webcom.com

    CCQ BBS Alpha 0.01 This python-based system for adding rich interactivity to a web site includes a multi-topic bulletin board. (4MAY-00) Sent via Deja.com http://www.deja.com/ Before you buy. From neilh at scintilla.org Sat May 27 20:35:11 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 28 May 2000 00:35:11 GMT Subject: case-sensitivity compromise proposal References: <4.3.1.2.20000523075551.014d9e70@phear.dementian.com> <8gjfa2$qd9$1@slb7.atl.mindspring.net> <39305677_2@corp.newsfeeds.com> Message-ID: <3RZX4.1441$Qu.10435@news-server.bigpond.net.au> > It seems that the only "used" case distinctions involve differences > in nocaps, Initialcaps, MixedCaps, and ALLCAPS. Another distinction is between interCaps and InterCaps. Mozilla's XPCOM is, um, interesting here. The interCaps convention is used in IDL and JavaScript, but the generated C++ code uses InterCaps. So you may implement "ReadFile()" but be called as "readFile()". Neil From NOSPAMjason at NOSPAMstreetrodstuff.com Fri May 12 14:42:15 2000 From: NOSPAMjason at NOSPAMstreetrodstuff.com (Jason Long) Date: Fri, 12 May 2000 18:42:15 GMT Subject: Best HTML module? Message-ID: Sorry if this is a silly question, but I'm Python newbie. I would like to be able to take an HTML template file and replace certain tags or comments with data in my Python variables. Is HTMLlib my best bet here? Python.org mentions ZTemplate from the makers of Zope for tasks like this, but I couldn't find it on their site. Thanks in advance. Jason -- Jason Long Webmaster http://www.streetrodstuff.com From ullrich at math.okstate.edu Wed May 31 17:17:47 2000 From: ullrich at math.okstate.edu (David C. Ullrich) Date: 31 May 2000 21:17:47 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <8h34v4$7ac$1@nnrp1.deja.com> <393530D7.D495D3F9@san.rr.com> Message-ID: <01bfcb47$42112680$e03f8ad1@daves-dell> Courageous wrote in article <393530D7.D495D3F9 at san.rr.com>... > > > > a deque is O(n), while the cost of removing all n members > > > from a python list is O(n!). > > > > You sure about that "n!"? Seems more like n^2 to me. > > (Of course n^2 is big, but n! would be much worse. It's > > a theorem that n! is bigger than anything.) > > Yeah, that was an error. What I was thinking when I wrote > n! was n+n-1+n-2... It's been a long time since my complexity > theory class, so I don't recall if that's identical to n^2 > or not. Forget what they taught you in that class and ask yourself how big _is_ it? On the one hand all the terms are less than or equal to n and there are n terms, so the sum is less than n^2. On the other hand half the terms are larger than n/2, and that's n/2 terms, so the sum is larger than n^2/4. So it's "exactly" O(n^2). > Anyway, I knew that n! would come back to haunt me. :)- Boo. > C/ > DU From intmktg at CAM.ORG Sat May 27 17:50:23 2000 From: intmktg at CAM.ORG (Marc Tardif) Date: Sat, 27 May 2000 17:50:23 -0400 (EDT) Subject: vars between classes In-Reply-To: <8457258D741DD411BD3D0050DA62365907A1AD@huina.oceanic.com> Message-ID: > I don't know if these questions are based on a concrete programming problem > you're trying to solve or just to help your understanding. My experience > (admittedly limited where OO programming is concerned) is that class > variables are extremely rarely needed. Even where I've tried to use them in > prototyping they've never survived into the production code. I'm sure > others experiences are different, and YMMV. Indeed this is related to a concrete programming problem. I'm trying to write a small class to parse html tables into lists. Of course, I have searched Parnassus for such code, but what was available didn't support embedded tables. I'm therefore writing my own class to recursively go through embedded tables and I think I'm almost there. If you like, I can send you my code once finished, I'd be very interested in what insight you could offer. Thanks for the help From tismer at tismer.com Tue May 2 14:32:14 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 02 May 2000 20:32:14 +0200 Subject: installing numpy References: <8eljen$r39$1@nnrp1.deja.com> Message-ID: <390F1F2E.E2743A39@tismer.com> luis.apiolaza at utas.edu.au wrote: > > Hi, > > I want to install Numpy in a NT machine and I have the .zip file I > downloaded from sourceforge. What do I do now? I remember using Numpy > from the LLNL site and that one had an installer. There isn't even a > setup.py file in the new distribution! Unzip it into your Python directory, without any prefixing. This will gove you a "Numeric" directory, plus an "include" which you might want to drop. Since there also is a Numeric.pth file, your "import Numeric" should work immediately. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From tuttledon at hotmail.com Thu May 4 17:50:41 2000 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 04 May 2000 21:50:41 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> Message-ID: "Thomas Wouters" wrote in message news:20000504161923.P11481 at xs4all.nl... > On Thu, May 04, 2000 at 12:02:22PM +0000, Don Tuttle wrote: > > > If Activestate really wants to endear itself to the Python community, why > > not develop a centralized repository for all the widely scattered Pyton > > modules? This would fill a great need at a relatively low cost to them. > > Widely scattered ? Which modules are those ? As far as I know, most can be > found in the Vaults of Parnassus (www.vex.net/parnassus). > Check out this major resource the Perl community has - http://www.cpan.org This site is mirrored on many servers around the world. Think of the disruption the Starship crash caused. That could not have happen to CPAN. It's absolutely wonderful to have Vaults of Parnassus, but this should just be the first step toward a CPAN like repository and the resources of Activestate could pull it off. (Then again, the anacronym works for Python too. Maybe one of you hackers could just graft us a tree onto CPAN. Don't think they'd notice do you? ;-) Don From neelk at brick.cswv.com Tue May 16 16:35:06 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 16 May 2000 20:35:06 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> <8fjhjc$l6k$3@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote: > Neel Krishnaswami wrote: > > Martijn Faassen wrote: > >> > >> We have OPT, ERR and DOC reasons for doing type checking: > >> > >> OPT -- the interpreter/compiler uses the type declarations to make our > >> code run faster. The more static the type checking, the better. > > > I think this is a bit of a myth. > > Perhaps so, but.. > > > If you can declare that a variable is a machine integer or float, and > > arrays of the same, you have enough information to get about 80% of > > the speed benefit that static typing can win you. > > What about classes and methods though? If you want to optimize some of > the dispatching it may be pretty helpful to have static typing. Strong typing doesn't help with dispatch elimination except in combination with something like Java's 'final' classes or Dylan's 'sealed' classes, or if you do whole-program analysis (like Cecil's Vortex compiler does). This is because in order to eliminate a dispatch, you need to know the direct class of an object, rather than just "this is an instance of some subclass of Foo". For example, you couldn't do dispatch elimination in this function: def square(n: Number): return n * n because the hypothetical Number class isn't a leaf class of the class hierarchy. (Well, you could if you could do interprocedural dataflow analysis and were able to prove that a particular call to square() would receive a machine integer or float, but that's a *lot* of work.) > Similarly, in a dynamic system you'd *lose* your nice declarations > as soon as you pass them into some function that doesn't have them > (barring type inferencing, which is about as non-easy as static typing, > if not more :). Lisp compilers are pretty smart about this: if you pass a typed function to a dynamic fn, it will check the types on the function and raise an error if they don't match. When they *can* compute all the types then they don't do the checks. I don't know if anyone has written an OO language that supports type inferencing -- I was under the impression that adding subtyping rules to Hindley-Milner type systems made them undecidable. > > Before static typing for speed is tried (with its complicating effects > > on implementation), I think it's better to go for the factor of 2 > > improvement that can be won via easy tricks like method caches, > > variable lookup optimization, and reducing function call > > overhead. (Look at Squeak Smalltalk for an example.) > > Definitely agreed. (method caching may not always be that easy, though, > given __getattr__ and friends..) True. I wouldn't mind if there were a smaller hammer than __getattr__, though -- usually I want to catch only a few attributes dynamically, rather than all of them. > >> ERR -- we get more robust code as the types are checked. It's nice when > >> this happens during compile-time, though run-time can also be > >> helpful. > > > With an interactive read-eval-print loop, run-time is just as good as > > compile-time, IMO, because you can test your system incrementally, as > > you build it. > > Not all people agree on this. I think some interface conformance > checking at compile-time would for instance be nice. But I > definitely agree that the ERR component of static type checking is > overrated. That's why I put in the IMO. :) Seriously, types are most helpful to me as documentation of intent, and as it happens I try to put the types of arguments into the docstrings of code I write. I have experimented with automatically checking the docstrings (see http://www.sff.net/people/neelk/open-source/TypeChecker.py), but it was never useful enough for me to pursue very far. Neel From m.faassen at vet.uu.nl Thu May 18 13:56:20 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 17:56:20 GMT Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> Message-ID: <8g1as4$p9q$2@newshost.accu.uu.nl> Grant Griffin wrote: > And, yes, I can even use WinZip. (BTW, why to you Unix people > separate your packager gizmo from your compression gizmo? Very > strange...) May be strange, but it allowed us to switch from .tar.Z files to .tar.gz files and now perhaps slowly to .tar.bz2 files without having to do anything to 'tar'. And 'tar' has various other uses as well. So does compression; you can for instance compress the output of some program or other convoluted stuff. :) unix-is-strange-but-true-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tim_one at email.msn.com Sat May 13 02:21:57 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 02:21:57 -0400 Subject: Augmented assignment (was RE: Why should I switch to Python?) In-Reply-To: <391BB5CA.3640@seebelow.org> Message-ID: <000101bfbca3$8a554b40$3f2d153f@tim> [Tim, in praise of += and its happy little friends] [Grant Griffin] > Forgive me, Tim, It takes much more than that to buy my forgiveness -- but then it takes much more than the rest to incur my implacable wrath . > but as a Python newbie, I had inferred that part of Python's design > philosophy was to minimize redundant constructs, to encourage regularity > in Python code. Likewise, another design philosophy I had inferred > was to minimize "hyroglyphics" (tm), to make the language easy to learn > and read; the aforementioned operators definity contribute to C's distinct > "gobbledygook" look to the uninitiated. My beloved '+=' (and friends) > fail on both these counts. > ... The syntactic case for augmented assignment is marginal, although the Pythonic Thesis "readability counts" certainly applies to long_name[indirect_index1[i], indirect_index2[j]] += 3 vs the current alternative. "+=" is easy to learn, and easy to read once learned -- Python is designed for people, not chimpanzees . Python has a long & unbroken history of adding more "mere syntactic sugar" with each release, and I don't think any addition of that nature has been regretted, except for the extent to which "lambda" snuck in on that basis. The much stronger case is semantic, though: Python supports operator overloading, and e.g. when you're slinging multi-megabyte arrays in NumPy, x = x + y # add matrix x to matrix y elementwise, storing back into x can be an efficiency disaster. Just as in C++, providing a fundamentally *different method* for "+=" than for "+" can be a huge win. To be a little more concrete while remaining totally inaccurate , the Matrix author would love to define Matrix.__add__ to return a new object, but Matrix.__addeq__ to modify its first ("self") argument in-place. The last design Guido sketched for this would allow each class author to make the "mutate or create?" choice for themself. There's no obvious way to get the effect of in-place x += y today, short of using x.add_in_place(y) notation, and the latter is a lot less readable in several natural domains. the-trick-to-a-good-philosophy-is-to-articulate-enough- contradictory-principles-so-that-what-you-really-want- to-do-can-always-be-rationalized-ly y'rs - tim From tim_one at email.msn.com Sat May 13 00:56:29 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 00:56:29 -0400 Subject: python improvements (Was: Re: New Language) In-Reply-To: <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: [Steven D. Arnold] > 1. I'd like an equivalent to perl's "use strict" pragma. It's > annoying to have to be so paranoid about making a typo in a > variable name. [Martijn Faassen] > How exactly would this work? It would seem hard to make this work > right in a dynamic language, but perhaps I'm missing some simple > strategies. Perl simply (& simplifying a bit) whines about vrbl names that appear uniquely within a file. They're usually misspellings, but sometimes not. Tools to do that for Python have been written several times too, but never caught on, despite that they've even found long-standing bugs in the std Python library. Check out Aaron Watters' pylint for the best of that breed. all-problems-are-ancient-as-are-all-cures-ly y'rs - tim From tim_one at email.msn.com Mon May 15 03:57:02 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 15 May 2000 03:57:02 -0400 Subject: The REALLY bad thing about Python lists .. In-Reply-To: <20000515092243.S13281@xs4all.nl> Message-ID: <000c01bfbe43$27c56f40$b82d153f@tim> [Jeff Petkau, on Python's conservative over-allocation when growing a list] > I fiddled around with timing tests (1.5.2 on Windows) to see what > Python's actual behavior is. If you're adding to a single list, it > often is linear, because the list is grown with realloc() which > can get lucky and just extend the size of the allocated block > without having to move it. On some flavors of Unix, this is more than just luck: realloc will eventually move the vector to "the end" of the address space, after which further growth is just a mix of boosting the VM high-water mark and the occasional sbrk. Under all flavors of Windoes, though, it appears to be luck (and can't be counted on when a single list gets very large (> about 100K elements)). > But if you're allocating other stuff while building your list, or > building two lists in parallel, realloc() doesn't get so lucky > and growing the list is O(N^2). Python does *some* over-allocation, though -- most lists in practice are really quite small, and show no measurable dependence on length. Most modern chips are very good at moving contiguous chunks of memory. For lists up to several thousand elements, I've never seen non-linear list growth behavior regardless of platform or number of lists. > I'd consider this a bug in Python. Na, it's functioning as designed. That doesn't mean it couldn't be improved, but Python runs on small platforms too, where people can't *afford* significantly more over-allocation than Python currently uses (either because they're using many thousands of tiny lists, or just one or two at the limit of their physical RAM). in-a-tradeoff-somebody-usually-loses-and-python-assumes- the-big-boys-are-better-able-to-cope-ly y'rs - tim From nospam.newton at gmx.li Mon May 1 02:16:50 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Mon, 01 May 2000 06:16:50 GMT Subject: What does "first class" mean? References: <3909F2F5.A6F91256@spacenet.tn.cornell.edu> Message-ID: <390c5db6.17614800@news.nikoma.de> On 29 Apr 2000 18:11:27 GMT, kc5tja at garnet.armored.net (Samuel A. Falvo II) wrote: >This isn't *strictly* true. The following code, for x86 processors, returns >a function that does nothing: Nope, it returns a pointer to a function. (See also the prototype of the function: NoOp *foo(void) means 'foo' is a function return 'NoOp *', not a 'NoOp'. Try writing 'NoOp' as return type and see what your compiler thinks.) You can't return functions in C, or have arrays of functions, etc. Pointers to functions, yes. Similarly in Perl, you can't pass around functions, only references to functions (AFAIK). It's probably the same in Python, only the language doesn't make it explicit that you're passing around references. You're still passing around pointers, but it looks as if you're passing around functions. Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From aruth at intercation.com Sat May 13 10:51:35 2000 From: aruth at intercation.com (Adam Ruth) Date: Sat, 13 May 2000 08:51:35 -0600 Subject: ASP Performance Message-ID: <8fjq8k$1juo$1@news.aros.net> I'm having a problem with ASP using python. It appears that each page reloads and doesn't run from the cache. It's as if each request was the first request, much like CGI. When I was testing Python for ASP a couple of weeks ago, it was caching the pages, and modules didn't get reloaded for every request. Has anyone seen this before? I've tried it with PWS on NT 4 WS, IIS 4 on NT 4 Server (2 different computers, one of which was rebuilt just to test this). -- Adam Ruth InterCation, Inc. www.intercation.com From 340083143317-0001 at t-online.de Sat May 20 11:47:51 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Sat, 20 May 2000 17:47:51 +0200 Subject: tibco rendezvous References: <3923f59b.3148108992@news.wwnet.net> Message-ID: <8g6c0k$sh4$17$1@news.t-online.com> Hmm, i have written a Python layer around TIB Rendezvous 5.3. We are using it for writing software interfaces here in our department. What would you like to know ? David Relson schrieb in im Newsbeitrag: 3923f59b.3148108992 at news.wwnet.net... > Anybody using Python with TIBCO's Rendezvous message-handling > software? > > I'm working on a web based application that needs to talk to a 24x7 > data collection system which uses Rendezvous. Rendezvous supports > Perl, Java, C, C++, and Objective-C. I could run perl scripts from my > python code, but I'd rather use straight python. > David Relson relson at ic.net > Ann Arbor, MI From kent at tiamat.goathill.org Fri May 26 13:24:59 2000 From: kent at tiamat.goathill.org (Kent Polk) Date: 26 May 2000 17:24:59 GMT Subject: urllib/ftpwrapper References: <959023972.859403@fezzik.endicor.com> <392A2EEE.ADB075A@stroeder.com> <959106495.82884@fezzik.endicor.com> <392B7941.A231E2D1@stroeder.com> <392e46fe$0$20776@personalnews.de.uu.net> Message-ID: <959360255.871392@fezzik.endicor.com> On Thu, 25 May 2000 17:06:24 +0200, Johannes Stezenbach wrote: >Michael Str?der wrote: >>In one of my projects I'm using the SocketServer.ThreadingMixIn to >>drive a multi-threaded HTTP server. For binding to a privileged port >>my naive approach was to do all the initialization stuff as root and >>do a setuid(wwwrun) just before calling method serve_forever() of >>the server class. Works just fine. >> >>Does anybody see any security problems with that approach? > >You may also want to call setgid() before setuid(). >The general rule is to do as little work as possible using >root privileges and drop them ASAP (least privilege principle). Sam Rushing contacted me with a test patch. I tried it and it worked. Hopefully he'll have an integrated solution RSN. From jae at ilk.de Sun May 21 00:05:18 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Sun, 21 May 2000 06:05:18 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: (message from Guido van Rossum on Sun, 21 May 2000 02:01:37 GMT) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: <21052000.2@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Guido" == Guido van Rossum writes: Guido> "Thomas Malik" <340083143317-0001 at t-online.de> writes: >> I've just convinced our whole department (at a german bank) to >> use Python instead of Perl. A case - insensitive language won't >> be acceptable by any of us. So, Guido, should i start looking >> for another job ...? Guido> This is an example of what I meant when I said "voting Guido> doesn't help". Guido> You're saying it's unacceptable -- a vote. No, Thomas just saying it's unacceptable... he also impliest that he'll take whatever you give him (or he would ask about the job-searching ;-) [...] Guido> Here's a way to make your vote count: explain what it is Guido> about case sensitive languages that you hate. Then we can Guido> have a discussion about it. You mean case insensitive, right? ;-) Anyway, I couldn't say why I hated about them... I've never had to deal with them. (Emacs-Lisp, Python, C, C++, Modula-2...) Actually, I couldn't even name a case-insensitive language offhand... and I doubt they are really easier than case sensitive ones. Guido> I am a very case-sensitive person myself: it bothers me when people Guido> don't start their sentences with capital letters or when they refer to Guido> themselves as "i" in lowercase -- or when people refer to Python as Guido> "python" or "PYTHON". (Come to think of it, it bothered me when you Guido> wrote "german" instead of "German" :-). Guido> Yet, here are some of the reasons why I am considering making Python Guido> case-insensitive: Guido> (1) Randy Pausch, a professor at CMU, found, when teaching Guido> Python to non-CS students in the context of Alice Guido> (www.alice.org), that the number one problem his students Guido> were having was to remember that case matters in Python. Guido> (The number two problem was 1/2 == 0; there was no Guido> significalt number three problem.) Did he try a Python that was case-insensitive? Maybe I'll be proven wrong, but I highly doubt the problems would have gone away with case-insensitivity. (And as someone else in this thread mentioned (Gordon?), I also think this is cultural... Windows is case-insensitive, while Linux (and most if not all major programming languages)). I just try to imagine Joe Random Python-User using case-insensitive Python3K, when he tries to read his code again after half a year... and finds `MyHTTPClass', `Myhttpclass', `myHTTPClass'... I wouldn't call such code readable. And if you enforce the same casing... well, you're back at square one. Here's an idea: why not give Python 3K a switch `--no-mixed-case-in-identifiers' (on by default for Clue L. Newbie ;-). Different casings would simply be detected and rejected (in the compilation phase, of course). All distributed modules would simply be forced to have to be case-insensitive (thus only one `SimpleHTTPServer' in SimpleHTTPServer... when accessing this from a case-sensitive program, I'd use SimpleHTTPServer anyway, even now. And in a case-insensitive program, I'd have to use SimpleHTTPServer). Of course programs would need to tell the interpreter what case they'd like to be in (so I can run case-sensitive programs in a case-insensitive installation). But that is all pretty pointless... I'm rather for keeping the case-sensitivity as it is and let people learn a bit (it can't be *that* hard... we Germans have to learn the difference between `Sie' and `sie' as little kids, so why can't teenager/young adult Americans? ;-) Guido> (2) I've met many people who are experienced and Guido> accomplished Python programmers but who still, when Guido> referring to Python modules or functions in an informal Guido> context (e.g. email), make up their own case conventions. Guido> E.g. people will write me about the String module or about Guido> FTPLib. That is also a result of the confusion in actual module names. I mentioned {Base,Simple,CGI}HTTPServer above. But most modules are all lowercase. String might come from when someone mentions the string module at the start of a sentence... or he/she just feels it should be capitalized when talking about it. I do *not* think that this is a valid point... because I doubt that these people would make many of these mistakes in actual code (and anyway, those (module names) are quickly found). Guido> I also know some of the things I plan to do to make the Guido> transition painless and to make the usual problems with Guido> case insensitivity more palatable. E.g. I may add a case Guido> insensitivity feature to IDLE which makes sure that all Guido> identifiers are written in a consistent case, I may add Guido> flags to pre-Py3k Python interpreters to turn on case Guido> insensitivity or case sensitivity or a special warning Guido> mode. This sounds as if the debate is over and your mind's already made up... I hope it is not. Personally, I'd have to give up on Py3K if this happens, and stay with 1.7+ (and I'd bet there'd be a 2.0 then). It's difficult enough to switch between languages (Objective-C, Python, Emacs-Lisp, C++ currently for me). But at least all of them are case-sensitive. And as hinted at above, I'm all for not dumbing Python down (someone else mentioned the LCD) but instead teaching the people up. And case-sensitivity is really not hardcore computer science. HTH (me ;-), Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html GTK - Free X Toolkit (http://www.gtk.org) Codito, ergo sum - I code, therefore I am -- Raster -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjknYHgACgkQN0B+CS56qs3uagCfbDiKqk+Dn3INkMQw1AOLcIvV beEAnR7znvLJpnaZloSs/PsPbxH4h0hD =Aluv -----END PGP SIGNATURE----- From m.faassen at vet.uu.nl Tue May 2 17:21:52 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 May 2000 21:21:52 GMT Subject: Advice on giving a python course References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> Message-ID: <8engtg$7fi$2@newshost.accu.uu.nl> Richard P. Muller wrote: > The web page for the course is at: > http://www.wag.caltech.edu/home/rpm/python_course/ > The slides for the first lecture are at: > http://www.wag.caltech.edu/home/rpm/python_course/Lecture_1.pdf > I wanted to give the students as much instant gratification as possible, > which is why I introduced the Gnuplot module and NumPy in the first and > second modules, respectively. I like the slides, also the instant gratification bit. I should've gone for more of that in my course, I think. That said, I tried to aim at newbies programmers perhaps a bit more than you do, though they're all computer people and there's some programmers there. My lesson notes are at: http://develop.diva.vet.uu.nl/zwiki/LesOverzicht By the way, this is an open wiki, so feel free to add comments, but don't demolish anything. :) Note that the assignments are in Dutch, though the notes are in English. And if only my students actually *did* the assignments. :) Only a few do. This course will now move into Zope, having laid some Python groundwork. The last few lessons I've mostly been focusing on actual small programs. I've been having a hard time explaining the concepts of object oriented programming; there's just too much procedural programming knowledge there. Next course I give, I think I'll try more hands-on systems to toy with from the start. But I do like getting the concepts straight, and slowly building them up from the beginning. Too much stuff for newbie programmers may confuse them too much, but perhaps some overwhelming isn't bad. Out of the 8 people who (sometimes, it fluctuates from 4 to 8 people) participate, I think I'll manage to teach Python to only 2 or 3. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From quinn at necro.ugcs.caltech.edu Fri May 19 16:34:49 2000 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 19 May 2000 20:34:49 GMT Subject: Python Ctrl-C Lock-ups (was Re: Irix 6.5, gcc 2.95.2, readline and control-C problem) References: <8f2031$m9o$1@slb3.atl.mindspring.net> <20000515090008.A1303573@vislab.epa.gov> Message-ID: On Mon, 15 May 2000 09:00:08 -0400, Randall Hopper wrote: >Quinn Dunkan: > |I have python compiled with gcc 2.8.1 on irix 6.5 system. If I hit ^C when > |readline is doing its thing, python locks up. Meanwhile, I have python > |and readline compiled with sgi cc on another irix 6.5 system, and everything > |works properly. > >Compile Python without threads and your problem will go away. I have the >same problem with Python, both on FreeBSD and IRIX. Aha, problem "solved", but of course only on machines where I don't run threaded scripts :) Does anyone know if this is a a readline problem, or a bug in python's readline module? thanks! From m.faassen at vet.uu.nl Fri May 5 11:12:27 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 May 2000 15:12:27 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> <39120F04.7B396522@oreilly.com> Message-ID: <8euocr$akg$4@newshost.accu.uu.nl> Konrad Hinsen wrote: > "Stephen R. Figgins" writes: >> One complaint I often hear about Python is that it has no CPAN like >> module repository. >> >> So, who all is working on this? Is this an appropriate item for a sig? >> I would love to get involved with other working to make this happen. > Perhaps the DistUtils SIG would be a good starting point; after all, a > standard distribution tool like DistUtils is almost a prerequisite for > standardized module distribution. Of course the logistics of implementing > servers is a separate task, but it should interest the same people. Agreed. Once the distutils are deemed mature enough, I think the best plan would be to have the Vaults of Parnassus join forces with some Zope hackers to revamp it for distutils and zopify it. Starting point would be the Distutils SIG, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cut_me_out at hotmail.com Mon May 29 21:39:59 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 May 2000 21:39:59 -0400 Subject: Triple quote problem in Pythonwin References: <6956js4qo9jamd6i86iccch7blsct7qs6n@4ax.com> Message-ID: Hmm, in both of the examples you gave, you only had one triple quote. Probably your problem is that you need to finish the string with a secondf triple quote. Eg s = '''''' """Here is a very long string that can if we wish span several...""" works. Alex. From claird at starbase.neosoft.com Thu May 25 03:18:24 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 May 2000 02:18:24 -0500 Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: In article <392CB9B3.F5484CCB at ses.curtin.edu.au>, Nick Bower wrote: >I colleague the other day, who was familiar with various procedural >languages said: > >"I want to learn OOP. Can you recommend a book (and language)?" > >Both of us are scientists, and my bias is Python in preference to Java. >But when thinking about it, it seemed to me that Python may not be the >best choice because it isn't obvious that there is a good book available >that teaches OOP from a basic through to advanced level with good >examples. Java however has a selection now, and it seems that if you >want to really learn more than just basic concepts in OOP then Java is >the language to go with. Although I have Programming Python, which >contains some examples, I'm not so fond of recommending it. > >If one of Python's goals is to be a good teaching language, shouldn't >there be a book about OOP using Python, rather than the current books on >Python with only chapters on OOP? > >What do other people think about this? Am I wrong in thinking there is >nothing available? > >FYI - I'm thinking of picking up Bruce Eskil's "Thinking in Java" for >myself, but wish there was something comparable in Python. > >Nick > > Bruce teaches good courses in Python. No, it's not the same as a book, but you ought to consider them for your acquaintances. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From hzhu at rocket.knowledgetrack.com Mon May 15 15:43:02 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Mon, 15 May 2000 19:43:02 GMT Subject: NEWBIE References: Message-ID: On Sun, 14 May 2000 18:58:55 GMT, Angela Campbell wrote: >Hello all you Python users, > >I am what you call a newbie or in my case some one who knows what varible, >and other technical terms, but am still struggling at the programming part, > >But I need more info, but keep in mind I am fusy, in other words, no buying >books! I much prefer on-line manuals (cheap) anyway help needed and I hope >someone could e-mail me a tutorial, preferably NOT HOW TO USE IT AS A BLOODY >CALC. I do know that much. > The pages of "Instant Python" (http://www.idi.ntnu.no/~mlh/python/instant.html) are really great. It teaches the language in a few hours. It touches upon data structures, flow controls, functions, classes, objects, files, exceptions, modules and more, all with readable and do-as-you-learn examples. After that the online tutorial on www.python.org makes a lot sense. After that you might go for the online module library reference. ... Enjoy! -- Huaiyu Zhu hzhu at knowledgetrack.com From brennanw at pond.com Tue May 2 20:34:29 2000 From: brennanw at pond.com (William C. Brennan) Date: Wed, 03 May 2000 00:34:29 GMT Subject: problem building Python in MachTen Unix References: <01HW.B531E90F0013E3A1037B464C@news.pond.com> <390CAA4D.6C554E23@gte.net> Message-ID: <01HW.B534EC7400033DDE03EC18DC@news.pond.com> [[ This message was both posted and mailed: see the 'To' and 'Newsgroups' headers for details. ]] On Sun, 30 Apr 2000 17:48:36 -0400, sue wrote (in message <390CAA4D.6C554E23 at gte.net>): Sue wrote: > Does ../Include/mach-o/dyld.h or ../mach-o/dyld.h exist? If > not, the include path is wrong. No, they don't exist anywhere on my machine. I presume they're a NeXt/Rhapsody kind of thing, at least that's what the comments in the configure file led me to believe. > I have found it's futile to argue with configure. Yes, I think I've just learned this lesson. ;-) Thanks for the confirmation. > Edit the makefile directly and save a copy elsewhere. Get the binary > built, and then backtrack. You may need to check config.h. After examining the makefile and config.h, I took a stab and removed the definition of "WITH_DYLD" from config.h. After that, the making of Python proceeded perfectly. Well, *almost* perfectly. I still fail a test in the math module. My newly build Python reports >>> math.modf(-7.1) (-0.9, -8.0) which is wrong. The correct answer is (-0.1, -7.0). If you (or anyone else) happens to have any inspiration as to why my math.modf fuction may be broken, I'm eagerly accepting suggestions. But python seems basically usable now, and for that I'm happy. Thanks for your help! -- bill -- Bill Brennan brennanw at pond.com From folker at t-online.de Wed May 31 12:13:11 2000 From: folker at t-online.de (Heinz Folker) Date: Wed, 31 May 2000 18:13:11 +0200 Subject: Problems with Tkinter, Canvas and Pythonwin Message-ID: <39353A17.3F6B36B@t-online.de> I want to write a little very simple turtle-gaphic. The window where you can write is a canvas. My problem: I want to command the turtles with the interpreter (the interactive window in Pythonwin), in order to use loops and recursions. After the canvas is opened the interpreter does not react to any of my commands. I think the problem is calling the mainloop function of Tkinter, but I don't know how to solve this problem From noreply at nospam.org Sun May 28 01:44:46 2000 From: noreply at nospam.org (Brian) Date: Sun, 28 May 2000 05:44:46 GMT Subject: wxPython mailing list ? References: <002301bfc859$280c4300$e4f192ca@Buddy> Message-ID: http://wxwindows.org/mailman/listinfo/wxpython-users "Issotyo P.B.S" wrote in message news:002301bfc859$280c4300$e4f192ca at Buddy... Did anybody know where I could subscribe for good wxPython Mailing list ? TIA [^_^] IPBS -------------- next part -------------- An HTML attachment was scrubbed... URL: From wware at world.std.com Tue May 9 09:20:15 2000 From: wware at world.std.com (Will Ware) Date: Tue, 9 May 2000 13:20:15 GMT Subject: Future of the Python Linux Distribution References: <3916F04F.7647B829@zipzap.ch> <391790A2.26CB9618@home.com> Message-ID: Alex (cut_me_out at hotmail.com) wrote: > > *Sigh*. I knew someone would make me do this. > > [ lotsa Postscript ] > How do you run this? I put it in a file tst.ps, and tried to look at it > with gv, but all I got was a blank page. Add a line at the end that says "showpage". Then you should be able to see it. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From walter at bnbt.de Thu May 25 06:34:27 2000 From: walter at bnbt.de (Walter Dörwald) Date: Thu, 25 May 2000 10:34:27 GMT Subject: ANNOUNCE: XIST 0.3 - an XML based extensible HTML generator Message-ID: <8givjk$vk8$1@nnrp1.deja.com> Hi all! What's new? ----------- * XIST now uses sgmlop directly, so it doesn't require xmllib anymore and works with PyXML-0.5.4 * A new example that generates XML documentation from Python modules, so you can write your Python docstrings in XML. Note that this isn't finished yet, and should be considered work in progress. * XIST now provides line number information in repr dumps and exceptions, which greatly simplifies finding error in XML files. * Various enhancements and bugfixes. What is it? ----------- XIST is a HTML preprocessor/generator and an XML transformation engine. Some of the significant features of XIST include: * Easily extensible with new XML elements * Can be used for offline or online page generation * Allows embedding Python code in XML files * Works together with httpdapy/mod_python/PyWX * Simplifies handling of deeply nested directory trees * Automatically generates HEIGHT and WIDTH attributes for images It was written as a replacement for the HTML preprocessor HSC (http://www.giga.or.at/~agi/hsc/), and borrows some features and ideas from it. It also borrows the basic ideas (XML/HTML elements as Python objects) from HTMLgen or HyperText. Where can I get it? ------------------- XIST is available from ftp://titan.bnbt.de/pub/livinglogic/xist/. Direct questions regarding XIST to walter at bnbt.de.

    XIST 0.3 - an XML based extensible HTML generator. (25-May-2000) Bye... Walter D?rwald Sent via Deja.com http://www.deja.com/ Before you buy. From psl at mitre.org Thu May 11 15:13:45 2000 From: psl at mitre.org (Mike Wingfield) Date: Thu, 11 May 2000 15:13:45 -0400 Subject: canvas in Pmw Message-ID: <391B0669.578876FF@mitre.org> I am trying to write an image to a canvas in an application using Pmw. When I do this I get the following error message: Traceback (innermost last): File "OutWin.py", line 24, in ? map.create_image(200,200, image=img, anchor = CENTER) File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1223, in _create_image return self.create('image', args, kw) File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1216, in _create (self.w, 'create', itemType) TclError: image "8827440" doesn't exist If I remove Pmw parts of the code it seems to work ok. What do I need to do to get the canvas to run within a Frame in an application using Pmw? From samibadawiNOsaSPAM at mail.com.invalid Tue May 2 10:06:20 2000 From: samibadawiNOsaSPAM at mail.com.invalid (Sami Badawi) Date: Tue, 02 May 2000 07:06:20 -0700 Subject: installing numpy References: <8eljen$r39$1@nnrp1.deja.com> Message-ID: <1aa59430.f37ce8fc@usw-ex0101-007.remarq.com> I just un zipped it under my main Python directory. -Sami Badawi * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From bwinton at tor.dhs.org Tue May 23 22:12:01 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Wed, 24 May 2000 02:12:01 GMT Subject: case sensitivity and XML References: <20000523113250.A2150232@vislab.epa.gov> <04b301bfc4cd$aa2a4560$1906a8c0@fc.fenx.com> Message-ID: On Tue, 23 May 2000 08:43:26 -0700, Emile van Sebille wrote: > >>>> class Foo: > pass > >>>> foo=Foo() >>>> foo.FOo=1 >>>> foo.FOo=[1,2,3,4] I think you mispelled Foo... No, really... :) and I'm not sure who's point I'm proving by pointing this out... >>>> foo.FOO=[10,11,12,13] >>>> foo.FoO=[20,21,22,23] >>>> map(lambda FOo,FOO,FoO: FOo+FOO+FoO,foo.FOo,foo.FOO,foo.FoO) Later, Blake. -- 9:06pm up 13:13, 1 user, load average: 0.00, 0.00, 0.00 From tim_one at email.msn.com Fri May 26 01:27:07 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 May 2000 01:27:07 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Message-ID: <000201bfc6d3$08650320$c52d153f@tim> [Les Schaffer, possibly not in favor of case-insensitivity] > ... > i can only venture a guess as to why things are headed this > way. Everyone who codes smells money, IPO money. So they figure if > they can twiddle their language to meet the masses, the unwashed > masses who can't learn case-sensitivity, OR SO THE EXPERTS TELL US, > then there is a fortune to be made. > > Absurd notion, right? > > But consider this, if python weren't suddenly (maybe thats the wrong > word) emerging as an excellent scripting language at a time when IPO > mania was at its peak (well maybe slightly post peak now), would we be > having these "in-depth" discussions about the optimization of the > langauge via case-insensivity based on towering arguments like 1. and > 2. above? > > Anyway, tahts as absurd as i can get. i just can't think of any other > reason why the language and newsgroup has to waste its time with a > discussion on case-sensitivity. Les, Guido has been talking about this for *years*. I don't know why c.l.py never noticed before, but it was an old topic long before this thread began. Over most of that period of time, Guido has been employed by the non-profit CNRI; it's unclear even to me what his job there actually is, but it appears to be writing DARPA grant proposals <0.9 wink>, and AFAIK not even the Clinton administration is funding a National Case Insensitivity Initiative. I think the evidence that making Python case-insensitive will actually help anyone is extraordinarily weak, but note that Guido hasn't *done* anything about this for years either. The Alice project thought it important enough that they actually changed their version of Python to ignore case, and in a world of weary Usenet debates (i.e., lots of talk, lots of froth, no consensus), that spoke very loudly to Guido. He'll do what he thinks best. I may have to punch him in the throat to get his attention on this one, but violence before its time is counter-productive. ideas-are-not-crimes-ly y'rs - tim From mlauer at trollinger-fe.rz.uni-frankfurt.de Sun May 14 10:51:32 2000 From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de) Date: 14 May 2000 16:51:32 +0200 Subject: [FAQTS] Python Knowledge Base Update -- May 14th, 2000 References: <20000514131743.16551.qmail@synop.com> Message-ID: <391ebd74@nntp.server.uni-frankfurt.de> Just wanted to thank your for your work. I think your site will become an essential resource for beginners and advanced python programmers. Great work! -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From tuttledon at hotmail.com Wed May 3 09:19:15 2000 From: tuttledon at hotmail.com (Don Tuttle) Date: Wed, 03 May 2000 13:19:15 GMT Subject: What's gives with Activestate? Message-ID: I went to Activestate http://www.activestate.com to see how their Python development efforts are coming along but couldn't find any Python news anywhere! In fact I had to dig for several minutes to even find the word "Python" used on the web sight! It looks like a Perl only website. Message to Dick Hardt, "Stop jerking us around! Python is not the red haired stepchild! If you are really going to support Python, you have to be willing to talk about it in mixed company. (That is, in front of Perl zealots) At least make a web page that refers to Python, gives us some news, and has a few relevant links. Is that asking too much?" Don -- Believe nothing no matter where you read it or who has said it, not even if I have said it, unless it agrees with your own reason and your own common sense. --Buddha From JamesL at Lugoj.Com Mon May 22 00:10:30 2000 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 21 May 2000 21:10:30 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> <3927FA67.94D85CAF@elite.org> <349gisk5q40o7n9h8m03e7sr4bbed8tigo@4ax.com> <39284A93.EB6B4312@Lugoj.Com> Message-ID: <3928B336.43F15815@Lugoj.Com> Fredrik Lundh wrote: > > James Logajan wrote: > > > The Alice study only proves that users can memorize the case conventions > > > used in a single specific library (in this case, the Alice environment), not that > > > they won't get into trouble again when they stumble upon a library that uses > > > different conventions. > > > > Slow learners until proven otherwise? What target IQ level would you > > consider an appropriate cutoff? > > given that I have to figure out the conventions of every new library, and > end up getting NameErrors and AttributeErrors now and then, I suppose > that target is 20-100 points above my own level. > > not that the IQ level has anything to do with it -- any decent designer > knows you'll get better results if you assume that users are very smart, > but also very busy. Frankly I'm amazed that so much is being written regarding this issue. If what is being discussed is a completely new language, then there is nothing to argue about. Case-insensitivity appears to be the way to go. If what is being discussed is an incremental improvement, where backward compatible is in some ways hoped for, then the issue is a non-starter and should not have been brought up. There is now a large body of production code and programmers conversant and comfortable with the existing language, so I think GvR is being somewhat irresponsible to suggest such drastic changes to Python. I would strongly suggest he consider calling it something non-Pythonic (I think "Homer" came up in another humorous context). Also, I think that the conventions that you mention encompass much more than case. I have found myself programming in Python, Java, C++ (standard strings and ACE strings) and often have to try and remember what function or method gives me the correct string length. Is it len(s), s.length(), s.size(), s.len(), strlen(s), or something else? Even within a single language such as C++ I find I have to check the class library for the proper convention. And this has nothing to do with case per se. Besides, I find that cut-and-paste tends to solve many of these problems. Lastly, I did a quick scan of the Alice documentation and found that in some spots it incorrectly used "Print ..." in some spots: To determine the length of a string, use the len() function: Print len(`This is a string.') 17 Incidentally, this works for arrays as well: Print len( [`This', `array', `has', `five', `elements'] ) and the correct "print ..." in others. And the method names were very long and mixed case in some places: Tree.SetTransparentTextureColor(White) and all lower case in others: for o in scene.getchildren(all): o.setlightingstyle(lit) So in one sense you are correct, but it strongly appears that it took some pathological naming conventions and some misinformed documentation (print vs Print) to draw out the problem. This wouldn't be the first dissertation where the conclusion turned out to be incorrect. That said, it would appear that a dynamically-typed language with Python-like semantics should probably be case-insensitive since such errors would often only be found at run-time. Statically-typed languages should in general flag such errors at compile time, so this may be why it has not been an issue in C/C++. Nevertheless, I think it is much much too late to consider this change creating a language that is even within the same family as Python. Why? Because attribute names can no longer be implemented as string types. A new attribute-name class must be invented with case-insensitive comparison operators. Backward compatibility will be made even more difficult. I suspect the introspective aspects of the language may require further reengineering than one may think. > > > Also, if you wish to be taken more seriously, may I humbly suggest that you > > avoid posting statements like the following: > > > > > Maybe non-geek programmers have better things to do with their time? > > if you have problems with that statement, I suggest reading more HCI > literature. for a popular account, start with Cooper's "The Inmates are > Running the Asylum". About 20 years ago I did some intense reading on studies of human-computer interfaces. (I assume that is what you mean by HCI?) People were full of opinions but research studies were few and far between. "Double-blind" was either a foreign concept or the money wasn't there to do it. Haven't read Cooper's tome, but it does look like it is opinionated. How many double-blind studies does he site? How many studies or any sort does he site? I normally now avoid "popular works". Have you read any of Ben Shneiderman's work? How about studies of the advantages and disadvantages of stable development environments? You and GvR may find it profitable to investigate those.... From avv at quasar.ipa.nw.ru Wed May 24 13:46:20 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Wed, 24 May 2000 10:46:20 -0700 Subject: Cross-compiling Python References: Message-ID: <392C156C.51EE84B6@quasar.ipa.nw.ru> Hi, Jan Kybic wrote: > Has anyone here ever tried to cross-compile Python? I tried, and I changed the tests in configure.in, which try to run apps locally, statically to their respective results I knew for sure for the target configuration. It was not difficult to guess the meaning of the tests from the corresponding parts of configure.in. You may consider something exotic, like running these applications on the target via rsh, but I believe it's not necessary. I also reported this issue there. There were also three people who ported Python to VxWorks, you may contact them, if they reveal themlselves, your target looks a bit similar. Alexander From chibaA at TinterlogD.Tcom Tue May 16 10:59:45 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Tue, 16 May 2000 14:59:45 GMT Subject: pyApache install References: <39215d4d.306703205@news1.on.sympatico.ca> Message-ID: <392161fa.307900637@news1.on.sympatico.ca> Sorry, let me a bit clear on the last comment I made. How would I go about replacing all of my include files. I downloaded the rpm for the GCC compiler I have, - would that be enough, or are there other rpms that I would have to re-install to get those include files? I installed this rpm: egcs-1.1.2-24.i386.rpm Off the RH6.1 distribution. I don't know if it replaced the include files --> I did to a recompile after installing this rpm with the --force switch (to force replacement of files),and I still got the same error with apache. kc On Tue, 16 May 2000 14:41:01 GMT, chibaA at TinterlogD.Tcom wrote: >The only error that I receive (when using apachectl start) is: > >/usr/local/apache/bin/apachectl start: httpd could not be started >[root at linux apache_1.3.12]# > >If I just try it as ./httpd, then I get "Segmentation Fault". > >I figured the defaults would at least allow me to compile correctly >(compile for make, and make install work fine - with no errors; it >just makes a faulty executable!?!) -- but I guess not. > >Re: could gcc be too new? Maybe I suppose. But would RH distribute a >gcc that would be incompatible with compiling something as standard as >apache? (6.2 I believe is the newest, I have RH6.1). I'd imagine >more people would have problems doing simple things as I - if that >were the case. Actually, I remember I had to copy some .h files into >my include directories (WAY back..). Is there anyway to reinstall all >of the GCC files & includes? (ie. where might I find the package to >do so? > >Thanks for all your help, > >kc > > > > >On Tue, 16 May 2000 08:21:10 +0000 (GMT), Oleg Broytmann > wrote: > >>On Tue, 16 May 2000 chibaA at TinterlogD.Tcom wrote: >>> I'm having problems figuring out how to install pyApache. Actually, >>> the root of it might have something to do with problems getting the >>> compiled apache server to run. If anyone has successfully recompiled >>> apache with pyapache (or.. even recompiled apache), could you lend me >>> a hand here? >> >> I did it many times, pretty successfully. >> >>> Basically, if I try and run ./configure, everything goes well (and >>> seemingly imports modules & stuff fine), the installation finishes, >>> and the apache directory & executables are all there. I go to run >>> apachectl start - and it gives me an unable to start message. If I >>> just try running ./httpd, it just says segmentation fault. >> >> Any more details? Any error message? >> >>> Any ideas? I'm running RH6.1, I have the rpm version of apache >>> 1.3.9-4 running already (but I killed the process while trying the >>> rebuilt one). I compiled (with and without pyapache) using apache >>> 1.3.9 (and for kicks, tried 1.3.12 as well) - but the same problem >>> each time (segmentation fault). When I type gcc -v, it returns gcc >>> version egcs-2.91.66 (which I assume is new enough - came with RH6.1). >> >> May be it is TOO new? I use gcc-2.7.2.3 and 2.8.1... >> >>Oleg. (All opinions are mine and not of my employer) >>---- >> Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru >> Programmers don't die, they just GOSUB without RETURN. >> >> > From contrex at home.com Wed May 24 23:29:49 2000 From: contrex at home.com (John C. Hollemans) Date: Thu, 25 May 2000 03:29:49 GMT Subject: Grail on OpenBSD Message-ID: <392C9BF8.9DFA8AD8@home.com> Hello ! Just wondering if anyone has run the (apparently obsolete) web browser grail under OpenBSD 2.6 lately. I followed the advice of a fellow on the OBSD newsgroup and ran into a problem. Here is the error stream. Can anyone point me into the right direction please ?? I have _never_ used python before ! Python is available as a package on OBSD and requires the usual "pkg_add ..." command to install. > _____ > Dave, > > I followed your tip, installed tcl/tk and python from my OBSD 2.6 CD, > downloaded the grail sources, unpacked into /usr/local/lib/grail0.6/* > and i get this message: > > localhost# /usr/local/lib/grail0.6/grail.py > File "/usr/local/lib/grail0.6/grail.py", line 145 > raise > ^ > SyntaxError: invalid syntax > localhost# > > Running the following python test gives these errors: > > localhost# python GrailPrefs.py > Traceback (innermost last): > File "GrailPrefs.py", line 349, in ? > prefs = test() > File "GrailPrefs.py", line 307, in test > exercise("prefs = AllPreferences()", env, "Suck in the prefs") > File "../utils/testing.py", line 34, in exercise > exec stmt in env > File "", line 1, in ? > File "GrailPrefs.py", line 133, in __init__ > self.load() > File "GrailPrefs.py", line 140, in load > self.sys = Preferences(os.path.join(utils.get_grailroot(), > File "/usr/local/lib/python1.5/posixpath.py", line 45, in join > elif path == '' or path[-1:] == '/': > AttributeError: __getslice__ > localhost# > > Would you be able to help with this ?? I have _never_ used python > before on any system. > > Regards / John > > Dave Simons wrote: > > > > We've tracked down the source of the following rumour to > > euth at uchicago.edu (euth) on dim., 21 mai 2000 19:30:32 GMT > > : > > > > >What do you recommend as a browser then? I have many problems > > >with Netscape, but I have yet to find a good unix > > >replacement. > > > > It's far from being the fastest and smoothest, since it's > > written in python, an interpreter language. But the good side is > > if you want to change something, well, you can change something. > > What's more it's only 336 Kbytes so it costs nothing to give it > > a try. > > > > http://grail.python.org/ > > > > -- > > > > ...What was God doing all that time - before the first day? > -- Message prepared: 20:10, 24/05/2000 From kgw-zamboni-news at stiscan.com Mon May 22 08:51:42 2000 From: kgw-zamboni-news at stiscan.com (Ken Walter) Date: Mon, 22 May 2000 12:51:42 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <3928A9CD.315ABEAF@cosc.canterbury.ac.nz> Message-ID: Why not just start every python file with a pragma indicating if the file is to be considered case insensitive or not. Then everyone can have it their way. If one of the choices turns out to be bad, it will fall into disuse. Ken Walter Remove -zamboni to reply All the above is hearsay and the opinion of no one in particular From etoffi at softhome.net Wed May 31 02:21:11 2000 From: etoffi at softhome.net (etoffi) Date: Wed, 31 May 2000 02:21:11 -0400 Subject: Python sighting in the wild: Red Hat's Anaconda GUI installer References: Message-ID: <3934AF57.706E14C7@softhome.net> As far as Linux installations go, the Caldera one is better, but still, I _am_ glad that Red Hat put theirs in Python. It provides solid evidence that everything doesn't have to written in C or Perl. To expand on this, and to provide a little more substance to this post, I think that more, if not a complete Linux (or BSD??) system should be written in Python, at least the upper level parts, such a editors, package managers, etc. What about games? PyMacs, anyone? ps: i have a biased dislike towards lisp, and parentheses in general. -- etoffi Visit beef.com for free beef!!! From effbot at telia.com Sun May 7 13:19:06 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 07 May 2000 17:19:06 GMT Subject: Unicode Unification Objections References: Message-ID: Dennis E. Hamilton wrote: > Consider the following. In Japanese texts, when a borrowed or employed > Korean word is used, a desired practice is to render the Korean > characters as different, even though some or all of them involve "the > same character" common to both languages. However, the iconography (or > calligraphy) is commonly different. This loses the ability to > distinguish the linguistic use of the character, forcing material to be > font-distinguished some how (e.g., give me the ones that look Korean, > not the ones that look Japanese). This means that the distinction can't > be preserved in simple text. the distinction cannot be preserved in a naked unicode character stream, but it's done that way on purpose. you cannot really handle text strings correctly (rendering, sorting, comparing, etc) unless you have language and locale information. this is as true for unicode as it is for latin 1 or any other multilingual character set. after all, the "western culture" isn't really as homo- geneous as you americans seem to think ;-) From glyph at twistedmatrix.com Mon May 15 19:32:09 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 15 May 2000 18:32:09 -0500 Subject: Stackless/microthreads merge news In-Reply-To: cg@gaia.cdg.acriter.nl's message of "15 May 2000 23:22:49 +0200" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> Message-ID: cg at gaia.cdg.acriter.nl (Cees de Groot) writes: > Christian Tismer said: [ my comments about java and COBOL snipped ] > > This argument has hit me right between the eyes. I may be changing > > targets again, not so sure, but see Jeff Senn's post and my reply. > > Rebuilding Python as a very tiny, scalable engine for > > microcontrollers could be what we need, soon. > Gee, you're easy to influence. One Java-hater passes by, drops a > couple of casual and largely incorrect remarks, and you immediately > retarget... I would be happy to learn why my remarks are "largely incorrect". > It's probably right that the ex-COBOL community is coming to > Java. Luckily, they're not the only ones, and the fact that the > COBOL guys are moving over doesn't immediately make a language > worthless. The ex-COBOL community is most of it, I think (or people who would do COBOL if java weren't around). If you look at Java forums, and the sort of things that Sun is doing with Java, this mostly holds up. The people to whom Java would have been interesting without the flaws it's currently living with are mostly moving on, or developing derivative, incompatible systems. This is a generalization, and as with all generalizations, it is wrong ;-). The python community, dispite being waaay smaller, seems more diverse and generally more fun. Certainly, less deluded about the limitations of the language. (I *love* watching popular net.personality python lovers argue about its deficiencies without coming to hate it!) > Side note: I haven't followed the whole stackless discussion, but I > don't understand why you can get C to follow your ideas without > having to modify the sillicon machine it's running on, while for > Java you would need to have to modify the software machine it's > running on. But then, I'm a no-brainer doing Java... Because he didn't make C stackless: he made Python-in-C stackless, and CPython is an implementation of a virtual machine as well as a language. JPython relies upon the Java virtual machine, and is just an implmentation of the Python language. Therefore, in order to make JPython stackless, he has to edit the Java virtual machine, in order to make CPython stackless, he had to edit the Python virtual machine. In fact, he commented that making C itself stackless would be too hard to really consider seriously and nobody in the community would appreciate it at all. glad-to-be-moving-away-from-java-because-I-can't- live-without-first-class-methods-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From effbot at telia.com Sun May 21 16:30:12 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 21 May 2000 20:30:12 GMT Subject: case sensitivity and XML References: Message-ID: Michal Wallace (sabren) wrote: > Not so. In xmllib, you use functions like: > > start_sometag(self, attrs): > pass checked the library reference lately? that's not the documented way of doing things... (tags can contain colons and dots -- and with namespaces, they can be complete URI's. the 1.5.2 alphas didn't even support the start/end hooks; iirc, I added the compatibility code...) xmllib already contains functions to map arbitrary tag names to handlers. see the library reference for details. > Suppose you have this: '' > Then, case sensitive python would yield this dictionary: > > attrs == {"a":"lowercase", "A":"uppercase", "a-b":"a dash b"} > > No problem whatsoever. Case INsensitive python yields the same dictionary, > but how do you tell "a" apart from "A"? For example, what is the truth > value of: attrs["a"] == attrs["A"] ? oh, you're still thinking that case-insensitive identifiers means that *all* string comparisitions should ignore case? I'm pretty sure that wasn't what Guido had in mind... > One option is to say that python just won't be able to parse some > XML documents. I think that would be suicide for the language, as > more and more people and companies start using XML. well, start/end has never worked for all valid XML documents, so that's not much of an argument... From xion at inorbit.com Wed May 10 23:25:40 2000 From: xion at inorbit.com (xion at inorbit.com) Date: Thu, 11 May 2000 03:25:40 GMT Subject: Python Websites: Message-ID: <391a27e8.2952935@news.prodigy.net> I'm looking for some cool Python fansites. Anyone have/know of any? We got: Vaults of Parnassus, Python.org, Starship, Programming Pub. That's all I know of. Well, wxWindows. Any others? From dgoodger at bigfoot.com Sun May 7 23:51:39 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 07 May 2000 23:51:39 -0400 Subject: constants? In-Reply-To: <7UpR4.4382$Ip.139041@cac1.rdr.news.psi.ca> References: <7UpR4.4382$Ip.139041@cac1.rdr.news.psi.ca> Message-ID: on 2000-05-07 23:03, Brian Alexander (crystalc at interlog.com) wrote: > I haven't seen anything about constant values in the documentation with > p152. Is it possible to create constant integers, floats etc? Nope. Just variables. UPPERCASE is often used as a convention for constant-equivalent variable names (meaning: "don't touch this!"). -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From erik at naggum.no Thu May 25 20:15:15 2000 From: erik at naggum.no (Erik Naggum) Date: 26 May 2000 00:15:15 +0000 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> <8gcoij$60n$1@news-int.gatech.edu> <14jX4.127099$VR.2257590@news5.giganews.com> Message-ID: <3168288915409437@naggum.no> * Christopher Browne | I'm allowed to be schizophrenic about this; I _also_ find it | irritating when certain denizens of newsgroups deliberately | _refuse_ to capitalize words at the beginnings of sentences. | (There's no need to expound on _why_ it is, #erik, I know what | your intent is.) _I'm_ irritated by people who don't pay attention while they expound on their irritations. #erik is wrong, by the way; #:Erik is right. #:Erik -- If this is not what you expected, please alter your expectations. From pinard at iro.umontreal.ca Tue May 16 14:02:04 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 16 May 2000 14:02:04 -0400 Subject: Decimals to fraction strings In-Reply-To: "Stuart D. Gathman"'s message of "Tue, 16 May 2000 13:33:48 -0400" References: <3921867C.7CAF105C@bmsi.com> Message-ID: "Stuart D. Gathman" writes: > Scott wrote: > > Does anyone know of a way to convert decimal numbers to a string > > representation of the fractional value? For example: > > 0.5 = "1/2" > > or > > 1.125 = "1 1/8" > 1) Convert to a fraction by counting places after the decimal: > 2) Divide top and bottom by their GCD (greatest common divisor): > 3) If desired (I don't), convert to mixed notation when num > den by > finding quotient and remainder of num / den: Yet your suggestion is straightforward, it might not always yield the "best" answer, because of the constraint put on the denominator to initially be an exponent of 10. It might be quite sufficient for the problem at hand. If I had this problem, I would probably explore GNU Calc sources, as they contain an algorithm for exactly this problem, that give better solutions. For Calc users, this is command `c F' (or `calc-fraction'). Take a look in the Calc manual for more information about how to choose precision. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From boud at rempt.xs4all.nl Wed May 24 12:01:05 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 24 May 2000 16:01:05 GMT Subject: __getattr__ and __setattr__ troubles References: <8gehq1$kq6$1@news1.xs4all.nl> <392ADA0E.D812EAD0@endea.demon.nl> Message-ID: <8gguc1$k30$1@news1.xs4all.nl> Niels Diepeveen wrote: > Boudewijn Rempt schreef: >> From the documentation I understood that __getattr__ is only called when >> the ordinary normal mechanism fails. However, I see it being called even >> when my app needs things like __cmp__ and __repr__. though not for the >> fields I added myself after creating the object. > That's right. The normal mechanism for attribute lookup is to look in > __dict__. If that does not work __getattr__ is called. This goes for > methods as well as any other attributes. Thanks! That was the solution. I'm still a bit surprised that __getattr__ was actually called for __cmp__, but there are logical reasons for that, I'm sure. -- Boudewijn Rempt | http://www.valdyas.org From tim_one at email.msn.com Sat May 13 12:58:49 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 12:58:49 -0400 Subject: correct round of reals? In-Reply-To: <006701bfbc05$04bfcbc0$0500a8c0@secret.pythonware.com> Message-ID: <000001bfbcfc$83147640$212d153f@tim> [Peter Schneider-Kamp, wants an IEEE nearest/even rint] [Fredrik Lundh] > def rint(v, m=4503599627370496.0): > if abs(v) > m: > return v > if v > 0: > return (v + m) - m > else: > return (v - m) + m That's pretty! I like it. > (this assumes IEEE doubles) And inherits the rounding mode in effect. Unclear whether Peter wants that, or wants to force nearest/even. [back to Peter] > Thanks. Do you know if e.g. VC++ uses IEEE doubles? > > The platforms this code has to run on are those that > do not have an rint(3) function. So a connected > question is if these platforms use IEEE doubles? Almost all current platforms use IEEE doubles. /F's method can be generalized by preceding it with, e.g., # Find largest positive integet _m (in float format) that's # a power of 2 and for which _m + 1. is exactly representable. _m = 1.0 i = 0 while (_m + 1.0) - _m == 1.0 and i < 500: # _m's not too big yet -- boost it. _m = _m * 2.0 i = i + 1 # Now _m is twice too big, or we never found a limit. _m = _m * 0.5 if not 10 < i < 120: raise SystemError("The floating-point on this machine " "looks bizarre") del i and replacing the "def" line via: def rint(v, m=_m): The new block of code is executed only upon first module import, so this is just as efficient in use, but avoids /F's 53-bit mantissa assumption. However, this rint inherits the rounding discipline used by the platform fp, and, as above, it's unclear (to me) whether that's what you want. If you want to force the issue, and be platform-independent, life is more complicated, in your choice of two ways: you can write a hairier algorithm (as I've done below), or you can write a whole bunch of simple (but obscure) algorithms #ifdef'ed on platform-specific symbols (they're "simple but obscure" by virtue of exploiting platform quirks, just as /F's simple but obscure routine exploits 754 defaults). best-of-all-is-to-learn-to-love-truncation<0.9-wink>-ly y'rs - tim from math import modf def rint(x): """x -> nearest integer, as a float. Halfway to nearest even. Caution: If x is NaN or an infinity, this is as unpredictable as the ISO/ANSI C routines it reiies on. If abs(x) <= 0.5, a zero is returned, but whether the sign bit is preserved is also inherited from the platform C. Ditto for the effect on the 754 "inexact" flag. In return for those minor insecurites, this computes 754 nearest/ even rounding on non-754 platforms too, provided C's double is a binary floating-point format. """ f, i = modf(x) absf = abs(f) if absf >= 0.5: i = i + (f < 0 and -1. or 1.) # Now i is the "add a half and chop" result. This is the # final result unless it's a halfway case. # Then: If i was odd before, this is the correct nearest/even # result, and its last bit is clear now. But if i was even # before, its last bit is set now, and needs to be cleared -- # & since i was even, adding 1 didn't propagate a carry. So, # in either case, clearing the last bit "works" (either leaves # a good result unchanged, or repairs a bad result). if absf == 0.5: i = modf(i*0.5)[1]*2. # i.e., clear last bit return i assert rint(0.) == rint(.4) == rint(.5) == rint(-.4) == rint(-.5) == 0. assert rint(.6) == rint(.9) == rint(1.) == rint(1.4) == 1. assert rint(1.5) == rint(1.9) == rint(2.) == rint(2.4) == rint(2.5) == 2. assert rint(-.6) == rint(-1.) == rint(-1.4) == -1. assert rint(-1.5) == rint(-1.9) == rint(-2.4) == rint(-2.5) == -2. assert rint(1.23e300) == 1.23e300 assert rint(-1.23e300) == -1.23e300 From richard_chamberlain at ntlworld.com Tue May 16 17:40:51 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Tue, 16 May 2000 22:40:51 +0100 Subject: mxODBC and delete References: <3920530E.79AACCDC@mitre.org> <3920e7d9_3@plato.netscapeonline.co.uk> <392170BD.DC816592@mitre.org> Message-ID: hmmm, You could try a free database like mySql. I think you need to discover where the issue lies. It sounds like your ODBC connection is ok, so I take it it must be a problem with connecting to that particular database. Richard Peter Leveille wrote in message news:392170BD.DC816592 at mitre.org... > > > latrada wrote: > > > > Peter, > > > > I can run a delete command on my setup (i've just checked). > > > > I suppose you've checked that ODBC set up ok? > > > > Can you run a select statement? > > > > Yes, and I can use insert. > > > I presume from below that you're connect with a user name and password - > > does this have authority to delete? > > > > Yes, I logged into the Oracle SQL *Plus GUI using the same username and > password, and I can delete through that GUI. > > > Have you tried a different database? > > Nope. I only have one database to work with. > > > > > Richard > > > > Peter Leveille wrote in message > > news:3920530E.79AACCDC at mitre.org... > > > I have been using the mxODBC package for access to a database. This has > > > been working great, until a recent problem that I have had. When I try > > > running the following code, python just freezes up. Does anyone know > > > what I am doing wrong, or if there is another way to do it? > > > > > > >>> import ODBC.Windows > > > >>> db = ODBC.Windows.Connect('????????','???','??????') > > > >>> c = db.cursor() > > > >>> c.execute('DELETE FROM ???????') From jerry_spicklemire at my-deja.com Thu May 11 10:49:43 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Thu, 11 May 2000 14:49:43 GMT Subject: Type Inference Life Preserver Message-ID: <8feh9v$3gs$1@nnrp1.deja.com> Greetings Gurus & Wizards, I just had a flash and thought I'd better spit it out to see if anyone of the illuminati thinks it's remotely feasible. If not, maybe Christian Tismer can do it on his day off. The insurmountable nagging gotcha of Type Inference seems to be, when it doesn't, that is, when the best guess turns out wrong. So, with continuations enabled (via Stackless) would it now be possible to wrap an entire Type Inference Module in a Try that catches type errors? The Try would discover the type, then call back to the point in the "continuation" where type was inferred, and force the correct type! This may be the most obvious CS101ish question, but I never took CS101. That's what comes of Guido bestowing a language comprehensible by even the great unwashed. See, it works! I also know that feasible and worth the trouble are two different things, but it seemed like a shame to lose the concept just because I was too shy to mention it (like that's ever been a problem . . .) Thanks for looking at this! Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Sun May 7 21:06:20 2000 From: cut_me_out at hotmail.com (Alex) Date: 07 May 2000 21:06:20 -0400 Subject: Strange error message when calling random in Py1.5 References: Message-ID: > >>> import random > >>> random.random(100) > Traceback (innermost last): > File "", line 1, in ? > random.random(100) > TypeError: too many arguments; expected 1, got 2 > >>> > > Whew. This one's not believable. Any ideas? I think this is the reason: >>> random.random ...I always thought the fact that the "TypeError: too many arguments" error is off by one for bound methods was very misleading. It confused the hell out of me one afternoon... It seems as if random.random is not meant to take any arguments, and returns a random float between 0 and 1: >>> random.random() 0.755391751557 Alex. From nick at spam_me_not_videosystem.co.uk Fri May 26 05:34:08 2000 From: nick at spam_me_not_videosystem.co.uk (Nick) Date: Fri, 26 May 2000 10:34:08 +0100 Subject: Help! Tkinter References: <3928f98e@news.xtml.co.uk> Message-ID: <392e4574@news.xtml.co.uk> Thanks. I managed to fix it in the end by just copying the Tcl DLLs into the DLLs directory of Python. Not ideal but it works. Wierd, it used to work just fine and then suddenly broke. I've no idea why! Cheers, Nick. From jmassung at magpiesystems.com Thu May 11 18:10:47 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Thu, 11 May 2000 16:10:47 -0600 Subject: number base conversion? (ASCII to Hex) References: <391b2bd5.66612734@news1.on.sympatico.ca> <56GS4.519$cZ3.27675@news.uswest.net> Message-ID: GOD! I'm stupid! ;) Everyone kindly ignore me, I though this was comp.programming ;) Jeff From hinsen at cnrs-orleans.fr Tue May 30 10:41:00 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 30 May 2000 16:41:00 +0200 Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> <393326D3.400AA248@cosc.canterbury.ac.nz> Message-ID: Travis Oliphant writes: > > Currently, Python provides no way for you to directly specify > > which one you want -- instead, it uses a heuristic based on the > > run-time types of the arguments. This clearly violates the principle > > of not trying to guess what the programmer meant. Therefore, it > > is un-Pythonic. QED. > > > > Thank you for this clear explanation. I agree with this statement. I > have been bit several times by this problem of being able to specify which > kind of division I want and having it depend on input types. Me too. Moreover, the only way to ensure that no integer division will take place is to write (1.*a)/b or (0.+a)/b, which looks rather weird unless you know the trick. float(a)/b is more obvious but will yield a very wrong result if a happens to be complex. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From cwr at crash.cts.com Sun May 21 12:24:51 2000 From: cwr at crash.cts.com (Will Rose) Date: 21 May 2000 16:24:51 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <8g92kj$2gg1$1@thoth.cts.com> ben at co.and.co wrote: : [ Lots of things about case-sensitivity and readability already said ] : I don't know about alice, but I think the quest for case-insensivity is : masking the problem at hand: : class Employee: : def __init__(self, salary=0): : self.Salary = salary : def set_salary(self, salary): : self.salary = salary : The problem is: there's no way to check a python program without running : it, and without variable declarations there's no way to catch errors : like these. Case-insensitivity is not going to help: [...] Yes, to me this is a weakness in Python. I once got badly bitten (two days debugging) when a Basic program automatically created a (misspelled) variable and initialised it; since then I've been a big fan of declaration before use. (Why the misspelling wasn't caught by inspection is another issue - suffice to say that my default scratch integer variable is now j not i. I have finally broken away from Fortran IV conventions!). However, I don't use Python as a classic interpreter; I always use an edit, 'compile', run, cycle, so my programs could in principle be statically analysed. Python is designed to be used from the interpreter command prompt, and so a lot of static checking (I don't know how much) isn't really practical. Will cwr at cts.com From neelk at brick.cswv.com Sun May 21 14:39:07 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 21 May 2000 18:39:07 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: Fran?ois Pinard wrote: > > I understand Guido's arguments, yet my feeling is that if you allow > for confusion at such a basic level as the lexical level, the > overall impact is much more deep than one might guess at first, and > confusion might perniciously multiply in many more aspects all later > works, all along. [...] I easily believe that studies might show > that unaware people prefer insensitiveness, yet modifying Python so > it favours unawareness might be a whole disservice to the overall > programming community [...] Perhaps you should look at languages that are case-insensitive, and see if people have the problems you suspect they might? Large bodies of source code for Common Lisp, Scheme and Dylan are available under open-source licenses. Furthermore, Dejanews has archives of all of these languages' newsgroups. You can read the code for yourself and check the archives to see if anyone else has had problems with case-insensitivity. Suspicions are most easily dispelled/confirmed via evidence, and taking the trouble to do this has the pleasant side-effect that you can either cease expending effort worrying, or move directly to taking positive action to correct the problem. Neel From claird at starbase.neosoft.com Thu May 4 13:57:37 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 4 May 2000 12:57:37 -0500 Subject: python's acceptance References: <019c01bfb5c9$057faa90$858647c1@DEVELOPMENT> Message-ID: <58F1F378FA2639B3.37265C558B9C396A.9AC8B6C56F75D141@lp.airnews.net> In article <019c01bfb5c9$057faa90$858647c1 at DEVELOPMENT>, =?iso-8859-1?Q?Ulf_Engstr=F8m?= wrote: . . . >'What is the gain for a customer when I'm using Python as oppesed to Java, >C/C++, VB, Perl...?' >On the programming side it's easy to give examples of 'why Python'. I have >several reason myself for the customer side as well and management here can >come up with quite a few more. But what I'm wondering is if there excists >such a list already, with comparisons. If there is one, where? If not, let's . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rkoenig at ginko.de Tue May 23 16:10:49 2000 From: rkoenig at ginko.de (Reinhard Koenig) Date: Tue, 23 May 2000 22:10:49 +0200 Subject: Special question to embedding Python into C++ Message-ID: <392AE5C9.CB4333ED@ginko.de> Hello, How can I embed Python into C++ and ship my application to an user not having Python? Is there a similar mechanism like freeze for embedded Python? Reinhard K?nig From johngrayson at home.com Fri May 12 15:30:15 2000 From: johngrayson at home.com (John Grayson) Date: Fri, 12 May 2000 19:30:15 GMT Subject: Python & networking (e.g. ping.py) References: <391C383E.CDC4198C@web.de> Message-ID: <8fhm3i$k39$1@nnrp1.deja.com> In article <391C383E.CDC4198C at web.de>, Christian Schaller wrote: > Hello... > > Are there any libraries in python that support writing programs such > as ping in Python (or do you know of a python version)? > > I know that I can create a socket, but then there is nothing like > ip_icmp.h (in ping case) that supports me further, isn't it? > > Thanks for any hints! > > bye > Chris... > Chris, Try this URL: http://the-tech.mit.edu/~jeremy/python/ This is quite easy to find at the Vaults of Parnassus. This repository should be the first place to look for Python solutions http://www.vex.net/parnassus/ John Sent via Deja.com http://www.deja.com/ Before you buy. From andre at beta.telenordia.se Tue May 30 21:12:42 2000 From: andre at beta.telenordia.se (André Dahlqvist) Date: Wed, 31 May 2000 02:12:42 +0100 Subject: Text search and tag_add Message-ID: <8h1le2$qk9$1@zingo.tninet.se> Hi everyone, I am trying to mark strings that start with "http://" in a Text widget as hyperlinks, and I have found a solution that _almost_ works: text.tag_configure("hyperlink", foreground="blue", underline=1) link = text.search("http://", 1.0, END) if link: text.tag_add("hyperlink", link, link+"wordend" The problem with this is that I can't get it to mark the whole link, it stops at "://". The reason for this seams to be that these characters are not taken to be part of the same word as "http", and therefore it stops there. Does anyone know of a way around this? // Andr? From g2 at seebelow.org Sat May 20 03:40:54 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 20 May 2000 08:40:54 +0100 Subject: OT: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> Message-ID: <39264186.119D@seebelow.org> Thomas Wouters wrote: > > On Thu, May 18, 2000 at 10:30:58PM +0100, Grant Griffin wrote: > > > BTW, why to you Unix people separate your packager gizmo from your > > compression gizmo? Very strange... > > Strange ? Really ? I find it strange you would want to put different > functionality into one program... > Packing and compressing are two different > things, so why force one program to do both ? :) I dunno...about the only program I know of that does just one thing is "Hello, World!". ;-) I guess I take a "shrink wrap" mentality, both from an author's and a user's perspective. The "gizmo" should meet the user's need, as defined by the user. (Note, however, that the "user" is partly defined by the "gizmo", because user's don't use gizmos which don't meet their needs.) For example, Python has many disparate features and functions, in an attempt to meet the needs of the Python user. We would regret it if it did only one thing, or if it was only allowed to do things which have some immediate conceptual relationship to each other. Instead, we benefit from the holistic integrity it somehow achieves from its disparate features. But to go back to tarring and feathering tar, the user has little need for packaging without compression, so packaging and compression constitute a single gizmo from the modern user's perspective. QED > > So much better to seperate the functionality: If you get a new version of > the compress utility, or a new compress utility that does it so much better, > you wont have to change anything in the packing utility. But isn't packaging pretty trivial? And disk space is cheap. I mean, this is the late 1980s, after all! So why isn't packaging built into _every_ modern compression utility? > And the other way > 'round. And decent packaging utilities provide support to magically include > compression, by calling the appropriate compress utility itself... GNU tar > has support for standard unix compress (.Z), gnu zip (.gz) and bzip2 (.bz2) > this way, and you can tell it to start any program you wish, with the > '--use-compress=' option. > > Just like there isn't a Wordperfect or Word-alike program on (traditional) > UNIX; no all-encompassing Word-processor. Instead, you edit using your own > favorite editor, passing it through your own favorite text formatter, to > translate it to a file format of your choosing. And just like Mosaic, long > ago, didn't provide support for all protocols itself, but rather let other > programs take care of them... You can see a lot has changed in the UNIX > world, in this regard :-) I've been teasing you guys a little on this, but in all seriousness, as I think about it more, it seems like the essential disconnect here is between the "command line" paradigm and the GUI paradigm. The "compound functionality" approach of UNIX makes good sense in a command-line paradigm (because it allows a lot of flexibility at the cost of a lot of typing, or writing scripts: more typing), but in a GUI paradigm, it's a lot more practical simply to build all functionality the user requires into a single program. (This is the essence of "shrink wrap".) And when that program _doesn't_ meet our needs, we simply get an upgrade, or find another program which does. Or better yet, we standardize on a single format, zip: very simple, very easy. With all due respect to the Windows-bashers of the world, I personally think that trading flexibility for convenience is a very good tradeoff: it makes me productive. (which-is-why-i-still-think-tar-is-strange-)-ly y'rs =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From brent.fulgham at xpsystems.com Wed May 17 18:52:23 2000 From: brent.fulgham at xpsystems.com (Brent Fulgham) Date: Wed, 17 May 2000 15:52:23 -0700 Subject: Question About Embedding into C++ Message-ID: > Traceback (innermost last): > File "", line 1, in ? > File "../FXPy/__init__.py", line 21, in ? > File "../FXPy/fox.py", line 2, in ? > ImportError: foxcmodule.so: undefined symbol: _Py_NoneStruct > This may be a stupid question, but is your program linked against libpython1.5.a? Also, did you build your extension module using the Makefile.pre.in and "make_shared" scripts from the Python distribution? Thanks, -Brent From cjc26 at nospam.cornell.edu Sat May 6 10:14:36 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sat, 06 May 2000 14:14:36 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: * Michael Hudson menulis: | > | > How do you do the equivalent of a for loop using templates? | | Noisily; it's been a while since I played with this kind of thing, but | hopefuly this will give you some idea: [snip template mess] I only knew that it COULD be done; I didn't know HOW. You scare me. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ icq 68165166 "IS I yes wardrobe yield [the] evaluation." member of A.H.M.A.D. From jwbnews at scandaroon.com Sun May 21 15:42:45 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 21 May 2000 12:42:45 -0700 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> <39271A25.A348E4B9@roguewave.com> Message-ID: In article <39271A25.A348E4B9 at roguewave.com>, Bjorn Pettersen wrote: > This brings up another interesting point... I'm assuming the subjects > from the Alice project/research would also prefer: > > 'token' == 'Token' AppleScript (not to be taken as "the only right way") does that: "token" is "Token" returns true, while considering case "token" is "Token" end considering returns false. ("is" can also be spelled as "=" if one wishes). And to make AppleScript a bit more fun, there is also ignoring diacriticals ... end ignoring The latter construct allows, eg, o mit umlaut (which I'm not going to attempt over Usenet) to equal plain o, so we could have one in one of the tokens above. The default considers diacriticals and ignores case. So certainly the Alice folks who had been exposed to AppleScript would have expected 'token' == 'Token'. --John the unhelpful -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From olipt at mayo.edu Tue May 23 15:11:01 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 23 May 2000 14:11:01 -0500 Subject: numpy for linux(ppc)? In-Reply-To: <8gedo6$o6q$1@nnrp1.deja.com> References: <8gedo6$o6q$1@nnrp1.deja.com> Message-ID: > I'm mostly familiar with Jack Jansen's terrific > MacPython installer for Macintosh, where Numpy > is included. (Jack should get some kind of award!) > > I notice that, at least for LinuxPPC, Numpy isn't > part of the "standard" RPM distributions. (why?) > > Where's the best place to get linux RPMs for Numpy? > src.rpm's are distributed at the SourceForge site: http://numpy.sourceforge.net RPM binaries for i386 are also available. -Travis From rkiendl at gmx.net Thu May 25 09:31:27 2000 From: rkiendl at gmx.net (Robert Kiendl) Date: Thu, 25 May 2000 15:31:27 +0200 Subject: Embedding Pythonwin: Debug-Build CArchiv Problem Message-ID: <392D2B2F.ABBCA22F@gmx.net> I embedded Pythonwin (Build 128 from CVS tree). I am using the debug libs python15_d, win32ui_d, pywintypes15_d in the Debug Build of my application. Everything works fine. But after doing glue.DynamicApplicationInit, the usage of CArchive inside my application crashes with a stack shown below. I do not have the problem in the release build, and the problem is not there before doing glue.DynamicApplicationInit. CRuntimeClass::Load called from CArchive::ReadClass seems to cycle over all dynamically linked DLLs and thereby my app classes are not found anymore when win32ui_d is attached: AfxLockGlobals(CRIT_DYNLINKLIST); for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL; pDLL = pDLL->m_pNextDLL) { for (pClass = pDLL->m_classList; pClass != NULL; pClass = pClass->m_pNextClass) { if (lstrcmpA(szClassName, pClass->m_lpszClassName) == 0) { AfxUnlockGlobals(CRIT_DYNLINKLIST); return pClass; } } } AfxUnlockGlobals(CRIT_DYNLINKLIST); Does anybody have an idea? robert -- Call Stack ------------------- KERNEL32! RaiseException at 16 + 106 bytes MSVCRTD! _CxxThrowException at 8 + 57 bytes AfxThrowArchiveException(int 6, const char * 0x00c18e9c) line 95 CArchive::ReadClass(const CRuntimeClass * 0x0057fd78 struct CRuntimeClass FFileFormatDesc_Map::classFFileFormatDesc_Map, unsigned int * 0x0012f898, unsigned long * 0x0012f890) line 305 CArchive::ReadObject(const CRuntimeClass * 0x0057fd78 struct CRuntimeClass FFileFormatDesc_Map::classFFileFormatDesc_Map) line 125 + 20 bytes operator>>(CArchive & {...}, FFileFormatDesc_Map * & 0x00000000) line 43 + 37 bytes CTrafficDoc::OnOpenDocument(const char * 0x0012fc88) line 176 From dale at out-think.NOSPAMco.uk Wed May 17 10:36:27 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 17 May 2000 15:36:27 +0100 Subject: Forcing type conversion References: <8fu9m9$2ab$1@supernews.com> Message-ID: <8fuapm$kjn$1@supernews.com> Whoa - enough! Thanks everyone. That was so fast, I'm considering throwing away all my other Python docs! :) -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Remco Gerlich wrote in message news:slrn8i5b34.6dp.scarblac-spamtrap at flits104-37.flits.rug.nl... > Dale Strickland-Clark wrote in comp.lang.python: > > How do I get Python to force 'a' and 'b' into strings so that the following > > concatenates instead of trying to add. > > > > a = 1 > > b = 2 > > a + ":" + b > > The str() function. > > a = 1 > b = 2 > str(a) + ":" + str(b) > > Or use the % operator, of course. > > -- > Remco Gerlich, scarblac at pino.selwerd.nl > > This is no way to be > Man ought to be free -- Ted Bundy > That man should be me From psxunderground at cjb.net Wed May 3 20:17:42 2000 From: psxunderground at cjb.net (psxunderground at cjb.net) Date: Thu, 04 May 2000 00:17:42 GMT Subject: The Playstation Underground Update Message-ID: The Real PSX Underground check us out online @ http://modchip.50megs.com Our URL changed cause CJB.net was being a total Bitch and thinks our site is in Violation of there terms ... Sorry for posting this twice but I think you should alll know the new URL atleast ... Thanks Hello fellow PSX owners and Fans Ive just setup the coolest new Hideout, here you can Buy, Sell and Trade Playstation games as well as the latest PSX addons like Modchips, VcD cards and so on. You can even get plans on how to build you own ModChip Burner to make your own modchips from parts from RadioShack, we have all the plans and software you will need to make them for -FREE- although we also sell them. We also got the plans and software to make your Own DreamCast ModChips which is very cool. and for a limited time we are Giving away a Free System of your Choice from DreamCast, Playstation, N64 or even the Jap PSX2 ... we sell everything that deals with Modifying or Backing-up games. We also have DVD Players with No Country Lock or Copy protection as low as $400 Canadian The Real PSX Underground check us out online @ http://modchip.50megs.com From teemu.keskinarkaus at ramk.fi Wed May 10 06:26:47 2000 From: teemu.keskinarkaus at ramk.fi (Teemu Keskinarkaus) Date: Wed, 10 May 2000 10:26:47 GMT Subject: Python, cgi and redirect References: <39191ca8.537672021@news.ramk.fi> Message-ID: <3919390e.544941163@news.ramk.fi> On Wed, 10 May 2000 10:20:37 GMT, nascheme at enme.ucalgary.ca (Neil Schemenauer) wrote: >Teemu Keskinarkaus wrote: >>Is there simple cgi module for python that can do redirect?? Now I'm >>doing redirect in cgi-script like this: >> >>print "Status: 302 Moved" >>print "Location: http://url.to.somewhere" >> >>That works fine except I get 'Premature end of script headers' errors >>in apache error_log everytime I use that script. > >You need to terminate the headers with a empty line ("\r\n"): > > sys.stdout.write("Status: 302 Moved\r\n" > "Location: http://url.to.somewhere\r\n" > "\r\n") > >I think most clients will accept "\n" although it is not >technically correct. Thanks for everyone who answered. I got it working right. I put empy 'print' at the end to do extra line and now there is no more errors in log when I'm using script! TK From phd at phd.russ.ru Mon May 29 08:40:04 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 29 May 2000 12:40:04 +0000 (GMT) Subject: Presenting output from md5.digest like md5sum from GNU textutils In-Reply-To: Message-ID: On Mon, 29 May 2000, [iso-8859-1] P?l Sollie wrote: > I am trying to write a script that is to save the checksum of all the > specified files to a database. I'd like to convert the output I get > from md5.digest to a human-readable format. Decimal values would be > OK, but I'd be thrilled to get the same output as md5sum from GNU > textutils. Attached. The actual algorith is Guido's. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. -------------- next part -------------- #! /usr/local/bin/python """ User wrapper for md5 builtin object Written by BroytMann, Jun 1997. Copyright (C) 1997 PhiloSoft Design """ from md5 import md5 class md5wrapper: def __init__(self, init=None): if init: self._md5 = md5(init) else: self._md5 = md5() def update(self, data): self._md5.update(data) def digest(self): return self._md5.digest() def __repr__(self): str = self.digest() return "%02x"*len(str) % tuple(map(ord, str)) # This nice was suggested by Guido def md5file(self, f): if type(f) == type(''): # If f is string - use it as file's name infile = open(f, 'r') else: infile = f # else assume it is opened file (fileobject) or # "compatible" object (must has readline() method) try: while 1: buf = infile.read(16*1024) if not buf: break self.update(buf) finally: if type(f) == type(''): # If f was opened - close it infile.close() if __name__ == "__main__": print "This must print exactly the string" print "Test: 900150983cd24fb0d6963f7d28e17f72" print "Test:", md5wrapper("abc") From m.faassen at vet.uu.nl Sun May 28 17:21:09 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 May 2000 21:21:09 GMT Subject: Another salvo in the indentation war? I hope not. References: <8gjqer$k8v$1@nnrp1.deja.com> Message-ID: <8gs2k5$m7m$3@newshost.accu.uu.nl> rzantow at my-deja.com wrote: > This isn't really intended to launch into Yet Another Indentation > Threat, but I have one plausible argument in favor of some form of > block marking: When a newsreader, browser, or mail program trashes the > indentation from examples of Python source, it is a real pain in the > hindlimbs to recover the original program logic. And of course there are the whitespace eating nanoviruses! Those are even worse. Anyway, if newsreaders, browser and mail software really trash the indentation, we'll have less chance of ILOVEYOU type viruses written in Python. :) In practice, I haven't really observed such trashing; perhaps because I'm not in a habit of copying lots of code like that, but perhaps also because it doesn't happen very often. Besides, if they do trash indentation, then that'll be hell for maintenance of let's say, C code, as well. I therefore suggest we don't send large programs by mail, unless it's in an attachment. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From noone at do.not.use Tue May 9 14:11:37 2000 From: noone at do.not.use (Russell Turpin) Date: Tue, 09 May 2000 13:11:37 -0500 Subject: Any module or library for full-text indexing? Message-ID: <391854D9.89285A9B@do.not.use> I'm looking for a Python module that does full text indexing, ie, that extracts a set of significant words from a text document, and searches for a candidate word in a list of words so extracted. The module should solve the following problems: COMMON WORD MANAGEMENT. No one wants to index on common words such as "the," "of," and "what." Ideally, a module that does full-text indexing would have some tool for managing the set of words that are defined as "common." Words not commonly in a dictionary, such as "Noam" and "Chomsky," are significant and should be indexed. COGNATES. The module should have some way of identifying variations of the same word when searching the index, ie, "goose" would also match on "geese," "mouse" on "mice," and "456" on "four-hundred fifty-six." This requires the module to have or make use of a language dictionary in some form. (I would be more than happy with noun cognates. Yeah, the number example is hard, and not required.) The package does not need to implement a persistence mechanism, nor manage the indices and their referents. In other words, the core functions I am looking for are: extract_significant: text -> word_list find: word, word_list -> set of hits These would be trivial functions if not for the linguistic aspects as described above, and it is precisely these problem for which I'm hoping to find a solution. Of course, if the module goes further, that is great. If there is no existing Python module for this, I would be interested in any C package that could be adapted toward this end. In this case, I would try to wrap the C package as a Python module, and make it available for other Python programmers. If there is no C package, I'll consider anything that can run on a Linux box. If there is no package that does this, I'll go out on the glacier and eat ice worms. Thanks! Russell From gmcm at hypernet.com Sat May 13 09:12:12 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 13 May 2000 13:12:12 GMT Subject: Q: Python Script vs. Win32 SendTo References: <4_4T4.1115$Xl.103670@news.goodnet.com> Message-ID: <391d54ac$0$13925@wodc7nh6.news.uu.net> Tom Vrankar wrote: > >I'm trying to write a python script that I want to place in Win32's SendTo >directory. [snip] >I can approximate what I want by creating a batch file, and dropping it's >shortcut in SendTo. I've editted the PIF to close on exit and run minimized, >but it's unsightly, and slow, and DOS-ifies the paths of the files I send to >it. That's all I've ever done. The shortcut has to be executable (not just have a file association). You can embed the script in the bat file: --------------------- @echo off rem = """ python -x %1 %2 %3 goto endofpython rem """ rem = """ :endofpython rem """ ----------------------- I vaguely recall posts from people who used the registry to tell Windows that .py files *are* executable, but I don't recall how that works. - Gordon From emile at fenx.com Wed May 10 17:35:01 2000 From: emile at fenx.com (emile at fenx.com) Date: Wed, 10 May 2000 14:35:01 -0700 Subject: HELP! Simple question re: dictionaries Message-ID: <3919D605.3CF9846@fenx.com> Refer to key and value as key and value. Each loop returns a key value pair. If the for loop was: for k,v in my_dict.values(): you would use k and v to refer to the values. To get a value from a dictionary, use: value = my_dict[key] Look on www.python.org for info. There's plenty there. HTH, Emile van Sebille emile at fenx.com wrote in message news:<3919d323.436983308 at news1.on.sympatico.ca>... > Sorry.. forgot to ask another thing related to this: > > 1. For the example below, how would I refer to JUST the key, value > referred to in the iteration of the for loop? > > for key,value in argumentList.items(): > print ? > > 2. Additionally, you can access a certain element of a list by using > a numerical subscript (like [1] - like an array). If, let's say, > there's one key & corresponding value in a dictionary, then how would > I reference that value - to let's say - print it out? > > Finally... if you know of a website that I could visit to get the > specs of syntax, please let me know (so I can stop asking these simple > questions!). > > Thanks again for your help, > > kc > > On 10 May 2000 20:34:09 +0100, Michael Hudson wrote: > > >chibaA at TinterlogD.Tcom writes: > > > >> Hi, > >> > >> I just want to write a for statement to go through each element of a > >> dictonary. I would have assumed it would look something like this > >> (argumentList being the dictonary): > >> > >> for ___ in argumentList: > >> # whatever... > >> > >> ... but I'm not sure of the exact syntax. If anyone knows, could you > >> let me know? Thanks! > > > >for key,value in argumentList.items(): > > # whatever ... > > > >is pretty idiomatic... > > > >Cheers, > >M. > > > >-- > >34. The string is a stark data structure and everywhere it is > > passed there is much duplication of process. It is a perfect > > vehicle for hiding information. > > -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html > > -- > http://www.python.org/mailman/listinfo/python-list > From nospam at sorry.com Sun May 14 17:49:38 2000 From: nospam at sorry.com (Keygrass) Date: Sun, 14 May 2000 21:49:38 GMT Subject: (gulp) newbie question - portablity of python References: Message-ID: Very nice of you to post that. Thank you. -cb Moshe Zadka wrote in message news:Pine.GSO.4.10.10005142328180.21724-100000 at sundial... > On Sun, 14 May 2000, Keygrass wrote: > > > So ... my question is this: Is this really too good to be true? > > Nope > > > Basically, I want a build a program that will replace words and number on > > another file. For example, if I had a file called "Outdoor_sports" that > > contained the word "baseball bat", I would want my program to change it so > > it would say "football". > > Here it is, in its entirety. > > ------- > #!/usr/local/bin/python > import string, sys > > def replace_word_in_file(file, word, replacement): > f = open(file) > s = f.read() > f.close() > s = string.replace(s, word, replacement) > f = open(file, 'w') > f.write(s) > f.close() > > if __name__ == '__main__': > if len(sys.argv) < 4: > exit(1) > for file in sys.argv[3:]: > replace_word_in_file(sys.argv[1], sys.argv[2], file) > ------- > > Save it as "replace.py", and it will work on pretty much anything. > For 10 more minutes of work, you can also write a Tk GUI which will work > on Windows an UNIX (and on MacOS, with a little coaxing) > -- > Moshe Zadka > http://www.oreilly.com/news/prescod_0300.html > http://www.linux.org.il -- we put the penguin in .com > > From moonseeker at my-deja.com Mon May 22 09:47:13 2000 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Mon, 22 May 2000 13:47:13 GMT Subject: how to find out the father class? Message-ID: <8gbdou$sd3$1@nnrp1.deja.com> Hi! How can I find out the father class of a given class? Regards, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From sollie at saint-etienne.no Mon May 29 08:06:25 2000 From: sollie at saint-etienne.no (=?iso-8859-1?q?P=E5l?= Sollie) Date: Mon, 29 May 2000 12:06:25 GMT Subject: Presenting output from md5.digest like md5sum from GNU textutils Message-ID: Being a clueless newbie at Python I have no idea how to do this. I am trying to write a script that is to save the checksum of all the specified files to a database. I'd like to convert the output I get from md5.digest to a human-readable format. Decimal values would be OK, but I'd be thrilled to get the same output as md5sum from GNU textutils. -- P?l Sollie sparkz at ikke.no sollie at bitemyshinymetalass.com From andrew at one.net.au Thu May 11 05:17:40 2000 From: andrew at one.net.au (Andrew Maizels) Date: Thu, 11 May 2000 19:17:40 +1000 Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> <391A58E5.C9487C30@san.rr.com> Message-ID: <391A7AB4.B132D9DA@one.net.au> Courageous wrote: > I just read that. It suggests that the threads may > be mutually locking eachother out some of the time, > but it does not say that they will not see a performance > gain once you discount the contention issues. > > In particular, the brief discussion might suggest to > this otherwise naive reader that if the threads were > operating in relative mutual exclusion to eachother and > objects which, once divided between them, were non- > co-referencial, here might not be as much contention > for python locking structures as the document mentions. Unfortunately, the locking mechanism is very simple: it doesn't know whether you're going to run into trouble or not, so it always acquires the lock so that only one thread of Python code can run at any time. However, I/O operations can effectively multithread, so if you're doing a lot of I/O, you may see a performance improvement. One of my programs ran up to 80% faster when moved from a single-processor to a dual-processor machine. Andrew. -- .sig still missing! No film at 11! From rumjuggler at cryptarchy.org Sat May 13 14:40:11 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 13 May 2000 18:40:11 GMT Subject: threading question Message-ID: I'm a complete novice as to threads, but the recent Waiter/Messenger examples made them seem simpler than the docs indicated, so I'm trying to figure them out. This script was basically so I could mess around with Conditions, but it never exits. from threading import * from time import sleep def printlist(list, cond): cond.acquire() while list:#this loop ends first in thread '1' print 'printing in %s' % currentThread().getName() i, list = list[0], list[1:] print i sleep(1) cond.notify() cond.wait()#when thread '1' breaks out of the loop, the #thread '2' is here cond.acquire() cond.notify() #so this should wake thread '2' cond.release()#and this should allow it to acquire the condition #allowing it to break out of the loop. When it #calls notify(), nothing should happen, and then #it should release. Instead, thread '2' never #acquires the condition in the first place #once thread '1' reaches this point. def makenew(): cond = Condition() cond.acquire() t = Thread(target=printlist,name='2',args=(['la','di','da'],cond)) t.start() printlist([1, 2, 3], cond) th = Thread(target=makenew,name='1') th.start() ---output: printing in 1 1 printing in 2 la printing in 1 2 printing in 2 di printing in 1 3 printing in 2 da Setting thread '2' to be daemonic allows the script to exit, but I'd like to know what the problem was. -- Barnabas T. Rumjuggler "It's is not, it isn't ain't, and it's it's, not its, if you mean it is. If you don't, it's its. Then too, it's hers. It isn't her's. It isn't our's either. It's ours, and likewise yours and theirs." -- Oxford University Press, Edpress News From dalke at acm.org Sat May 13 00:10:34 2000 From: dalke at acm.org (Andrew Dalke) Date: Fri, 12 May 2000 22:10:34 -0600 Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: <8fioa4$dlo$1@slb6.atl.mindspring.net> Martijn Faassen wrote: > How exactly would [an equivalent to perl's "use strict" pragma] work? > It would seem hard to make this work right in a dynamic language, but > perhaps I'm missing some simple strategies. I'm not familiar enough > with 'use strict' in Perl to know what Perl is doing in this respect. It doesn't have to be correct always, just for reasonable cases. Perl's 'strict' can be wrong too, and for similar reasons. A version for Python would be like Aaron Watter's kjpylint, which tells you if a variable is mentioned once, or used before set. Of course, it doesn't work for getattr and other tricks. It also fails when a function uses a global variable before it's set, since it doesn't do call analysis, and it doesn't understand lambdas. The current version uses the 1.4 syntax so some code will trip it up. I sent Aaron a patch for that, but I don't think it's been integrated into kjpylint yet. Other solutions might be to use the SPARK grammer for Python or scan the bytecode for which locals and globals are used. Or modify the Python parser to keep track of all variable references and do the same logic, which was the original request. Andrew dalke at acm.org From mhammond at skippinet.com.au Fri May 26 02:13:13 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 26 May 2000 06:13:13 GMT Subject: Out parameters to COM objects References: <8F3FD1F1Bbillybobhotmailcom@166.93.207.145> Message-ID: "Glenn Farrow" wrote in message news:8F3FD1F1Bbillybobhotmailcom at 166.93.207.145... > > >>> iRead = ns.Read(sBuf, 4096) sBuf = ns.Read(None, 4096) should work. Although it probably wont unless you have run makepy for the type-library... Mark. From jkraska1 at san.rr.com Fri May 5 02:06:27 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 05 May 2000 06:06:27 GMT Subject: Copyright and License References: Message-ID: <39126597.B4ABCD98@san.rr.com> Mikael Olofsson wrote: > > On 05-May-00 Courageous wrote: > > That's the understatment of the century. As a matter of legal practice, > > in the United States your copyright is worthless if you don't have it > > registered, most assuredly in particular if someone else does. > > And anything is worthless unless you have 50 lawyers to back it up. This is one of those cases where it can be nearly worthless even when you *do* have 50 lawyers to back it up. What you have to understand is that the letter of the law not withstanding, legal precedent and case rulings tell an entirely different story. For whatever reason, the current holder of the valid legal registered copyright is often the final word. The moral of the story: registration is a good idea (and cheap). C/ From shapr at uab.edu Wed May 3 17:52:49 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 03 May 2000 21:52:49 GMT Subject: Problems with HTMLgen tables References: <3dnzbdty.fsf@jumbo.skott.dk> Message-ID: <3910A2DC.A2D6FAC8@uab.edu> "Martin Sk?tt" wrote: > > Hi > I'am trying to create an HTML table from a Python script using the > HTMLgen module. In the following lines you can see my test program, > the file i read, and the Python output when running it. Can you help > me solve the problem? (Red Hat 5.2, Python 1.5.1) > table.body = [] > doc.append(table) > for line in fila: > inf = string.strip(line) > table.body.append(inf) I get the same error on Debian 2.1, Python 1.5.2 As best as I can tell, making an empty body and then appending to it is something HTMLgen doesn't like. I looked at the documentation for HTMLgen, and it seems the preferred method is to make your list first, and then set it to table.body I got the above to work with this change: table = HTMLgen.Table() bodybitz = [] for line in fila: bitz = string.split(line,' ') bodybitz.append(bitz) table.body = bodybitz It's just a workaround, but I hope it helps. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt and my cat started dancing around singing "I'm nacked, I'm nacked!" From tkroll at hawaii.edu Thu May 25 06:18:59 2000 From: tkroll at hawaii.edu (Ty K. Kroll) Date: Thu, 25 May 2000 10:18:59 GMT Subject: Simple thread prob Message-ID: I'm trying to build a thread that will timeout. I've only used simple threading in Python. I'm thinking wait() in Event or join() in Thread may be helpful, but the documentation is sparse. Can anyone point me in the right direction? Thanks. -Ty From greg at cosc.canterbury.ac.nz Tue May 9 01:42:28 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 09 May 2000 17:42:28 +1200 Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> <3910CDEF.73746A35@cosc.canterbury.ac.nz> Message-ID: <3917A544.D23BDBD1@cosc.canterbury.ac.nz> Niklas Frykholm wrote: > > Do you think each screen object should > (transparently) run in a separate microthread? That would probably be overkill. I once tried to implement a GUI library (for Sun's NeWS window server) by giving each widget its own event handling thread, but I found that it didn't really gain me anything and added a lot of unncessary complexity, so I went back to a more traditional approach. The option of giving any object its own thread might be interesting, though. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From fiona at sitegnome.com Tue May 16 11:02:02 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 16 May 2000 15:02:02 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 16th, 2000 Message-ID: <20000516150202.11591.qmail@synop.com> Hi All, Another bundle of entries into http://python.faqts.com Cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How does the statement 'global' work? http://www.faqts.com/knowledge-base/view.phtml/aid/2902 ------------------------------------------------------------- Fiona Czuczman Remco Gerlich, Thomas Wouters Answer1: Inside functions, if you assign to a variable, it is assumed to be local to the function. If you want to assign to a global (module namespace) variable, you'll have to tell Python that it's a global first. ie, x = 4 def spam(): x = 5 spam() Doesn't change the module's x. But x = 4 def spam() global x x = 5 spam() does. If, inside a function, you only use the variable and never assign to it, it can't be a local variable, so Python assumes you mean a global. This doesn't only hold for functions, but classes and methods too. Answer2: Python has two namespaces it uses for name lookups: the 'local' namespace and the 'global' namespace (you could call it the 'search path'.) The local namespace is the function or class you are in, the global namespace is the namespace of the module. If you are not in a function or class, the local namespace is the global namespace. However, *assigning* to a variable does not use this search path ! Instead, if you assign, you always assign in the local namespace. So, for instance: X = None def FillX(x): X = x would not work, because the X you assign to, is the *local* X, not the global one. This wouldn't even generate an error, by the way. Even more confusing is it if you read from and assign to 'X' in the same function: X = None def FillX(x): if not X: X = x In Python 1.5.2, this generates a NameError: Traceback (innermost last): File "", line 1, in ? File "", line 2, in FillX NameError: X and in Python 1.6, an UnboundLocalError: Traceback (most recent call last): File "", line 1, in ? File "", line 3, in FillX UnboundLocalError: X It generates this strange error because the 'X' name exists in the local namespace, but at the time of the test on X, it isn't filled in yet. The interpreter knows it should be there, but can't find it at the time of execution. And this is what the 'global' keyword is for. It says 'this name is global, *even if* it gets assigned to. You only need it when you are assigning to globals, not when you are mutating them (appending to lists, adding to dictionaries, etc.) ------------------------------------------------------------- How do Python and Java compare? http://www.faqts.com/knowledge-base/view.phtml/aid/2906 ------------------------------------------------------------- Fiona Czuczman Courageous, Warren Postma, dana_booth, Cameron Laird, Roman Milner, Martijn Faassen, Bob Hays, Andrew Cooke, Glyph Lefkowitz Topic 1: I would just like to know how serious python is taken in the IT industry and how it compares to something like Java. Answer(s): - Recent events have proven that the computer industry is a lot less staid and unmoving than it used to be. Everybody's getting paranoid that someone else will beat them to the next big thing. That being so, I expect a big cloud of Python hype any day now. Perl had it's hype day, as did Java. - Larger companies probably do not take Python seriously. In the industry, though, small, faster moving companies can have an advantage. I work at a mid-sized manufacturing plant, and we're given the freedom to use whatever we like, as long as the plant keeps working. :) We use OpenBSD servers running MySQL and Samba. Shell, Perl, and Python scripting drives everything, and the Windows users are connecting using TCL/TK apps. We do lots of things that many plants our size do not do, or spend a lot of money doing. That being said, it's been my experience that Python is easier to use than Java. While I use Perl for small text parsing scripts, I've found Python to be very well suited for creating even semi-large programs. Like many, I was excited about Java a few years ago, but found it to be a bit cumbersome for the small to medium sized apps that we needed to create. I especially don't like the I/O in Java. - Larger companies like Intel, Motorola, Microsoft, Compaq, IBM, ...? See, for example, . That's a cheap shot on my part. Mr. Booth is right. Conservative (in some sense) MIS departments *are* wont to scorn Python. It can be tough getting approval from many of them to use Python for a project such as that under consideration here. It's worth it, though--*particularly*, I claim, for Web work. - In the company I work for, the two languages are both used for different (but overlapping) areas. Java is used for the product; Python is used for scripting tasks (automating builds, etc). This strikes me as quite sensible. The real reason is probably historical, but I feel Java is better for large projects because: + near-static typing helps enforce interfaces + various language constructions (eg Interfaces) help enforce a modular approach + easier to hire for + programmers used to Java code, which tends to be more explicit (long winded and tedious if you like), and so easier to understand On the other hand, Python is better for scripts because: + compact + flexible (can use functions as well as objects; objects blend nicely into the general synax using __ methods) + quicker to write + easier to modify Note that the argument above doesn't mean Java is better - in many ways it is worse, but safer/more common. Cue arguments about blunt knives ;-) Performance is not critical in the software I am involved in - provided the speed is reasonable, reliability is more important. Otherwise, I guess we'd use C. Topic 2: If a web application was written in both Java and Python, which would companies prefer? Answer(s): - Java. This is because IT professionals pick products that they can't get fired for picking. An old setting in the IT industry: "nobody ever got fired for picking Oracle." - I heard it as "nobody ever got fired for buying IBMs". Then the clone industry sort of stole IBM's thunder, technological lead, etcetera. IBMs became Also Rans. So will Java. Once the hype evaporates, you have just one more language, with good bits and not so good bits. - *companies* would always prefer Java, because that has all the buzz, they've heard of it, it's hyped all over the place. Whether they *should* prefer Java is another question. - I work in the IT organization of a large multinational bank (in the top ten world-wide). When we had to build an interface system that required mapping data and we didn't know the target map (it kept changing - big surprise, right?), we used Python for the mapping. What used to take days to change (in C++) then took at most an hour; testing became the long leg of development.... The only problem I had in getting Python accepted was that most people have Java experience but not Python experience. I handled that by having four people in the group learn Python enough to modify our production app - it took each of them less than three days to get up to speed. We brought in a consultant to port the application to a new version of the underlying library (which is SWIG wrapped) and it took him two days. Case made, no more problems.... BTW, we've used JPython in a second production application already. - Java, mostly because Java has a cooler logo, and Java is backed by Sun, which is a big company. Software companies, especially, prefer this, because they like to think that having a large company behind something means something. That's if you're marketing it as being in a certain language. One thing that we do too much in this industry is focus on our implementation technology. YOU should be familiar with the technology, YOU should be aware of its strengths and weaknesses, but your customers should just know what it does and how well it does it. It would be cool if you could get python a little bit more press, but you don't necessarily have to try to ride Java's (or Python's) marketing success. If you do that, the success of your product becomes bound up with successes and failings of the language and platform which may or may not have anything to do with your program at all. Topic 3: Which is more maintainable? Answer(s): - In my humble opinion, I would put it this way: 1. It takes less python code to do something in Java 2. The Less Code you write, the less there is to maintain. As a matter of opinion, I find Python far more "readable". The syntax is clear, the built in data structures and types are simple enough to grasp, but powerful enough to be useable. - Depends on the code you write, I imagine. Python may be considered less maintainable as it's harder to enforce interfaces, can't do static type checking, etc. Python may be considered more maintainable as its code is shorter, more readable, you get flatter inheritance hierarchies, you can more easily change things around, and you can more easily reimplement things. I myself would prefer Python; I think a solidly engineered piece of Python could would be as maintainable if not more than a solidly engineered piece of Java code, and faster to set up to boot. - Can't choose. Python is easier to change but IMHO works better as a prototyping and quick-mod layer, not quite as robust as Java. - Python. Python can do just about anything in fewer lines of code, and is vastly more readable to boot (not to mention having lovely space-saving features like function and method objects and module-global variables.) I don't think i've *ever* found a language more maintainable than python, and I love it. Even one-liners I tossed off to solve very specific problems are completely readable (and even somewhat reusable!) to me weeks after I write them, even if I'm trying to be purposefully obtuse or clever ;-) Not to mention the fact that everything is a first-class object in python, so you don't end up worrying about how the heck you're going to write your code to deal with int/long/double/float without incurring extra overhead both in syntax and in memory: you can just treat everything as a number in python. (As if it were object oriented or something!) Compare the following to snippets: class Foo: def __init__(self,x=15): self.x=x def bar(self, a, b): return self.x+a+b ... public class Foo { int x; public Foo(int x) { this.x=x; } public int bar(a,b) { return x+a+b; } } The java version looks slightly more complex, but they appear to be approximately the same: until you realize that Java is operating on integers, and Python is operating on *anything which can be added*! This could be strings, complex numbers, integers, floating point numbers (despite the fact that we should, of course, never use floating-point (thanks tim)). In order to get similiar functionality in the Java version with appropriately aesthetic syntax, the code would be about 20 times longer. Less code == less to fix == less to maintain == fewer bugs. Topic 4: Which is more scaleable? Answer(s): - Keep in mind that a lot of your python can connect to third party tools at native speeds, if you learn a trick or two. - Scalable up or scalable down? Python scales DOWN much better. There's a lot more overhead in making and distributing a Java application, so Java scales down poorly. On the other hand, I'd say more work has gone into Java, and using Java for what would traditionally be called a "transaction processing" (TP) system. Java has some features in it's Enterprise Java Beans architecture specifically designed to handle high volume transaction technology. This is not garden variety stuff, and not something that most small or medium sized businesses need to worry about. This is more like "I run a bank and I have 100,000 online customers accessing their account data and doing transactions at the same time" type stuff. Not everybody needs Java or Enterprise Java Beans, but some people do. For the time being at least, Python has no equivalent technology. - As for features, I'd say this would be Java; it gets more development in this department, and I imagine it can run on SMP machines without any global interpreter lock. That said, the Python environment is more dynamic which may help you in scaling (distributed objects and so on), the Python environment is more compact, Python may be even more portable than Java, so you can scale up to bigger machines. - Solely depends upon your architecture, not your language IMHO. - Python has a global interpreter lock, so multithreading doesn't speed it up as much. So, if you're going to buy an Enterprise Server 1000000000 or whatever, with altogether too many processors to run your code, the answer is *probably* java. (There are ways around this in python, but not all of them are immediately obvious.) The minimum investment to get good performance out of Java is higher than that to get good performance out of python though. However, Java has some issues with memory usage. I have a machine with more than enough RAM to do this: glyph at helix:~% python Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> x=range(5000000) >>> glyph at helix:~% cd app/IBMJPython-1.1 glyph at helix:~/app/IBMJPython-1.1% ./jpython JPython 1.1 on java1.3.0 (JIT: jitc) Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> x=range(5000000) Out of Memory You might want to try the -mx flag to increase heap size So it depends how you want to scale. In JPython, which is translating the Python to Java bytecodes and running it as it it were java, this allocation is too large. Not because java has more overhead and I don't have enough RAM for it, but because Java gives up halfway through when it realizes there's not enough space in its "allowed" memory block for that list. Notice that I'm using "IBMJpython" here, which is JPython installed on the newest, funkiest JVM available for Linux, the IBM JDK 1.3 port. It is *possible* to increase maximum memory usage by passing commandline options, but (A) who wants to figure out how much memory a long-running application is going to take ahead of time and have to restart it if it overgrows that and (B) performance begins to suffer as you do that. Also; you can easily bind your Python code to other systems, profile out the performance bottlenecks, easily, by extending or embedding Python in C or C++. And finally; this point is often overlooked, but it is VERY important; critical, almost -- bindings for Python to native functionality on your platform *probably already exist*. Java shoehorns you into ONE API, ONE loosely-defined standard implemented shoddily by Sun, ONE way to write GUI's, no ability to do multiplexing (all I/O is blocking and in threads) ... all in all, the poor performance and poor scalability of Java's standard library damn the language more thoroughly than any other feature of it. After all, java "scales" because it has true multithreading that will take advantage of multiple processors, but there are optimizing algorythms for servers that are *impossible* in java because of library decisions (no multiplexing, as I said), whereas Python will give them to you. Topic 5: Which is faster eg. Java servlets or Python CGI with mod_python? Answer(s): - Don't know about that - but there is some strong evidence that Zope (python based application server) is faster than servelets: http://www.zope.org/Members/BwanaZulia/zope_benchmarks/tomcat1.html I think any major web project should consider Zope. It has transformaed the way I think of web development. FWIW, I work at a moderate sized telco and we do all of our web sites in Zope. More on Zope at: http://www.zope.org - In theory Java code should be faster; it does a lot more optimizing. In practice however.. Zope seems to outspeed some Java servlet servers: http://www.zope.org/Members/BwanaZulia/zope_benchmarks/benchmarks.html More on Zope: http://www.zope.org Zope is based on Python. Definitely do look at Zope if you're into web programming. Doing the same task in Python may often be faster than Java, possibly due to Python's high-level constructs and the huge overhead of the average Java runtime environment. Here's some research on that and more: http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf Note that the *development speed* with Python is generally estimated to be quite a bit faster than the development speed with Java. This is also an important factor! - Can't tell you. However, we did some timings on Python, JPython and Java (I rewrote a few Python/JPython classes in Java - took < 1 hour) and found that Java was faster than both, with Python coming in next and JPython being pretty slow. - Since Python does all of its I/O buffering in C, and Java does all of its buffering in Java, Python is going to be faster, despite all of Java's "theoretically optimal" interpreter optimizations. If your code is *really really* CPU bound, java might do better, but given Java's wonky cpu-hog GC behavior, it's likely that you'll lose there too. (If you're seriously that CPU bound, nothing beats C, so a C application with python "steering" would beat java anyway.) Servlets also use the standard-output facility in java: as shown on my Java-versus-Python page -- http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html this is NOT very fast at all. I have no idea why the performance difference is so significant. Final Notes: - Well if it's performance you want, ASP and embedded COM is probably what you want. - Performance at the price of portability, definitely. ASP + native COM interfaces in C/C++ and Com+'s transactions. The "MTS" feature of COM+ would give you speed and scalability and absolutely NO portability! You'd also be working in an environment with a lot of inertia to overcome whenever changes are required in the system. Python is great from Prototype to working systems precisely because it adapts quickly. I'd accept lower performance, use SOAP instead of COM+/MTS From what I've read and seen, Microsoft's MTS "object runtime environment" is extremely fast. Writing COM components in Visual C++ can be a pain in the butt, but if all you really need is performance, and you don't need flexibility, it's definitely going to scale up nicely. Now if you factor the Real and Messy world in, where requirements are constantly changing, you can color me Python again. I would rather maintain and develop a system in python where I can adapt quickly to changing requirements than work on a system where draining every last drop of performance from the bare iron was a driving force in the design of the system. In the end, it's not always about performance. - The main advantage of Python would be its readability and high development speed. Another big advantage of Python is the existence of Zope. Yet another advantage is Python and Zope's open sourceness. The main advantage of Java would be its massive industry support. - Have you seen ? Which is faster? Both are. Run-time performance of the common implementations (and Web embeddings) of Java and Python are suffici- ently close that the comparison depends strongly on the details of the application under consideration. Vulgar recognition of this often appears as, "benchmarks are garbage." In fact, benchmarks are very valuable. It's quite likely in your case that run-time perfor- mance is *not* a significant differentiator. Others have already written you about scalability and maintainability. Python's more portable than Java. You didn't ask, but you should know that. Java's improving, and someday will probably dominate here. A few years ago, we thought surely it'd happen by now. It hasn't, yet. As others have hinted, it's not necessary to put the two in opposition. It can be quite rational to use both Python and Java, sometimes together, with JPython (or even more esoteric bindings). Yes, I understand MISthink that claims to want to standardize on One True Language. If that's truly a constraint on you, we can discuss strategies for dealing with it. - I am a "java expert". I've been working with the language since its inception. It started out as a genuinely good thing: but it has fallen into complete decay. If you don't decide to go with python for this project of yours, I would highly recommend finding something other than Java for this. History is *already* littered with the corpses of projects which thought that Java would solve their problems. (Corel Office for Java, Marimba, hundreds of unreleased, unpublicized projects...) I am a "python newbie". I have been working with python for 3-6 months (I don't remember exactly how long). Even in this short time, I have come to love python, not because it's the end-all be-all of programming languages, but because it actually picks some things that it wants to be good at, and does those things very well. The language's strengths are well-matched to the interpreter's, and the environment is overall a positive experience. Not only that, I look around every day and see successful projects, both open (Zope) and closed (UltraSeek) that are using python with success. Java attempts to be everything to everyone, and, as such things are fated, becomes nothing to anyone. Java CLAIMS to do everything well, but actually does everything so poorly that Sun has to promise that it will be "better in the next release", and they've been doing this for long enough that it amazes me that people believe them anymore. - I do not intend to discredit java here; it is certainly worthwhile for some things, but it is *really* not everything Sun claims it is. Hopefully if people realize this, Sun will actually make strides towards delivering on all of these wonderful promises that they've made, or relinquish control to someone who will. The thing that Java is most useful for at the moment is interfacing with other applications written in Java; it's very easy to link any arbitrary java code to any other arbitrary java code, even without a "development kit". This is nothing on python's introspection, but it's certainly leaps and bounds beyond C (I won't even talk about C++. Fragile base classes? Yuck.), and a lot of things are available to work with. If you can afford to take a slight speed hit for maintainability, readability, and flexibility, but you still need interoperability with Java, JPython is a *wonderful* thing. Check it out at www.jpython.org. ------------------------------------------------------------- Should __getattr__ increment the reference count before it returns the appropriate attribute, or not? writing a Python module in C++ http://www.faqts.com/knowledge-base/view.phtml/aid/2907 ------------------------------------------------------------- Fiona Czuczman Gordon McMillan It should incref the attribute and leave the owner alone. Imagine a sequence like this: newref = a.b # here's your __getattr__ a = None Now a's refcount drops. If it drops to 0, it gets deallocated, which will decref b. Without an incref in __getattr__, the user would have an invalid reference. ------------------------------------------------------------- Are colons unnecessary in my Python code? http://www.faqts.com/knowledge-base/view.phtml/aid/2910 ------------------------------------------------------------- Fiona Czuczman Courageous, David Porter, Fran?ois Pinard, Moshe Zadka, Dirck Blaskey Lead in discussion: Sometimes colons seem syntactically unnecessary. For example: if : statement else: statement Really, else doesn't need a colon, as far as I can tell (I can see the need for the if, supposing you want to have the statement on the same line). Answer(s): - When using python-mode in Emacs (or jed), the colon facilitates auto-indention. Also, if you forget the colon, the next line will not be indented, so you will catch your mistake. - Granted, but it is always good for a language to have a bit of redundant information. When properly thought, such redundancy prevents various mistakes from programmers (once they are used to it, of course :-), and often increase overall legibility. - Theoretically, a colon is only necessary in things like if yes: print "yes" Since otherwise the parser can figure out when to stick a colon. However, usability studies show people are more comfortable when the beginning of a block is signaled, and I can see why: if yes print "yes" Seems....naked. Much less readable then if yes: print "yes" Guido didn't want 10 ways (or even 2) to spell things, so the colon is mandated for all. - > if yes: print "yes" Oddly enough, the parser doesn't really need the colon here either. It can manage to figure out where the if expression ends without it. The colon is almost entirely for readability purposes. (there are a couple of places where ambiguity occurs without it). If you're curious about the other thread, or about Python without colons, or to test my above assertion, check out: http://www.danbala.com/python/colopt ------------------------------------------------------------- Does anyone have any hints in configuring Python for BeOS? http://www.faqts.com/knowledge-base/view.phtml/aid/2911 ------------------------------------------------------------- Fiona Czuczman Donn Cave The Problem: I've managed to compile it but under make test it just hangs on test_p_open2.py. Once I remove that file from the testing sequence seems to go into an infinite loop after test_threading. Also the struct module test failed as well. A possible path to the solution: Well, I have three hints: 1. Change the optimization from '-O3 -mpentiumpro' to just plain '-O'. I'd start with a clean unpack of the distribution and make this change to "configure", and then run configure with the usual flags. (--with-thread --prefix=/boot/home/config) That's the most important. The problem with struct is some incorrect code from gcc -O3. (I assume you're on Intel hardware.) I don't know exactly what it does, but it works fine if I insert a printf. Who knows what else could suffer, maybe the test_threading problem is also compiler error. The worst thing was when some experiments with popen2 dropped the whole system into the kernel debugger. 2. Don't bother with test_popen2. I don't know what's wrong with it, but it's going to hang. 3. Don't bother with test_select. Likewise don't know what the actual problem is, but BeOS select has bugs, defects, weaknesses etc. One thing you might fix in selectmodule.c, if you need select(), is to use FD_SETSIZE for the 1st parameter to the C function, instead of the calculated maximum size. With those three changes, I made it through the test suite with only the usual failures. From slhath at flash.net Thu May 4 08:23:49 2000 From: slhath at flash.net (Scott Hathaway) Date: Thu, 04 May 2000 12:23:49 GMT Subject: python's acceptance Message-ID: This post is meant to generate thoughtful discussion, not burn me to a crisp, so here it goes. I am a Windows programmer who uses mostly VB (I know how bad it is...I use it all the time). I love the language syntax of python! It is clean, easy, and extremely powerful. Yet, I have two items that I believe keep Python from growing with Windows users: 1. In making this transition, I have had trouble because I am not used to trying to layout gui's with pure code. If python could get a gui builder (like vb or delphi) that was mainstream and used native controls on each platform, it could easily give VB or Delphi a run for their money. I have recently looked at Boa Constructor that lays out wxPython code and lets you build a gui! This is awesome. I have not used the PythonWorks program, but I will try it once it is out. 2. It is nearly impossible for a newbie like me to build an .exe on the Windows platform with Python. I have tried three different methods with a simple wxPython program (freeze, standalone, and installer). I cannot get any of them to work. It appears that I need to tell them what files I need to distribute, but I do not know that info. Python needs an installer that can scan the code and automatically add the appropriate files for people who are idiots like me. Once these two things are done, I could easily scrap VB and use Python exclusively. Has anyone else experienced these frustrations? What can be done to solve them? (I also realize that perhaps they have been solved and I just don't know where to look). Please comment. Scott From dworkin at ccs.neu.edu Wed May 3 15:56:57 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 03 May 2000 15:56:57 -0400 Subject: How do you send mail through python In-Reply-To: Sindh's message of "Wed, 03 May 2000 19:17:54 GMT" References: <8epu0e$ltq$1@nnrp1.deja.com> Message-ID: Sindh writes: > I have been struggling to findout which module has the facilities for > sending email through python. http://www.python.org/doc/current/lib/module-smtplib.html -Justin From jkraska at bbn.com Wed May 3 20:43:44 2000 From: jkraska at bbn.com (Joe Kraska) Date: Wed, 03 May 2000 17:43:44 -0700 Subject: Using continuations to do your own scheduling... In-Reply-To: <3910B34D.EE9DDF29@tismer.com> References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F31A5.6452D256@tismer.com> <390F7CB5.8BD62851@san.rr.com> <200005032257.PAA11560@ESCHER.SD.BBN.COM> Message-ID: <200005040044.RAA12686@ESCHER.SD.BBN.COM> Christian, et al., Thought you might appreciate this. It's a fairly simple example of how to do your own scheduling with continuations in Python. In a more advanced M&S setting, the call to time.sleep(s.ticks) would instead be something which coordinated the passage of model time, not actual wall- clock time. Note the presumptions of call depth and the scheduler; this obviously has to be thought out carefully and could get you into major trouble if you're wrong. The trick is to make certain that no one but you is calling your procedures. Joe. ---- import continuation import time class Schedulable: c=0 ticks=0 def fail(): c=continuation.caller(2) c.jump(0) def succeed(): c=continuation.caller(2) c.jump(1) def passtime(ticks): c1=continuation.caller(1) c2=continuation.caller(2) s=Schedulable() s.c = c1 s.ticks = ticks c2.jump(s) def procedure1(): passtime(1) succeed() def procedure2(): passtime(1) fail() def procedure3(): passtime(1) def dispatch(f): s=f() t = type(s) if t.__name__ == "instance": #WRONG: what's the syntax f/ "Schedulable"? time.sleep(s.ticks) s.c.jump() elif s == 1: print " procedure succeeded explicitly" elif s == 0: print " procedure failed explicitly" else: print " WARNING UNINTERPRETABLE VALUE: IMPLICIT SUCCESS" def test(): dispatch(procedure1) dispatch(procedure2) dispatch(procedure3) test() From thomasm at legend.co.uk Sat May 20 06:55:56 2000 From: thomasm at legend.co.uk (Thomas Mangin) Date: Sat, 20 May 2000 11:55:56 +0100 Subject: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) References: Message-ID: <39266ef9.0@katana.legend.co.uk> > > > > Erm, how would you parse this? > > > > > > > > if yes () > > > > I would say that seni-colon have *only* to be use to separate condition from > > instruction, so this is : > > if yes (): > > _ > > But maybe it means: > if yes: () > > Which is perfectly valid Python: > > >>> yes = 1 > >>> if yes: () > ... > () Not if the grammar specify VALID : if VALID : if : INVALID : if in this case you can not have: if yes () condition : yes instruction : () which is invalid I really do think this is the best way to do (at least the one I would like to see) Thomas From dag at orion.no Fri May 19 07:55:43 2000 From: dag at orion.no (Dag Sunde) Date: Fri, 19 May 2000 11:55:43 GMT Subject: ValueError: unpack tuple of wrong size??? References: Message-ID: <3Z9V4.10635$gy4.1445130@juliett.dax.net> I found the solution... Thanks to you both; Oleg & Fredrik...) When the idl defines it like: boolean LoginToMarket ( out long lLoginId, out Object supplier) raises (NoAccess); ...where both parameters are out-values, and the method has a return-value, it should be called without any parameters, and returns a list with the return-value at position 0, and the parameters following in the defined order... [Dbg]>>> print self.m_pElTermin.LoginToMarket() (1, 6, ) [Dbg]>>> Dag... "Oleg Broytmann" wrote in message news:Pine.LNX.4.21.0005191017170.493-100000 at fep132.fep.ru... > On Fri, 19 May 2000, Dag Sunde wrote: > > Question: > > When a method has a boolean return, and two output-params, how do I > > call it? > > I think you must pass two Buffer objects, that will get filled upon > return; the return value should be one boolean... > > Oleg. (All opinions are mine and not of my employer) > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > From claird at starbase.neosoft.com Mon May 8 09:16:58 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 8 May 2000 08:16:58 -0500 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: <0867817EB1B3A76A.FBD93754A864D6FC.8AC91DCAEC51970E@lp.airnews.net> In article , Michael Hudson wrote: >Glyph Lefkowitz writes: . . . >> > - age. the other "P" language[0] has been around a little longer.. right? >> >> I hear this tossed around a lot. How *much* longer? > >I think perl was born in 1987 and Python in 1991. Not sure about >either of those though. . . . Larry was working on Perl in 1986. It acquired the name and appeared as a 1.0 in the last month of 1987. Guido chose his project and its name in December 1989. Executables existed during 1990. The first public release was in 1991. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From scarblac-spamtrap at pino.selwerd.nl Sun May 21 16:10:44 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 21 May 2000 20:10:44 GMT Subject: OT: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> Message-ID: Grant Griffin wrote in comp.lang.python: > I've been teasing you guys a little on this, but in all seriousness, as > I think about it more, it seems like the essential disconnect here is > between the "command line" paradigm and the GUI paradigm. The "compound > functionality" approach of UNIX makes good sense in a command-line > paradigm (because it allows a lot of flexibility at the cost of a lot of > typing, or writing scripts: more typing), but in a GUI paradigm, it's a > lot more practical simply to build all functionality the user requires > into a single program. Of course, in the Unix philosophy, the GUI is a third utility that does its thing, namely calling tar and gzip with the options that the user has checked, or something. I have a utility for ripping audio off CDs, a utility for burning CDs, and a utility that provides a GUI frontend to them. It's nice! The GUI mail clients I have are just a frontend to a sendmail command. And other mail servers like QMail provide there own command named 'sendmail' with the same option set... Little tools that can be combined is from a mixed-tool philosophy. I want the GNU command line tools, this freeware mail client, that big mail server, a commercial database, and glue them all together with some Python util... et cetera. Windows programs are mostly designed to glue their users to the app, it seems. For commercial software, it's important that users can do everything they need inside your program - and can't easily make the switch to other programs that maybe do a little part of it better. Of course, I'm teasing you a little too. The truth is probably somewhere in the middle of these viewpoints, right? -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From billtut at microsoft.com Tue May 9 16:09:36 2000 From: billtut at microsoft.com (Bill Tutt) Date: Tue, 9 May 2000 13:09:36 -0700 Subject: Python on 64 bit/IA-64 ... Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD077@RED-MSG-50> > From: 'Trent Mick' [mailto:trentm at activestate.com] > > On Tue, May 09, 2000 at 01:00:13PM -0700, Bill Tutt wrote: > > > > > > > From: Trent Mick [mailto:trentm at activestate.com] > > > > > > > > > > > > I am not a big numerical analysis guy so I don't know about > > > changing PyFloat > > > to be a long double. That is Guido's decision, although I > > > wouldn't bet on > > > that changing. > > > > > > > > > > MSVC++ doesn't even support 80-bit "long double"s. > > > > Bill > > > Well that answers that then doesn't it. :) > Yeah, royally sucks. All code that currently uses doubles really should be using long doubles instead, it'd make their numerical calculations more accurate. Bill From johngrayson at home.com Wed May 31 18:54:05 2000 From: johngrayson at home.com (John Grayson) Date: Wed, 31 May 2000 22:54:05 GMT Subject: Newbie Tkinter Question References: Message-ID: <3935980E.D609911@home.com> Sure you can, just use a lambda expression. Here is an example which shows an 'activate' callback (button command) and a MB1 binding. Note that the binding has to allow for the event object: from Tkinter import * def prtIt(text): print text root = Tk() Button(root, text='B1', command=lambda arg='Button 1': prtIt(arg)).pack(side=LEFT) b2 = Button(root, text='B2') b2.pack(side=LEFT) b2.bind('', lambda e,arg='Button 2': prtIt(arg)) root.mainloop() John Grayson Dean wrote: > > Is it possible to pass arguments to a callback in Python/Tkinter? I know > this can be done in Perl, but after reviewing the documentation, it's not > clear to me that you can pass any arguments ( except the event object ) to a > callback function bound to an event. Any help would be greatly appreciated! > > Dean From charlie at intelligenesis.net Thu May 11 11:27:11 2000 From: charlie at intelligenesis.net (Charlie Derr) Date: Thu, 11 May 2000 11:27:11 -0400 Subject: Why should I switch to Python? In-Reply-To: <000401bfbaf5$877f8b60$2aa0143f@tim> Message-ID: [Tim Peters] ~ ~ [Grant Griffin] ~ > Speaking of C, I find myself missing the "x=" operators, and "++". ~ > However, I understand and endorse the reasons Python omits them. ~ ~ While ++ makes little sense in a language with immutable numbers, I'm probably missing something obvious here, but why? The only weird part that i see is that in order to implement it you would have to do a type check and make sure the operand is of type integer, which certainly seems to violate python's spirit, but I don't understand what's relevant about numbers being immutable. I never write "5++" it's always "varName++", which can obviously be done the long way with "varName = varName + 1". Couldn't this be implemented with assignment in this fashion? (not that i would want it to be done, i'm just curious) tia, ~c ~ ~ ~ -- ~ http://www.python.org/mailman/listinfo/python-list ~ From rgb122 at my-deja.com Tue May 9 11:46:17 2000 From: rgb122 at my-deja.com (rgb122 at my-deja.com) Date: Tue, 09 May 2000 15:46:17 GMT Subject: Load Arbitrary Script as Module? Message-ID: <8f9bs3$b9u$1@nnrp1.deja.com> Is there a way to load a module given a full filepath? Something like: driver = LoadModule("C:\\Stuff\\sample.py") driver.someFunction() Thanks, Rob Sent via Deja.com http://www.deja.com/ Before you buy. From tismer at tismer.com Sun May 28 09:15:53 2000 From: tismer at tismer.com (Christian Tismer) Date: Sun, 28 May 2000 15:15:53 +0200 Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> Message-ID: <39311C09.75F70C54@tismer.com> Amit Patel wrote: > > I have to warn you. This is a bit wacky, and I have no illusion that > any of this will go into Python. It's just some stuff that Python has > inspired me to think about, mainly because Python exposes namespaces > to the programmer, and programmers do cool things with it. How far > can that go? (You're supposed to run away yelling when you hear > someone say "How far can something go?") This idea touches on > stackless (because stack frames become objects, which are on the heap) Yes I'm watching you :-) > and nested scopes, too, if that'll help you run screaming. But if > you're ready to read some crazy stuff, here it is: > * The "global" keyword: ... > x = 5 > def foo(): > def cheese(): > global.x = 5 Looks good. Global means global, not just one world up. > * Cycles and refcounting > > If we do nested scopes, we already get the cycles problem. I don't > think making namespaces into objects makes anything worse. I'm not sure whether this necessarily needs to create cycles. If we don't do statically nested scopes, but just dynamically nested scopes, the outer variables are always looked up via the chain of running frames when this is needed, so there will be no cycle, the same way as "self" doesn't create cycles in the first place. ... > * The "with" statement from Pascal: > > I suspect you can do "with" pretty easily but I'm not sure about the > details. It may require multiple inheritance (aiee) if you want to > be able to see local variables at the same time you see an object's > fields. "with" could be a construct similar to the current try..except clauses, building a stack-like override to the __parent__ lookup. This would create circular references in the context of the with, which is just fine since we end the with at some time. > * Assignment to __parent__: > > So far I've been assuming that __parent__ is something set by Python > for internal use. For objects, it's set when you call a class > constructor. For classes, it's set when you declare the class using > the "class" construct. For namespaces, it's set when you call a > function. > > But really, the cool stuff is really when the user can assign to > __parent__! Please drop that. The __parent__ should always be true. A function instance's parent namespace is always its caller. BTW, in Stackless, the caller can of course be assigned, but then it is consistent that __parent__ always walks that way. ... > x = 5 > def foo(): > print x > x = 3 > print x > > IMO, this should print 5 and then 3. The unified namespace > proposal would do this. However, Python currently gives a > NameError. I think the current NameError is good as it is. In most cases it shows an error in the implementation. Changing the scope of a variable automatically would prevend optimization of locals, and it would give more surprizes and errors than benefits IMHO. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From thomas at xs4all.net Mon May 1 02:37:32 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 1 May 2000 08:37:32 +0200 Subject: Circular Dependancies In-Reply-To: <8F26D44DDjoshtinamecom@209.208.0.7>; from josht@iname.com on Mon, May 01, 2000 at 02:00:09AM +0000 References: <8F26D44DDjoshtinamecom@209.208.0.7> Message-ID: <20000501083732.N11481@xs4all.nl> On Mon, May 01, 2000 at 02:00:09AM +0000, Josh Tompkins wrote: > I've read in a couple of places that circular dependancies are not a good > thing to have in a program. I'm actually kind of curious: why is this? > Is it a style thing, or something that can actually confuse the > interpreter/compiler? Actually, there are two (or more ?) kinds of circular dependancies: variables containing each other, and modules that include eachother. An example of the first is: >>> a = [] >>> b = [] >>> a.append(b) >>> b.append(a) If you then do >>> del a,b you can never reach a or b again, but they aren't removed from memory either, because both are still referenced to (by the other.) In other words, it's a memory leak. This kind of thing is easy to step into if you are fiddling with traceback()s in try/except clauses -- you quickly end up with a traceback containing a variable, like a namespace, that contains a reference to the traceback itself. The other thing is fortunately more immediately visible, and happens when you have to modules include eachother, like so: # file spam.py import eggs wants = None class Ham(eggs.Eggs): pass # file eggs.py import spam class Eggs: pass if spam.wants: [...] The Python parser reads each file line by line, and actually executes the files like that. It starts to load spam.py (provided that's the script you call, or module you load first,) reaches 'import eggs', starts to read 'eggs', reads 'import spam', notices it's already reading in the file 'spam.py' -- not in its entirity, but there's nothing it can do about that -- so continues, and at the line 'spam.wants' it tries to retrieve the value of the 'wants' entry in the spam namespace. But since the 'wants' entry hasn't been created yet, this fails with an attribute error: >>> import spam Traceback (most recent call last): File "", line 1, in ? File "spam.py", line 2, in ? import eggs File "eggs.py", line 5, in ? if spam.wants: AttributeError: wants The best solution is 'dont do that then'. Another workable solution is to put import statements at the last possible moment -- inside functions, classes, or right after you define all classes and functions but before you start with actual code that is executed during (the first) import. The problem with this is that it tends to get hairy over time, when you forget why that order is so specific. And we thought python was easy to maintain ! :-) Improve-the-list-quality--quote-the-FAQ-today-ly y'rs, ;-) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at netcom.com Mon May 22 11:36:16 2000 From: aahz at netcom.com (Aahz Maruch) Date: 22 May 2000 15:36:16 GMT Subject: Thread dummy References: <391BB583.B1B14C47@yahoo.com> Message-ID: <8gbk5g$9a6$1@nntp9.atl.mindspring.net> In article , Glyph Lefkowitz wrote: > >Multithreading could be easy to explain with Python, but I don't know >of any good tutorials for it. Anyone? Assuming I get off my ass and finish my slideshow for OSCON, my presentation there should be a decent start. Unfortunately, DejaNews is moving its servers and doesn't seem to have my old posts, and Remarq is unusable. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Not everything in life has a clue in front of it...." --JMS From kelley at bioreason.com Fri May 5 14:40:31 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 05 May 2000 19:40:31 +0100 Subject: test harnesses for python References: <391185E7.6CD5BC93@connix.com> <3911E765.38A36872@uab.edu> Message-ID: <3913159F.8F5EAC8E@bioreason.com> We have been using (Guido's?) regrtest.py bundled with python's library. It is in the test module. It has been working fabulously well so far. Shae Erisson wrote: > I use PyUnit from http://pyunit.sourceforge.net/ > > PyUnit is the Python version of SUnit (smalltalk), JUnit(java), etc. all > available from: http://www.xprogramming.com/software.htm > -- > sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre > bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt > 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From blues-l at cyberus.ca Mon May 15 15:25:03 2000 From: blues-l at cyberus.ca (blues-l at cyberus.ca) Date: Mon, 15 May 2000 15:25:03 -0400 Subject: Newbie question- Tkinter Message-ID: <39204F0D.3B87D553@cyberus.ca> I'm having a real problem getting Tkinter to go on Win95. Here is my "PATH": C:\WINDOWS>path PATH=Y:.;C:\MAGICSQL\SQLANY50\WIN;C:\PROGRA~1\MICROS~1\OFFICE;C:\NOVELL\CLIENT32 ;D:\PYTHON;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BIN;C:\ETC;D:\PERL5\BIN;D:\TCL\BIN;D :\TCL\LIB\TCL8.0;D:\TCL\LIB\TK8.0;D:\PGP;Z:. Here is the contents of the Tcl\lib\tcl8.0 directory: D:\Tcl\lib\tcl8.0>dir Volume in drive D has no label Volume Serial Number is 3F2D-11F8 Directory of D:\Tcl\lib\tcl8.0 .

    05-11-00 11:54a . .. 05-11-00 11:54a .. OPT0 1 05-11-00 11:54a opt0.1 HTTP2 0 05-11-00 11:54a http2.0 SAFE TCL 26,754 11-10-98 6:39p safe.tcl HISTORY TCL 8,989 09-14-98 11:40a history.tcl HTTP1 0 05-11-00 11:54a http1.0 REG1 0 05-11-00 11:54a reg1.0 TCLINDEX 1,485 07-24-98 8:06a tclIndex INIT TCL 47,407 02-10-99 7:06p init.tcl PARRAY TCL 882 09-14-98 11:40a parray.tcl WORD TCL 4,470 09-14-98 11:40a word.tcl 6 file(s) 89,987 bytes 6 dir(s) 511,803,392 bytes free This is what I end upwith when I test Tkinter after it loads in python: >>> Tkinter._test() "Traceback (innermost last): File "", line 1, in ? File "D:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test root = Tk() File "D:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {d:\Tcl\lib\tcl8.0} {} ./lib/tcl8.0 C:/tcl8.0a2/library C:/library This probably means that Tcl wasn't installed properly." What's going on???? I don't know where "{} ./lib/tcl8.0 C:/tcl8.0a2/library C:/library" is coming from. Its not in autoexec.bat - which does have : set PYTHONPATH=.;d:\python\lib;d:\python\lib\tkinter set TCL_LIBRARY=d:\Tcl\lib\tcl8.0 set TK_LIBRARY=d:\Tcl\lib\tk8.0 I have re-installed twice. From bwarsaw at python.org Mon May 8 14:14:57 2000 From: bwarsaw at python.org (bwarsaw at python.org) Date: Mon, 8 May 2000 14:14:57 -0400 (EDT) Subject: Python Emacs Mode and fontification References: <3918407E.C95C72B5@exceptionalminds.com> Message-ID: <14615.1057.871524.107860@anthem.cnri.reston.va.us> >>>>> "TG" == Timothy Grant writes: TG> I recently converted to Xemacs (though I have yet to be TG> confirmed or baptised) solely due to its excellent python TG> mode. However, I am now faced with a really weird TG> fontification problem. I have a source file that doesn't TG> appear any different from any of the other source files I have TG> created, however, everytime I add new code to the file, Xemacs TG> fontifies it as a """string""". If I save the file exit and TG> reload it, all the fontification is correct, but the minute I TG> make any changes it gets out of whack again. TG> Perchance would anyone have some guiding light for an Xemacs TG> neophyte? It's in the FAQ :) http://www.python.org/emacs/python-mode/faq.html Pay careful attention to the last paragraph... -Barry From greg at cosc.canterbury.ac.nz Tue May 30 21:33:03 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 31 May 2000 13:33:03 +1200 Subject: PyCFunction? What is it? References: <39332C24.3B34D9A@cosc.canterbury.ac.nz> Message-ID: <39346BCF.386C07E4@cosc.canterbury.ac.nz> Fredrik Lundh wrote: > > ome programmers prefer to write: > > mymethod(MyOwnObject *self, PyObject *args) You're quite right. I didn't look at the declarations in cStringIO carefully enough -- it does exactly that. So the casts there are not redundant after all. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From dan at netrics.com Mon May 1 23:57:56 2000 From: dan at netrics.com (Dan Gindikin) Date: Tue, 02 May 2000 03:57:56 GMT Subject: [Announce] Cmdline, a module to help you parse the command line Message-ID: <8eljnu$r7j$1@nnrp1.deja.com> While this module has a very simple interface, it does a lot of things for you. Things like basic type checking, helpful error messages with the problems in the command line underlined, and flexibility about how values are passed to options. homepage: http://members.home.com/gindikin/dev/python/cmdline download: http://members.home.com/gindikin/dev/python/cmdline/cmdline.py Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Sun May 28 22:29:05 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 02:29:05 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <20000522183552.A29224@mudge> <3929D3F6.DE9CCCBC@prescod.net> Message-ID: <3931D690.2B5DE664@san.rr.com> > Most Kleenex-languages we studied were especially easy to write, in that > "much easier" category. Now that I'm grown up, I'm not much interested in > Kleenex-languages anymore, and would feel sorry if Python was becoming one. Oh my golly, the poor, poor Kleenex. It feels sooo used! :) Pardon me, but I think Python makes a perfectly wonderful Kleenex language. I do know what you mean, however. I think most professional programmers who use Python for any length of time want to see it maintain/acquire the properties which allow it to be a mainstream programming language. C/ From dale at out-think.NOSPAMco.uk Fri May 26 16:14:56 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 26 May 2000 21:14:56 +0100 Subject: A Python Beginner on Win32 References: <8gmhpa$jq3$1@nnrp1.deja.com> Message-ID: <8gmm0d$lb6$1@supernews.com> You also need a file called win32-all.exe which you can download from the same place and then run it. Also, you will probably find PythonWin a little nicer to use than IDLE - which is part of the same file. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants wrote in message news:8gmhpa$jq3$1 at nnrp1.deja.com... > Hi All, > > When I decide to know what Python is, I downloaded the installation for > Win32, py152.exe, and ran it. > It installed Python and Tcl/Tk. Okey. > Then I tried to run IDLE to see what they mean by saying "Python GUI" . > No way. It just doesn't want to find Tcl/Tk. > It says: > > Traceback (innermost last): File "idle.py", line 3, in ? PyShell.main() > File "I:\programs\Python\Tools\idle\PyShell.py", line 611, in main root = > Tk() File "I:\programs\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ > self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't > find a usable init.tcl in the following directories: {} ./lib/tcl8.0 > I:/programs/Python/tcl8.0/library I:/programs/Python/Tools/library This > probably means that Tcl wasn't installed properly. > > Whatever I did, copied tcl/tk to the places where python wanted to find the > - nothing!!! Is there a GUI at all? > > Yuri Leikind > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From db3l at fitlinxx.com Wed May 24 17:00:50 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 May 2000 17:00:50 -0400 Subject: expanding string variables References: Message-ID: "Michaell Taylor" writes: > dict_set_list = {"first second ... seven"} > set = string.splitfield(dict_set_list) > for group in set: > group = group1[index]*group2[index]...etc > > (I loop over 'index' elsewhere) That is, I would like for the term "group" > to be expanded to first, second, ...seven, Thus > allowing python to process: > > first = first1[index]*first2[index]...etc > second = second1[index]*second2[index]..etc > ... > seven = seven1[index]*seven2[index]...etc Taking your problem as stated, one high level approach to doing what you want would be to just build up the actual command you want executed as a string and then dynamically execute it with the 'exec' statement. So for example, your for loop could be written as: for group in set: exec "%s = %s1[index] * %s2[index]" % (group,group,group) and you would then have local entries for "first", "second", etc.. with your result values. For example, the first pass through the loop the execution string would become: "first = first1[index] * first2[index]" This is just one example of building the string - there are any number of ways to do so, so a better one might suit depending on the operation you are actually coding (e.g., you might build the array name strings once and reuse if you want to use them in multiple expressions) But, if possible, you might also want to revisit your data structure to see if you can't use a multi-dimensional approach of some sort rather than a naming convention. For example, you have 7 sets of 20 dictionaries. Why not just use a list of lists of dictionaries. Then you could just index into them however you wanted. I'm wondering if the other language you're coming from perhaps forced the flattening of data structures and thus provided some more convenient constructs for manipulating the name of the data itself rather than the structure. For example, rather than > first1 = {'firstelement': 45 ....., 'fifty': 89} > first2 = {...} > ... > first20 = {...} > second1 = {...} > ... > second20 = {...} why not structure it as: dataset = [ [ {'firstelement':45 ...}, # first1 {...}, # first2 ... ], [ {...}, # second1 ... ], ... ] You wouldn't have to initialize it explicitly like this - starting dataset off as an empty list ([]) and appending or setting elements as you construct the data is just as easy. And then your loop could become: for group in range(7): dataset[group][1][index] * dataset[group][2][index] and so on. dataset[0-7] would be equivalent to first-seven, and the second list index the equivalent of the "1"-"20" suffix you have on your names, and then it's a normal dictionary access. If you wish to maintain name access (e.g., "first" rather than [0]), just make it a dictionary of dictionaries instead of a list. Using a more complex data structure generally lends itself more easily to construction and computation, although as shown above, if you really want to use variable naming the way you have, Python's ability to dynamically execute arbitrary code fragments as strings can solve that as well. -- -- 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 g2 at seebelow.org Sat May 6 03:37:14 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 06 May 2000 08:37:14 +0100 Subject: HTMLParser tag contents Message-ID: <3913CBAA.64BB@seebelow.org> Hi Gang, I've been trying to figure out how to use HTMLParser. My immediate need is to extract the entire of a file. (I could do that with 're', but I'm trying to learn HTMLParser.) Sure, HTMLParser will returns a tag's _attributes_, but I can't figure out how to get to the tag's _contents_. Can it do that? thanks-in-advance-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From danielt3 at gte.net Thu May 25 23:23:17 2000 From: danielt3 at gte.net (Daniel T.) Date: Fri, 26 May 2000 03:23:17 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <20000522183552.A29224@mudge> <3929D3F6.DE9CCCBC@prescod.net> Message-ID: In article , Ian Parker wrote: >In article s.net>, Tres Seaver writes >>In article <3929D3F6.DE9CCCBC at prescod.net>, >>Paul Prescod wrote: >>>> However, I am having trouble imagining how removing case-sensitivity from >>>> the language could improve usablility for any programmer, regardless of >>>> his/her skill level. Most people seem to have no particular trouble with >>>> case-sensitivity in natural languages; >>> >>>If you review the variety of formatting conventions in this list, you'll >>>find that that is not the case. Guido himself documented how people >>>speak of the String and FTPLib modules and python programming language. >>> >>>> why should a computer language be any different? On the other hand, >>>> maybe I am just too ingrained in my old thought patterns. >>> >>>I prefer case sensitivity. But I think that most of the arguments people >>>make in favor of it are bunk. >>> >>>1. If you spend time with newbies -- especially Windows-trained newbiews >>>-- you will note the case sensitivity is a problem. >>> >>>2. Code written in a case insensitive language is roughly as robust and >>>readable as that in a case sensitive language. >> >>As one who has worked for a long time in a case-insensitive language >>(ObjectPascal), I cannot disagree more strongly. ObjectPascal code >>which is written by case-neglecting programmers is painful to read, >>and harder to maintain. It *also* tends to be sloppier, and therefore >>buggier, in other ways (fencposts, etc.) >> >>Case sensistivity provides exactly the same kind of benefit as indentation: >>it reduces the space in which individual "style" impacts the code, in order >>to increase sharability of code. >> >>Tres. > >Tres > >I've also worked for a very long time in case-insensitive languages. >I'd thought that I wasn't too bothered either way. However, you've just >persuaded me that case sensitivity probably is better. I don't know about the above. At my present workplace, we use C++, I have to deal with reams of variables who's only difference is the case. If we used a case insensitive language, this would not be a problem. I also personally find it much easer if I don't have to worry about whether the variables name is seatbelt, or seatBelt. :-) -- When a thing ceases to be a subject of controversy, it ceases to be a subject of interest. -- William Hazlitt From steffen.ries at sympatico.ca Thu May 25 08:44:10 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Thu, 25 May 2000 12:44:10 GMT Subject: object browser in emacs References: Message-ID: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) writes: > I just realized the folowing interesting thing: If you enable jde mode for > java, you can use the speedbar which lists objects in a convenient tree in a > separate window. Now if you edit python code it automatically lists python > objects (including all python modules in the directory). Really cool. > > Is the speedbar a part of jde-mode that happens to also work in python-mode, > or is it a language-neutral app? Can I ask python-mode to use it > automatically? Speedbar is independent of jde. It basically understands every language, which supports `imenu.el', which includes C, C++, emacs-lisp and of course python. If I'm not mistaken, since emacs-20.5 it is part of the standard distribution (before you had to install it yourself). hth, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From phd at phd.russ.ru Wed May 17 04:19:50 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 08:19:50 +0000 (GMT) Subject: RedHat 6.2, Zope, trouble In-Reply-To: <39220D55.3D7FA38@wl.vg> Message-ID: On Tue, 16 May 2000, Peter Halliday wrote: > I am a developer and have been getting nothing, but trouble with any > Python solution to web development. I am running Red Hat 6.2. I run Seems more and more people have major troubles wirh RH6.2. I cannot help much 'cause I stopped using RH after 4.2 and switched to Debian. (But I use many different systms, actually - Linux, Solaris, FreeBSD - and never had problems with Python and Zope.) > I kept getting an error that said I needed the 1.5.2 > version of python, but I have it. May be you have not only 1.5.2, but older version too. Look into z2.py - what is the path to that python? It is possible they use /usr/bin/python where your python is /usr/local/bin/python (or vice versa)... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From moshez at math.huji.ac.il Sat May 27 04:48:55 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 27 May 2000 11:48:55 +0300 (IDT) Subject: Java vs Python In-Reply-To: <8gjkga$fjo$1@nnrp1.deja.com> Message-ID: On Thu, 25 May 2000 faatdilac at my-deja.com wrote: > Oh yeah, and which language do you think the trio Larry, John and Guido > use to develop Perl, Tcl and Python. > BTW, Matz also uses C to develop Ruby. > > Amateur does not know to appreciate the very tool that creates the > universe of programming languages, it's C. The only reason those people used C was that "it was there, and it was portable". This made for a very wise decision socially (which is part of the reason Python/Perl/Tcl are popular), but C was certainly not the optimal language for that. Consider, for example, that a Java programmer does not have to learn Java/Python API -- she merely writes Java classes, and JPython can use those. Consider that the real pain with writing extensions for all three is to manage memory, something that would be spared if Scheme/Lisp/Java were selected as an implementation platform. C is a good language for what it does, but claiming that the fact Python is written in C makes C "holier" is not very accurate. Not to mention that this would suggest that JPython proves that Java is the perfect platform. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From brianfr at grace.speakeasy.org Tue May 30 18:31:34 2000 From: brianfr at grace.speakeasy.org (Brian Fritz) Date: Tue, 30 May 2000 22:31:34 GMT Subject: Pmw.initalise() probs Message-ID: I just downloaded and installed the pmw tarball on my NT box. Everything looked pretty straight forward so I'm a bit mystified by the error I'm getting. The "import" seems to be finding the library but I can't call the "initialise" function which seems to be a common call in all the examples I've looked at. > PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) > >>> import Pmw > >>> root = Pmw.initialise() > Traceback (innermost last): > File "", line 1, in ? > AttributeError: initialise The version of Pmw is 0.8.4. I had the same problem using the console shell and I have added the path to the directory I installed Pmw into to the PYTHONPATH registry entry. Maybe it was the long weekend... Am I missing something here? TIA! Brian From etoffi at softhome.net Fri May 26 16:31:26 2000 From: etoffi at softhome.net (etoffi) Date: Fri, 26 May 2000 16:31:26 -0400 Subject: p2c Message-ID: <392EDF1E.55BAFD47@softhome.net> i heard somebody mention p2c. python to c? pascal to c? peas turnips and carrots? -- etoffi From mhammond at skippinet.com.au Sat May 20 01:39:41 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 20 May 2000 05:39:41 GMT Subject: Wrapping C++ under windows References: <1000519113849.ZM178800@noah.scripps.edu> Message-ID: "Michel Sanner" wrote in message news:1000519113849.ZM178800 at noah.scripps.edu... > Hello, > The shared library I get dumps the core when it is used and I suspect that this > happens because the constructor of these shared objects is not called when the > shared object is loaded. Are you definately using the "/MD" compiler option (or "/MDd" for debug builds)? This is the most common cause of crashes. > So my first question is: has the windows Python1.5.2 binary I got from Mark > hammond's download site been compiled and linked using a C++ compiler ? I wouldnt have got a 1.5.2 binary from my site - all my releases depend on the Python 1.5.2 core from www.python.org The answer is "no" - but that shouldnt matter - I believe it should work find for a DLL. Im fairly sure I rely on this behaviour (but dont have time to check for sure). > I am also wondering what type of DLL project I should use in VS6.0 ? I usually > use and "empty DLL" for Python extension. Might this be the problem ? Nope - as long as the CRT flags (as above) are correct. > Do I have to explicitly write a explicite DllMain ? Nope - but you can if you want - although they arent that useful in a Python extension, as there is no way to predict the Python state - ie, you can have one, but if it tries to use Python things may go screwey (depending on how the DLL is loaded) Mark. From sbrunning at trisystems.co.uk Tue May 16 12:17:59 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 16 May 2000 17:17:59 +0100 Subject: Downloadable Tkinter documentation References: <34575A892FF6D1118F5800600846864D2A3F94@intrepid> <39216220.72977EEB@yale.edu> Message-ID: <34575A892FF6D1118F5800600846864D2A9FE0@intrepid> Paul Magwene wrote in message <39216220.72977EEB at yale.edu>... >Check out websucker.py in the /Tools/webchecker directory of your python >distribution. This is great for downloading sights en-masse. Just do >something like: > >python websucker.py http://www.pythonware.com/library.htm > >And it goes to work.. Cool! Thanks for that. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From phd at phd.russ.ru Thu May 18 11:04:18 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 18 May 2000 15:04:18 +0000 (GMT) Subject: urllib/ftpwrapper Message-ID: Hello! In the urllib.py (Python 1.5.2) there is a class ftpwrapper. In the line 610 of the module it has the call self.ftp.voidresp() (method endtransfer). This call hangs an almost all FTP URLs. You noted it too - reread your comment in webchecker.py, method safeclose :) To overcome the problem I wrote my version of ftpwrapper (in my URL robot) without the call to voidresp. Last night the robot checked a database of 3000 URLs, and never failed on FTP URLs. Do you understand and can explain why the call is there? Could we just remove it from urllib? Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From ulf.engstrom at b2b-link.com Fri May 5 08:38:37 2000 From: ulf.engstrom at b2b-link.com (=?iso-8859-1?Q?Ulf_Engstr=F8m?=) Date: Fri, 5 May 2000 14:38:37 +0200 Subject: Docstrings in COM Message-ID: <004001bfb68e$d78a0060$858647c1@DEVELOPMENT> Is there a way to display the docstrings when using the Python-program as a COM-object. Ie. I have a program in Python which has a lot of small functions, taking a lot of arguments. Since you can't use key-word arguments with Python COM-objects you need to know in which order to enter the arguments. Thus I need to have the docstrings or some other mean of getting a short documentation to show up in the COMinterface. Anyone has any ideas? Regards Ulf From andre at beta.telenordia.se Tue May 30 11:54:21 2000 From: andre at beta.telenordia.se (André Dahlqvist) Date: Tue, 30 May 2000 16:54:21 +0100 Subject: Marking hyperlinks in a Text widget References: <8h04jo$lgh$1@zingo.tninet.se> Message-ID: <8h0kn5$6pv$1@cubacola.tninet.se> > Hello, Andr?. Not so long ago, I posted the following bits to this > list. I revised them since, because of a tiny bug. Extracted from: > > http://www.iro.umontreal.ca/contrib/recode/lib/htmlpage.py > > I use that code to enhance some TEXT before inserting it into a Web > page. Thanks for the suggestion, but this is not really what I am looking for. I just need to find strings in a Text widget that starts with http:// or ftp:// and change the color of them to blue and underlined. I tried checking the IDLE source since the IDLE editor does color markup, but it was too complex to figure out how to translate this into my little problem. Does anyone have any other suggestions? // Andr? From cut_me_out at hotmail.com Mon May 29 00:34:45 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 May 2000 00:34:45 -0400 Subject: Compact syntax for 0-matrix? References: Message-ID: How about this: from copy import copy def zeromatrix (n, m): line = n * [0] matrix = map (copy, m * [line]) return matrix I agree with the guy who said you should check out Numeric Python, though. It will probably work out to be more flexible for you, in the long run. Alex. From wjarek_nospam at hotmail_rem_ove_.com Mon May 15 17:38:35 2000 From: wjarek_nospam at hotmail_rem_ove_.com (Jarek Wilkiewicz) Date: Mon, 15 May 2000 21:38:35 GMT Subject: Python vs Java : GUI, drag an drop Message-ID: Hello, I'm planning to write a UI application which will require support for drag and drop (D&D). The user of my GUI will need to be able to pick a tool from a palette and drop it into a workspace, move things around (a bit like in Visio), resize, etc. At present I'm considering using Java, the 2D API and Java D&D API. Can I accomplish something similar using Python ? What graphic libraries would I use ? Does it make more sense than coding the GUI in Java? Thanks, Jarek From markx.daley at intel.com Thu May 4 11:11:08 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Thu, 4 May 2000 08:11:08 -0700 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) Message-ID: <75F7304BB41CD411B06600A0C98414FC0A40FD@ORSMSX54> Hmmm, sounds like reverse Polish notation to me. - Mark -----Original Message----- From: jschmitt at vmlabs.com [mailto:jschmitt at vmlabs.com] Sent: Thursday, May 04, 2000 1:42 AM To: python-list at python.org Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) Be forwarned, I have a particularly strong hate-on for hungarian notation. I think it is no coincidence that the worst software in the world and the worst programming conventions come out of the same establishment. I have a bunch of philosophical reasons for disliking hungarian notation, but I think the most basic is that it is the antithesis of structured programming practices. Two of these practices would be data hiding and data abstraction. Hungarian notation is directly at odds with these ideals. How can you have any level of abstraction if the user of the abstraction has to be concerned with the minutia of the implementation? And, the very idea of hungarian notation is the exact opposite of data hiding. > > release. Is it painful? You bet. Just ask Billy -- the translation from > > old symbol names to new names broke the compile for weeks. But once it was > > all over, I had fixed no less than 14 bugs that would *never* become > > apparent until after I'd released the code to the public. Most of the bugs > > were bound to be of the "intermittent" type too, so I was particularly > > pleased at the end result. If your problems are solved by this kind of mindless busy work, you have much bigger problems that any amount of hungarian notation will ever fix. I good primer on writing maintainable code is recommended. Try _Programming_with_Dick_and_Jane_. > > Again, it takes skill to use a tool well. What does it take to recognize such a mind-numbing productivity inhibitor? Hungarian notation is a stupid way to mask stupid programming habits. There's no need for it in any language, and in a dynamically typed language like Python, it's even more sinful than in a statically typed language such as C. Just so there's no question about attributions, I'm enclosing the whole message that I'm replying to. In article <8el305$h77$1 at ites.inria.fr>, Cedric Adjih wrote: > Samuel A. Falvo II wrote: > > In article <8ehrb9$mm5$1 at ites.inria.fr>, Cedric Adjih wrote: > >> If you can read, you should be able to read the definition of > >>any variable, and there are serious drawbacks. A flame of this > >>notation is for instance in "Developing Windows NT Device Drivers": > >>"The so-called `Hungarian Notation' (developped by a Hungarian > >>programmer at Microsoft) is one of the worst ideas to have hit > >>software development in many years" > > > "All good ideas are judged from the enemies they make." -- I forgot who. > > >> The main problem, is that when you change the type of a structure > >>you _cannot_ change the name (because other people are using it), > >>so the type specification becomes plain wrong. The 'wParam' > >>is reported to be such an example (now unsigned 32 bits), there > >>are other examples in Microsoft API (should be worse with Win64). > > > Hungarian notation is fine for the definition of an API, as long as its used > > to describe abstract concepts, like arrays, pointers to things, a count of > > whatever, etc. Hardcoding the bit-widths of types is obviously going to get > > you into trouble in the future. Just because Microsoft fscked up the > > execution doesn't mean the idea is somehow "bad." > > > Like I said earlier, I use it only when it makes *sense* to. Like anything > > else you have in your toolshed, Hungarian notation is a tool. Those who are > > skilled in its use will not have the problems you cite above. :) Those who > > aren't only use it because it's a fad. > > It's ok. It's just that most of the time I've read some code using it, > it was following Microsoft broken conventions. I personally don't > like marking pointers/arrays (he! that would be like Perl), but I > using it in a clever way, is of course quite good. > > >> Also each time you change the type of one variable/parameter, > >>you have change all the variable names of all the code under > >>your control. > > > In my work with Dolphin, I've found, on several occasions, where I needed to > > change symbol names pervasively throughout the source. I have found #MORE > > BUGS# just waiting to crop up and bite me in the butt this way than through > > any other technique. The very thing you cite as a "problem" is the very > > thing that will help reduce the number of bugs in Dolphin upon its final > > release. Is it painful? You bet. Just ask Billy -- the translation from > > old symbol names to new names broke the compile for weeks. But once it was > > all over, I had fixed no less than 14 bugs that would *never* become > > apparent until after I'd released the code to the public. Most of the bugs > > were bound to be of the "intermittent" type too, so I was particularly > > pleased at the end result. > > > > I view it as sheer laziness on the programmers part. You get what you pay > > for. > > That's right. This is why, when I change code and break some > invariant/expectation (even if the types aren't changed), I often > change the variable/struct/function names, to review all the code > possibly using it. > > >> And finally, for multi-platform code, it makes less sense: > >>what happens if you don't have 2-bytes integers and you > >>have code with wXXXX variables (unsigned int 16 bits) ? > > > On PowerPCs, a word is 32-bits. On Intels, 16-bits. So what's the lesson > > to be learned here? Don't hardcode widths in the meanings of your symbols. > > > Hungarian notation as used by Microsoft is by far NOT the only way to use > > it. > > No but the very name "Hungarian notation" comes from its (incorrect) use > at Microsoft. > > > For example, I *never* identify word-widths in my Hungarian notated > > variable names. Why? Because of the very problem you cite above. However, > > I do indicate higher-level meanings with prefixes: p for pointer, c for a > > count (e.g., cb for a count of bytes, cuint32 for a count of 32-bit unsigned > > integers, etc), a for array, etc. > > > Again, it takes skill to use a tool well. > > Agreed. > > -- Cedric > Sent via Deja.com http://www.deja.com/ Before you buy. From amitp at Xenon.Stanford.EDU Sat May 27 18:34:23 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 27 May 2000 22:34:23 GMT Subject: [PATCH] A compromise on case - another suggestion References: <34575A892FF6D1118F5800600846864D35F585@intrepid> Message-ID: <8gpihf$set$1@nntp.Stanford.EDU> Will Ware wrote: | Simon Brunning (sbrunning at trisystems.co.uk) wrote: | > [regarding Nick M's proposal for error messages] | > I envision this being enabled by default, to help newbies like | > myself. Expert users should be able to disable the check via a | > command line option if they wish. | | Is there any performance hit to the clearer error messages? I would think | (not having studied the patch) that, for code with no errors in it, the | penalty would be only for testing the error, not for how it would be | processed if it did happen. If that's right, there's no incremental | performance cost for the improved error messages. Assuming experts don't | have such brittle egos as to find the extra information offensive, it'd | make sense to enable them all the time. | | If it's correct at all, the no-additional-performance-hit reasoning should | also apply to people who want to hook in fancier near-miss-detection | functions (swapping letters, leaving a letter out, etc). Python could | be the world's first dyslexia-friendly programming language. Cool. That'd be quite useful for me. I've often wondered why compilers and interpreters don't spend enough time on error messages. Once there's an error, you aren't worried about computer efficiency -- instead, I would think you'd want to spend computer time to help the human spend less time debugging. For NameError and AttributeError, misspellings, case changes, missing '_', and forgetting 'self.' should be checked. For indentation, Python could check if a ':' was missing on the previous line, or if there were any suspicious tabs involved. For IndexError, it'd be helpful to have some suggestions -- such as knowing what the range was. Instead of: >>> ['a', 'b', 'c'][5] Traceback (innermost last): File "", line 1, in ? IndexError: list index out of range How about: >>> ['a', 'b', 'c'][5] Traceback (innermost last): File "", line 1, in ? IndexError: list index 5 out of range [0..3) Instead of: >>> 1357109358*6183 Traceback (innermost last): File "", line 1, in ? OverflowError: integer multiplication How about: >>> 1357109358*6183 Traceback (innermost last): File "", line 1, in ? OverflowError: integer multiplication of 1357109358 and 6183 exceeds sys.maxint (2147483647) A little extra computer time in analyzing errors would help save a lot of human time. - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From fiona at sitegnome.com Tue May 23 09:05:53 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 23 May 2000 13:05:53 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 23rd, 2000 Message-ID: <20000523130553.16613.qmail@synop.com> Hi! Below are the entries I've entered tonight into http://python.faqts.com - Fiona ## New Entries ################################################# ------------------------------------------------------------- How can I link python code to a GUI interface generated by Glade or GTK or whatever please? http://www.faqts.com/knowledge-base/view.phtml/aid/3171 ------------------------------------------------------------- Fiona Czuczman Mitch Chapman Here's an example. Two files are attached. GladeBase.py provides two base classes. Class UI creates a widget hierarchy from a Glade file. Class Controller provides an MVC-style controller for the UI. The main() function of the module shows how to use these base classes to build and control a GUI. ui.glade is a simple user interface created using Glade. If you plop it into the same directory with GladeBase.py and then run GladeBase.py, you should get an application window on your display. The cool part about James Henstridge's libglade, on which this example is based, is the way it wires up callback routines. You pass it a dictionary of callable objects, keyed by name. It roots through the Glade-based user interface hierarchy, and for every connected signal declared in the interface, it looks for a callable of the same name in the callback dictionary. If it finds one, it plugs it in. It's cheap and easy. In the example, Controller._connectToUI() assumes that you will derive from class Controller and define all of the callback methods in the derived class. Hoping this helps... --- #!/usr/bin/env python """This is an example of accessing Glade-built UIs from Python.""" import gnome.ui, gtk, libglade class UI(libglade.GladeXML): """Base class for all UIs loaded from glade.""" def __init__(self, filename, rootname): """Initialize a new instance.""" libglade.GladeXML.__init__(self, filename=filename, root=rootname) self.root = self.get_widget(rootname) def show(self): """Make the UI visible.""" self.root.show() class Controller: """Base class for all controllers of glade-derived UIs.""" def __init__(self, ui): """Initialize a new instance. `ui' is the GladeXML UI to control.""" self.ui = ui self._connectToUI() def _connectToUI(self): """Wire up self to its UI. This method assumes that any method defined by self's class could be a Gtk+ callback. It wires up any methods referenced by self's ui.""" names = dir(self.__class__) d = {} for name in names: d[name] = getattr(self, name) self.ui.signal_autoconnect(d) def show(self): """Show the user interface.""" self.ui.show() def main(): """Module mainline (for standalone execution)""" class SampleController(Controller): def on_pushBtn_clicked(self, *args): """Called when the 'push me' button is clicked.""" print "Thanks for pushing me." gtk.mainquit() def on_win_delete_event(self, *args): """Called when the window is deleted.""" gtk.mainquit() theUI = UI("ui.glade", "win") theController = SampleController(theUI) theController.show() gtk.mainloop() if __name__ == "__main__": main() --- CreateWorkspace create_workspace src pixmaps C True True GtkWindow win delete_event on_win_delete_event Wed, 03 May 2000 00:16:13 GMT GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False False True False GtkVBox vbox1 False 0 GtkLabel label1 Go on, push the button. GTK_JUSTIFY_CENTER False 0.5 0.5 0 0 0 False False GtkButton pushBtn True clicked on_pushBtn_clicked Mon, 22 May 2000 15:28:00 GMT Push Me 0 False False ------------------------------------------------------------- How can I find out the father class of a given class? http://www.faqts.com/knowledge-base/view.phtml/aid/3175 ------------------------------------------------------------- Fiona Czuczman Emile van Sebille >>> class A: pass >>> class B(A): pass >>> B.__bases__ (,) ------------------------------------------------------------- Is there any difference between the random number generator in the'random' module and that in the 'whrandom' one? Is there a way to get a reproducible sequence of random numbers? What's the quality of the numbers generated? http://www.faqts.com/knowledge-base/view.phtml/aid/3173 ------------------------------------------------------------- Fiona Czuczman Emile van Sebille, Tim Peters,Jim Richardson, Ivan Frohne If I'm not mistaken, whrandom is imported by random, and importing random would be the normal way of accessing it. You shouldn't use whrandom: whrandom is an interal implementation detail of random.py. whrandom.py should probably be renamed to _whrandom.py (or something) to stop people from tripping over it. Repeatable sequences can be generated by reseeding with the same value: >>> import random >>> random.seed("Spam") >>> print random.random() 0.188524911272 >>> print random.random() 0.795451892756 >>> print random.random() 0.191986312458 >>> random.seed("Spam") >>> print random.random() 0.188524911272 >>> print random.random() 0.795451892756 >>> print random.random() 0.191986312458 >>> print random.seed.__doc__ Seed the default generator from any hashable value. None or no argument returns (0, 0, 0) to seed from current time. Regarding the quality: If you know enough about random numbers to understand an answer to that question, then telling you it's the standard Wichman-Hill (that's where "wh" comes from) generator is all the answer you need . Seriously, test it and determine whether it's adequate for your application; if you can't test it objectively, then you have no way of knowing whether any other package is adequate either (and neither does anyone else, so don't ask). Ivan Frohne wrote a very nice package of stronger generators, which should be available from his Starship page. But unless you're doing extreme work, WH should be adequate for a start. Any serious program relying on random numbers should be tested with at least two distinct generators, though, and Ivan's pkg is great for that. You can find the algorithm used in whrandom.py and random.py (in Fortran 77) at http://lib.stat.cmu.edu/apstat/183 . It was published in the Journal of Applied Statistics in 1982, and is now a little long in the tooth. The period is about 7e12, which you might think is large, but, when you get right down to it, it's not large enough. In fact, an alternative algorithm with period 2e18 is now recommended at the site listed above. But the truth of the matter is, random.py will give you perfectly fine uniform random numbers for most purposes, if you're not too fussy, and don't need hundreds of millions of them. As an aside, for those using linux, then /dev/random and /dev/urandom are good reseources for (very nearly) random numbers. ## Edited Entries ############################################## ------------------------------------------------------------- What's the best way to obtain seeds for random number generators? http://www.faqts.com/knowledge-base/view.phtml/aid/2770 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, Mike Steed, Ivan Van Laningham, Will Ware, Paul Jackson RFC 1750 provides a whole lot of information on this topic: http://www.faqs.org/rfcs/rfc1750.html "Computer clocks, or similar operating system or hardware values, provide significantly fewer real bits of unpredictability than might appear from their specifications." Depending on how serious you are about randomness, you may want to use a hardware source (e.g., an audio input device). See 8.7 in the following document: http://www.faqs.org/faqs/cryptography-faq/part08/ Also, under linux, see /dev/random. random.c claims: * This routine gathers environmental noise from device drivers, etc., * and returns good random numbers, suitable for cryptographic use. Will Ware wrote: If you really need a lot of randomness, and you don't mind spending an evening or two with a soldering iron, I once made up a pretty good random bit generator circuit, described at: http://world.std.com/~wware/hw-rng.html You can bring the bits in one of the pins of your printer port. I have some information about a Linux device driver for the thing, if you're interested in pursuing it, that was developed by some students who recently used the circuit for a course project. ----------------- A Random Number web site from SGI is: http://lavarand.sgi.com/ From samschul at pacbell.net Thu May 11 13:53:05 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Thu, 11 May 2000 17:53:05 GMT Subject: windll module? References: Message-ID: <8fes1r$gks$1@nnrp1.deja.com> windll is part of the Dynwin package Use the following URL: http://www.nightmare.com/~rushing/dynwin/ Sam Schulenburg In article , Gaetan Corneau wrote: > What happened to the windll module? > I can't find it... > ______________________________________________________ > Gaetan Corneau > Software Developer=20 > Copernic.com=20 > http://www.copernic.com > E-mail: corg at copernic.com =20 > ______________________________________________________ > "Les T=E9l=E9tubbies, c'est de la musique d'ascenseur pour les yeux" > > -----BEGIN GEEK CODE BLOCK----- > Version: 3.1 > GCS/B/MU d- s+:++ a C++=20 > UL+ P--- W+ N- K- W++ t--=20 > !5 X- R+ tv-- b++ DI++=20 > G e++ h---- r+++ y++++ > ------END GEEK CODE BLOCK------ > > Sent via Deja.com http://www.deja.com/ Before you buy. From wware at world.std.com Thu May 11 15:19:52 2000 From: wware at world.std.com (Will Ware) Date: Thu, 11 May 2000 19:19:52 GMT Subject: class instance checking -- newbie References: Message-ID: Tim Northover (tim at pnorthover.freeserve.co.uk) wrote: > I think I need to determine whether an object belongs to a particular > class (specifically whether it is a MatchObject)... >>> class Foo: ... pass ... >>> a = Foo() >>> a <__main__.Foo instance at e3a20> >>> isinstance(a, Foo) 1 >>> isinstance(11, Foo) 0 -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From mhammond at skippinet.com.au Tue May 9 22:35:06 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2000 02:35:06 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> <3917f55c.842808@news.btx.dtag.de> <3917f685.115228@news.btx.dtag.de> Message-ID: "Stefan Franke" wrote in message news:3917f685.115228 at news.btx.dtag.de... > On Tue, 09 May 2000 00:44:38 GMT, "Neil Hodgson" > wrote: > > You could try a more recent beta of Scintilla from > >http://www.scintilla.org/Scintilla.DLL > > which is put in the Python16\Pythonwin directory. Save the older > >Scintilla.DLL first as this may be worse. > > I tried the new DLL (the download name seems to be > http://www.scintilla.org/Scintilla.dll ) with the same result. May I > send you a Dr. Watson report to neilh at scintilla.org ? Neil, Stefan and I have been going over this in private email, and it turns out to be a bug in Pythonwin that will be fixed in builds 133 and later... Mark. From jschmitt at vmlabs.com Tue May 30 18:15:24 2000 From: jschmitt at vmlabs.com (John Schmitt) Date: Tue, 30 May 2000 15:15:24 -0700 Subject: *blink* That's neat. In-Reply-To: <8h0ne2$70i$2@newshost.accu.uu.nl> Message-ID: I take it then that there is a paper I can read the observations that lead to the conclusion that students had a problem with case sensitivity? Where might it be found? A quick peek on alice.org did not reveal it. John -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Martijn Faassen Sent: Tuesday, May 30, 2000 8:41 AM To: python-list at python.org Subject: Re: *blink* That's neat. Fredrik Lundh wrote: [lots of snippage] Note that I'm not questioning the Alice result on case-sensitivity; [even more snippage] From senn at maya.com Tue May 23 14:11:46 2000 From: senn at maya.com (Jeff Senn) Date: 23 May 2000 14:11:46 -0400 Subject: [PATCH] A compromise on case In-Reply-To: nickm@mit.edu's message of "Tue, 23 May 2000 17:18:25 GMT" References: Message-ID: <3dn9nnkt.fsf@SNIPE.maya.com> nickm at mit.edu (Nick Mathewson) writes: ... > names. I decided the best way to do this was to patch the code that > raises NameError and AttrError. > > My rationale was this: Guido has said that he's considering > case-insensitivity because beginners often run into problems. ***My > hypothesis is that their problems aren't due to the language, but due > to the unhelpful error messages it gives.*** After all, who could ... > So I tried to make a quick-and-dirty patch the Python interpreter to > do something more reasonable. Here's a sample interaction: ... > >>> print MAP(square, [1,2,3]) > NameError: No such name as 'MAP'. Perhaps you meant 'map'? Merits of the patch aside (I like the idea!), it still doesn't get to the core of *why* Guido suspects there are benefits to making the language case-insensitive. Just consider how to handle the more complex case of code like: CountOfLumberJacksAvailable = 12 if something.or.other(): CountOfLumberjacksAvailable = CountOfLumberJacksAvailable + 1 print CountOfLumberJacksAvailable Code, which you will notice, generates no "errors"... Guido's assertion (which I believe) is that we humans are not used to reading case as being significant to the meaning of a word -- in addition our ability to even perceive the case of a word is pretty poor. I'm sure that there are studies in the cog-sci reading- comprehension area that support this result and demonstrate that memory for case is pretty pathetic. Guido is developing a language product for enabling people to use computers -- not training people to (rearrange their perceptual systems to) think the way a computer does. -- -Jas From g2 at seebelow.org Sun May 7 11:51:48 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 07 May 2000 16:51:48 +0100 Subject: HTMLParser tag contents References: <391544E1.6F0@seebelow.org> Message-ID: <39159114.BFB@seebelow.org> Grant Griffin wrote: > > Oleg Broytmann wrote: > > > > On 5 May 2000, Grant Griffin wrote: > > > Perhaps I misspoke. I agree that the solution would probably have to occur at > > > the level of SGMLParser, but I guess my question remains: can it do that? if so, > > > how? > > > > > > In looking at the SGMLParser source code, it doesn't appear to have any > > > mechanism to capture the contents of a tag. > > > > You cannot "just do it" :) You need to write a class inhertied from > > SGMLParser, define the methods for capturing and from this point > > forward capture ALL text and ALL tags until . > > Thanks for the tip, Oleg. I experimented with your approach and it worked, but I finally decided just to use 're', to preserve HTMLParser's other features. Here's what I came up with: --- class HTMLParserEx(HTMLParser): import re head_re = re.compile(r"<\s*head.*?>(.*)<\s*/head\s*>", re.S | re.I) body_re = re.compile(r"<\s*body.*?>(.*)<\s*/body\s*>", re.S | re.I) def __init__(self, formatter, verbose=0): self.alldata = '' HTMLParser.__init__(self, formatter, verbose) def reset(self): self.alldata = '' HTMLParser.reset(self) def feed(self, data): self.alldata = self.alldata + data; HTMLParser.feed(self, data) def get_text(self, text_re, debug=0): srch = text_re.search(self.alldata) if srch is None: if debug: print 'No match: Data is:' print self.alldata return '' else: return srch.group(1) def get_body_text(self, debug=0): return self.get_text(HTMLParserEx.body_re, debug) def get_head_text(self, debug=0): return self.get_text(HTMLParserEx.head_re, debug) --- I'm a Python tyro, so comments and criticisms from 'experts' are welcome. (at-times-like-this,-i'd-prefer-more-library-documentation-and -examples-to-reading-open-source-)-ly y'rs, =g2 p.s. It took a long time for me to figure out how to combine flags for 're'. I finally found that in 'Contents_of_Module_re.html', but I would like to kindly recommend to the python docs folks that they might want to spread some redundant needles on that point throughout the re doc haystack; in particular, I didn't find any examples of combined flags in the docs. -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From moshez at math.huji.ac.il Sat May 20 12:25:43 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 20 May 2000 19:25:43 +0300 (IDT) Subject: command history in the interpreter? In-Reply-To: <3926D1F3.8D07DC60@kurir.net> Message-ID: On Sat, 20 May 2000, alex k wrote: > i had python1.52 in linux/mandrake7. when i pressed the uparrow at the > console i could access the command history, so to speak. just like in > bash. > > now i use slackware7. i installed both python1.52 and python1.6 (the > former replacing the latter). it didn't work in none of them. > all of the arrowkeys type things like ^[[C ^[[D and such. Well, whoever built it did not do a good job -- so you'll have to. Get the Python 1.5.2 sources (not 1.6 -- it's still alpha). Edit "Setup.in" to include the readline library, and make sure you installed the slackware package with the header files of "readline". Now, follow the good old "./configure;make;make install" routine and you get a Python with command line history in /usr/local > the python interpreter in win98 (1.52 and 1.6) also don't give me the > history function. PythonWin is supposed to have a history function. > it's so awkward now that i can't even edit the txt without deleting it > (backspace). Maybe "Del" works? > is that feature hidden somewhere in the interpreter, or did mandrake > somehow add it themselves? Apparently, Mandrake are more competent at building Python from sources. (Actually, it's probably Red Hat, and they use Python) -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From tismer at tismer.com Mon May 29 08:30:43 2000 From: tismer at tismer.com (Christian Tismer) Date: Mon, 29 May 2000 14:30:43 +0200 Subject: DECREFing and PyArray functions in C Extensions References: <290520000802122720%pecora@anvil.nrl.navy.mil> Message-ID: <393262F3.9CD9CFBB@tismer.com> "Louis M. Pecora" wrote: > > In article , Roger Hansen > wrote: > > > static PyObject * > > foo(PyObject *self, PyObject* args) > > { > > PyArrayObject *array; > > double* a; /* C ptr to the NumPy array data field */ > > > > if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) { > > return NULL; /* Error indicator */ > > } > [cut] > > > > Py_INCREF(Py_None); return Py_None; > > } > > > > where f is some function. I don't need to DECREF array in this > > example since PyArg_ParseTuple does not increase the reference count, > > right? > > That looks right to me, but what is this: > > Py_INCREF(Py_None); return Py_None; > > What's going on there with Py_None? The function is supposed to return no value. Returning no value in Python means to INCREF and return Py_None. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From thiele at muc.das-werk.de Wed May 10 11:29:54 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 10 May 2000 17:29:54 +0200 Subject: member by member copy??? References: <8fbska$4ti$1@nnrp1.deja.com> Message-ID: <39198072.A3D1C599@muc.das-werk.de> > Use copy.copy and copy.deepcopy. >>> class X: ... def __init__(self): ... self.a = 5 ... >>> x = X() >>> list = [x] >>> cl1 = copy.copy(list) >>> cl2 = copy.deepcopy(list) >>> list[0].a = 6 >>> list[0].a 6 >>> cl1[0].a 6 >>> cl2[0].a 5 Thomas From pinard at iro.umontreal.ca Mon May 22 23:37:02 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 23:37:02 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Russell Wallace's message of "Tue, 23 May 2000 03:51:01 +0100" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> <3929D3F6.DE9CCCBC@prescod.net> <3929F215.166D@esatclear.ie> Message-ID: Russell Wallace writes: > > The most honest arguments are "case sensitivity feels cleaner" and that > > it "is more popular with existing programmers." > It seems to me that the important argument in this context is "case > insensitivity will break millions of lines of existing code, and perhaps > split the user base if a significant number of existing users refuse to > switch". I can see good arguments either way - overall it doesn't > strike me as a major issue - but I'm dubious about changing it at this > stage. It seems many of us a a reason against it. My main reason for praying that Guido will stand by what he gave us so far, is that Python is a clean language, and that case insensitiveness is an open door to sloppiness right from the lowest level and initial contact with the language. That will corrupt everything from down up in the long run. It's not really a thing we should do to children, and not either a thing children should do to us. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jkraska1 at san.rr.com Wed May 3 02:21:47 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 06:21:47 GMT Subject: Advice on giving a python course References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> <2OOP4.1626$dp5.583559@paloalto-snr1.gtei.net> Message-ID: <390FC620.E1363CBB@san.rr.com> > > wanted (I wanted to do something text-based, speed wasn't a big > > issue). APL and LISP, the languages my father recommended, were both > > too obtuse to express the things I wanted to express easily. Your mistake there was not realizing that while it may have been difficult to express the easy things, you would have discovered Lisp to be quite a bit easier at expressing the very, very difficult things than all other noteworthy languages of the time. In fact, it's still very, very good at it. (apologies to c.l.p for the out of group evangelism) C/ p.s. hey, we dynamic language folks have to stick together, right? :) From shapr at uab.edu Wed May 31 11:01:12 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 31 May 2000 15:01:12 GMT Subject: "non-essential difficulty" - case enforcing? References: <8ge7ka$ouo$1@slb6.atl.mindspring.net> <39351648.ED1F1288@uab.edu> <8h37ve$djt$1@slb7.atl.mindspring.net> Message-ID: <39352F52.B5A5B462@uab.edu> Aahz Maruch wrote: > I've read my Brooks, too. Thing is, I'd almost agree with you > that case sensitivity is an accidental difficulty for *writing* code, > but I absolutely disagree that case sensitivity is an accidental > difficulty for *reading* code. Which is the point that I was making > about indentation. > > i tHinK You woULd aGrEe thAt tHiS iS HarDer TO reAd. But it's not much > harder to write.... I do agree with the writing versus reading, that's why I agreed with (or elaborated on, I don't remember) an earlier post and ended up suggesting that case be enforced according to certain standards in the output. I haven't come up with a good standard, but I think one could be designed. I also agree with the idea that an IDE or editor could do case-enforcing and allow case-sensitivity to remain. I don't know how hard that would be to implement though. In summary, case-enforcing seems like it could be a solution, I just don't know how it would work :) Could anyone suggest a workable case-enforcing policy? The only other way I can think of to get around the case problem and not get rid of case sensitivity is to have an IDE that's smart enough to figure out when a variable or name is being created versus when it's being modified and change the highlighting accordingly. That's something I would know how to do, and I don't think it would be difficult. My reasoning for that solution is that when I get confused about case, it's because I am working with a new variable when I thought I was working with one I already had. Are there other cases of problems? :) how-much-of-the-success-of-VB-is-because-of-its-spiffy-IDE-ly y'rs -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt From wlfraed at ix.netcom.com Sun May 28 17:14:52 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sun, 28 May 2000 14:14:52 -0700 Subject: Java vs Python References: <8goqht$439$1@nnrp1.deja.com> <392FF563.403AD31F@home.com> Message-ID: On Sat, 27 May 2000 10:18:43 -0600, Ivan Van Laningham declaimed the following in comp.lang.python: > > Are there any OSs written in COBOL? I think not. > Which only shows that practically everyone agrees that COBOL is not appropriate for OS development (it wasn't meant to be, either). C, with its low-level datatypes and pointers is effectively a replacement for assembly. OTOH, a lot of the DEC VAX software was built in BLISS. There is also the UCSD P-System. And to scare folks, Ada Core Technologies is working on created JGNAT (a version of GNAT that produces JVM object code). Now that could get... strange... Ada and Python joining via Java? -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From tseaver at starbase.neosoft.com Mon May 15 15:30:20 2000 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 15 May 2000 14:30:20 -0500 Subject: newbie confession References: <39203962.2685CFB3@yahoo.com> Message-ID: In article <39203962.2685CFB3 at yahoo.com>, sn wrote: So, yes, I am hooked. > >My name is Steve, and I'm a Pythonoholic. *all together now* "Hi, Steve!" Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at digicool.com http://www.zope.org Digital Creations From boncelet at udel.edu Mon May 8 02:10:10 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 08 May 2000 16:10:10 +1000 Subject: Generating combinations with repetitions References: <3912183C.9718FB77@udel.edu> Message-ID: <39165A40.7E7EC73F@udel.edu> Jeff Raven wrote: > On Fri, 05 May 2000 10:39:25 +1000, Charles Boncelet wrote: > > > >Here is a slight variation to the combinations algorithm I posted a > >couple of weeks ago, now as a Class: > > > >(python code deleted) > > Well, it works, but it doesn't fare too well when compared to the > alternatives. Calculating 20 choose 20 this way (with or without > repetitions) consumes far more memory and time than is really > necessary. > You're exactly right. It hadn't occurred to me that the intermediate results my algorithm computed could be *much* larger than the final resurt. E.g., len(choices(20,20))=1, but along the way my algorithm computes an array of size choices(20,10) = 184756. I had an algorithm similar to yours, but deleted it in favor of the more "elegent" solutiion. :-( BTW, rchoices(20,20) (with repetitions) generates a list of 68923264410 items, too big for my computer, no matter what algorithm I use. Charlie Boncelet -- ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From grisha at ispol.com Wed May 24 19:04:10 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Wed, 24 May 2000 19:04:10 -0400 Subject: ANNOUNCE: mod_python 2.0 - A Python module for Apache. Message-ID: Mod_python is an Apache HTTP server module that allows embedding Python within Apache, bringing together the versatility of Python and the power of Apache. More information is available at: http://www.modpython.org/ Enjoy! -- Gregory (Grisha) Trubetskoy grisha at ispol.com From mjhand at concentric.net Sat May 27 02:07:19 2000 From: mjhand at concentric.net (Manus Hand) Date: 27 May 2000 02:07:19 EDT Subject: HowCanI: inlined exceptions References: <392EE821.714573DD@visionart.com> Message-ID: <392F652A.A91D88EB@concentric.net> Pete Shinners wrote: > > what i'd really,really like to do is define something > that works like this > > def catch(expression, errcode=None): > try: > return expression: > except: > return errcode > > if __name__ == '__main__': > name = catch(fields[1], 'Anonymous') > > i would really like to do this for myself, because i > would use it extensively! > Personally, I think the nicest, most readable, and most Pythonic way to write it is: try: name = fields[1] except: name = 'Anonymous' But if you want anything cleaner than that, and which does not involve passing the code to be evaluated into a function with a try:except:, you'll have to wait for Guido to implement something like this: name = fields[1] except 'Anonymous' so that we can use the "or" idiom in a slightly different way. :-) I gotta admit, I would make use of that if it was there... But-I-wouldn't-necessarily-recommend-holding-your-breath-ly-y'rs, Manus From gmcm at hypernet.com Mon May 15 14:22:00 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 May 2000 18:22:00 GMT Subject: How python development is speedy! References: <391FFDB5.FC9A85CA@cui.unige.ch> Message-ID: <39204048$0$14803@wodc7nh1.news.uu.net> Sunil Hadap wrote: >I use Python,I don't know Java. I am just curious, people keep >reporting that Python is very fast in development as compared to Java >and C++. Is this because of language feature or because of reduced >compile-run-debug cycle, or something else! > >When I look at my Python code, I see little difference in terms of >development efficiency as compared to C++ when used with STL and other >good libraries. Does the higher types such as lists and tuples make >Python so powerful, after all C++ had all that. Those are factors. But the major one (at least for me) is syntactic simplicity. I sometimes use Python to prototype something I know will end up in Java or C++. In those cases, I tend to write my Python so it will be translatable, (ie, I don't make use of use of Python features that I won't have in Java / C++). In this case, the productivity gain decays pretty quickly and I quit prototyping as soon as I know it's reasonable. An app that will stay in Python gets designed quite differently (particularly in terms of class hierarchies - I think "components" in Python). From sjoshi at ingr.com Wed May 31 13:01:13 2000 From: sjoshi at ingr.com (sjoshi at ingr.com) Date: Wed, 31 May 2000 17:01:13 GMT Subject: How to embed message in Exchange ?? Message-ID: <8h3ggh$fnl$1@nnrp1.deja.com> Hello All I'm using the testExchange script as stepping stone send messages embeded with text (like HTML, RTF) using MAPI. As per MS docs. I need to create an attachment object and set its type to ActMsgOle. The question is how and from where do I tell python to load the type definitions. This is what the attchment object needs ' Active Messaging 1.1 oAttachment.Type = ActMsgOle thanks Sunit Sent via Deja.com http://www.deja.com/ Before you buy. From rumjuggler at cryptarchy.org Sun May 21 15:22:49 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 21 May 2000 19:22:49 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: <91egis4v9spsp8iteg0p4ok4bimlv4mr5t@4ax.com> On 21 May 2000 18:22:26 GMT, scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) wrote: >Besides, it's apparently easier >to use for newbies, who have never learned that 'Friend' and 'friend' are >completely unrelated words. Then they should learn that they are. If a person can't get used to case-sensitivity, I don't see how that person will get over the learning curve for other aspects of the language. People get marked down on essays for not beginning sentences with capitalized words, anyway; it's not like case-sensitivity is a revolutionary concept limited only to programming languages. -- Barnabas T. Rumjuggler I'm sure there isn't a single person alive who hasn't mistaken an antimetabole for a chiasmus before. -- John Flynn From mskott at image.dk Wed May 17 16:18:21 2000 From: mskott at image.dk (Martin Skřtt) Date: Wed, 17 May 2000 20:18:21 GMT Subject: Data Entry References: <3922F9AB.7F509A0F@maptel.es> Message-ID: Oscar Bosca writes: > It's incredible, but I've found the way to entry data from a program > something like: ( in C ) Hmmm... I expect you forgot a word in this :-) > or maybe is it because with Python you can't ask for data and > keeping it in a variable? Well, indeed you can and its mentioned in the library refference with the following example: >>> s = raw_input('--> ') --> Monty Python's Flying Circus >>> s "Monty Python's Flying Circus" As you see input is nicely placed in an object. For you to play with :-) -- Martin Sk?tt mskott at image.dk 'In a certain sense, all decent programming languages are equally powerfull' Dr. Alan Turing From gmc333 at my-deja.com Tue May 30 16:47:49 2000 From: gmc333 at my-deja.com (gmc333 at my-deja.com) Date: Tue, 30 May 2000 20:47:49 GMT Subject: case sensitivity and XML References: <20000523113250.A2150232@vislab.epa.gov> <7LxW4.9151$Za1.142121@newsc.telia.net> <392B40F0.324E0189@cosc.canterbury.ac.nz> Message-ID: <8h19df$sgp$1@nnrp1.deja.com> In article , Ian Parker wrote: > In article <392B40F0.324E0189 at cosc.canterbury.ac.nz>, Greg Ewing > writes > >Fredrik Lundh wrote: > >> > >> so why not enforce these rules, just like we're enforcing the > >> indentation rules: > >> > >> >>> class foo: > >> SyntaxError: Class name should be Foo > > > >There are some precedents for this. Smalltalk requires > >global variable names to start with a capital. HUGS > >distinguishes type names from other names by whether > >they start with a capital. Some Eiffel compilers chide > >you if you don't spell class names in ALLUPPERCASE and > >other names in alllowercase. > > > > I don't think I could return to programming in a language that > _required_ capitalisation or uppercase to indicate the purpose or > function of some name. I'm reminded of old Basic where a string was > indicated with a $ or somesuch. Isn't that a little like Perl. Almost > Hungarian. > Actually, the standard in Eiffel is for everything to be case- insensitive. Some compilers like SmallEiffel (http:\\smalleiffel.loria.fr) issue warnings by default for name case inconsistencies, but this can be turned off. And yes, a '$' prefix for vars is very Perl-ish. And I agree it's a syntactic grotesquery. Greg Sent via Deja.com http://www.deja.com/ Before you buy. From cfelling at iae.nl Tue May 30 17:18:38 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 30 May 2000 23:18:38 +0200 Subject: vars between classes References: Message-ID: <8h1b7e$git$1@animus.fel.iae.nl> Marc Tardif wrote: > How can I maintain variables between classes and superclasses without > passing explicitly as methods arguments? For instance: I think you were confused by the diabolic behavior of "self.some_class_var". Please refrain from using that construct whenever you deal with true class variables. The "self." construct starts looking in the instance name space, then looks in the class name space and then in all it's parent's classes name spaces. So you can access a class var as if it were an instance var, but only in expressions, *not* at the left-hand site of an assignment! And only *prior* to an assignment to an instance var with that name!!! The following annotated code will not only bewilder you, but alse give you the behaviour you were after (if I guessed right:) -------------------------------------------------------------------------- #! /usr/bin/python import string class A: mine = 'A' # a class var def __init__(self): print "A's init, no instance var yet:", A.mine, self.mine, # now we create an instance variable shadowing the class var self.mine = string.lower(self.mine) print ", now with instance var:", A.mine, self.mine def mines(self): # return the class and instance variable mine return "printing A's: %2s %4s" % (A.mine, self.mine) def drink(self): # drinking gives us double vision, not our whole class self.mine = self.mine * 2 class B(A): def __init__(self): print "B initially without class var:", A.mine, self.mine, # now we create a clas variable shadowing the inherited one B.mine = 'B' print ', now with class var:', B.mine A.__init__(self) def mines(self): return A.mines(self) +\ (", and B's: %4s %4s" % (B.mine, self.mine)) def drink(self): # we drink like our parents, A.drink(self) # but we never drink alone, so the whole class gets drunk B.mine = B.mine * 2 def booze(self): self.drink() # and if we really really drink our parents get drunk too A.mine = A.mine * 2 def print_abc(mess): print 'After', mess print 'a', a.mines() print 'b', b.mines() print 'c', c.mines() a, b, c = A(), B(), B() print_abc('instantiation') b.drink() print_abc('b.drink') b.booze() print_abc('b.booze') -- groetjes, carel From ldr at trail.com Wed May 31 15:22:00 2000 From: ldr at trail.com (Dean) Date: Wed, 31 May 2000 13:22:00 -0600 Subject: Newbie Tkinter Question Message-ID: Is it possible to pass arguments to a callback in Python/Tkinter? I know this can be done in Perl, but after reviewing the documentation, it's not clear to me that you can pass any arguments ( except the event object ) to a callback function bound to an event. Any help would be greatly appreciated! Dean From brunnsNObrSPAM at beer.com.invalid Wed May 24 05:52:07 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Wed, 24 May 2000 02:52:07 -0700 Subject: Customize keybindings in IDLE?? References: <38B69811.1F1F5661@bibsyst.no> Message-ID: <27462f03.4a212d2a@usw-ex0104-033.remarq.com> See extent.txt in the IDLE directory for instructions... Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From cwr at crash.cts.com Sat May 20 01:41:56 2000 From: cwr at crash.cts.com (Will Rose) Date: 20 May 2000 05:41:56 GMT Subject: Damnation! References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> Message-ID: <8g58j4$11ei$2@thoth.cts.com> Guido van Rossum wrote: : Francois Pinard writes: :> Roy Katz writes: :> :> > 1. Python 3000 may be case-insensitive. :> :> Horror, hell, and damnation! April 1st should be far behind us by now! :> :> I would hate[1] writing with inconsistent casing, with nothing on my side :> to help me writing consistently. I much prefer what Python is, today, on :> that regard. So, how do I register my vote? Where do I leave my tears? :-) : Python is not a democracy. Voting doesn't help. Crying may... :-) :> Besides, is there any real need behind case-insensitiveness? Or is it :> just another step forward (backward? :-) on that road that would drive us :> towards a click-on-the-pink-button-and-hear-the-soft-sound version of Python? : This is all taken way out of proportion. I promise that Python 3000 : won't suddenly be introduced without further discussion. Every issue : will discussed here and elsewhere and we'll explain why we want to : change the design. We'll also explain what we're going to do for : compatibility. : In the mean time, we're too busy with Python 1.6 to be able to answer : each question about Py3k. Once 1.6 is released I promise to create a : FAQ about Py3k. : Some quick answers: for case insensitivity, we'll have tools that : enforce consistent casing (and maybe the case insensitivity will be in : the tools alone). Well, either make it ALL UPPER CASE or all lower case, I don't care; please do not, repeat not, make it case-preserving and case-insensitive. That way madness lies. This a deal-breaker for me; I've written a fair bit of Python, but haven't spent a lot of time on it and still have a great deal to learn. If Py3k is going that route, I need to stop wasting time now and resume my fight with Perl. When will the Py3k FAQ be out? July/August? Will cwr at cts.com From intmktg at CAM.ORG Sat May 27 11:10:38 2000 From: intmktg at CAM.ORG (Marc Tardif) Date: Sat, 27 May 2000 11:10:38 -0400 (EDT) Subject: vars between classes In-Reply-To: Message-ID: On Sat, 27 May 2000, Moshe Zadka wrote: > On Sat, 27 May 2000, Marc Tardif wrote: > > > OK, here's working code now. My previous code was only meant to help > > demonstrate my problem. In this new code, I have tried to change var in > > the first class by calling "first" explicitly. Unfortunately, "3" is still > > not printed: > > > > #!/usr/local/bin/python > > > > class first: > > def __init__(self, var): > > self.var = var > > self.myMethod() > > > > def myMethod(self): > > print "first:", self.var > > second(self.var) > ^^^^^^^^^ > Here you construct a new object of class "second", which inherits > its __init__ from "first", which calls its "myMethod", which prints > "second." It's still not very clear what you expect to happen. > Right. What I would like to happen though is for 'var' to change in 'first' if I change it in 'second'. I could probably set var global, but since I'm still quite new to Python, I'm wondering if there's a more proper solution. From mhammond at skippinet.com.au Tue May 9 22:49:42 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2000 02:49:42 GMT Subject: __getattr__ and extend COM object References: <8fa4p1$8jf$1@nnrp1.deja.com> Message-ID: * Use win32com.client.genncache.EnsureModule to get the module object you makpy'd. eg: mod = gencache.EnsureModule(...) * Implement you class as normal - something like: class MyWibble( mod._WhateverMakePySaysItIs ): def __getattr__(self, attr): if attr == "WIBBLE": return self.DynamicProperty(attr) else: return mod._WhateverMakePySaysItIs.__getattr(self, attr) Then use your class, instead of Dispatch("whatever") to create the COM object. Should work like a charm. After all, it is all just Python code :-) Mark. wrote in message news:8fa4p1$8jf$1 at nnrp1.deja.com... > I have a COM object that I have makepy'd. > > The COM object has a func DynamicProperty("WIBBLE") which gets WIBBLE > from the DB (acolumn on a table) > > I'd like to extend my COM object using __getattr__ so that I could do > myobj.WIBBLE > instead of > myobj.DynamicProperty("WIBBLE") > > Any suggestions as to how I can do this? > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From rwallace at esatclear.ie Tue May 23 04:34:33 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Tue, 23 May 2000 09:34:33 +0100 Subject: The REALLY bad thing about Python lists .. References: <000501bfbee7$62318ac0$a2a0143f@tim> Message-ID: <392A4299.762F@esatclear.ie> Glyph Lefkowitz wrote: > > "Tim Peters" writes: > > ISO/ANSI C doesn't fully define what happens when (roughly) integer division > > or % are handed negative numbers. > > The foibles of standards commitees will never cease to amuse me. > Thank you for this little tidbit. Don't blame the C committee, blame the CPU manufacturers. C doesn't define the result because CPUs aren't consistent about what result they give. (Under what circumstances would you want to use % on negative numbers? I can't think of any.) -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From gregb at krakatoa.mpce.mq.edu.au Fri May 12 22:37:36 2000 From: gregb at krakatoa.mpce.mq.edu.au (Gregory Baker) Date: 13 May 2000 12:37:36 +1000 Subject: Win32 Registry Access Message-ID: Short of writing a module in C, is there an easy way of accessing the registry from within Python. I only really need read access, but I'm just kind of interested to know. Strangely, I couldn't find the answer to this in "Python Programming on Win32", and no amount of poking around has given me any insight as to how to do it. Registryless-ly yours, Greg Baker From aahz at netcom.com Wed May 24 11:33:24 2000 From: aahz at netcom.com (Aahz Maruch) Date: 24 May 2000 15:33:24 GMT Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> Message-ID: <8ggso4$67a$1@slb6.atl.mindspring.net> In article <39260CB6.464EE302 at san.rr.com>, Courageous wrote: > >I thought about this for a while, and my suspicion is that the first >negative reaction that people have against case insensitivity is >probably the instinctive (and false) idea that everyone would be >writing python programs without case. No, I think it's more that many of us have an instinctive revulsion against trying to read code with random case. If you read the posts in all these threads, there is much more acceptance of mono-case languages than case-insensitive languages. In addition, while Guido rejects "status quo" as an argument, I think that's a specious POV. To change the status quo IMO requires evidence that the status quo should be changed. This is a subtle distinction, but I think it's a critical one. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From python at rose164.wuh.wustl.edu Tue May 9 23:45:53 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Tue, 9 May 2000 22:45:53 -0500 Subject: COM Sockets References: <20000503173130.22333.00002350@ng-md1.aol.com> Message-ID: <029901bfba3c$dc4867c0$5d22023f@spkydomain> ----- Original Message ----- From: "Rafferty" Newsgroups: comp.lang.python To: Sent: Wednesday, May 03, 2000 4:31 PM Subject: COM Sockets > I am trying to establish a socket from Excel using COM python code. I > started with the sample code and tried enclosing it in COM but when I > execute I get a socket error 10061. Any ideas I want to use COM to send > data from Excel or Word to a socket server for testing. > [snip code] I tried your COM server and it worked fine for me (after demangling the whitespace). I called your server from Excel and had it put the results in the button caption. I was running both the server and Excel on the same machine, but I can see no reason it shouldn't work across the network. My VBA code is something like (from memory, please ignore typos): Sub CommandButton1_Click socsrv = CreateObject("ICE.COMUtilities") CommandButton1.Caption = socsrv.COMCreateSocket() End Sub I wrote a simple threaded echo server. This code is tested: from socket import * import thread def child(s): while 1: data = s.recv(1024) if not data: break s.send(data) def main(): so = socket(AF_INET,SOCK_STREAM) so.bind('',4000) so.listen(5) while 1: conn,addr = so.accept() thread.start_new_thread(child,(conn,)) print `addr` if __name__ == '__main__': main() I used port 4000 out of habit, and changed only that in your COM server. HTH, David From andres at corrada.com Wed May 31 09:41:01 2000 From: andres at corrada.com (andres at corrada.com) Date: Wed, 31 May 2000 09:41:01 -0400 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com In-Reply-To: <8h1ama$nd8$1@newshost.accu.uu.nl>; from Martijn Faassen on Tue, May 30, 2000 at 09:09:30PM +0000 References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <8h1ama$nd8$1@newshost.accu.uu.nl> Message-ID: <20000531094101.A18889@corrada.com> How does this announcement relate to the news that the Python CVS tree moved to sourceforge.net? That is, will pythonlabs host the CVS tree eventually? ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From bjorn at roguewave.com Tue May 16 14:21:23 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 16 May 2000 12:21:23 -0600 Subject: python source -> ast References: <39218269.99B3B830@roguewave.com> Message-ID: <392191A3.894CA837@roguewave.com> Fredrik Lundh wrote: > > Bjorn Pettersen wrote: > > A while back I remember someone creating a module similar to the > > 'parser' module, but created more 'intuitive' ASTs (i.e. not quite as > > deep). > > > > I've searched at the vaults and python.org but couldn't find it... > > Anyone have any pointers? > > iirc, it's part of python2c: > http://lima.mudlib.org/~rassilon/p2c/ > > Thanks! (if anyone else is interested it's in transformer.py with a code example in gencode.py). -- bjorn From echuck at mindspring.com Sat May 13 22:30:10 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Sat, 13 May 2000 22:30:10 -0400 Subject: webpages in python References: <3912348F.87F1CAA8@swt.edu> Message-ID: <391E0FB2.F7055C24@mindspring.com> root wrote: > > Folks, > > I have already created webpages in HTML. Now since python is hot > nowadays I would like to make my site dynamic using python. > Where can I get the starting tutorials for creating webpages in python > or some similar help. > > Shah See the link in my .sig: -Chuck ____________________________________________________________ http://webware.sourceforge.net From guido at python.org Wed May 17 14:37:00 2000 From: guido at python.org (Guido van Rossum) Date: Wed, 17 May 2000 18:37:00 GMT Subject: Q? Calling nearest inherited method References: <392295a8.3800058174@news.u-psud.fr> Message-ID: <3923112C.4758A8C0@python.org> Laurent POINTAL wrote: > > On Wed, 17 May 2000 11:54:53 +0000 (GMT), Oleg Broytmann > wrote: > > >: On Wed, 17 May 2000, Laurent POINTAL wrote: > >: > Given a class hierarchy like this: > >: > A > >: > B inherits A > >: > C inherits B > >: > > >: > A define dothis method. > >: > C define dothis method. > >: > > >: > In the C.dothis, I wants to call my nearest parent class dothis > >: > method. That is, call B.dothis if it is defined, or A.dothis if it is > >: > defined... > >: > >: I think B.dothis() will do it just right, no? > > I was afraid it resolve in a single (B) method search... but it search > also in B parents (even when prefixed explicitely with B). > > Thanks. > > Python is really wonderful. There's a better way. (I believe Jeremy Hylton first suggested this; he saw it as an idiom in another language:) class C(B): super_doit = B.doit def doit(self, arg): self.super_doit(arg) This avoids the need to explicitly pass self. -- --Guido van Rossum (home page: www.python.org/~guido/) From srn at fn.com.au Thu May 4 03:58:03 2000 From: srn at fn.com.au (Stephen Robert Norris) Date: Thu, 04 May 2000 07:58:03 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> <390FC76A.59FB5779@san.rr.com> Message-ID: In article , kc5tja at garnet.armored.net (Samuel A. Falvo II) wrote: > Add to that his claim that "technology doubles ever year" is also > incorrect. To be more specific, Moore's law states that the performance > of microprocessor systems double every 18 months (not every year), and > refers > *strictly* to hardware. It does *NOT* apply to software. Want proof? > Windows. Actually my recollection (which is bourne out by the interview with Moore at http://www.sciam.com/interview/moore/092297moore1.html) is that the original law was that computing power (actually components on a chip) would double every _year_. In 1975 he revised it to ever two years; according to him he never, _ever_ said 18 months. Stephen From kern at caltech.edu Sun May 14 19:19:33 2000 From: kern at caltech.edu (Robert Kern) Date: 14 May 2000 23:19:33 GMT Subject: GUIs References: <7ACS4.5039$ur1.107262@news6-win.server.ntlworld.com> <391cb04a.62616489@news.telus.net> <391f2b3c.21319366@news.telus.net> Message-ID: <8fnca5$896@gap.cco.caltech.edu> In article <391f2b3c.21319366 at news.telus.net>, invalid.address at 127.0.0.1 (David) writes: [snip] > http://www.google.com/search?q=tkinter&num=10&meta=hl%3Den%26lr%3D&btnG=Google+Search > > Hey! Python comes up *exclusively* on the first ten hits! Python's more > Tkinter than Tcl is! Sorry to burst your bubble, but Tkinter is the name of Python's interface to Tk, the GUI toolkit designed for Tcl. So we should really be surprised if Tkinter is mentioned without Python. Sorry again. -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From gfor_ewu at ispchannel.com Thu May 25 15:58:37 2000 From: gfor_ewu at ispchannel.com (Greg Fortune) Date: Thu, 25 May 2000 19:58:37 GMT Subject: syntax highlighting for Kedit References: <8gjfi6$bke$1@nnrp1.deja.com> Message-ID: Seriously consider using Nedit or simply use the IDLE editor included with Python. Nedit works great for many many different languages and does a fair job of working with Python. The IDLE editor, of course, has excellent support and works great on both Windows and Linux. Launch IDLE by popping open a console and typing idle. Greg Fortune wrote in message news:8gjfi6$bke$1 at nnrp1.deja.com... > Python ppl: > > Does anyone in the Python community use Kedit? > Do you have a syntax highlighting module for _.py files? > Can you share? > > Thank you in advance... > > scott2237 > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From mwh21 at cam.ac.uk Sat May 27 18:00:49 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 May 2000 23:00:49 +0100 Subject: ob_refcnt INCREF and so on... References: <39301826.91D0E17D@san.rr.com> Message-ID: Courageous writes: [snip] > Can someone confirm or deny this, and if I'm mistaken, explain why > the refcnt of the object is 2 at the point where I print it?????? > > If correct, is there a predictable time when the temporary will > lose it's reference hold on the object? YHBT-M (You Have Been Time-Machined): >>> print sys.getrefcount.__doc__ getrefcount(object) -> integer Return the current reference count for the object. This includes the temporary reference in the argument list, so it is at least 2. >>> The reference will go away after the function returns. Read the source for the CALL_FUNCTION opcode(s if you're in 1.6aX) for the gory (and I do mean gory) details. The comment isn't strictly true, either: >>> class C: ... pass ... >>> sys.getrefcount(C()) 1 >>> HTH, Michael -- 3. Syntactic sugar causes cancer of the semicolon. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From steven2 at satunet.com Fri May 26 14:54:43 2000 From: steven2 at satunet.com (steven2 at satunet.com) Date: Sat, 27 May 2000 01:54:43 +0700 Subject: translating Perl Cookbook? In-Reply-To: <8ggtit$7ll$1@slb0.atl.mindspring.net> References: <8ggtit$7ll$1@slb0.atl.mindspring.net> Message-ID: <979.000527@satunet.com> On 5/24/00 22:47 Aahz Maruch wrote: > There was a discussion of this a few months ago, and I wrote to O'Reilly > asking if they wanted to hire me to do it. They said they already had > someone working on the project, but I don't know what the ETA is. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) Thanks to everybody who has responded. I perceive the response as positive. So should we do it? Yes (at least I would). The project is now hosted on SourceForge: http://sourceforge.net/project/?group_id=6064 Only an iota is translated (hey, I'm a Python newbie! :-). Feel free to drop in and/or share your code. -- Steven "case-sensitive" is so unixish. if dos/windows were born first, it would be called "case-discriminating". From bfordham at piratech.net Mon May 15 16:20:29 2000 From: bfordham at piratech.net (Bryan Fordham) Date: Mon, 15 May 2000 20:20:29 GMT Subject: popen2 + passwd References: <391F78CC.362C5D12@flashmail.com> <958419676.155123@cdwork.cvt.stuba.sk> Message-ID: <39205b8a.450393468@nntp.infoave.net> -----BEGIN PGP SIGNED MESSAGE----- On 15 May 2000 19:41:59 GMT, garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) wrote: >Jp Calderone wrote: > : Can anyone tell me why this doesn't work? > > : import popen2 > > : i, o = popen2.popen2('passwd bin') > : pwd = '12345ASD' > : o.write(pwd + '\n') > : o.write(pwd + '\n') > : i.close() > : o.close() Try calling o.flush() after sending the first pwd. The information in the pipe isn't actually written until you close it, or until it's flushed. HTH - --B -----BEGIN PGP SIGNATURE----- Version: N/A iQCVAwUBOSBb8w2B1TBOdblFAQHcJgP9HwEQAH4LVxGfXg6LhkrksFA2BEwG7Dtr X84E2hC1nBjVzfSIJGVKI9Hk1CLaXWJXvW9lQ12kAkdgXzQq05nDCF8QRgU4XBHq aQq5X8147Jb543SqzzaG/RNVL6PdmHFClTX7R5eS+PY4zhz1jF/PwGTXEbrkdYom Rs2KIY9nR5E= =9/Kb -----END PGP SIGNATURE----- From robin at jessikat.demon.co.uk Tue May 30 05:57:34 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 30 May 2000 10:57:34 +0100 Subject: VCC PRIORITY QUEUE NATIVE IMPL References: <3932C43C.8E617E0@san.rr.com> Message-ID: In article <3932C43C.8E617E0 at san.rr.com>, Courageous writes > > >This is a visual c++ implementation of a heap-priority queue. >It is 5-6 times faster than the equivalent python, as tested >doing heapsort. This priority queue implements "lowest is best" >priority, so all pops always retrieve the lowest item in the >queue. > >This is my second implementation of a python C extension, and >I believe it is correct, however there exists some small chance >I've messed up something with references, as I'm fairly new at >this. > >Hope someone finds this useful, > >C/ ... very nice I'm sure, but wouldn't it be better to stuff this on a home page somewhere and give us a bit of information to go along with it about how and why it's useful and perhaps a simple python example? I guess this may have something to do with the queue comparison you mention elsewhere, but as a lowly engineer I'm not sure. Minor carping aside it builds fine. -- Robin Becker From thor at localhost.localdomain Mon May 22 12:22:54 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 22 May 2000 16:22:54 GMT Subject: ANN: PythonPoint - PDF Presentation Slide Package References: Message-ID: On Mon, 2Andy Robinson wrote: >PythonPoint, from ReportLab, is an Open Source package for making >presentation slides. There's still time to use it for Monterey 2000! > >Slides are defined in an XML syntax, and a Python script converts them into >a PDF document. It uses the ReportLab PDF library, the only pdf library to >expose advanced Acrobat presentation features. Capabilities include > >- Outline tree for easy navigation >- Page transition special effects >- Full control over text attributes >- Vector images coded in Python >- Accepts bitmap images in most common formats >- Style sheets and templates - re-brand presentations in seconds! > > http://www.reportlab.com/demos/pythonpoint/pythonpoint.html > > >CEO/Chief Architect, ReportLab Inc. > >p.s. thanks to Tom Christensen, whose "PerlPoint" last year provided the >idea and the name. > -- From relson at expressgate.net Thu May 18 09:56:16 2000 From: relson at expressgate.net (David Relson) Date: Thu, 18 May 2000 13:56:16 GMT Subject: tibco rendezvous Message-ID: <3923f59b.3148108992@news.wwnet.net> Anybody using Python with TIBCO's Rendezvous message-handling software? I'm working on a web based application that needs to talk to a 24x7 data collection system which uses Rendezvous. Rendezvous supports Perl, Java, C, C++, and Objective-C. I could run perl scripts from my python code, but I'd rather use straight python. David Relson relson at ic.net Ann Arbor, MI From michael.husmann at teleatlas.com Thu May 25 01:21:04 2000 From: michael.husmann at teleatlas.com (Michael Husmann) Date: Thu, 25 May 2000 07:21:04 +0200 Subject: What's in a name? References: <392c17d3$0$17863@wodc7nh7.news.uu.net> <392C3738.58C41202@muc.das-werk.de> Message-ID: <392CB840.1E5E5B06@teleatlas.com> Thomas Thiele wrote: > > > > > > > 1. Remove a (potential) hurdle for new programmers. > > > > I really don't undersytand why case-sensitivity should be a hurdle? > > Is orthography a hurdle to learn reading and writing? That's what I think. Case insensitivity is a restriction and no progress. -Michael From jkraska1 at san.rr.com Sat May 27 00:01:32 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 27 May 2000 04:01:32 GMT Subject: Microthreads: wait( duration ) with minimal processor overhead, u References: Message-ID: <392F494E.AB935747@san.rr.com> > Normal sleeping threads (for instance, a thread that has blocked while > waiting for input from a queue, or waiting for a timer to finish) do not > take up any processor activity until the they are reactivated by the > event that wakes them. I think you may be working on an already-solved > problem. Eh? These are *microthreads*. Using thousands and thousands of "normal" threads will clobber your cpu. And yet in a very simple test of microthreads, I was able to spawn up 10,000 of them and watch them finish in under 3 seconds flat. Quite remarkable. I'll be a monkey's uncle if the author of the uthread library doesn't know all about how normal threads work... C/ From adjih at crepuscule.com Thu May 18 08:35:37 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 18 May 2000 12:35:37 GMT Subject: Problem using PyRun_String() References: <39234922.508F587@mixadlive.com> Message-ID: <8g0o2p$q09$2@ites.inria.fr> Eric wrote: > Hi, > I'm having problems running PyRun_String() in C. Although my > code seems ok, the function returns NULL in every case and does > a system error. I've tried examples of the documentation and I still > have the same results. If you didn't do it, maybe you could print the traceback. PyObject* result=PyRun_String(....); if(result==NULL) { PyErr_Print(); ... bail out ... } Then, if you show us the traceback, we might be more able to help you [assuming the initialization steps were ok] :-) -- Cedric From jkraska at bbn.com Wed May 3 18:57:01 2000 From: jkraska at bbn.com (Joe Kraska) Date: Wed, 03 May 2000 15:57:01 -0700 Subject: Stackless/microthreads merge news In-Reply-To: <3910AAA1.2207ECC0@tismer.com> References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F31A5.6452D256@tismer.com> <390F7CB5.8BD62851@san.rr.com> Message-ID: <200005032257.PAA11560@ESCHER.SD.BBN.COM> Christian Tismer wrote: >Courageous wrote: >> Quite. I corresponded with the Kiev implementors a while >> back, asking them why they hadn't added continuations to >> Java. They responded back with "impossible on the JVM". > >Ah, this is the elixier. Gimme more impossibles, and I'll fly. Well, of course what they meant was "impossible with the current JVM". Their project set out to be JVM- compatible. They implemented first class functions in Java, closures, variadic argument support, and a variety of other things and were still JVM-compatible. Given the Lispishness of Kiev, I began to wonder if they'd considered doing continuations. Continuations can be very helpful in a modeling & simulation environment, as it sometimes becomes necessary to do your own scheduling in such environments. But they claimed that the current JVM couldn't do it. Sure would be nice if it could! Joe Kraska San Diego Ca From phd at phd.russ.ru Thu May 25 07:43:07 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 May 2000 11:43:07 +0000 (GMT) Subject: Python & Interbase In-Reply-To: <392CC2D2.380B1502@tin.it> Message-ID: On Thu, 25 May 2000, Jilani Khaldi wrote: > where can I find information (code, hints...) about Python and > Interbase? You can find information on: -- www.python.org -- ftp.python.org -- Parnasus: http://www.vex.net/parnassus/ -- DejaNews: www.deja.com... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tismer at tismer.com Tue May 23 07:19:53 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 23 May 2000 13:19:53 +0200 Subject: Python performance notes... References: <392A2ED5.6A35B754@san.rr.com> Message-ID: <392A6959.7479936@tismer.com> Courageous wrote: > > I did a simple for loop and tested it, trying a variety of > length loops. It took a bit of time to get this right, as > for smaller loops, the test was biased by the relative high > cost of function invocation. When it settled out, a for-loop > in python is about 100 times slower in python than the > equivalent in ANSI C. Irrespective of function invocation > overhead, the decision to go native pays off almost > immediately, with time differences in python versus native > code being noticeable with as low as 100,000 simple iterations. > > Writing native methods in python is, fortunately, quite easy. And creating bugs, as well. :-) > TO WIT: > > PyObject* Test ( PyObject* self, PyObject* args ) > { > int i; > for(i=0;i<100000;i++); > return Py_None; > } You didn't INCREF your result. Call this function often enough, and your system will crash, since Py_None has an empty deallocator. Furthermore, I'd suggest to do a different test than the above. Empty loops don't happen in reality, and it makes limited sense to compare a Python loop against a compiler, which in this case even has the chance to optimize the full thing away. Instead, I would at least do some action in the loop that involves some Python objects. In order to figure the real loop cost out of it, I would run two different tests: One with one action per loop cycle and on with two. This should give a good estimate of the cost of the action, and it can than be factored away to find the loop cost. I'd also like to have more info on what computation your conclusion is based. If you only have a loop that does a trivial task, the loop overhead might count. But if there are actions which take some time, then I doubt that just removing the loop would buy me so much. The calling overhead of the objects in your code is still there, and unless you leave Python totally and use native C structures all the time, you will not gain much more than 30, maybe 40 percent of speed by avoiding the interpreter. This is IMHO not enough to justify writing C code by hand, with the additional risk of poking holes into a quite stable system. Using some automation like P2C for this *might* make sense, while the speedup is still not convincing enough to use a compiler. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From pitts at callnetuk.com Sun May 14 15:34:43 2000 From: pitts at callnetuk.com (Andy) Date: Sun, 14 May 2000 19:34:43 GMT Subject: learning Message-ID: <391effd1.9894246@news.callnetuk.com> Does anyone know any good site for learning python. This is the first programming language I have tried to learn after someone recommended it as a good first language and I need a site that'll be able to teach a complete newbie. Thanks in advance Andy From pinard at iro.umontreal.ca Sun May 21 22:07:00 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 21 May 2000 22:07:00 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: "John W. Baxter"'s message of "Sun, 21 May 2000 12:28:02 -0700" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: "John W. Baxter" writes: > 8. Francois: "Why Scheme adopted case insensitivity is a mystery to me." > My guess is, as with domain names, timing, and the difficulty of writing > lower case on KSR-33 Teletypes and upper-case-only glass teletypes. KSR-33 Teletypes? I am not sure if we really think the same thing, but your are referring to those machine guns working at 110 bauds? Those engineering wonders made up from the assembly 2500 distinct _mechanical_ pieces!? With the paper tape reader/puncher option? I'm not sure such really abound nowadays. I once believed that Scheme was invented for the homo sapiens. :-) Will the design of the next century Python be driven by the need to support, euh, hum..., Teletypes? :-) > walk around with cards full of )))))))... in their shirt pockets, to be > slapped onto the end of submitted card decks: one at least got something > back if there were too many )s. Flavourful story, and quite believable! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From wlfraed at ix.netcom.com Tue May 30 11:08:12 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 30 May 2000 08:08:12 -0700 Subject: auto increment operator?? References: <3933001E.D63F1A46@uniserve.com> <20000530132103.A469@xs4all.nl> Message-ID: <0vl7jskf87cdb2km40n60vdmmh40gbqks7@4ax.com> On Tue, 30 May 2000 13:21:03 +0200, Thomas Wouters declaimed the following in comp.lang.python: > Actually, this isn't true. C had the auto-increment operators because B had > it, and B (and C ? i forget) were first developped on the PDP-7. The PDP-7 > did not have the auto-increment assembler instruction -- the PDP-11 did, > but B and C didn't get ported to that machine until later. > Ah, I hadn't realized the -7 lacked that set of operations... -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From wware at world.std.com Tue May 23 20:14:32 2000 From: wware at world.std.com (Will Ware) Date: Wed, 24 May 2000 00:14:32 GMT Subject: [PATCH] A compromise on case References: Message-ID: Nick Mathewson (nickm at mit.edu) wrote: > >>> print MAP(square, [1,2,3]) > NameError: No such name as 'MAP'. Perhaps you meant 'map'? > >>> print string.JOIN(['a', 'b', 'c']) > AttributeError: JOIN. Perhaps you meant 'join'? This is definitely the coolest most ingenious thing I've seen all day, maybe all week. The whole case-sensitivity thread was staring to grate on my retinae, but this makes it all worthwhile. It would be good to put some #ifdef's in ceval.c and wherever else is applicable, and maybe an option in the 'configure' script, so that different flavors of error message could be invoked when the python executable is built. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From cpmcda01 at shark.kitenet.net Tue May 2 19:44:42 2000 From: cpmcda01 at shark.kitenet.net (Craig P McDaniel) Date: 2 May 2000 23:44:42 GMT Subject: How to get terminal width? Message-ID: <8enp9a$1hn$1@news.louisville.edu> I need to write a command line script in Python that needs to know the width of the terminal in characters. I've looked through several modules and haven't yet found what I'm looking for. Does anyone know where I need to look? -- Later, _) Craig McDaniel _)_) craig at tool.net _)_)_) cpmcda01 at slug.louisville.edu From hgg9140 at seanet.com Mon May 1 19:02:46 2000 From: hgg9140 at seanet.com (Harry George) Date: 01 May 2000 16:02:46 -0700 Subject: Advice on giving a python course References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> Message-ID: Looks ok to me. Make sure they get to code early and often. I just taught a course last Thrusday and Friday. The audience was engineers who have been doing knowledge-based engineering with lisp and prolog, plus accessing these apps from web sites. Like you, I started with 5 people and had to turn them away when we ran out of workstations in the classroom. I wanted to use Essential Reference, but not all the copies arrived in time, so mostly we worked from the web-based course notes. On the web page, I had links to the (locally installed) html documentation. So once people knew about the Library Reference, they could search for features on their own. I concentrated on getting people over the hello, world barrier (getting something to run). After the intro session and a quick scan through the remaining sessions, the students self-selected favorite areas to work exercises. Here is my outline: 1 Introduction 1.1 Objectives 1.2 Where and why? 1.3 Cool Stuff 1.4 Setup emacs 1.5 Intro to documentation 1.6 Hello world 1.7 Running Hello 1.8 Quick Start 1.9 Exercise 1a 1.10 Exercise 1b 1.11 Exercise 2a 1.12 Exercise 2b 1.13 Exercise 3a 1.14 Exercise 3b 1.15 Exercise 3c (exercises: mkpythonproj, pyperl, and regular expressions) 2 CGI 2.1 Agenda 2.2 What is a CGI? 2.3 What is required? 2.4 Code faster? 2.5 Exercise 1a 2.6 Exercise 1b 2.7 Run faster? 2.8 Exercise 2 (exercises: using cgipm.py to build, comline debug, install, and run cgi's) 3 XML 3.1 Agenda 3.2 What is XML? 3.3 Why is it used? 3.4 How is it programmed? 3.5 Hello: XML file 3.6 Hello: DOM 3.7 Hello: Traverse the DOM 3.8 KIRTS import/export 3.9 Exercise 1 3.10 Exercise 2 (exercises: using xml.dom for simple, then complex parse-and-write) 4 Extend and Embed 4.1 Agenda 4.2 Extend 4.3 Extend -- setup 4.4 Extend -- code 4.5 Extend -- use it 4.6 Embed -- setup 4.7 Embed -- makefile 4.8 Embed -- code 4.9 Install standalone (exercises: extensions, embedded, and "installer") 5 GUI 5.1 Agenda 5.2 What is required? 5.3 Reactive Systems 5.4 Model-View-Controller 5.5 Platform independent implementations 5.6 TkInter 5.7 Gtk 5.8 Exercise 1a 5.9 Exercise 1b 5.10 Exercise 1b -- cont. (exercises: run the Demos, pick an interesting one, see how it is implemented, tweak it and observe changes. I really hammered on doing a gui-independent reactive app which could be driven by a test script and then adding gui's.) "Richard P. Muller" writes: > I will be giving a short course on Python to my research group > (computational chemistry and materials science). I would like to raise > the average level of programming ability in our group, so that more > people can take on the "hard" programming projects that until now have > only been undertaken by a few of the better programmers. > > I had anticipated having 5-6 people show up in the group, but was > overwhelmed with 20 people responding, which is both exciting and > intimidating. > > Since I'm sure other people on this list have taught similar courses, I > was wondering if I could get some helpful suggestions, and/or feedback > on the way I've structured the course. > > The web page for the course is at: > http://www.wag.caltech.edu/home/rpm/python_course/ > > The slides for the first lecture are at: > http://www.wag.caltech.edu/home/rpm/python_course/Lecture_1.pdf > > I wanted to give the students as much instant gratification as possible, > which is why I introduced the Gnuplot module and NumPy in the first and > second modules, respectively. > > Any help, suggestions, criticism, or pity will be gratefully received. > > Rick > rpm at wag.caltech.edu > -- Harry George hgg9140 at seanet.com From timo at alum.mit.edu Sun May 28 00:10:58 2000 From: timo at alum.mit.edu (Timothy O'Malley) Date: Sun, 28 May 2000 00:10:58 -0400 Subject: Cookies / CGI References: Message-ID: <280520000010584565%timo@alum.mit.edu> hola. For what it's worth: In article , Oleg Broytmann wrote: > # ----- create ----- > #! /usr/local/bin/python -O > > def set_cookie(): > import time > t = time.gmtime(time.time()) > t = (t[0] + 10,) + t[1:] # add 10 years :) > > import Cookie > cookie = Cookie.Cookie() > > cookie["id"] = str(1024) > cookie["id"]["expires"] = time.strftime("%a, %d-%b-%Y %T GMT", t) You don't have to format the time string yourself. Cookie.py will do it for you. Just set the value to the number of seconds: cookie["id"]["expires"] = 10 * 365 * 24 * 3600 From hgg9140 at seanet.com Sun May 7 22:00:04 2000 From: hgg9140 at seanet.com (Harry George) Date: 07 May 2000 19:00:04 -0700 Subject: PyBalsa? References: <4CCD34DC434D6019.93763A3431326470.47F9322EA18914C1@lp.airnews.net> Message-ID: I like the idea of pmail, so I downloaded and built it, but it didn't run for me. I was trying to run it in fvwm2. Is it enlightenment-specific? ** WARNING **: unknown widget class 'GnomeApp' gtkf.MainWindow.MainWindow: ERROR: GladeWindow: could not find widget: MainWindow Traceback (innermost last): File "/usr/local/bin/pmail", line 33, in ? gtkf.FrontEnd().run(show_preferences) File "/usr/local/share/pmail/gtkf/FrontEnd.py", line 47, in run win = MainWindow.MainWindow() File "/usr/local/share/pmail/gtkf/MainWindow.py", line 65, in __init__ self._window.set_usize(w, h) AttributeError: 'None' object has no attribute 'set_usize' Roman Milner writes: > Well - I don't know anything about balsa but pmail is a gtk based > mailer written in python that works well. It's still pretty early in > its life - but it doesn't crash. > > http://www.scottbender.net/pmail -- Harry George hgg9140 at seanet.com From owen at astroNOJNK.washington.edu.invalid Mon May 15 14:30:41 2000 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Mon, 15 May 2000 11:30:41 -0700 Subject: python improvements (Was: Re: New Language) References: Message-ID: <8fpfoj$e0m$1@nntp6.u.washington.edu> In article , "Tim Peters" wrote: >[Steven D. Arnold] >> 1. I'd like an equivalent to perl's "use strict" pragma. It's >> annoying to have to be so paranoid about making a typo in a >> variable name. > >[Martijn Faassen] >> How exactly would this work? It would seem hard to make this work >> right in a dynamic language, but perhaps I'm missing some simple >> strategies. > >Perl simply (& simplifying a bit) whines about vrbl names that appear >uniquely within a file. They're usually misspellings, but sometimes not. >Tools to do that for Python have been written several times too, but never >caught on, despite that they've even found long-standing bugs in the std >Python library. Check out Aaron Watters' pylint for the best of that >breed. Thus demonstrating the utility of having such functionality built into the language, preferably with enough power to find variables that are being read without being set. I would personally like to be required to declare variables before using them, a la smalltalk. (Just declare the names, not specify a "type".) It would greatly simplify this kind of error checking. (Not being forced to declare variables is dangerous, as has been amply demonstrated by FORTRAN over the years. That language finally allowed one to optionally force declarations.) Also on my wish list (inspired by Smalltalk): - class instance variables and class variables are declared as part of the class declaration and nowhere else. The current system seems dangerous, especially for class variables. It's too easy to mis-type a variable name and so create a new one. - class methods (e.g. ClassName.doSomething(...)). Often useful where global functions might otherwise be wanted. By requiring the class name one gets namespace protection and categorizes the function as relevant to objects of the given class. - class methods don't need "self" as the first argument; it's a keyword that is autmomatically defined. Less confusing because the caller's argument list matches the receiver's argument list. Also, by forcing a keyword ("self") to be used, improves code uniformity. -- Russell From sabren at manifestation.com Wed May 24 14:03:26 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Wed, 24 May 2000 14:03:26 -0400 (EDT) Subject: Cookies / CGI In-Reply-To: <8ggbn1$2vk$1@gxsn.com> Message-ID: On Wed, 24 May 2000, RS Solutions wrote: > Hi, > > Is there a simple script somewhere I can look at that sends and retrieves > cookies via CGI? > > I've looked at the cookie module but its not clear to me how that gets > posted to the end-user. if you use weblib (http://weblib.sourceforge.net/ - get the cvs version, not the snapshot): ----------------------- import weblib ## show cookies from the browser: print "the cookies are:" print "
      " for c in weblib.request.cookie.keys(): print "
    • %s - %s
    • ", (c, weblib.request.cookie[c]) print "
    " ## set some new cookies: weblib.response.setCookie("x", "this is x") weblib.response.setCookie("y", "this is y") Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From drew.csillag at starmedia.net Mon May 1 15:33:44 2000 From: drew.csillag at starmedia.net (Andrew Csillag) Date: Mon, 01 May 2000 15:33:44 -0400 Subject: Class Factories in Python: How? Message-ID: <390DDC18.222428DA@starmedia.net> Sounds like you probably want metaclasses. See http://www.python.org/doc/essays/metaclasses/. In short, what metaclasses allow you to do is to turn a class definition into a function call (at which time you can do whatever). Warning: it can make your head explode, but can save a bunch of work if used properly. -- print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/ t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0)) From smigowsky at dspace.de Fri May 5 10:41:23 2000 From: smigowsky at dspace.de (Stefan Migowsky) Date: Fri, 5 May 2000 15:41:23 +0100 Subject: Docstrings in COM Message-ID: <326536345498D311B3BC00105A39802A0746B4@PDC-DSPACE> If you want to see the docstring in e.g. VB you have to provide type information. For this you have to write an IDL file for your COM Server compile this using the MIDL compiler and include the resulting TLB file in this in VB via the "Projects\References..." menu. In Python you can use the makepy tool to generate a wrapper which then creates a wrapper class with all the definition from the IDL file. Stefan >-----Original Message----- >From: Ulf Engstr?m [mailto:ulf.engstrom at b2b-link.com] >Sent: Friday, May 05, 2000 1:39 PM >To: python-list at python.org >Subject: Docstrings in COM > > >Is there a way to display the docstrings when using the >Python-program as a >COM-object. >Ie. I have a program in Python which has a lot of small >functions, taking a >lot of arguments. Since you can't use key-word arguments with Python >COM-objects you need to know in which order to enter the >arguments. Thus I >need to have the docstrings or some other mean of getting a short >documentation to show up in the COMinterface. Anyone has any ideas? >Regards >Ulf > > >-- >http://www.python.org/mailman/listinfo/python-list > From jbauer at rubic.com Wed May 10 14:49:31 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 10 May 2000 13:49:31 -0500 Subject: Custom adduser function... References: <81DD38F43381D111BA3E00A076A0998A45A05B@XENON> Message-ID: <3919AF3B.4E5E3BEE@rubic.com> Channel21 Python Team wrote: > for some reason, the -p option does not actually > set the password to what we think it is. I.E., if > you run "/usr/sbin/useradd -p passwordval usernameval" > it doesn't actually set the password to passwordval... Ah, the useradd command wants the encrypted [crypt(3)] password passed in as an argument. You can modify the earlier code to pass in the encrypted password or create the account without a password and use os.popen to set it via the passwd command. -Jeff From stephen at cerebralmaelstrom.com Wed May 31 01:32:42 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 31 May 2000 05:32:42 GMT Subject: OT: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <392EEEE3.2D37@seebelow.org> <393403D7.CAA8AB7D@sage.att.com> Message-ID: <_t1Z4.29279$WS3.338373@typhoon.we.rr.com> I don't think this is really a case of which one is more productive or fast, but more on where you are at the time that you're doing it. If you're sitting in a shell, then using 'tar zvxf' is just as fast as any GUI version would be. But if you're already in a GUI and aren't working in a shell, then starting up the shell and doing your tar'n isn't going to work for you then, either. My problem with tar was not remembering the 'zxvf' part, but instead remembering exactly how the file was either a) spelled, b) capitolized, or c) punctuated(sp?). Even with an 'untar' script to do it, I just might forget to capitolize a letter or put a '-' in the wrong place. Not that you can't use wildcards to make it quicker, I know, mind you.. but I don't think the shell approach would ever be quicker then be using WinRAR (Am I the only one who doesn't use Winzip?) to right click on the compressed-file and click 'Extract to...' or 'Extract to (name of file)\' in that ever so friendly context menu. Two quick clicks :) --S Garry Hodgson wrote in message news:393403D7.CAA8AB7D at sage.att.com... > Grant Griffin wrote: (snip) > > But when extracting > > from someone _else's_ archive, I think the GUI thing clearly has the > > command-line approach beat. > > maybe. i type "Unpack archive-name" in a shell window, and i'm done. > "Unpack" being a trivial python or ksh (i forget which, and don't care) > script which figures out the right thing to do. From gduzan at gte.com Fri May 12 10:10:22 2000 From: gduzan at gte.com (Gary D. Duzan) Date: Fri, 12 May 2000 10:10:22 -0400 Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> <8feh9q$3gn$1@nnrp1.deja.com> Message-ID: <391C10CE.95B72254@gte.com> Rabid evangelists don't help for the very reason that they come across as rabid, and therefore easily dismissed for their lunatic fringe ideas. What Python really needs is basically what it is getting: more and more Real People solving Real Problems with Python Really Easily, and then telling other people about it. Just add a little emphasis the the last bit and we're set. Gary Duzan GTE Laboratories jerry_spicklemire at my-deja.com wrote: > > Hi Python Fans, > > This may be the last time that I know _the_answer_ > to a question that shows up here, so I'd better > make the most of it. > > Michael Hudson wrote: > > Glyph Lefkowitz > writes: > > > > > Vetle Roeim writes: > > > Unfortunately, one of the best features of the > python community is > > > that it seems to have a sane group of people > in it who know multiple > > > languages and will choose appropriate ones for > the appropriate task. > > > We need more rabid, unabashed evangelists. :-) > > > > Why? > > Yeah, that's the one. The reason I can tell you > why evangelists are needed, oh exalted gurus and > wizards ("We're not worthy!"), is that I am most > certainly not. You may all have binary > chromosomes, but the grim truth is most bitheads > are more like me. We are just lucky to be able to > do anything that folks pay money for at the start > of the twentyfirst century, however poorly. We are > the subsistence farmers of the Web Wide World. > > That's why Python is even more important, and > absolutely essential to me. I NEED Python very > badly, and so does the seemingly endless throng of > mediocre coders. Most of us will never transcend > our own feeble limits, but Guido gave us a tool > that let's us get stuff done anyhow. It's really > just as simple as that. > > You guys are glad to have found another great > language, one among many, and know exactly when > and how to use it. The rest of us are struggling > through CS101 with C++, Java, and the rest. That's > right, Pascal is dead, Basic is an historical > footnote. These days they start kids out with C++ > and Java because students want to learn "job > skills". It's no accident that Visual Basic is so > popular, in the real world of workaday > programming! > > The reason Python needs more rabid evangelists is > because so many still don't know it exists. "Never > heard of it", that's what thay say every time I > mention Python to a newbie. They don't even know > had much they need it, and that's a crying shame. > > Don't hold your breath for any mind blowing code > to emerge from this corner, but you can bet > your last billion that I'll keep touting Python to > anyone who betrays the faintest glimmer of > interest, and even some who don't! > > Say Hallelujah! > Jerry S. > > Sent via Deja.com http://www.deja.com/ > Before you buy. From m.faassen at vet.uu.nl Thu May 11 07:56:59 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 May 2000 11:56:59 GMT Subject: A REALLY COOL PYTHON FEATURE: References: <391A3FD4.25C87CB4@san.rr.com> Message-ID: <8fe76b$684$1@newshost.accu.uu.nl> Courageous wrote: > While all the oldtimers here already know this, I thought > I might share something really cool with some of my newbie > peers.... :) >>>> somenames = ["fred", "barney", "wilma", "betty"] >>>> reallycool = reduce ( lambda x, y: x+", "+y, somenames ) >>>> reallycool > 'fred, barney, wilma, betty' >>>> > Check that out. Do you know what a royal pain in the ass > it is in most languages to do this? It's a godawful pain > in the ass, let me tell you. And there it is, in all it's > glory: > reduce ( lambda x, y: x+", "+y, somenames ) It's actually pretty easy in Python, too. :) (you think all this reducing and lambda-ing is *easy*?) import string string.join(["foo", "bar", "baz"], ", ") Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkraska1 at san.rr.com Sun May 28 14:44:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 28 May 2000 18:44:34 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <3920AD73.BC4B6783@san.rr.com> Message-ID: <393169AB.FB137C59@san.rr.com> Roy Smith wrote: > > Courageous wrote: > > early adopter of a programming language which isn't popular. > > I'm having trouble with that concept. Seems to me, pretty much by > definition, by the time the language has become popular, it's too late > to be an early adopter, no? Well I went to review the thread and the history seems to have dropped off my newsreader. If I recall, though, what I was saying is that early adopters of programming languages are probably more mentally flexible than others. Python is really still in its infancy; it is popular enough to be known, but not popular enough to be considered a mainstream programming language. C/ From effbot at telia.com Sun May 21 18:10:31 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 21 May 2000 22:10:31 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com> <3.0.6.32.20000520233958.00839560@earthlink.net> <3927FA67.94D85CAF@elite.org> <349gisk5q40o7n9h8m03e7sr4bbed8tigo@4ax.com> <39284A93.EB6B4312@Lugoj.Com> Message-ID: James Logajan wrote: > > The Alice study only proves that users can memorize the case conventions > > used in a single specific library (in this case, the Alice environment), not that > > they won't get into trouble again when they stumble upon a library that uses > > different conventions. > > Slow learners until proven otherwise? What target IQ level would you > consider an appropriate cutoff? given that I have to figure out the conventions of every new library, and end up getting NameErrors and AttributeErrors now and then, I suppose that target is 20-100 points above my own level. not that the IQ level has anything to do with it -- any decent designer knows you'll get better results if you assume that users are very smart, but also very busy. > Also, if you wish to be taken more seriously, may I humbly suggest that you > avoid posting statements like the following: > > > Maybe non-geek programmers have better things to do with their time? if you have problems with that statement, I suggest reading more HCI literature. for a popular account, start with Cooper's "The Inmates are Running the Asylum". "Users would rather be successful than knowledgeable." -- Alan Cooper From tseaver at starbase.neosoft.com Sat May 13 13:07:29 2000 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 13 May 2000 12:07:29 -0500 Subject: Was Re: "stuff", a general request for help, now 'Ideas on correct use of PyUnit in Unit Tests' References: <391C0024.3BF9EFAD@uab.edu> Message-ID: In article <391C0024.3BF9EFAD at uab.edu>, Shae Erisson wrote: >If you ascribe to the Extreme Programming methodology, UnitTests come >from User Stories. User Stories are 'functional requirements' that the >client has given you. Therefore, I think UnitTests should not test the >code, they should test that the functional requirements are passed. XP distinguishes between "unit tests", which programmers write to test their code, and "functional tests", which customers write (or help write) to ensure that the "user stories" which a development increment was supposed to deliver are in fact present. The major point here is that *all* unit tests *must* run without failure before any work is checked in; functional tests are only required to run at the "acceptance" meeting at the end of an increment. XP mandates that developers who find a bug (intentional plural, see "Pair Programming") first write a new unit test which exercises / demon- strates the bug, then fix the bug, then rerun *all* tests to verify both that the bug was fixed and that no new bugs were introduced. Likewise new features: write the test which exercises the feature, add the feature, run all tests. Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at digicool.com http://www.zope.org Digital Creations From jraven at psu.edu Tue May 2 21:11:54 2000 From: jraven at psu.edu (Jeff Raven) Date: 3 May 2000 01:11:54 GMT Subject: How many is "too many" with lists? References: <8emtqt$dsf$1@nntp9.atl.mindspring.net> Message-ID: On Tue, 02 May 2000 12:48:01 -0400, Matthew Hirsch wrote: >Generating the list is slow. I'm accessing each element with a for >loop. I was just curious. > >Matt > > How are you generating them, and how slow is too slow? With some optimized Python code on my rather sluggish P166 with 32meg I can crank out a list of all 296010 combinations for C(27,6) in around 18-19 seconds -- a little worse if I make some conscessions in the code to cut down own memory use (though in either case it eats up most of my ram). I suspect if you want to go faster you'd need to write it in C, but this really is a problem where the algorithm can make a notable difference (and once you've optimised it in python, the translation to C almost writes itself). Jeff Raven From jlj at cfdrc.com Mon May 22 11:05:30 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Mon, 22 May 2000 10:05:30 -0500 Subject: PyOpengl... gone forever? References: Message-ID: <39294CBA.16F1A13B@cfdrc.com> Pete, I have both the source tarball and the Windows installer executable for PyOpenGL-1.5.5 (which I think was the last "official" release). File sizes are: OpenGL.exe 1,169,407 bytes PyOpenGL-1.5.5.tar.gz 548,679 bytes Please let me know if you'd like for me to mail one or both of these. Hope this helps, Lyle Pete Shinners wrote: > > i've asked once before, but i'm still lost here. > > my top spies have informed me that pyopengl lives on > the starship at http://starship.python.net:9673/crew/da > > this site has been inactive for too long now. i'm asking > someone out there who got a copy of pyopengl before starship > nosedived to please get it to me. > (don't worry about large attachments, cable is fast) > > i've just been getting into python when starship went > down, and it seems like a lot of staple modules were > stored there. i'm sure it is frustrating to many people, > but for the new developer it makes things uncomfortable too! > > thanks to all who can get my in the right direction From jwbnews at scandaroon.com Thu May 25 10:26:04 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 25 May 2000 07:26:04 -0700 Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <8F3F72DB7davemrquizorg@212.27.32.76> Message-ID: In article <8F3F72DB7davemrquizorg at 212.27.32.76>, nospam.mrquiz at free.fr (Dave Simons) wrote: > I wasn't taking too much notice at the time, so can anyone tell > me how much marketing went into C to make it the biggest-selling > language the world has ever known? Not much "marketing" as we know it. However, giving Unix and C to universities infiltrated C into the thinking of a generation of CS grads (and not-quite-grads). I was out of that environment long before then, so I wasn't infected...C looked pretty useless for a long time (and I still don't much like it). --John (who about 5 years ago had to stop saying he had been around computers twice as long as C had) -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From effbot at telia.com Tue May 30 04:41:55 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 30 May 2000 08:41:55 GMT Subject: destructors -- when are they called? References: <393351D2.3533AEFF@san.rr.com> <78JY4.1025$Hz.6998@news-server.bigpond.net.au> <39336E5F.E3E651D3@san.rr.com> Message-ID: Courageous wrote: > > This should be quite obvious from the Py_DECREF macro - it explicitely > > calls the delete function when the ref count hits zero. In the current > > implementation, it is indeed guaranteed (even though the language spec > > specifically refuses to guarantee it) > > Actually both of these are interesting data points. So what > you're saying is that code functionality which relies on a > 0 object reference calling the destructor will work 100% of > the time now, but might break in the future. don't confuse the CPython implementation with the language. in the current CPython implementation, this will always work. I'm pretty sure it will work throughout the entire 1.X series (changing it would simply break too much existing code). but the language specification deals with things on the Python level, and Python doesn't really require reference counting. so your code may not work under *other* implementations (including future C implementations of future Python versions, of course). if that's a problem, you better stick to pure Python code ;-) From markx.daley at intel.com Tue May 2 14:02:37 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Tue, 2 May 2000 11:02:37 -0700 Subject: Submitted for your perusal... Message-ID: <75F7304BB41CD411B06600A0C98414FC0A40EE@ORSMSX54> All, Many thanks to those of you who have helped me to develop this little script. Find attached the first reasonably working copy of my data collection routine. There are a couple of points to make. 1) The try:/except: portion is pounded out because I am having difficulty manipulating the servername list to append the current server name in the event of a failed connection. The idea is, if the connection is lost or fails, the name is appended to the end of the list, to be repeated ad infinitum until data is successfully retrieved. 2) I'm sure some of the coding techniques I'm using are cumbersome, but this is my first attempt. Please be patient, and any and all input is appreciated. 3) Feel free to adapt this to your own uses. I don't know how handy this might be, but it has improved data retrieval in my workplace tremendously. Thanks again. - Mark From mikael at isy.liu.se Fri May 26 03:17:50 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 26 May 2000 09:17:50 +0200 (MET DST) Subject: [PATCH] A compromise on case In-Reply-To: Message-ID: On 26-May-00 Nick Mathewson wrote: > >>> class NumHolder: > ... def __init__(self, num): > ... self.x = num > ... def get(self): > ... return x > ... > >>> NumHolder(5).get() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 5, in get > NameError: No such name as 'x'. Perhaps you meant 'self.x'? > > Forgetting 'self' is one of the most common beginner errors on > comp.lang.python. The extra code required to detect it: 4 lines! Beautiful! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 26-May-00 Time: 09:17:29 This message was sent by XF-Mail. ----------------------------------------------------------------------- From jkraska1 at san.rr.com Wed May 17 21:12:51 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 18 May 2000 01:12:51 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: <3923444A.ABD7182@san.rr.com> > some programming. Any fool can write unreadable code in any language. > Writing code that is unreadable to someone who is fluent in a language > is probably a sign of incompetence. Yes, but show me the STL for a vector of vectors, or the complimentary iterator for a vector of vectors. The syntactic complexity alone is enough to send a programmer running for the hills. It's no wonder that so many C++ programmers defected to Java with it's generic containers of Object, and likewise generic iterators of Object. Having learned C++ in 1985, and looking back on the last 15 years, I followed it's growth, and increasingly grew to rely on a restricted subset of the language. The horrible syntactic abberations that have descended out of the STL are a complete abomination and a sign of a major weakness in the language, IMO. > Not being able to read the code of a > competent programmer probably indicates your own level of inadequacy. You should have kept this last remark to yourself; suppose to yourself that even if you are right, sometimes right remarks in particular are best left unspoken. C/ From josh at fujitsu.co.nz Wed May 24 23:43:35 2000 From: josh at fujitsu.co.nz (Josh Robb) Date: Thu, 25 May 2000 15:43:35 +1200 Subject: Python and COM servers References: <392ACFB4.213143D4@icyb.kiev.ua> Message-ID: <8gi7hv$29m$1@thresher.netlink.co.nz> What new ADSI interface? "Mark Hammond" wrote in message news:bJIW4.2087$bZ3.11513 at news-server.bigpond.net.au... > There is no decent documentation, and there are no simple example. The > simplest example is probably the "internet" extension (that doesnt use > SWIG), or probably the new ADSI interface for one that does. > > The best docs are probably my previous postings in this newsgroup - some > going back quite some time. > > Mark From senn at maya.com Thu May 11 16:29:45 2000 From: senn at maya.com (Jeff Senn) Date: 11 May 2000 16:29:45 -0400 Subject: PalmPilot and python In-Reply-To: Jeff Collins's message of "Wed, 10 May 2000 14:11:24 -0700" References: <8fc11i$9q8$1@nnrp1.deja.com> <14617.37067.507992.310545@malibu.aero.org> <14617.52272.770628.900238@malibu.aero.org> Message-ID: Jeff Collins writes: > > FWIW- on a similar project we are considering writing a malloc-ish > > thing for the Palm that uses a records in a "scratch database" as > > "heap".... just a thought... (Gah! I wish they got PalmOS > > right-er...at least it's not WinCE...) > > Other projects (don't remember which - PocketSmalltalk, PocketForth?) > that have tried to use the DataManager for virtual memory eventually > gave up because of the speed hit. Apparently, DM accesses were just > too slow. I'd be interested to see improvements in this area. I'm aware -- but at the moment *slow* Python on my Palm is better than no Python on my Palm... > > Any psychic energy I can send along to aid the Palm port is on its > > way... > > ;-) > > There it is! Got it. Thanks;) No prob. -- -Jas From rumjuggler at cryptarchy.org Sat May 27 02:38:48 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 27 May 2000 06:38:48 GMT Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> <392f60e8.260627511@news.nikoma.de> Message-ID: On Sat, 27 May 2000 05:53:57 GMT, nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) wrote: >On Fri, 26 May 2000 06:26:23 -0700 (PDT), Darrell Gallion > wrote: > >> rzantow at my-deja.com wrote: >> : When a newsreader, browser, or mail program trashes >> : the indentation from examples of Python source, it is a >> : real pain in the hindlimbs to recover the original >> : program logic. >> >> Don't use tabs in the source, then all is well. > >Try feeding this to python, then: > >if 1 == 1: >print "This won't work" > >You'll get a SyntaxError if somebody removes all leading indentation. You could filter your scripts and replace all tabs with \t. Leading \ts would then be converted to tabs on the receiving end. -- Barnabas T. Rumjuggler In the morning I came awake as I always do, like a man trapped in a car going over a cliff. -- Russell Hoban, _The Medusa Frequency_ From shecter at darmstadt.gmd.de Thu May 25 13:50:07 2000 From: shecter at darmstadt.gmd.de (Robb Shecter) Date: Thu, 25 May 2000 19:50:07 +0200 Subject: How to "shell out"? Message-ID: <392D67CF.47BFCA8F@darmstadt.gmd.de> Hi, I want to write a python wrapper for the Linux "dialog" package. I'm having problems invoking the utilities from Python, though. The libraries I've found so far for doing this (commands module) capture the outputs and inputs of the new process, and this means that the display is never shown. Is there a library function in Python which lets it really shell out to a new process, giving the new process complete control over the terminal, and putting itself on hold until the process completes? Thanks, Robb From Wolfgang.Grafen at marconicomms.com Wed May 31 12:49:33 2000 From: Wolfgang.Grafen at marconicomms.com (Wolfgang Grafen) Date: Wed, 31 May 2000 18:49:33 +0200 Subject: memory leak on solaris 2.5.1 / 2.6 ? References: <3935126D.32AFBAA1@marconicomms.com> <3dln0qx271.fsf@amarok.cnri.reston.va.us> Message-ID: <3935429D.9C0C6491@marconicomms.com> William Annis wrote: > akuchlin at mems-exchange.org (Andrew M. Kuchling) writes: > > > Wolfgang Grafen writes: > > > >>> x = "1001" * 5000000 > > > will occupy about 22 MB. > > > >>> del x > > > doesn't decrease the amount of allocated Memory. > > > > > > With Suse-Linux the memory will be properly freed on a Intel PC and > > > a pre-compiled Python 1.5.2 version. > > > > This is probably because of the different malloc() implementations on > > the two platforms. When the request is for a large area of memory, > > Linux malloc() will use mmap() to allocate it for just this reason; on > > freeing the memory the process size will shrink when the memory region > > is unmapped. Solaris malloc() probably doesn't do this; this theory > > could be confirmed, > > Right. Solaris assumes that if you ask for a chunk of memory, > you are probably going to ask for it again later, even after a free(). What is it for? After consuming the fast silicon main memory the process slows extremely down when swapping to disk although it could demand freed memory! Wolfgang From olipt at mayo.edu Fri May 26 09:49:14 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Fri, 26 May 2000 08:49:14 -0500 Subject: DECREFing and PyArray functions in C Extensions In-Reply-To: Message-ID: I've been asked to post a follow-up to my recent post on decrementing reference counts in C extensions to Python. > The short answer is, everything must be DECREF'd. Whenever you use a > PyArray_XXXXXXX construct that gives you back a PyArrayObject, you own a > reference. You must DECREF before leaving the subroutine or you have a > memory leak. > This is still my advice, but I would reword it: Every PyArrayObject that you successfully receive from a PyArray_XXXXXX call has an increased reference count (you own a reference). Unless you are returning the object to the user (using return PyArray_Return(obj) or PyArray_BuildValue with the "N" construct) you must DECREF the object before leaving the subroutine or you will create a memory leak.. > > In the same message you later point out that a call to > PyArray_ContiguousFromObject must include a PyDECREF before returning from > the C routine. However, on page 69 of the numericalpython.pdf manual the > array "array" is not called in a PyDECREF call before a return NULL; It is > called before a successful return of the routine at the end of the code. > The calling of PyDECREF is not clear. We could all use some help on this > since memory leaks are evil. Can you post a clarifier to when PyDECREF > must be used? Thanks for any help. > I'm not sure which example you are talking about. In my version of the PDF documentation there are two examples which use "array" as a variable name: one on page 71 and another on page 72. The context seems to indicate you are talking about the example showing how to accept input data from any sequence type (my page 72). If this is the case, then the reason Py_DECREF(array) is not called for the NULL return is that if the PyArray_ContiguousFromObject call returned NULL then there is no object whose reference count needs to decremented. Note that it would not be a problem to use Py_XDECREF(array) here if it made things more clear since Py_XDECREF(obj) does nothing if obj is NULL. Py_XDECREF(obj) is used whenever you are unsure of whether or not obj is NULL. I use this call often in the fail: part of my subroutines. Let me know if I can clarify things further. -Travis From fiona at sitegnome.com Fri May 19 09:08:07 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 19 May 2000 13:08:07 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 19th, 2000 Message-ID: <20000519130807.7925.qmail@synop.com> Greets! Tonight I've entered the following into http://python.faqts.com Have a good week-end, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- Where can I find information about how to manipulate Excel with Python? http://www.faqts.com/knowledge-base/view.phtml/aid/3093 ------------------------------------------------------------- Fiona Czuczman Robert Citek I strongly recommend the "Python Programming on Win32" by Mark Hammond & Andy Robinson. Visit http://www.oreilly.com/catalog/pythonwin32 Here is some sample code: # this example starts Excel, creates a new workbook, # puts some text in the first and second cell # closes the workbook without saving the changes # and closes Excel. This happens really fast, so # you may want to comment out some lines and add them # back in one at a time ... or do the commands interactively from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.Workbooks.Add() xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!' xlApp.ActiveWorkbook.ActiveSheet.Cells(1,2).Value = 'Python Rules 2!' xlApp.Close(SaveChanges=0) xlApp.Quit() del xlApp # raw_input("press Enter ...") ------------------------------------------------------------- Is there a way to "kill" a thread that is currently asleep? Can I stop, destroy, suspend, etc. a thread that is asleep? http://www.faqts.com/knowledge-base/view.phtml/aid/3078 ------------------------------------------------------------- Fiona Czuczman Jeff Blaine From: http://www.python.org/doc/current/lib/module-threading.html "Python's Thread class supports a subset of the behavior of Java's Thread class; currently, there are no priorities, no thread groups, and threads cannot be destroyed, stopped, suspended, resumed, or interrupted...." ------------------------------------------------------------- How can I create a "rollover" effect? http://www.faqts.com/knowledge-base/view.phtml/aid/3086 ------------------------------------------------------------- Fiona Czuczman John Grayson Here is a minimal example. Choose your own images... from Tkinter import * class ActiveButton(Button): def __init__(self, master, inimage=None, outimage=None, activate=None): self.master = master self.inI = PhotoImage(file='icons/%s' % inimage) self.outI = PhotoImage(file='icons/%s' % outimage) Button.__init__(self, master, command=activate, image=self.outI) self.bind('', lambda e, state=1, s=self: s.change(e, state)) self.bind('', lambda e, state=0, s=self: s.change(e, state)) def change(self, event, state): if state: self.configure(image=self.inI) else: self.configure(image=self.outI) if __name__ == '__main__': root = Tk() button = ActiveButton(root, inimage='smooth.gif', outimage='tline1.gif', activate=root.destroy) button.pack() root.mainloop() ------------------------------------------------------------- How do I force a dump of sys.last_traceback (last traceback object) to a file object, or stringio or something similar? http://www.faqts.com/knowledge-base/view.phtml/aid/3083 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh Have a look here: http://www.python.org/doc/current/lib/module-traceback.html ------------------------------------------------------------- How do I get Python to force 'a' and 'b' into strings so that a + ":" + b concatenates instead of trying to add? http://www.faqts.com/knowledge-base/view.phtml/aid/3082 ------------------------------------------------------------- Fiona Czuczman Andy Lester, Remco Gerlich, Martijn Faassen, Scott The str() function. a = 1 b = 2 str(a) + ":" + str(b) Or use the % operator, of course. str = "%d:%d" % (a,b) ## Edited Entries ############################################## ------------------------------------------------------------- How do I write a raw string (r'...') that ends with a backslash? http://www.faqts.com/knowledge-base/view.phtml/aid/3022 ------------------------------------------------------------- Beat Bolli, Fiona Czuczman Moshe Zadka r'this ends with a ' '\\' A pure raw string cannot end with an odd number of backslashes. The above, using the fact that consecutive string literals are concatenated at runtime, is the standard workaround. From kain at cableadmin.com Tue May 16 17:51:40 2000 From: kain at cableadmin.com (Scott) Date: Tue, 16 May 2000 21:51:40 GMT Subject: Decimals -> Fraction strings, my solution Message-ID: Hi all, I've come up with one solution to my problem. Its probably quite inefficient, but it does what I need for now. Feel free to tear it apart and/or give any advice on how to better implement it. This code will take either a number or a string (ie '0.5') and return a string of the fraction (ie '1/2'). Here it is: #!/usr/bin/env python # fract.py convert numbers/decimal strings to fraction strings import string def plist (num): """Returns a list of numbers that evenly divide into num. This is seems quite inefficient and probably should be changed""" p = [] for x in range (2, num+1): if num % x == 0: p.append (x) p.append (num) return p def gcd (numer, denom): """Return the greatest common denominator of two numbers""" if denom % numer == 0: return numer p1 = plist (numer) p2 = plist (denom) p1.reverse () for x in p1: if x in p2: return x def coerce (num): """Coerce a string into a number. If not, return 0""" try: n = string.atoi (num) except ValueError: n = 0 except TypeError: n = 0 return n def makefract (dec): """Makes a fractional string from a decimial number passed in string or numerical format""" if type (dec) == type (''): if string.find (dec, '.') < 0: return dec whole_str, frac_str = string.split (dec, '.') whole = coerce (whole_str) numer = coerce (frac_str) denom = pow (10, len (frac_str)) else: if type(dec) == type(0): return str (dec) whole = int (dec) if dec - whole: numer = int ((dec - int (dec)) * \ (pow (10, len (str(dec-int(dec)))-2))) denom = pow (10, len (str (numer))) else: numer = 0 denom = 0 if numer == 0 and whole == 0: return '0' if numer == 0: return '%d' % whole gd = gcd (numer, denom) numer = numer/gd denom = denom/gd if whole: return '%d %d/%d' % (whole, numer, denom) else: return '%d/%d' % (numer, denom) if __name__ == '__main__': print '0.5625 : ', print makefract ('0.5625') print '69.4375 : ', print makefract (69.4375) print '35 : ', print makefract (35) print '38.0 : ', print makefract (38.0) From jlj at cfdrc.com Wed May 24 10:02:21 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Wed, 24 May 2000 09:02:21 -0500 Subject: How do I create extensions to Python in C? References: Message-ID: <392BE0ED.12E4DA0E@cfdrc.com> Ryan, You should start with the very good online documentation on this very subject; refer to it as writing a Python extension if you want to use the local jargon ;) The official docs for this are here: http://www.python.org/doc/current/ext/ext.html I would like to be able to point you to some good books which address this topic, but the fact is there aren't that many. Mark Lutz's "Programming Python" covers it pretty well, and despite the book's "age" most or all of the information on this topic is still up-to-date. Another book, "Internet Programming with Python" (by Aaron Waters, Guido, others?) had some material on extending Python but it was a little sketchy. I think this one is now out-of-print but you may be able to find it on-line somewhere. Once you understand the basic concepts, you should check out SWIG, a freely available tool which helps to automate a lot of the process and lets you focus on the application itself. SWIG's home page is here: http://swig.sourceforge.net If you're just wrapping basic C function calls, SWIG will do about 90% of the work for you. I am a big fan of SWIG, as I suspect are many people on this mailing list. Hope this helps, Lyle Ryan Donahue wrote: > > I new to python and would like to use it to call some C functions. How do I > do this. > > Ryan Donahue ryan at velara.com From m.faassen at vet.uu.nl Wed May 31 21:17:45 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2000 01:17:45 GMT Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934242B.ECFDBAAE@endea.demon.nl> <8h1k0q$h04$2@newshost.accu.uu.nl> Message-ID: <8h4djp$pkc$1@newshost.accu.uu.nl> Fredrik Lundh wrote: > Martijn Faassen wrote: >> > I'm not sure Alice has much of a "result" to offer on the subject. As >> > far as I can tell from the paper I have read, doing away with case >> > sensitivity was just the nearest hack available, not a decision based on >> > scientific analysis of the whole interface problem. >> >> True; I don't think there was done any double-blind research into this >> phenomenon. > I'm probably just dense, but how would you design such a > double-blind test? Construct two Python interpreters (or environments). One is case-sensitive, the other is case-insensitive. Then randomly distribute them to your newbie programmers (you need a statistically significant batch of these; don't know how many that would be). Set them a number of programming tasks. See how quickly and how well they complete the tasks, and perhaps do some measurement of their 'frustration level'. Perhaps to make it even more confusing, instruct half the amount of programmers about case-sensitivity issues (even those that end up using the case insensitive interpreters; you don't know anyway). That would seem to be a fairly double-blind test to me, right? :) Also fairly tough to be. >> It was just an anecdotal observation, perhaps in a more controlled setting >> than ours, but probably still doesn't weigh much more strongly than our own >> anecdotal observations. > As far as I understand, the Alice researchers observed that > errors caused by case *mismatches* are a real and important > problem. They don't claim that there are no better *technical* > solutions than the one they implemented. Yes, but those observations were probably anecdotal, right? They'll have more experience with this than we do, and they'll have dealt with more newbie programmers. But they'll have a bias just like anyone else. So their anecdotal evidence, while stronger than our various claims, does remain anecdotal. In science this means you can be inspired to form a theory on it, but it doesn't automatically means your theory is closer to the truth; you need empirical testing to strengthen it. (but *having* a theory is probably at least better than having no theory at all) > (iirc, alice just casefolds everything in the "reader". Which > reminds me of some recent private mail, which boldly claimed > that if you implement things in that way, your language is not > really case sensitive at all...) So you told them about setattr() and friends, right? :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Sunil.Hadap at cui.unige.ch Mon May 15 09:37:57 2000 From: Sunil.Hadap at cui.unige.ch (Sunil Hadap) Date: Mon, 15 May 2000 15:37:57 +0200 Subject: How python development is speedy! Message-ID: <391FFDB5.FC9A85CA@cui.unige.ch> Hello, I use Python,I don't know Java. I am just curious, people keep reporting that Python is very fast in development as compared to Java and C++. Is this because of language feature or because of reduced compile-run-debug cycle, or something else! When I look at my Python code, I see little difference in terms of development efficiency as compared to C++ when used with STL and other good libraries. Does the higher types such as lists and tuples make Python so powerful, after all C++ had all that. Sunil -- "Live as if you would die tomorrow, learn as if you would live forever." --Mahatma Gandhi From effbot at telia.com Tue May 30 05:51:20 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 30 May 2000 09:51:20 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <39333CC3.32805F5@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: > So what? It's also been pointed out that it's quite feasible > to define a join that makes sense for more than just strings, > and that string joining can be efficiently accommodated as a > special case. that's really a different topic. > I think that a suitably generalised join should be a builtin, > like map and reduce. your "generalized join" is someone else's "crippled reduce" (and be careful with overgeneralizations: neither "joining numbers" nor "reducing strings" make much sense...). > > or don't -- I'm sure your time could be better spent on hunting down > > real problems in the 1.6 alphas... > > Bugs can be fixed at any time. But if we don't speak up soon > before what we see as a serious aesthetic mistake becomes > entrenched, it will be too late. if you think that keeping string.join in there is the most serious design mistake in 1.6, you may be in for some really interesting surprises... From moshez at math.huji.ac.il Sun May 21 14:56:23 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 21 May 2000 21:56:23 +0300 (IDT) Subject: Integer division (was: Case-sensitivity... (was: Damnation!)) In-Reply-To: Message-ID: On 21 May 2000, Bernhard Herzog wrote: > If i/j does not do integer division, the only real solution seems to be > what Moshe Zadka proposed: introduction of a rational type with (long) > int numerator/denominator pairs. > > I'm not sure I'd like that. It sounds like a serious performance hit. Well, premature optimization is the root of all evil: much better to go for correctness, and let the user optimize memory with float(i/j) --> get a floating point approx. quotient(i, j) == int(i/j) --> get the integral part of i/j (negative number issues are undecided) > You could easily end up carrying around a lot of precision that's not > needed in many applications. And if that becomes a problem, just optimize it away. > This could be alleviated by introducing a special integer division > operator. Or a builtin function -- I doubt there is so much need for one it deserves its own little SHIFT+number character. rationally y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From punck at SpamIsBadPenguinMints.cx Tue May 16 23:50:59 2000 From: punck at SpamIsBadPenguinMints.cx (Chris Armstrong) Date: Tue, 16 May 2000 22:50:59 -0500 Subject: database choice. (gadfly?) Message-ID: Hi all. I'm looking for a local file database (ie, no server like mysql or pgresql) that is safe with threads. I've looked into gadfly, but it says that it's not really safe to do concurrent writes to the same database in multiple threads. Does anyone have any experience with this? I want to make the install of my program as simple as possible, and don't want to require the installation of MySQL or something like that, and I don't really need a high-end database. Any suggestions? thanks. -- Chris Armstrong http://penguinmints.cx Geek code version 3.12 GCS d? s:-- a--- C+++ UL++++>++++ P++ L+++ E--- W++ N+ o? K- w-- O-- !M V PS+(+++) PE? Y+(--) PGP(--) t+ 5 X+ R tv+ b+>++ DI+ D+++ G e- h!(--) r- y? Go to www.geekcode.com to find out what on earth this is. From embed at geocities.com Wed May 17 10:52:39 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 17 May 2000 10:52:39 -0400 Subject: How to reprint sys.last_traceback Message-ID: I see that the last traceback object is in the sys module as sys.last_traceback. How do I force a dump of that to a file object, or stringio or something like that? (as a python function) Warren From owski at hotmail.com Thu May 11 15:22:46 2000 From: owski at hotmail.com (owski at hotmail.com) Date: Thu, 11 May 2000 19:22:46 GMT Subject: ASP Performance Message-ID: <8ff19j$mmu$1@nnrp1.deja.com> I've got a strange problem with Python in ASP. Every request for a page causes the page to be reloaded. Including re-importing all modules. It's as if each page request is the first page request, and it can be quite slow. Last week I had it running fine where it would only 'load' on the first request, and now something has changed. Any ideas on how I can get the pages to run normal again? Thanks in advance, Adam Ruth Sent via Deja.com http://www.deja.com/ Before you buy. From oeschger at netscape.com Thu May 25 22:24:59 2000 From: oeschger at netscape.com (Ian Oeschger) Date: Thu, 25 May 2000 19:24:59 -0700 Subject: XML namespaces and xmllib Message-ID: <392DE07B.71E3F0D1@netscape.com> I don't seem to be able to turn off the namespacing support in xmllib so I can just get the unnamespaced elements and attributes. __use_namespaces, which looked like a likely place to start, gets reset as soon as I actually start parsing data, so something like this doesn't do anything for me: class XP(xmllib.XMLParser): def unknown_starttag(self, t, a): print t print a def syntax_error(self, message): pass p = XP() p.__use_namespaces = 0 ... p.feed(data) Nor does trying to set it within the event handler (e.g., self.__use_namespaces = 0). Maybe I'm overlooking something obvious here. Is there some way tohandle this w/o hand-stripping the namespace? Thanks a lot Ian Oeschger -- Ian Oeschger Principal Writer, Netscape From paul at prescod.net Tue May 30 09:41:10 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 30 May 2000 08:41:10 -0500 Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934242B.ECFDBAAE@endea.demon.nl> <393474CF.C19298A@cosc.canterbury.ac.nz> Message-ID: <3933C4F6.266AC004@prescod.net> Greg Ewing wrote: > > ... > > I ses this more as an argument in favour of having > a proper boolean type which is clearly separated from > the other types. If Python had that, things like > 'if a == 1 or 2' would produce a type error instead > of doing something unexpected. I'm all for a proper boolean type but I get annoyed when I have to test objects against null in Java. We could get a proper boolean type and still have boolean interpretations for other types. If Python were being designed from scratch I would probably have voted on the "only booleans are booleans" side. Now that its deployed and people seem to like the way it is, I would treat that fact as a more important consideration than my natural tendency towards purity. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "I want to give beauty pageants the respectability they deserve." - Brooke Ross, Miss Canada International From breiter at usf.Uni-Osnabrueck.DE Thu May 11 09:58:21 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 11 May 2000 13:58:21 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> Message-ID: <8fee9t$csg$2@newsserver.rrzn.uni-hannover.de> In article , wware at world.std.com (Will Ware) writes: > Bernhard Reiter (breiter at usf.Uni-Osnabrueck.DE) wrote: >> The FreeGIS Project (freegis.org) > > Yikes! I hope there isn't somebody out there working on an > open-source Regis-Philbin-bot. I don't get it. Please explain. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From akuchlin at mems-exchange.org Thu May 25 17:18:01 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 25 May 2000 17:18:01 -0400 Subject: Python aware editors (was: Re: syntax highlighting for Kedit) References: <8gjfi6$bke$1@nnrp1.deja.com> <392D89AB.DCD3CAEE@stud.ntnu.no> Message-ID: <3dg0r6uy5y.fsf@amarok.cnri.reston.va.us> Peter Schneider-Kamp writes: > Yeah, I know I am lazy and probably could look this up by myself, but is > there a recent list of python aware editors? > > I know of nedit/vim/emacs/fte, but there are so many. If you draw up a list, please let me know and I'll add them to the Editor HOWTO (http://www.python.org/doc/howto/editor/). The original author of the HOWTO seems to have vanished; anyone want to take over maintaining it? -- A.M. Kuchling http://starship.python.net/crew/amk/ Men of action, I notice, are rarely humble, even in situations where action of any kind is a great mistake, and masterly inaction is called for. -- Robertson Davies, _The Table Talk of Samuel Marchbanks_ From phd at phd.russ.ru Wed May 17 04:14:26 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 08:14:26 +0000 (GMT) Subject: Python / CGI / E-mail problem In-Reply-To: <3921C3C8.90A5E7C9@uklinux.net> Message-ID: On Tue, 16 May 2000, Sreekant Kodela wrote: > I tried using the MimeWriter but failed. Do you have any simple exampe by > any chance. #! /usr/local/bin/python -O import sys, os, string from mimetools import choose_boundary from MimeWriter import MimeWriter import base64 try: from cStringIO import StringIO except ImportError: from StringIO import StringIO def gen_mime(zip_file): email_from = "Oleg Broytmann " email_to = "phd at sun.med.ru" #sendmail = open("sendmail", 'w') sendmail = os.popen("/usr/sbin/sendmail '%s'" % email_to, 'w') sendmail.write("""From: %s To: %s Subject: %s Precedence: bulk MIME-Version: 1.0 """ % (email_from, email_to, zip_file)) mime = MimeWriter(sendmail) firstpart = mime.startmultipartbody("related") firstpart.write("""\ Your mailer does not support MIME encoding. Please upgarde to MIME-enabled mailer (almost every modern mailer is MIME-capable). """) subwriter = mime.nextpart() subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", "inline; filename=\"%s\"" % zip_file) subwriter.startbody("application/zip") zip_file = open(zip_file, 'r') base64.encode(StringIO(zip_file.read()), sendmail) zip_file.close() mime.lastpart() sendmail.close() def run(): zip_file = sys.argv[1] gen_mime(zip_file) if __name__ == '__main__': run() Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From erno at iki.fi Thu May 25 19:38:44 2000 From: erno at iki.fi (Erno Kuusela) Date: 26 May 2000 02:38:44 +0300 Subject: intersection References: <392D4BDC.6F339367@muc.das-werk.de> Message-ID: >>>>> "Thomas" == Thomas Thiele writes: Thomas> l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] Thomas> l3 should be [4,5] Thomas> It' s not diffucult to program it, but I couldn't find a Thomas> build-in-fucnction. Or I'm blind? there is no built-in for this as far as i know. just use a dictionary: >>> l1 = [1,2,3,4,5]; l2 = [4,5,6,7,8] >>> d = {} >>> for item in l1: ... d[item] = 42 ... >>> l3 = filter(d.has_key, l2) >>> l3 [4, 5] if you are doing a lot of set-ish things, it might be a good idea to have a look at kjBuckets at . -- erno From g2 at seebelow.org Sat May 20 16:57:41 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 20 May 2000 21:57:41 +0100 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <8g1as4$p9q$2@newshost.accu.uu.nl> <39245386.B350E309@sage.att.com> <3926363A.B1F@seebelow.org> <3925640f$0$28525@wodc7nh1.news.uu.net> Message-ID: <3926FC45.5621@seebelow.org> ben at co.and.co wrote: > > Gordon McMillan wrote: > > > You might as well ask why the Windows way does it backwards: > > zipping a tar will almost always yield better compression than > > tarring a bunch of zips (more redundancy to work with). (Yes, it's > > easier to extract one file from the latter, but that's not the common > > usage.) > > Indeed: > > $ ls -lh tartest/ > total 40k > -rw-rw-r-- 1 ben ben 1.0k May 19 18:35 test.1 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.10 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.2 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.3 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.4 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.5 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.6 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.7 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.8 > -rw-rw-r-- 1 ben ben 1.0k May 19 18:36 test.9 > > $ tar zcf tar.gz tartest/ > $ zip -r tar tartest/ > $ ls -lh tar.* > -rw-rw-r-- 1 ben ben 272 May 19 18:36 tar.gz > -rw-rw-r-- 1 ben ben 1.6k May 19 18:42 tar.zip Maybe you guys are right. You know, since I mostly use zip, I'm tempted to buy one of them fancy 13.2 gig disks for $120 just to cover cases like this. However, I'm not sure my old-dog-of-a-computer can handle a disk bigger than the 5 gig one it's already got. ;-) a-millicent-here-a-millicent-there;-pretty-soon-you're-talking -real-money--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From garabik at melkor.dnp.fmph.uniba.sk.spam Tue May 23 10:51:03 2000 From: garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) Date: 23 May 2000 14:51:03 GMT Subject: Python3k extended grammar References: <392456A9.993FB15C@concentric.net> <8g1q8u$drc$2@newshost.accu.uu.nl> <8g6bae$977$16$1@news.t-online.com> Message-ID: <959093413.711604@cdwork.cvt.stuba.sk> Thomas Malik <340083143317-0001 at t-online.de> wrote: : ... :> Oh, and 1/2 might give you :> a float. :> :> Rather minor changes. Then of course.. :> : Uff, hard hammer that, rather. How do you do integer division, then ? And I rather like pascal approach with div: 5 div 2 = 2 : what is it good for, anyway ? I mean, what's the advantage of it for : breaking many exisiting programs ? hmmm... clearer syntax, less confusing arithmetics? I agree that the sheer number of existing application outweights these advantages. : I'm surely not against improvements in the Python language, but : 1. case insensitivity sounds like complete nonsense to me. Who needs it, : actually ? my words :-) : 2. promoting integer divisions to float sounds quite stupid to me: : (x/y) * y + x % y == x should always hold true in any sane language should it? or rather: (x div y) * y + x % y which is more readable? I am parsing the first expression as: take x, divide by y, multiply by y, (that's x again), add x modulo .. oops, what is the definition of % for real numbers.. oops, what if x and y are integers... ok, I finally got it! whereas I parse the second expression as: take x, do integer division (ok, so x and y have to be integers), multiply by y (remainder remains) etc etc... oh, it introduces another keyword... a disaster / should not be used for integer division. I consider this a design flaw (FORTRAN or C suffer from this too, but there it is acceptable, since these languages were _not_ written to be easily readable). It should either promote operands to float, or to newly introduced rational type. Floats have their problems. Rational numbers have their problems. But float division is useful in physics. Rational division is useful if you want to have the result as exact as possible, e.g. in mathematics or logic. Integer division is unnatural, integer numbers are ring, not field. If you do some intensive computation in a loop using float division, you end up with rounding errors. If you use rational divisions, you face the danger of _really big_ nominators and denumerators, with unexpected overflows, unless you make them long integers and loose performance... Which is better default? Hard to decide.... But certainly not integer division. : about the optional(!) static typing, good idea. But no new interpunctuation : or keywords, please! why not, when it is justified? after all, complex numbers were not in python from the beginning.... : One reason why i've never learned Perl is that basically every character on : my keyboard is being used for some builtin variable or one of n ways to : write down an attribute access. We don't need that in Python. I fully agree. Like using / to denote two _completely_ different things: integer division and float division Sorry for flaming, I got carried away :-) -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From rekoenig at debis.com Tue May 23 08:02:18 2000 From: rekoenig at debis.com (Reinhard =?iso-8859-1?Q?K=F6nig?=) Date: Tue, 23 May 2000 14:02:18 +0200 Subject: Special question to embedding Python into C++ Message-ID: <392A734A.7FF991D3@debis.com> Hello, How can I embed Python into C++ and ship my application to an user not having Python? Is there a similar mechanism like freeze for embedded Python? Reinhard K?nig -- -------------- next part -------------- A non-text attachment was scrubbed... Name: rekoenig.vcf Type: text/x-vcard Size: 277 bytes Desc: Visitenkarte f?r Reinhard K?nig URL: From gansevle at my-deja.com Tue May 9 04:45:35 2000 From: gansevle at my-deja.com (Fred Gansevles) Date: Tue, 09 May 2000 08:45:35 GMT Subject: Iterating over items in the registry References: <2B1262E83448D211AE4B00A0C9D61B03BA7335@msgeuro1.creo.be> <8f6jvc$8d8$1@nnrp1.deja.com> Message-ID: <8f8j7c$g88$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > "Fred Gansevles" wrote in message > news:8f6jvc$8d8$1 at nnrp1.deja.com... > > In article 2B1262E83448D211AE4B00A0C9D61B03BA7335 at msgeuro1.creo.be, > > > Here is the code of a function that returns the SID of the currentely > > loggedin user. > > While it makes a nice demo of enumerating the registry, its probably not > the best way to get the current user. Try this: > > >>> import win32security, win32api > >>> win32security.LookupAccountName(None, win32api.GetUserName()) > (, u'BOBCAT', 1) > > (ie, the result is the SID, the system where the SID came from, and the > type of SID.) What I needed here was the string-representation of the SID, not a PySID instance. BTW Is there another way than `get_sid()' to get the string- representation of a PySID? I mean the representatin used in the registry, like: S-1-5-21-287209118-495725318-452798024-1257 > > Mark. > > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at rocket.knowledgetrack.com Fri May 26 18:42:49 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Fri, 26 May 2000 22:42:49 GMT Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> Message-ID: On Thu, 25 May 2000 04:20:08 GMT, Philip 'Yes, that's my address' Newton wrote: >Hi there, > >In the other P language, the standard idiom is > > for $key (sort keys %d) { ... } # (1) > >The naive approach in Python would be > > for key in d.keys().sort(): pass # (2) > >However, this doesn't make sense (I realise this). I presume that this >makes a temporary list containing the keys of d, sorts this list, throws >the list away and then does the equivalent of 'for k in None: pass'. Python returns None to remind users that sort is in place. This does what you want def sort(a): a.sort() return a for key in sort(d.keys()): pass Huaiyu From cut_me_out at hotmail.com Tue May 9 09:29:17 2000 From: cut_me_out at hotmail.com (Alex) Date: 09 May 2000 09:29:17 -0400 Subject: Future of the Python Linux Distribution References: <3916F04F.7647B829@zipzap.ch> <391790A2.26CB9618@home.com> Message-ID: Thanks for the tip, Will. But the page is still blank, unfortunately, even when I take your advice... Alex. From arkconfused at hotmail.com Wed May 3 02:10:02 2000 From: arkconfused at hotmail.com (arkconfused at hotmail.com) Date: Wed, 03 May 2000 06:10:02 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> Message-ID: <8eofrh$1bl$1@nnrp1.deja.com> Sorry for being rude or an A$$, but the question of where computer technology will be in the next 5-10 years is crazy! And the comment that Python will be a string presence, if you have learned from historical events, things like BETA, Mac, and Python have and will disappear. When it comes to technology, people want what the majority has along with lots of support! Right now, I see Python being the BETA, and Perl being the VHS. Maybe in a YEAR or TWO, Python will have gained more support in the industry, and if it doesn't, I see it being replaced just like the BETA machine's did. Who really knows where computers will be in the next 5-10 years? Remember, technolgy doubles every year and the drive for wireless devices and smart applicances has just began and will drive out newer demands on development tools, the support for these tools, and the turn around for product! In article <8ZjL4.273$CP3.3311 at news.uswest.net>, "Jeff Massung" wrote: > IMHO, C++ will DEFINITELY be here 10 years from now, as will assembler - > they are just inherent in computers - the core languages (used to make > Python, Java, Basic, etc). But I personally think that as computers grow in > speed exponentially, and the internet becomes much faster (10 years, maybe > everyone will have T1 access?) interpreted languages will be increasingly > more important and used widespread - not for sale (because the code is > needed), but rather for distribution within a business, or with other > programs, the web, etc. > > Of course I'm refering to interpreted languages as a whole. Now to just > Python. I am new to Python, but being an accomplished C/C++ programmer, I > have already begun seeing the power and use of Python. And like Java (and I > believe unlike Perl) has a great following and good programmers commited to > its success (Perl I feel is more of a "hack"ing language that people that > don't code in other languages use). > > So to conclude - I feel Python and Java will have a strong presence in the > near and far futures. Of course they will be different from how they are > today - and possibly in how they are used, but they will be there. > > Jeff > > j vickroy wrote in message <38FDB8A7.E701F81F at sec.noaa.gov>... > >Hello all, > > > >I'm relatively new to Python and am trying to gain support for it at my > >work place. To that end, I'm giving a brief (overview) presentation. > >One of the items I have been asked to consider is where will Python be > >5-10 years from now. I certainly don't know where C++ or Java will be > >in that time frame! Any ideas on where to research the future plans for > >Python would be appreciated. > > > >Thanks for your time, > > > >- jv > > > > -- ARKConfused arkconfused at hotmail.com Sent via Deja.com http://www.deja.com/ Before you buy. From cjc26 at nospam.cornell.edu Wed May 31 00:12:51 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 31 May 2000 04:12:51 GMT Subject: Marking hyperlinks in a Text widget References: <8h04jo$lgh$1@zingo.tninet.se> <8h0kn5$6pv$1@cubacola.tninet.se> Message-ID: * Andr? Dahlqvist menulis: | | Thanks for the suggestion, but this is not really what I am looking for. | I just need to find strings in a Text widget that starts with http:// or | ftp:// and change the color of them to blue and underlined. I tried | checking the IDLE source since the IDLE editor does color markup, but | it was too complex to figure out how to translate this into my little | problem. Does anyone have any other suggestions? Here's what I do in my irc client: textw.tag_config('url', foreground='blue', underline=1) textw.tag_bind('url', '', show_hand_cursor) textw.tag_bind('url', '', show_arrow_cursor) textw.tag_bind('url', '', click) urlfinder=re.compile(r'((?:http://|www\.)[^\s<>[\]{}()`"\'|\\^$]+[^\s<>[\]{}()`" \'|\\^$.?!:;\-])') l=urlfinder.split(str) for n in range(len(l)): if n%2 == 1: textw.insert('end', l[n], ('url', l[n])) # use a tuple so url can be retrieved later else: textw.insert('end', l[n]) def click(event): os.system("netscape -remote 'openURL(%s)'" % \ textw.tag_names('@%d,%d' % (event.x, event.y))[1]) Basically I'm using re.split to split the text into a list of alternating urls and non-urls. Then, I insert every other member of the list (the urls) with the url tag. The click() function shows how you can retrieve the url later. (It took me a while to figure that one out, so I figured I'd be nice and show you that too. ;) -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From mwh21 at cam.ac.uk Wed May 24 03:56:23 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 May 2000 08:56:23 +0100 Subject: EMBEDDERS--REQUEST FOR COMMENTS: References: <392B67C2.860767B4@san.rr.com> Message-ID: Courageous writes: > My presumption is that, in this instance, I don't increase the > reference count on the valuem because I've ascertained that it's a > primitive (string, int, et al). > > However, if this were a real object, I'd be doing an INCREF() on it, > and furthermore, would have to take care to do a DECREF() on what I > was assigning over. > > Do I have this right? No. In this case, PyString_AsString returns a pointer to the internal buffer of the string object. Look here: /*const*/ char * PyString_AsString(op) register PyObject *op; { if (!PyString_Check(op)) { PyErr_BadInternalCall(); return NULL; } return ((PyStringObject *)op) -> ob_sval; } You need to make a copy somehow... strdup, or somesuch presumably. Cheers, M. -- Two things I learned for sure during a particularly intense acid trip in my own lost youth: (1) everything is a trivial special case of something else; and, (2) death is a bunch of blue spheres. -- Tim Peters, 1 May 1998 From erno at iki.fi Wed May 3 17:01:12 2000 From: erno at iki.fi (Erno Kuusela) Date: 04 May 2000 00:01:12 +0300 Subject: Python for CGI w/Apache (httpdapi) References: <8epjj0$9qa$1@nnrp1.deja.com> Message-ID: You can httpdapi.RequestHandler.build_cgi_env(), which returns a dictionary. if you want to turn these into real environment variables, you can just loop over the returned dict and stuff them into the os.environ dictionary. -- erno From neelk at brick.cswv.com Tue May 23 21:16:26 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 24 May 2000 01:16:26 GMT Subject: [PATCH] A compromise on case References: Message-ID: Will Ware wrote: > Nick Mathewson (nickm at mit.edu) wrote: > > >>> print MAP(square, [1,2,3]) > > NameError: No such name as 'MAP'. Perhaps you meant 'map'? > > >>> print string.JOIN(['a', 'b', 'c']) > > AttributeError: JOIN. Perhaps you meant 'join'? > > This is definitely the coolest most ingenious thing I've seen all day, > maybe all week. The whole case-sensitivity thread was staring to grate > on my retinae, but this makes it all worthwhile. This does call for some kudos -- Nick has advanced the discussion further than 300 posts could. Neel From robin at jessikat.demon.co.uk Sat May 13 10:45:17 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sat, 13 May 2000 15:45:17 +0100 Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> Message-ID: <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> In article <391d592e$0$13925 at wodc7nh6.news.uu.net>, Gordon McMillan writes >Courageous wrote: > >>I don't get it. The code for python lists is, as plain as >>the nose on the end of my face, a resizeable vector >>implementation. Which is all well and good, but where >>are the linked lists for those of us who want insert, >>delete, and append to be O(1)? > >In practice, linked lists are O(really big 1). That is, for most usage, >Python's supposedly O(n) lists will outperform them. Trust me on >this. I've optimized a *lot* of C / C++ code by replacing linked lists >with (overallocated) realloc-ing vectors. In most cases the speed up >is dramatic (even when a linked list appears the correct structure). > >- Gordon > well it may be true for a lot of things, but it's certainly not true for insertion and deletion intensive eg from time import time def listTest(n,ntests=100000): L = range(n) h = n/2 t0 = time() for t in xrange(ntests): del L[0] L.insert(0,0) del L[h] L.insert(h,t) return (time()-t0)/ntests for n in (10, 100, 1000, 10000): print "n=%6d, t=%.10f" % (n, listTest(n)) produces n= 10, t=0.0000181000 n= 100, t=0.0000225000 n= 1000, t=0.0000681000 n= 10000, t=0.0006784000 which is clearly not O(1); arguing that making accesses O(1) is 'the right thing to do' will get short shrift from the complexity experts who will want to know about the overall usage. -- Robin Becker From bobg at emphatic.com Tue May 16 13:02:22 2000 From: bobg at emphatic.com (Bob Glickstein) Date: Tue, 16 May 2000 10:02:22 -0700 (PDT) Subject: Choice of language In-Reply-To: <3921523B.F93EF787@mindspring.com> References: <3921523B.F93EF787@mindspring.com> Message-ID: <14625.32542.132486.760008@marzipan.emphatic.com> Chuck Esterbrook writes: > Given the success, maturity, functionality and stability of the > Python programming language, as well as the ease of embedding and > extending it, has anyone in the Latte community considered creating > a Python version of Latte? Well it certainly sounds like you have! I only know a little about Python thus far (and I like what I know), but I believe it would be wholly unsuitable for and/or very difficult to adapt to the job that Latte does (as is also the case with many other successful, mature languages). The main problem is that Latte documents must mix together code and text in a syntactically pleasing way. I believe Latte achieves this in the most syntactically friendly way possible, because the syntax of the code portions of Latte is very, very simple: there are {...} constructs and \... constructs, and that's it. If you want to include {, }, or \ in text, you escape it with a backslash: \{, \}, and \\. The choice of { } and \ was made because those characters occur rarely in (English) text, so collisions between code and text are minimal. Python, on the other hand, has numerous syntactic constructs, all of which have to be distinguishable from text. This would dramatically increase the need for quoting and escaping in Latte, which would violate the overriding design consideration. Also, because Python's syntax is line-oriented and because whitespace is significant, it would be much harder to mix together code and text and preserve the layout of the original. For instance, if this were a Latte paragraph, I could embed a call to {\function} like so and the output of the function would appear integrated into the paragraph, with the surrounding whitespace intact. Latte uses a particular model to represent the lexical structure of the input document, including the whitespace surrounding each word and code construct, that does not appear workable with Python's lexical structure. On the other hand, I don't want to discourage you if what you'd like to do is Pythonize Latte. Here's what you'd have to do: concoct a syntax that allows you to represent text and code together, and then write a parser for it that can produce a parse tree in the same format as that produced by Latte's existing reader.cxx/grammar.y. You'll probably need a new subclass of Latte_Obj to represent regions of Python code, and the eval() of your new subclass would call the Python interpreter and convert the output into other Latte_Objs (like Latte_Lists, Latte_Groups, and Latte_Strs). Finally, you might want to wire up the Latte intrinsics in definitions.cxx to be callable from Python, although most of the intrinsics have Python equivalents, so this may not be strictly necessary. If you decide to undertake this project, please let me know. I'd be most curious to follow its progress and provide what assistance I can. Cheers, - Bob PS: For the benefit of other readers of this message: Latte can be found at . From usenet at inter-slice.com Thu May 11 01:09:07 2000 From: usenet at inter-slice.com (James Felix Black) Date: Thu, 11 May 2000 00:09:07 -0500 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> Message-ID: > Two big ones come to mind: using complex data structures, and > modularizing your code. Both are much easier in python. I won't dispute your second point, but I don't understand your first. [ code snipped ] > In perl, doing this is so painful to me that I'm not even going to > try it now, and it only gets worse as your data structures get more > complicated. I'm not sure exactly what you mean: %friends = { Bob => [ ], Jane => [ "Lisa", "Mabel", "Freddy" ], Lisa => [ "Mabel" ] }; for $name (keys %friends) { print "$name has these friends:\n"; for $f (@{ $friends{ $name } }) { print " ", $f; } print "\n"; } Sure looks similar, doesn't it? Of course, the de-referencing of the array reference looks bizarre, and perl doesn't have the wonderful REPL loop, but the assignment is almost completely identical to the python syntax. What I (as a perl programmer/python novice) really miss in python are true closures. Is this a language feature yet? One marvelous thing that python has, though, is reduce, which I find so massively useful that I carry it around with me in perl land wherever I go. YMMV, of course, (jfb) From Gareth.McCaughan at pobox.com Mon May 8 15:49:02 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 08 May 2000 20:49:02 +0100 Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <391645E3.3B850279@san.rr.com> Message-ID: <86aei0oma9.fsf@g.local> Neil Schemenauer wrote: > "==" works just as well. Python smart enough to try a pointer > compare first. The code path is almost the same so I doubt there > would be much speed gained by using "is". Er, surely it will fall back on a string comparison if the two aren't pointer-equal? I think concern about efficiency is misplaced here, in any case. >>> import time >>> x = range(500000) >>> y = map(str, x) >>> def test_i(): ... t0 = time.time() ... u = map(lambda t: t==5000, x) ... t1 = time.time() ... return t1-t0 ... >>> def test_s(): ... t0 = time.time() ... u = map(lambda t: t=='5000', x) ... t1 = time.time() ... return t1-t0 ... >>> test_i() 1.45546197891 >>> test_i() 1.34740400314 >>> test_s() 1.71845293045 >>> test_s() 1.70223104954 >>> 1.702/1.347 1.26354862658 If the difference in speed is only 25% here, it's unlikely to be a big deal in any real program. (I don't mean that the cost of a string compare is only 25% more than that of an integer compare; that's not the point.) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From thomas at cintra.no Tue May 30 16:27:49 2000 From: thomas at cintra.no (thomas at cintra.no) Date: Tue, 30 May 2000 20:27:49 GMT Subject: Using strings with ' in them in SQL-queries Message-ID: <39342055.1301760@news.c2i.net> Hi, I need to insert strings with ' in them in query-strings. I`m using the PostgreSQL-database. If I try stuff like this : db = _pg.connection(....) db.query('insert into test (id, name) value (1, 'fdsfds''fdsf') ') That works ok. But the string I need to insert I get from a variable. I cannot seem to use a variable in the query-string. Is there any way around this? How can I handle characters in strings that may comprimise the requirements of a valid sql-statement?? Thomas From mikael at isy.liu.se Thu May 4 21:09:56 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 May 2000 03:09:56 +0200 (MET DST) Subject: Copyright and License In-Reply-To: <391218B4.56604A0C@san.rr.com> Message-ID: On 05-May-00 Courageous wrote: > That's the understatment of the century. As a matter of legal practice, > in the United States your copyright is worthless if you don't have it > registered, most assuredly in particular if someone else does. And anything is worthless unless you have 50 lawyers to back it up. Yes, we've heard of the legal procedures of the great big brother on the other side of the pool. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 05-May-00 Time: 03:07:40 This message was sent by XF-Mail. ----------------------------------------------------------------------- From embed at geocities.com Mon May 15 11:04:41 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 15 May 2000 11:04:41 -0400 Subject: "Is-it-a-word-module" References: <391fa345.433631699@news.online.no> Message-ID: > In a indexing-module I now index alot of "words" that actually are > just a meaningless stream of characters, stuff like "translated" URLs, > other stuff generated by Internet-robots of some kind. At first I > thought I could just lookup each "word" in a dictionary, but then I > realized that alot of stuff, like names like my own, are not in the > dictionary but should be indexed. I therefore want some way of > guessing if a bunch of character actually could be a meaningful word. If all you want to filter out is URLs and CGI-jumble, why not include anything as a word that contains only letters, or at most one piece of punctuation (can't, won't). If your data is all in English, that'll do nicely. If not, and you want to be thoroughly international about it, you've got a nasty problem on your hands. Your email address showed up as garble on my screen, for example, because it's not using the same code page as me. Warren From effbot at telia.com Fri May 19 13:00:56 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 19 May 2000 17:00:56 GMT Subject: accesing socket at a lower level? References: <8fvahn$qin$1@bob.news.rcn.net> <8g0ool$q09$3@ites.inria.fr> <8g1egp$cpk$1@bob.news.rcn.net> Message-ID: Z 3 Penguin wrote: > >Hmm... What told you there were some extra bytes at the beginning? > > TCPDump Log. have you tried using any of the standard networking libraries under that tool? try running the following script under TCPDump: import urllib fp = urllib.urlopen("http://www.python.org") print len(fp.read()) the first three bytes send to the server should be "GET". if they're not, the script should raise an exception (if this happens, please post the output from TCPDump). From ge at nowhere.none Thu May 18 11:18:02 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 18 May 2000 15:18:02 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> <3923444A.ABD7182@san.rr.com> <5e27ryA9s9I5EwLG@robinton.demon.co.uk> Message-ID: In article <5e27ryA9s9I5EwLG at robinton.demon.co.uk>, Francis Glassborow wrote: >>> Not being able to read the code of a competent programmer >>> probably indicates your own level of inadequacy. Being able to restrict oneself to dealing with the output of competent programmers is a luxury that many people do not have. >However if I have a piece of code that is written by someone >whose expertise I respect and I cannot understand it then my >first question is about my own competency. Sure. But when trying to read the code of less-than-competent programmers I find that I have a much easier time with languages like Python and Modula-3 than I do with C++ and Perl. >There is a phenomenal amount of badly written code in any >language that gains any degree of popularity. True. But in my expierience I think it is usually easier to figure out what a badly written piece of Python code actually does is generally easier than a badly written piece of C++ code. This is probably due mostly to the fact that C++ is a far more complex language, and therefore I don't know some of it as well as I do Python. Figuring out what the code was _supposed_ to do is another question entirely... -- Grant Edwards grante Yow! Make me look like at LINDA RONSTADT again!! visi.com From crystalc at interlog.com Sun May 7 23:03:38 2000 From: crystalc at interlog.com (Brian Alexander) Date: Sun, 7 May 2000 23:03:38 -0400 Subject: constants? Message-ID: <7UpR4.4382$Ip.139041@cac1.rdr.news.psi.ca> Hello; I haven't seen anything about constant values in the documentation with p152. Is it possible to create constant integers, floats etc? Many thanks. Brian. From claird at starbase.neosoft.com Sun May 14 07:31:36 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 14 May 2000 06:31:36 -0500 Subject: GUIs References: Message-ID: <230A2193AC22C803.029D9BC666CF8E4F.C3CE9F1ABF2EDF5B@lp.airnews.net> In article , Andrew MacIntyre wrote: >On Thu, 11 May 2000, Richard Chamberlain wrote: . . . >> What's the general consensus about the pros and cons of these? > >That there is no general consensus. Worth repeating. > >I'm sure that with a bit of trawling you can find Gerrit Holl's (sp?) web >pages detailing vital statistics of most of the popular GUI interfaces for >Python - I don't have the reference handy at the moment :-( . . . points to it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From fredrik at pythonware.com Thu May 4 06:52:54 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 4 May 2000 12:52:54 +0200 Subject: houston python users References: Message-ID: <005f01bfb5b6$ebb9c940$0500a8c0@secret.pythonware.com> > I can just imagine it: "Houston, we have a metaclasses problem" it's actually "Houston, we have a traceback": http://www.deja.com/=dnc/getdoc.xp?AN=282212494 From embed at geocities.com Mon May 15 12:59:46 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 15 May 2000 12:59:46 -0400 Subject: Java vs Python References: <391F88EB.D25BB0F8@san.rr.com> Message-ID: "Courageous" wrote in message news:391F88EB.D25BB0F8 at san.rr.com... > > > I would just like to know how serious python is taken in the IT industry > > Python hasn't even made their radar. Recent events have proven that the computer industry is a lot less staid and unmoving than it used to be. Everybody's getting paranoid that someone else will beat them to the next big thing. That being so, I expect a big cloud of Python hype any day now. Perl had it's hype day, as did Java. > > If a web applicatoin was written in both Java and Python, > > which would companies prefer ? > > Duh. Java. This is because IT professionals pick products > that they can't get fired for picking. An old setting in > the IT industry: "nobody ever got fired for picking Oracle." > I heard it as "nobody ever got fired for buying IBMs". Then the clone industry sort of stole IBM's thunder, technological lead, etcetera. IBMs became Also Rans. So will Java. Once the hype evaporates, you have just one more language, with good bits and not so good bits. > > 1. Which is more maintainable ? > > Python. No comparison. In my humble opinion, I would put it this way: 1. It takes less python code to do something in Java 2. The Less Code you write, the less there is to maintain. As a matter of opinion, I find Python far more "readable". The syntax is clear, the built in data structures and types are simple enough to grasp, but powerful enough to be useable. > > 2. Which is more scaleable ? > > Hrm. Hard to say. Do keep in mind that a lot of your python > can connect to third party tools at native speeds, if you > learn a trick or two. Scalable up or scalable down? Python scales DOWN much better. There's a lot more overhead in making and distributing a Java application, so Java scales down poorly. On the other hand, I'd say more work has gone into Java, and using Java for what would traditionally be called a "transaction processing" (TP) system. Java has some features in it's Enterprise Java Beans architecture specifically designed to handle high volume transaction technology. This is not garden variety stuff, and not something that most small or medium sized businesses need to worry about. This is more like "I run a bank and I have 100,000 online customers accessing their account data and doing transactions at the same time" type stuff. Not everybody needs Java or Enterprise Java Beans, but some people do. For the time being at least, Python has no equivalent technology. > Well if it's performance you want, ASP and embedded COM is > probably what you want. > > *running for cover*. Performance at the price of portability, definitely. ASP + native COM interfaces in C/C++ and Com+'s transactions. The "MTS" feature of COM+ would give you speed and scalability and absolutely NO portability! You'd also be working in an environment with a lot of inertia to overcome whenever changes are required in the system. Python is great from Prototype to working systems precisely because it adapts quickly. I'd accept lower performance, use SOAP instead of COM+/MTS From what I've read and seen, Microsoft's MTS "object runtime environment" is extremely fast. Writing COM components in Visual C++ can be a pain in the butt, but if all you really need is performance, and you don't need flexibility, it's definitely going to scale up nicely. Now if you factor the Real and Messy world in, where requirements are constantly changing, you can color me Python again. I would rather maintain and develop a system in python where I can adapt quickly to changing requirements than work on a system where draining every last drop of performance from the bare iron was a driving force in the design of the system. In the end, it's not always about performance. Warren From thomas at xs4all.net Mon May 8 16:18:35 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 8 May 2000 22:18:35 +0200 Subject: using os.stat to determine stat.st_blocks on OS that supports it? In-Reply-To: <8f71l2$gnq$1@fizban.fizban.pprd.abbott.com>; from steingra@pprd.abbott.com on Mon, May 08, 2000 at 06:39:30PM +0000 References: <8f71l2$gnq$1@fizban.fizban.pprd.abbott.com> Message-ID: <20000508221835.B13281@xs4all.nl> On Mon, May 08, 2000 at 06:39:30PM +0000, Andrew Steingruebl wrote: > I'm trying to write a disk usage monitoring program. As part of it, I > need to determine actual file size/disk-blocks-used. > If I read the manuals correctly, the os.stat call, even on OS's that > support extra stat fields, does not return the st_blocks value. use os.statvfs: statvfs(path) -> (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax) Perform a statvfs system call on the given path. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mhammond at skippinet.com.au Thu May 11 21:49:35 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 12 May 2000 01:49:35 GMT Subject: Pythonwin com? References: <8ffgdr$840$1@nnrp1.deja.com> Message-ID: "Sam Schulenburg" wrote in message news:8ffgdr$840$1 at nnrp1.deja.com... > Frame = {} # Here I have to set Frame up as a tuple That doesnt look like a tuple to me? > return self._ApplyTypes_(0xa, This decoded is: > 1, > (24, 0), 24 = VT_VOID - function has no return value. > ((2, 1), (16396, 3)), 2 params: (2,1) == VT_I2, PARAMFLAG_FIN (19396,3) == VT_BYREF | VT_VARIANT, PARAMFLAG_FIN|PARAMFLAG_FOUT ie, first param in an "in" integer. second param in an "in/out" byref variant. The "in" implies it is not simply an out. My guess is that the problem is the VT_VARIANT - ie, Python doesnt know the type of the param at all - it only knows it is byref. What are the types of the objects in the array? What we can do is change the makepy definition for: > def PutFrame(self, > frame=defaultNamedNotOptArg, > FrameArray=defaultNamedNotOptArg): > """Put Frame Data""" > return self._ApplyTypes_(0xb, > 1, > (24, 0), > ((2, 1), (16396, 3)), Note the params are almost identical - we could change this to VT_BYREF | VT_I2 (or some more specific type than variant - whatever makes sense). Who wrote the object? Mark. From neilh at scintilla.org Wed May 3 19:30:40 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 03 May 2000 23:30:40 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> <390FC76A.59FB5779@san.rr.com> Message-ID: > Add to that his claim that "technology doubles ever year" is also incorrect. > To be more specific, Moore's law states that the performance of > microprocessor systems double every 18 months (not every year), and refers > *strictly* to hardware. It does *NOT* apply to software. Want proof? > Windows. It surely does. The amount of code in Windows increases with every release. My new copy of Windows 2000 feels about twice as 'heavy' as last years model. It wouldn't fit on the old partition. Neil From hzhu at rocket.knowledgetrack.com Fri May 12 15:28:07 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Fri, 12 May 2000 19:28:07 GMT Subject: NaN again - and IEEE arithmatics Message-ID: Sometime ago I asked about reading back from a file containing arrays with NaN as elements. Someone kindly suggested >>> from math import exp >>> NaN = exp(1000)/exp(1000) >>> NaN nan However this breaks in 1.6 (or maybe because it is installed on another machine). >>> import math >>> NaN = math.exp(1000) / math.exp(1000) Traceback (most recent call last): File "", line 1, in ? OverflowError: math range error Any suggestion of how to deal with it in this case? Is there a generic way? If I understand correctly, NaN is a standard feature in IEEE floating point arithmatics. So why isn't there a predefined class or object for NaN? It might go into the math or Numeric module, I think. Thanks -- Huaiyu Zhu hzhu at knowledgetrack.com From jbauer at rubic.com Wed May 17 15:32:49 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 17 May 2000 14:32:49 -0500 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> Message-ID: <3922F3E1.9A5F49DA@rubic.com> Glyph Lefkowitz wrote: > The point being, of course, more Linux users have > tar than Windows users have WinZip, and more Linux > users have Python than Windows users do; but I am > sure that GNU tar is downloaded less than WinZip. Why does this matter? Python for Windows is available (py152.exe) as a self-extracting .exe file. Jeff Bauer Rubicon Research From mikem at wetafx.co.nz Wed May 24 03:59:11 2000 From: mikem at wetafx.co.nz (Mike Morasky) Date: Wed, 24 May 2000 19:59:11 +1200 Subject: Python and Mac OS X References: Message-ID: <392B8BCE.BB2233B5@wetafx.co.nz> Jerome Chan wrote: > Does Python work with Mac OS X? There is a version that currently works with Mac OS 9 with the carbonlib library. I From z3penguin at penguinpowered.com Wed May 17 19:38:04 2000 From: z3penguin at penguinpowered.com (Z 3 Penguin) Date: Wed, 17 May 2000 19:38:04 -0400 Subject: accesing socket at a lower level? Message-ID: <8fvahn$qin$1@bob.news.rcn.net> I am working on writing python code to access the AIM servers. i have been looking at what my code sends out, and using something like from socket import +ACo- s+AD0-socket(AF+AF8-INET,SOCK+AF8-STREAM) s.send(whateverstring) tacks on some extra bytes at the beggining. this confuses the AIM servers. Any ideas? (Note: I am not good with C and am against having to write this in C) -Penguin ----- Z 3 Penguin Antarctica z3p+AEA-penguinpowered.com +ACI-You make yourself tougher by whatever means you can, and then you strike by suprise, you sneak up, you backstab, you blindside, you cheat, you lie, you do whatever it takes to make sure that you come out on top.+ACI- -Bean From 340083143317-0001 at t-online.de Sun May 28 12:02:43 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Sun, 28 May 2000 18:02:43 +0200 Subject: ANNOUNCE: TIB/Rendezvous module for python Message-ID: <8grfrg$pjv$13$1@news.t-online.com> hi, just for the people programming with TIB/Rendezvous, a commercial messaging middleware by TIBCO (http://www.rv.tibco.com): i've put a python module onto sourceforge (http://rvpython.sourceforge.net), which allows one to use the TIB/Rendezvous 5.3 API in python. The TIBCO middleware allows one to build efficient distributed applications. The python module opens the complete C++ Rendezvous API to the python programmer, plus some extensions on it, making it very easy to write distributed software & application interface software. See the web pages above for more details. Thomas Malik From neelk at brick.cswv.com Sat May 13 08:10:14 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 13 May 2000 12:10:14 GMT Subject: python improvements (Was: Re: New Language) References: Message-ID: Moshe Zadka wrote: > On 12 May 2000, Neel Krishnaswami wrote: > > > If you can declare that a variable is a machine integer or float, and > > arrays of the same, you have enough information to get about 80% of > > the speed benefit that static typing can win you. > > What about array-based member lookup, vs. dict-based? I.e., if we can > optimize foo.bar to be either a 1) compile-time error or 2) an index to > the member array, it will speed up quite a lot of code. I bet this one is really hard, because __init__ methods can contain arbitrary code; in legal Python code different instances of the same class can contain different slots. (I've seen this used extensively in real code, too -- people often write methods that add slots.) But the related problem of speeding up module name lookups isn't really a type-system problem, and can be solved independently of the type system. You could add a "static module" type that forbids mutating the module bindings dictionary after initialization, and doesn't permit the use of eval/exec statements in code defined in the module. This would allow a) fast variable lookups for all variables in a static module, and b) would allow a host of optimizations to be applied. For example, knowing all the bindings at compile time will let you know if you can replace range() with an in-C for loop that doesn't have the heavy object overhead. > > Before static typing for speed is tried (with its complicating > > effects on implementation), I think it's better to go for the > > factor of 2 improvement that can be won via easy tricks like method > > caches, variable lookup optimization, and reducing function call > > overhead. (Look at Squeak Smalltalk for an example.) > > Can you give some kind of reference, beside the Squeak Smalltalk > source code? How easy are the tricks? Most are pretty straightforward -- the things you think of first when you think "How can I speed up Python?" For example, Squeak stores caches method lookups so that it doesn't have to do nested dictionary lookups to find a method on each call. I think the reason it hasn't been done in Python yet is because it needs cycles -- a class needs to know about its subclasses to tell them when the cache becomes invalid. > > Note also that it can be hard to declare 'machine integer' as a > > type, if type-class unification becomes reality and you can > > subclass Integer. > > Not if we have a type system which will allow you to say "an int, > and nothing else. Not a subclass". I'm very much in favour of such a > type-system, but I'm a minority -- this seems an OPT-based target, > and most type-sig people are ERR people. You should *definitely* look at Squeak, then. They have defined a subset of Smalltalk that the image can recognize as translatable into C, and can optimize the hell out of. Neel From urner at alumni.princeton.edu Mon May 29 01:15:23 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 28 May 2000 22:15:23 -0700 Subject: Compact syntax for 0-matrix? References: Message-ID: Alex wrote: > >How about this: > >from copy import copy > >def zeromatrix (n, m): > line = n * [0] > matrix = map (copy, m * [line]) > return matrix I like it. >I agree with the guy who said you should check out Numeric Python, >though. It will probably work out to be more flexible for you, in the >long run. > >Alex. I've used Numeric Python some. However, in a teaching context, I don't want to hide anything from view. NumPy doesn't always meet my criteria in this regard, even though it is fast and useful. I'm not doing really big matrices, and speed isn't really important. But good advice in any case, and I appreciate it. Plus I like your function. Teaches me something. Kirby From dirck.IsGettingTooMuchSpam at pacbell.net Mon May 22 12:19:32 2000 From: dirck.IsGettingTooMuchSpam at pacbell.net (Dirck Blaskey) Date: Mon, 22 May 2000 09:19:32 -0700 Subject: Damnation! (was: Re: Python3k extended grammar) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <392877EE.4992@esatclear.ie> Message-ID: Russell Wallace wrote in message news:392877EE.4992 at esatclear.ie... > ... > Quick question: Any chance of removing the requirement for colons at the > end of class, def, if, for, while lines? That's the only thing about > Python's syntax I truly dislike, and I still keep tripping up on it; > pretty nearly all the rest I find fine. When I brought this up a couple of months ago, no one seemed to think it was a good idea. I implemented the hack just for fun, though I haven't actively been using it. (Fired it up recently during a discussion: "do single line if statements need colons?" on c.l.python). The primary argument seemed to be: 1) Guido doesn't like Optional Anything (...One-Obvious-Way...) 2) The colons make the code *slightly* more readable If you are interested in the whole discussion or want the code, it's available at http://www.danbala.com/python/colopt d From keating at mech.uq.edu.au Sun May 7 23:42:02 2000 From: keating at mech.uq.edu.au (Tony Keating) Date: 8 May 2000 03:42:02 GMT Subject: Reading fortran 'unformatted' binary files Message-ID: I'm sure this has been asked before, but I can't seem to find any information on deja or on the web. How can I get python (with Numpy) to read in arrays from a file created from a fortran code? I've looked at a package called numpy-signaltools, but the RPM seems to be missing a number of files (so it doesn't work). Anybody have any simple solutions? Tony. -- Tony Keating [http://www.mech.uq.edu.au/~tonyk] Department of Mechanical Engineering, University of Queensland, AUSTRALIA From BgPorter at NOacmSPAM.org Thu May 25 21:29:13 2000 From: BgPorter at NOacmSPAM.org (Brett g Porter) Date: Fri, 26 May 2000 01:29:13 GMT Subject: Python performance notes... References: <392A2ED5.6A35B754@san.rr.com> <8gjcc1$nam$1@nntp9.atl.mindspring.net> <1BgX4.91233$R4.523653@news1.rdc1.nj.home.com> <392DBEAB.B5147578@san.rr.com> Message-ID: "Courageous" wrote in message news:392DBEAB.B5147578 at san.rr.com... > > > Except your version will run *much* slower given a large dataset. > > map's are implemented using balanced tree algorithms, while the python > > example is using a hash table. > > The SGI hash_map<> would have been a better choice. > STL maps are an example of trying to cram in the > kitchen sink, IMO. hash_map woulda been good, yes, but I don't have the SGI STL on my machine. I haven't instrumented the code, but a quick eyeball comparison of the two using the full text of 'Crime and Punishment' shows the C++ version on my machine to be at least as fast as the Python, balanced trees or not. I took Aahz' original point to be that since the Python version could be written significantly faster than a C version, there was a class of problems where that metric alone makes Python the clear winner. I was more interested in the speed of development issue, which for this one case, choosing C++ allowed me to write the solution as quickly as I might have in Python, without sacrificing execution speed. From thiele at muc.das-werk.de Tue May 9 09:30:56 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 09 May 2000 15:30:56 +0200 Subject: Calling a program and read its stdout (UNIX) Message-ID: <39181310.A6706499@muc.das-werk.de> Hallo! I want to call a (shell-)command from a python program and read its standart output. I also want to set the user and the enviroment before. At first I did the following: I forked a new process and replaced it by calling execv. But so I'm not able to read the stdout, because I cannot change stdout - fileobject. (Changing these objects doesn't affect the standard I/O streams of processes executed by os.popen(), os.system() or the exec*() family of functions in the os module.) (from py_doc) And if I use os.popen() I can read the output, but I cannot set the user and the enviroment because popen opens a new shell. Is there someone who can help me? Thanks Thomas From sabren at manifestation.com Mon May 8 17:46:56 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Mon, 8 May 2000 17:46:56 -0400 (EDT) Subject: import modules at runtime In-Reply-To: <8f6jd5$7mg$1@nnrp1.deja.com> Message-ID: On Mon, 8 May 2000 martin_valiente at my-deja.com wrote: > Hi * > > Is there a way to create an object instance giving its classname at > runtime? Hey Martin, how's this? :) >>> class C: ... pass ... >>> def makeNew(className): ... return getitem(globals(),className)() ... >>> makeNew('C') <__main__.C instance at 80dac50> Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From paul at prescod.net Tue May 9 16:25:49 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 09 May 2000 13:25:49 -0700 Subject: HTMLParser tag contents References: <3913CBAA.64BB@seebelow.org> <8f773p$i1f$1@nntp9.atl.mindspring.net> <39191553.26AA@seebelow.org> Message-ID: <3918744D.1FD9B23D@prescod.net> Grant Griffin wrote: > > Therefore, for Python 1.6, I would like to recommend that SGMLParser be > modified to provide a method called "get_tag_contents" (or whatever) > which can be called at the point of any "end_xxx" to convey the tag's > contents (which would include not only text but contained tags and their > text.) (The reason SGMLParser has to be modified is that its index into > its "rawdata" array is local to its parser routine.) You could be parsing a 100MB HTML/SGML document 1 K at a time. I don't think you want SGMLLIB to keep around the entire 100MB "just in case" you ask for the contents of the BODY tag. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Art is always at peril in universities, where there are so many people, young and old, who love art less than argument, and dote upon a text that provides the nutritious pemmican on which scholars love to chew. -- Robertson Davies in "The Cunning Man" From pinard at iro.umontreal.ca Mon May 8 17:59:36 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 08 May 2000 17:59:36 -0400 Subject: PyBalsa? In-Reply-To: Henning Schroeder's message of "Tue, 9 May 2000 00:42:24 +0200" References: Message-ID: Henning Schroeder writes: > *But* it lacks one important "feature": speed. Try parsing a mailbox > (using mailbox.UnixMailbox) with 600 messages and compare it with > e.g. mutt. So a C module would be essential. I know I'm cheating, as Babyl files are a bit simpler to parse than `mbox' files, yet I was recently surprised by the blazing speed of parsing a Babyl file in pure Python, through some careful use of `string.find'. My impression is that the same could be done for `mbox' as well, with a bit more of attention. By the way, I choose to not fully rely on the modules in the Python library, as they do more work than I really needed, and I felt (without checking) they would slow things down significantly. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From a.kupries at westend.com Wed May 10 14:55:36 2000 From: a.kupries at westend.com (Andreas Kupries) Date: 10 May 2000 20:55:36 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> <39144E9E.4928C7E2@tismer.com> <39184C59.DD33AA67@tismer.com> Message-ID: Jeff Senn writes: >Christian Tismer writes: >> BTW the Kaffe code was interesting, especially how the JIT works. >> I'll look into this again, but not for Java. ::)) > Ah yes... I looked at it a bit when he first was hacking. > Food for thought: > Several times I have considered what it would be like to have a > 'simple-unified-VM' that supported continuations (if not full > continuations -- then at least micro-threading) and could run > Python, Java Script, Ruby, ... [Visual] Basic?, Perl??, > ... Java????... > It would not really be that hard -- I would give up type-strength > and speed-performance in the first go-round in favor of a tiny and > simple extremely portable VM that applied an extensible library of > primitive functions to Python-style dynamically typed objects on the > heap. http://mini.net/pub/ts2/minotaur.html (Forth underneath) -- Sincerely, Andreas Kupries ------------------------------------------------------------------------------- From tamer at tammura.at Thu May 18 11:53:17 2000 From: tamer at tammura.at (Tamer Fahmy) Date: Thu, 18 May 2000 17:53:17 +0200 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> Message-ID: <392411ED.8645F174@tammura.at> Thomas Wouters wrote: > > On Thu, May 18, 2000 at 10:30:58PM +0100, Grant Griffin wrote: > > > BTW, why to you Unix people separate your packager gizmo from your > > compression gizmo? Very strange... > > Strange ? Really ? I find it strange you would want to put different > functionality into one program... Packing and compressing are two different > things, so why force one program to do both ? :) > > So much better to seperate the functionality: If you get a new version of > the compress utility, or a new compress utility that does it so much better, > you wont have to change anything in the packing utility. And the other way > 'round. And decent packaging utilities provide support to magically include > compression, by calling the appropriate compress utility itself... GNU tar > has support for standard unix compress (.Z), gnu zip (.gz) and bzip2 (.bz2) > this way, and you can tell it to start any program you wish, with the > '--use-compress=' option. > > Just like there isn't a Wordperfect or Word-alike program on (traditional) > UNIX; no all-encompassing Word-processor. Instead, you edit using your own > favorite editor, passing it through your own favorite text formatter, to > translate it to a file format of your choosing. And just like Mosaic, long > ago, didn't provide support for all protocols itself, but rather let other > programs take care of them... You can see a lot has changed in the UNIX > world, in this regard :-) Not only that. Because it seperates them - it compresses them much better. Why? Because the tar utility packages all the files in to a single file and runs the desired compression algorithm over it instead of just zipping every single file and putting it compressed into the archive... Never-be-rude-to-an-arab-and-especially-not-to-a-Linux-user'ly y'rs, Tamer. -- -////- | Tamer FAHMY, cs student at the univ. of technology Vienna --o o -- | irc, fics: tuhtah --- < --- | web:http://www.tammura.at/ mailto:tamer at tammura.at - v - | Support bacteria -- it's the only culture some people have! From loewis at informatik.hu-berlin.de Mon May 29 11:49:34 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 May 2000 17:49:34 +0200 Subject: python logical objects? References: Message-ID: "Michal Wallace (sabren)" writes: > I've been thinking about how objects relate to one another, and it > occurred to me that there's a use for "ad hoc" rules. One common approach is to model this closely to the real world. For every interaction between two object in the real world, also have an interaction between the programming objects. You'll find that interactions are often drawn using sequence charts during design. If such stuff interests you, I recommend reading a book about OO analysis and design. They often propose a notation in the book as well; I'd chose one that use UML these days. > For example, suppose you maintain an online grocery store, and the > manager comes to you and says she wants to offer a sale: buy two eggs > and get a free can of spam. How do you code it? Is it a method of a > Product or Cart or Spam or Egg class? Does it go in a Specials class? > Some kind of Coupon mechanism? What if its a temporary sale, and next > week you get one free egg with every can of spam? So how does the interaction work in your store? The customer picks some products. What next: a) the store operator suggests: together with what you've got, you can get such and such for a reduced price. b) the customer needs to select the additional products herself, and the sale is only considered at the cashier. In the second case, it is really the salesperson that knows all the sales, and compares them with the goods purchased. So clearly, the algorithm computing the total needs to have knowledge about all the products being purchased, and special sales available. > Which roughly means: "The price of spam is 0 if you bought 2 eggs. > Otherwise, the price of spam is 1". (I'm only vaguely familiar with > prolog, so this might not be the "best" way to do this, but it works.) The problem may not be the way to write this down, but the algorithm to compute the total. There are a number of options for such algorithm, such as: a) take one special after another, and see whether they match. If they do, compute the price for the special, and check-mark the goods involved. When all special sales are done, add the price of the remaining goods. b) try to find the minimum price, in case there is overlap between the specials. There are probably different algorithms to do so, one is: detect all special sales that potentially apply. Then apply algorithm a) for all permutations of the sales. > Better yet: is anyone else interested in doing something prolog-ish > with python? It appears that continuations, as provided by the stackless Python, offer a nice approach to back-tracking. It is not that much the presentation of the facts that is tricky - I believe an OO language does much better than Prolog here. It is the problem solving algorithm, which is partially implicit in the Prolog system, but more explicit in an OO language. Having back-tracking to explore the solution space should give you equivalent expressive power. Regards, Martin From tismer at tismer.com Wed May 3 18:30:28 2000 From: tismer at tismer.com (Christian Tismer) Date: Thu, 04 May 2000 00:30:28 +0200 Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F1FA2.8E57AC51@tismer.com> Message-ID: <3910A884.AEE3CD05@tismer.com> Konrad Hinsen wrote: > > Christian Tismer writes: > > > If it should be necessary to make Java stackless > > in order to convince Guido, I'd even go that way. (ROTFL:-)) > > I see it's time to create an association that fights against the > threatening extinction of stacks. Stacks of all computers, unite! Yeah, that's true. Stacks are too weak. Unite, and fear my final POP -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From nascheme at enme.ucalgary.ca Sun May 7 23:56:11 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 May 2000 03:56:11 GMT Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> Message-ID: Charles Boncelet wrote: >When running vim with syntax coloring on, sometimes I get >strong, dark colors and sometimes weak, pastel ones. I >have no idea why the colors vary. Anyway, how can I always >get the strong, dark colors? You haven't given enough information for me to help. Are you using the editor on the same machine? In the same terminal? There is nothing in python.vim to cause this behavior. >Or, does anyone have a python syntax file of which they are >proud and willing to distribute? I don't know about proud but mine is already distributed with Vim. Version 5.6 doesn't seem to include my latest changes. You can get the current version from: http://www.enme.ucalgary.ca/~nascheme/vim/syntax/python.vim Extra highlighting is available in the latest version. I believe that Bram will be including it in the next release of Vim. Neil -- "Applying computer technology is simply finding the right wrench to pound in the correct screw." -- Tim Wright, Sequent Computer Systems. From ivanlan at home.com Sun May 7 23:58:06 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Sun, 07 May 2000 21:58:06 -0600 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: <39163B4E.AA23F3E4@home.com> Hi All-- Michael Hudson wrote: > > Glyph Lefkowitz writes: > > > Vetle Roeim writes: > > > > > - age. the other "P" language[0] has been around a little longer.. right? > > > > I hear this tossed around a lot. How *much* longer? > > I think perl was born in 1987 and Python in 1991. Not sure about > either of those though. > It came out at least as early as '86. > [biggo snippo] > > Unfortunately, one of the best features of the python community is > > that it seems to have a sane group of people in it who know multiple > > languages and will choose appropriate ones for the appropriate task. > > We need more rabid, unabashed evangelists. :-) > > Why? > > [little-o snippo] > > > [1]: I like Lisp, but it *does* have a PR-problem. > > > > Lisp *IS* a PR-problem. Lisp needs to change its name and shed some > > syntax before it's ever going to get 'mainstream' acceptance; the > > ideas in lisp are good, but too many cs students have been tortured > > with it ... > > Lisp needs to *shed* some syntax? What are you smoking? Lisp has no > discernable syntax (and that's arguably one of it's better features). > Have you read "Lisp: Good News, Bad News, How to Win Big" by Richard > P. Gabriel? It's well worth a read: > > http://www.naggum.no/worse-is-better.html > > IMHO, Lisp has not entered the mainstream because people are too > close-minded to realise that something can be both different from what > they are used to and yet a good thing. Not that modern lisp is > perfect, but it's flaws aren't insurmountable given, say, one tenth of > the money that's gone into Java. > This may all be true, and I do agree that lisp is both different and good, but nonetheless it can be beastly difficult to write clean code and get it debugged. Use Python and the barrier you have to overcome to write unclean code is vastly higher. In fact, I would go so far as to say that if you write obfuscated Python code you're doing it on purpose and have all the skills and talent to write perfectly clear code. > Cheers, > M. > > -- > it's not that perl programmers are idiots, it's that the language > rewards idiotic behavior in a way that no other language or tool > has ever done -- Erik Naggum, comp.lang.lisp > -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From petersc at stud.ntnu.no Mon May 22 06:18:26 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 22 May 2000 12:18:26 +0200 Subject: Decimals -> Fraction strings, my solution References: <3922bbbb.59529999@client.ce.news.psi.net> <3922E238.29CEDE3B@stud.ntnu.no> <39242f0a.1044508290@news> Message-ID: <39290972.4F2BF6E@stud.ntnu.no> "David C. Ullrich" wrote: > > Why does Python's implementation of modulo make > this a good idea? Is there a problem with the "original" > > def gcd(a, b): > while a: > a, b = b % a, a > return b > > that I've just never found? Hei David! Actually the only problem I see is that the outcome is negative. return abs(b) would of course also solve that. Additionally I wrote "while a > 0:" which of course makes problems for negative numbers... :-7 > The reason the counter-quibble seems worth > mentioning is that the abs makes it much less generic: > Without the abs you can use the function for any > objects with a __mod__ method (assuming that a has > to eventually become false for some reason). For > example you can use it to find the gcd of two > polynomials a and b, if you give your polynomials > an appropriate __mod__. (I don't think there's any > such thing as an appropriate __abs__ for polynomials...) Good point. As all the important number theoretical relations still hold there is no problem with that. sometimes-missing-something-obious-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From m.faassen at vet.uu.nl Sat May 27 18:53:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 May 2000 22:53:06 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <000201bfc6d3$08650320$c52d153f@tim> Message-ID: <8gpjki$h70$2@newshost.accu.uu.nl> Tim Peters wrote: [snip] > Les, Guido has been talking about this for *years*. I don't know why c.l.py > never noticed before, but it was an old topic long before this thread began. In fact it's very funny; I've mentioned the case-insensitivity bit a couple of times in the recent months on this newsgroup. I've however always included the Standard Pythonic Flamewar Suppressor; a reference to evolutionary biology, Haskell or Aristotelian philosophy. I never thought this made any difference, until someone *else* responded to the same question about Py3K in *without* this Flamewar Suppressor. *then* all hell broke loose. I therefore conclude that use of the Flamewar Suppressor actually *works*. Not that this entire discussion was a flamewar, though it got close in several places (including this one). Mostly it has been moving into tangential topics, such as old terminals and causality in Latin. Still, look at what a little disclaimer line can do. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From parkw at better.net Thu May 11 22:07:20 2000 From: parkw at better.net (William Park) Date: Thu, 11 May 2000 22:07:20 -0400 Subject: Import without a .py file In-Reply-To: <391B58DF.4605438B@rochester.rr.com>; from mross@rochester.rr.com on Fri, May 12, 2000 at 01:03:55AM +0000 References: <391B58DF.4605438B@rochester.rr.com> Message-ID: <20000511220720.A3852@better.net> On Fri, May 12, 2000 at 01:03:55AM +0000, Michael Ross wrote: > > I would like to accomplish the equivalent of an import, but store module > code in a database (rather than in .py files). > > Is there any way to create a module using code that did not originate in > a file? For example, I can get the text for the code into a string > object, and then I'd like to say > > s = ...string containing code with classes and functions... > import module using s > > obviously I can't do that, but something equivalent would be nice. > > > Thanks! > Mike Ross exec(s) --William From tismer at tismer.com Thu May 25 12:36:22 2000 From: tismer at tismer.com (Christian Tismer) Date: Thu, 25 May 2000 18:36:22 +0200 Subject: Python performance notes... References: <392A2ED5.6A35B754@san.rr.com> <392A6959.7479936@tismer.com> <392AAF35.AA1E5542@san.rr.com> Message-ID: <392D5686.1E1552F3@tismer.com> Courageous wrote: ... > > Empty loops don't happen in reality, and it makes limited > > sense to compare a Python loop against a compiler, which in > > this case even has the chance to optimize the full thing > > away. > > Well, it didn't change it to i=i+100000, if that's > what you mean. What I was really testing was the > cost of the increment operation, establishing a worse > case. We already know that the best cases are better, > but doing the worse case allows us to compare to other > worse case situations, IMO. A friend of mine wanted > to know what the loop cost was, to compare it to TCL > as a watermark. I see what you want, but not why. Comparing worst cases from artificial construct which don't occour in real programs might be fun, but might be as well be misleading. If a decision maker reads "Python loop == 100 * slower than C", this is bad for everybody. Comparing typical cases can lead to better decisions. I't talk about an "extreme case", but then turn to a "realistic case". So, a more typical case would be: - a loop - some operations on Python objects Given that, the loop cannot be optimized away. You have the following mapping then: Python script C translation ------------- ------------- loop construct C loop loop jump C jump interpreted object ops C calls to object ops Well, comparing these gives you a bit more than optimizing the loop from Python into C; it also translates some other bytecode operations, but keeps using the high level objects. Pretty much what P2C would produce. Measuring the exact loop overhead in both versions could be acomplished quite easily by duplicating the object operations. > > The calling overhead of the objects in your code is still > > there, and unless you leave Python totally and use native > > C structures all the time, you will not gain much more > > than 30, maybe 40 percent of speed by avoiding the interpreter. > > Well, that's interesting, any pointers which prove this, > or is this experience speaking? This is experience, from lots of experiments with speeding Python up, using the P2C translator, and so on. After it became clear to me that there is this 40% limit, unless you do massive program analyses, I stopped thinking of optimizing the current interpreter any longer. but-started-to-think-of-much-more-drastic-things-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From dalke at acm.org Fri May 12 03:00:08 2000 From: dalke at acm.org (Andrew Dalke) Date: Fri, 12 May 2000 01:00:08 -0600 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> <5v+rnIBnysG5Ewoc@robinton.demon.co.uk> <391C7B1D.2D3D@seebelow.org> Message-ID: <8fga08$vgj$1@slb0.atl.mindspring.net> Grant Griffin wrote: >My complaint with Python as a learning language is that it spoils you. >Just as it's hard to convice BASIC users of the need to declare >variables in C, [...] Getting off-topic - The last time I did BASIC was in '92 with QBasic. (An algorithm and GUI for finding the crystal cell shape and size from x-ray powder diffraction images, if you have to ask :) . I vaguely recall new-fangled syntax using % or some other characters used to specify the data type. Or maybe it was a DIM statement? (Searching ... ah-ha! Both are right: http://www.geocities.com/SiliconValley/Bay/5707/qbasic.html ) Anyway, I used them because it gave a performance advantage. I assume VB has similar syntax? Then explaining declarations to BASIC programmers these days should be straight-forward; just say C always expects you want performance so you always have to state the type, but C only has one way to do that. Now I'm recalling fondly all those old BASIC programs I wrote. Mmmmm, BASIC programming. Andrew dalke at acm.org From wayne.izatt at myself.com Mon May 22 17:30:03 2000 From: wayne.izatt at myself.com (Wayne Izatt) Date: Mon, 22 May 2000 21:30:03 GMT Subject: translating Perl Cookbook? References: <12113.000523@satunet.com> Message-ID: <3929A6DE.C3FF17FB@myself.com> A somewhat similar effort is "The eff-bot Guide to the Python Standard Library" by Fredrik Lundh. Its a great way to quickly apply standard library functions to everyday problems. The Perl Cookbook, however, is a great deal deeper and includes excellent explanations of how everything works. I keep it handy for its algorithms, even when I'm coding in Python. That said, the eff-bot book is only available as eMatter from fatbrain, and my experience with them has been nothing short of a nightmare - 7-day turnaround on email; the same, broken, version of the pdf file sent twice; an idiotic copy-prevention scheme that prevents me from using the text unless I'm online and not behind a firewall. Worst of all, its a Windows-only system. Still, I reccommend it highly. (If we could get enough volunteers together, perhaps we could split up the Perl Cookbook, and each deliver one fully translated and explained recipe every other week or so). Oh, for a 36-hour day! cheers steven2 at satunet.com wrote: > Hi, > > Just wondering if anybody is interested in translating the recipes > (and as much as the other code snippets) from The Perl Cookbook into > Python. > > I understand that some code will not translate smoothly or produce > "optimal" Python code, but the purpose is to help people with Perl > background to learn and master Python faster -- as they will tend to > expect Python to be able to do many of the tasks they previously > accomplish using Perl. A greater proportion of the recipes in the Perl > Cookbook is not about Perl syntax, but about doing common tasks, so > perhaps we should concentrate on those parts first. > > I hope this will be a fun project; being a Perl coder and currently in > the Python learning curve, I thought that working on this project will > be a great way to learn Python for me. :-) > > If there is enough interest, I will setup an account at SourceForge to > host this project so that people can contribute code. > > Regards, > Steven Haryanto From chuyser at flash.net Mon May 1 08:38:35 2000 From: chuyser at flash.net (Cindy Huyser) Date: Mon, 01 May 2000 07:38:35 -0500 Subject: Trouble with Pmw ComboBox get() Message-ID: <390D7ACA.5CB91267@flash.net> I have a form on which I am using several combo boxes to get information. I have been using the info to build a tuple to pass to a function, and it's been working well. Now, suddenly, all I get from the get() function are the default selected values; I'm beginning to suspect I have a mean hidden character somewhere. Any ideas? The code declaring the boxes and then getting info from them is pasted below. Regards, Cindy Huyser self.courseCombo=Pmw.ComboBox(self.courseCRow1, entry_width=8, listbox_width=10,dropdown=1, scrolledlist_items=self.courses) self.courseCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.courseCombo.selectitem(self.courses[0]) self.facultyCombo=Pmw.ComboBox(self.courseCRow1, listbox_width=10,dropdown=1, scrolledlist_items=self.faculty) self.facultyCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.facultyCombo.selectitem(self.faculty[0]) self.dayCombsCombo=Pmw.ComboBox(self.courseCRow1, entry_width=6, listbox_width=10,dropdown=1, scrolledlist_items=self.dayCombs) self.dayCombsCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.dayCombsCombo.selectitem(self.dayCombs[0]) self.startTimeCombo=Pmw.ComboBox(self.courseCRow1, entry_width=8, listbox_width=10,dropdown=1, scrolledlist_items=self.startTimes) self.startTimeCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.startTimeCombo.selectitem(self.startTimes[0]) self.timeBlockCombo=Pmw.ComboBox(self.courseCRow1, entry_width=10, listbox_width=10,dropdown=1, scrolledlist_items=self.timeBlocks) self.timeBlockCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.timeBlockCombo.selectitem(self.timeBlocks[0]) self.roomsCombo=Pmw.ComboBox(self.courseCRow1,entry_width=12, listbox_width=10,dropdown=1, scrolledlist_items=self.allRooms) self.roomsCombo.pack(side=LEFT, expand=1, padx=5, pady=2) self.roomsCombo.selectitem(self.allRooms[0]) self.labCheck=Checkbutton(self.courseCRow1, text="", state=NORMAL, variable=self.labStatus) self.labCheck.pack(side=LEFT) (LATER...) def addClass(self, courseToAdd=None): while len(self.newCourse)>0: del self.newCourse[0] # Function works for passed parameter and combo box read if not courseToAdd: self.newCourse.append((self.courseCombo.get(), self.facultyCombo.get(), self.dayCombsCombo.get(), self.startTimeCombo.get(), self.timeBlockCombo.get(), self.roomsCombo.get(), self.labStatus.get())) else: self.newCourse.append(courseToAdd) self.getIndices(self.newCourse[0]) # Find conflicts and append them to conflicts dictionary foundConflict=self.findConflicts(self.newCourse[0], self.courseIndices) # If conflict found, prompt the user if foundConflict==1: answer=askyesno("Conflict Detected", "Adding this course will produce a conflict. Do you want to schedule it anyway?") if answer==1: # Append the class to the list of classes self.schedule.append(self.newCourse[0]) # Append the course to the course dictionary for item in self.courseIndices: self.classSchedule[item].append(self.newCourse[0]) # Course schedule has been updated; send course to make room changes self.grid.redraw(1, self.newCourse) else: # Undo the change to the conflicts dictionary self.removeConflicts(self.newCourse[0], self.courseIndices) elif foundConflict==0: # Append the class to the list of classes self.schedule.append(self.newCourse[0]) # Append the course to the course dictionary for item in self.courseIndices: self.classSchedule[item].append(self.newCourse[0]) From fig at oreilly.com Thu May 4 09:19:14 2000 From: fig at oreilly.com (Stephen R. Figgins) Date: Thu, 04 May 2000 13:19:14 GMT Subject: Installing numpy References: <3910b8e1.0@news2.cluster1.telinco.net> Message-ID: <3911776F.25845625@oreilly.com> I don't have a C compiler installed on my Windows system, so I haven't ever tried compiling the source code. Was there some reason you didn't want to use the precompiled version? If you get the zip file all you have to do is unzip it into your Python directory (using a tool like winzip.) It will create some directories for NumPy and put a .pth file in the Python directory so Python picks up the path next time you run it. That should be all you need do. Stephen R. Figgins Python DevCenter http://www.oreillynet.com/python From djc at itga.com.au Thu May 11 19:58:41 2000 From: djc at itga.com.au (Dave Cole) Date: 12 May 2000 09:58:41 +1000 Subject: Bolting a Bison/Flex parser into Python References: Message-ID: <878zxgfxla.fsf@heresy.itga.com.au> >>>>> "Clint" == Clint Olsen writes: Clint> Hello: I have this desire to write a parser using GNU Bison and Clint> then allow people to write Python code to use the objects built Clint> by the parser. I'm not quite sure how to design this, and I'm Clint> not sure if I'm approaching the problem in the correct way. [snip] Clint> My motivation for doing this is to create a rock solid parser Clint> using Bison (I've had experience with this before), and using Clint> the Pyton/C API to allow Python programmers to to write Clint> programs using lists and dictionaries I create. Clint> This allows me to accomplish two things: Clint> 1) I have a C interface to write programs to hook up to my Clint> parser should I need the speed of C. 2) People who don't want Clint> to get bogged down by C++/C can use a higher-level interpreted Clint> language to get work done much quicker using the same parser. Clint> I don't have to maintain two parsers. [snip] Clint> So, my question is this: Is my objective reasonable, and can Clint> you point me in a general direction in the Python documentation Clint> for accomplishing this task? I don't think embedding the Clint> Python interpreter into my C program is necessarily what I Clint> want, but perhaps someone here has had some experience with Clint> this type of application. This will keep me from making poor Clint> decisions from the beginning that could make the task more Clint> complicated. Not sure if it is a reasonable way to go because you have not provided enough information to make that decision. I imagine that it would not be too hard to achieve what you want to do. One of the big reasons for using bison is that the parser is going to be pretty fast. Certainly much faster than the same thing in Python. You did not mention the structure, volume, and typical usage patterns on your data, so it is a bit hard to make a good recommendation. If you are dealing with a large amount of data of which applications typically access less than 10%, then you could benefit from a technique I have used here to speed Python programs by an order of magnitude. By loading all of the parse tree into native C structures, you retain compatibility with the non Python applications. You could then wrap those native C structures with Python proxies on demand. If the Python program does not access an attribute, then do not create it. References to child parse tree nodes are handled in exactly the same way. When a reference to a child node is used, create the proxy for the child and cache the reference in the proxy for the parent node. If you need any more explanation, I would be more than happy to help you out. - Dave From phil at geog.ubc.ca Mon May 15 12:32:31 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 15 May 2000 09:32:31 -0700 Subject: OpenDX Python Wrapper -- any interest? References: <20000515112219.C1304991@vislab.epa.gov> Message-ID: Randall Hopper writes: > A while back I wrote a Python wrapper for OpenDX, complete with > callbacks to Python and exceptions thrown across the DXL layer. Before I > devote any time toward preping, packaging, and posting it, I thought I'd > first see if any others are interested in this tool (e.g. to build Python > apps which use DX for graphics/visualization under-the-hood). > Yes, I'm trying to ween some government colleagues off of IDL and would be very interested in a Python/DX wrapper. There's a chance I will have a coop student funded next year to work on visualization tools for the Canadian GCM and for Landsat 7/Terra/Aqua imagery, I'll know in October. Regards, Phil Phil Austin INTERNET: phil at geog.ubc.ca (604) 822-2175 FAX: (604) 822-6150 http://www.geog.ubc.ca/~phil Associate Professor Atmospheric Sciences Programme Geography #217 University of British Columbia 1984 W Mall Vancouver, BC V6T 1Z2 CANADA From lexberezhny at email.msn.com Tue May 2 21:56:52 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Tue, 2 May 2000 21:56:52 -0400 Subject: Designing an Application Message-ID: Hi, I am not sure if this is appropriate to this list but I though I would try anyway. I am writing a Grade book program using a gadfly database, and a PyGTK front end. I split everything up into a database library (all the SQL stuff, and database initialization), grade book library (class definitions for a student, assignment, etc), and an interface.py GTK file. Here is an stripped down student class: class Student: def __init__(self, studentID): student = database.getStudent(studentID) # runs the SQL query and returns a student list self.Name = student[0] self.Grade = student[1] etc... My future goal would be to allow the teacher to add his or her own properties to a student, and maybe even add independent object (ie a teacher wants to keep track of the favorite animals of each student, so there would be an object for an animal maybe, and a property in the student table to relate to the animal table, something to that effect, etc..) Well I can not think of a good way to implement this without putting a few hacks together. I guess what I'm trying to do is create dynamic classes? Or is there some other way to do this? Any suggestions or experience tips would be greatly appreciated. On a side note I am doing this for a school project, so I'm learning as I'm going along and willing to read any documentation, etc. - Lex Berezhny From tismer at tismer.com Sat May 6 12:55:58 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 06 May 2000 18:55:58 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> Message-ID: <39144E9E.4928C7E2@tismer.com> Glyph Lefkowitz wrote: > > Christian Tismer writes: > > > Well, I got the Kaffe sources. This was easy. > > Yay open source! Kaffe is really quite nice. I hear they've even > fixed the lack of BigDecimal, etc... > > > Now I'm trying to get the Blackdown Sources, since I'd like to read > > the green threads implementation. These should be sitting in some > > patches, I think. Whether I'll work on either of them is still > > open, but I want to read them. > > I'd recommend against reading them. They will make your brain dirty, > in two ways: you will have to look at Sun source code (green_threads > was not implemented by blackdown) and you will end up being unsuitable > for cleanroom efforts such as Kaffe and Classpath. Aaahh. Good advice. Is Classpath something where I should look at, too? > > Searching since hours, I cannot find their patches, just all the > > mirrors with binaries. Does anybody have an idea where to get them? > > Yes. Sign an NDA with Sun and I'm sure they'll be happy to give them > to you. If you're not on the blackdown team, you can't get the code > which they have written, because Sun owns it under NDA. Gulp! No I won't do that :-) > I don't think I will have any success with convincing you not to do > this, but PLEASE consider doing something other than working on Java, > especially Sun's Java. Java-the-language is really just dumb (no > function pointers, no macros, no closures ...) and java-the-platform > is so non-functional it's a wonder anyone uses it at all. Well, not really for Java or Sun, but for JPython it is necessary to modify Java, probably. Well, do you have an alternative idea where I should implant Stacklessness and continuations, with more feedback than in Python? Python is too small to find enough supporting people, I'd like to leave the small corner and get more publicity for this stuff, and a community to work on it. But where to go? Tcl. Hmm, I'm not an expert on Tcl, but probably the wrong users. Perl. Much users. But I remember headaches when I looked into the code, shudder. NOH!. List, Scheme. They already have it. C/C++ compilers. A nightmare, probably. To make it quite clean, the compilers must be changed to be enabled to turn stacks into heaps on demand. And that for many copmpilers... no chance. Java. Well, somewhat promising, since it gets so much hype and is really used (although you're right, the reasons a weak). But this stuff is again on the machine specific part, so I'd have to do it for many VMs. And what is there for Windows??? > Stay good, Chris, stay good sigh...help...whatshouldIdo... ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From effbot at telia.com Thu May 11 11:10:50 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 15:10:50 GMT Subject: Extract links from html-page References: <391a8ea7.100679489@news.online.no> Message-ID: <_3AS4.6766$Za1.106211@newsc.telia.net> thomas at cintra.no wrote: > I`d like to extract just the links in a web-page or html-document. It > would be nice if relative links like ' href="/source/test_pyt.tgz">Logo in a page at > http://www.test.site.org became > "http://www.test.site.org/source/test_pyt.tgz" in the end too, but ... from the eff-bot archives: # # extract anchors from an HTML document # # fredrik lundh, may 1999 # # fredrik at pythonware.com # http://www.pythonware.com # import htmllib import formatter import string import urllib, urlparse class myParser(htmllib.HTMLParser): def __init__(self, base): htmllib.HTMLParser.__init__(self, formatter.NullFormatter()) self.anchors = [] self.base = base def anchor_bgn(self, href, name, type): self.save_bgn() if self.base: self.anchor = urlparse.urljoin(self.base, href) else: self.anchor = href def anchor_end(self): text = string.strip(self.save_end()) if self.anchor and text: self.anchors.append((self.anchor, text)) if __name__ == '__main__': URL = "http://www.pythonware.com" f = urllib.urlopen(URL) p = myParser(URL) p.feed(f.read()) p.close() print "anchors =", p.anchors print "title =", p.title From mwh21 at cam.ac.uk Tue May 30 08:08:14 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 May 2000 13:08:14 +0100 Subject: auto increment operator?? References: <3933001E.D63F1A46@uniserve.com> <20000530132103.A469@xs4all.nl> Message-ID: Thomas Wouters writes: > Not that it isn't a very helpful operator, in C, regardless of the > underlying assembler :-) I would like to see the +=-style operators in > Python, as they (imho) clearly fit in, and using '+= 1' is not that much > more typing than '++'. It also stays an assignment statement, and it still > *looks* like an assignment operator. I hope Guido or someone with Guido's > ear (or permission) in time grabs Michael Hudsons' patch and incorporates it > into the CVS tree... Hopefully even before 1.6, but I'm not putting up any > bets ;-P To make this more likely modify my patch so that one can implement __addeq__ (or equivalent) methods, but so Python falls back to __add__ in the default case. This requires a large rewriting of the patch, btw, and my finals start in less than a week... Cheers, Michael -- 42. You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From jam at quark.emich.edu Sat May 27 19:49:05 2000 From: jam at quark.emich.edu (Jeff) Date: Sat, 27 May 2000 19:49:05 -0400 Subject: Getting Variables from a file In-Reply-To: <39305B84.A06745E9@bioeng.ucsd.edu>; from cjensen@bioeng.ucsd.edu on Sat, May 27, 2000 at 04:34:28PM -0700 References: <39305B84.A06745E9@bioeng.ucsd.edu> Message-ID: <20000527194905.A25643@quark.emich.edu> On Sat, May 27, 2000 at 04:34:28PM -0700, Curtis Jensen wrote: > I have a text file of the form: > > (var = integer) > dof = 8 > elements = 10 > mesh_dof = 300 > . > . > . > . > > I want to read the file from within Python and then create a variable in > python of the same name as what is in the text file, and holding the > assigned value. Assuming I don't already know the names of the > varialbes; how do I do this? I can do the file I/O, but how do I change > a character string into a variable name? Thanks. > use 'exec': [~] [7:47pm] [jam at quark-pts/2] % python Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> exec("dof=8") >>> dof 8 For more information, check here: http://www.python.org/doc/current/ref/exec.html Hope that helps. Regards, J -- || visit gfd || psa member -- From claird at starbase.neosoft.com Mon May 29 05:22:21 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 29 May 2000 04:22:21 -0500 Subject: Makefiles [offtopic] References: <392D3795.8B6D59CA@san.rr.com> Message-ID: In article , Konrad Hinsen wrote: >Fran?ois Pinard writes: > >> Courageous writes: >> >> > What *is* the best tool for managing builds? >> >> I do not know, but it will likely be written in Python! :-) > >And it might not be so far away: > http://software-carpentry.codesourcery.com/ . . . Software Carpentry certainly intends to create it. For a glimpse of what's available now, see -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From n89553 at stud.upb.de Mon May 8 10:35:58 2000 From: n89553 at stud.upb.de (Mirko Liss) Date: Mon, 08 May 2000 16:35:58 +0200 Subject: Python Front End to Dos Progrrams? References: <8eurti$2dt$1@ssauraab-i-1.production.compuserve.com> Message-ID: <3916D0CE.A85E9EDB@stud.upb.de> James Pannozzi wrote: > Has anyone ever written a Python front-end to DOS based programs in which > the user clicks on a menu and then the Python program generates the correct > set of goofy dos app keypresses and sends it to the dos app? Is this > do-able? I suppose you need two different things: a. The python equivalent of the expect - command which is available under Unix. expect parses the standard output of an application and feeds to its standard input. There are various packages available at ftp.python.org or at the Vaults of Parnassus. Some are plain wrappers around Unix's expect, some emulate expect. b. A Python GUI toolkit to create window frames, buttons, etc. Tcl/Tk and Tkinter are already included into the W95 Python Distribution. You might only need some documentation how to use Tkinter. wxPython suits me fancier, but that's just my own silly opinion. friendly regards, Mirko -- M Li?, Tel 05251-740120 From jwiegley at inprise.com Wed May 17 13:58:46 2000 From: jwiegley at inprise.com (John Wiegley) Date: 17 May 2000 10:58:46 -0700 Subject: Auto-insert of colons in Emacs Message-ID: Why hobble your mind with a detail the computer can figure out for itself? It's very strictly defined where a colon should go in Python, so it makes little sense that humans should be bothered with this detail. If it makes the code more readable for those who didn't write it, I can understand; but the author has better things to think about. Accordingly, the following snippet of Emacs code will ensure there is always a colon where it should be. You should never have to type them again, except when you want the whole statement to fit on one line. To use it, just put everything after the "----" in your .emacs file. Enjoy. This was written for users of python-mode.el (http://www.python.org/emacs/python-mode/) ---------------------------------------------------------------------- (eval-after-load "python-mode" '(progn (defvar python-keywords-wanting-colon '("def" "class" "if" "while" "else" "try" "except" "finally" "for" "lambda")) (defvar python-kwc-regexp nil) (require 'advice) (defadvice py-newline-and-indent (before always-insert-colons activate) "Always make sure that colons appear in the appropriate place." (unless (eq (char-before) ?:) (let ((here (point)) insert-colon already-has-it) (save-excursion (beginning-of-line) (save-excursion (if (search-forward ":" here t) (setq already-has-it t))) (unless already-has-it (unless python-kwc-regexp (require 'regexp-opt) (setq python-kwc-regexp (concat "\\s-*\\<" (regexp-opt python-keywords-wanting-colon t) "\\>"))) (if (looking-at python-kwc-regexp) (setq insert-colon t)))) (if insert-colon (let ((last-command-char ?:)) (py-electric-colon nil)))))))) From DOUGS at oceanic.com Sat May 27 14:05:53 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 27 May 2000 08:05:53 -1000 Subject: vars between classes Message-ID: <8457258D741DD411BD3D0050DA62365907A1AC@huina.oceanic.com> Maybe what you really want to do is the following. It may be you're confusing class construction and inheritance and the effects of instantiation: #!/usr/local/bin/python class first: class_var = 0 def __init__(self, var): self.var = var first.class_var = var self.myMethod() def myMethod(self): print "first:", self.class_var second(self.var) print "last:", self.class_var class second(first): def myMethod(self): print "second:", self.class_var first.class_var = 3 def test(var): first(var) if (__name__=='__main__'): test(2) From m.faassen at vet.uu.nl Wed May 31 21:21:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2000 01:21:50 GMT Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934A8F5.520B858C@prescod.net> <8h325e$6fo$2@newshost.accu.uu.nl> <39357B5A.2317BE98@endea.demon.nl> Message-ID: <8h4dre$pkc$2@newshost.accu.uu.nl> Niels Diepeveen wrote: > Martijn Faassen schreef: >> And it would seem to be very hard to do away with booleans >> on the semantic level; is there any programming language that does without >> 'and' and 'or' equivalents? > Early BASIC, I think. It's not too hard to get rid of "and" and "not", > for example, write "if a and not b" as: > if a: > if b: pass > else: > ... Ah, right; true. I hadn't thought of that. Messy. But then we're talking about early BASIC. :) > Doing without "or" gets messy if you don't have "goto". Nested if-elses > with a single boolean operator is probably something most people can > deal with. One would hope so! If we were evil trolls we'd pull a Greg Ward and post a message by Guido claiming he wants to get rid of 'and' for this reason. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From spamfranke at bigfoot.de Sun May 7 14:47:24 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sun, 07 May 2000 18:47:24 GMT Subject: passing methods/functions References: <39151C30.B1C60EC4@san.rr.com> Message-ID: <3915b9d0.2925923@news.btx.dtag.de> On Sun, 07 May 2000 07:29:48 GMT, Courageous wrote: > >Passing around "pointers to functions" is something I intrinsically >understand, but if an instance of an object passes a reference to >one of its methods, how does python keep track of the instance? A "bound method" basically keeps a pair of references - to the method and the instance: >>> class C: pass >>> class C: ... def a(): pass >>> C.a >>> C().a Stefan From paul1brian at my-deja.com Mon May 29 10:19:54 2000 From: paul1brian at my-deja.com (paul1brian at my-deja.com) Date: Mon, 29 May 2000 14:19:54 GMT Subject: EJB and servlets with JPython Message-ID: <8gtu9s$f80$1@nnrp1.deja.com> Can anyone tell me if there are any good resources / articles on using JPython to create EJB components or just simple servlets ? ------------- paul1brian at yahoo.com Sent via Deja.com http://www.deja.com/ Before you buy. From wtanksle at dolphin.openprojects.net Sat May 13 15:53:02 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 13 May 2000 19:53:02 GMT Subject: Augmented assignment (was RE: Why should I switch to Python?) References: <000101bfbca3$8a554b40$3f2d153f@tim> <391DA871.DDBAC4DE@do.not.use> Message-ID: On Sat, 13 May 2000 14:09:37 -0500, Russell Turpin wrote: >Tim Peters wrote: >> .. Python has a long & unbroken history of adding more "mere >> syntactic sugar" with each release, and I don't think any >> addition of that nature has been regretted, except for the >> extent to which "lambda" snuck in on that basis. >Who would regret lambda? Guido, for one. He points out that it doesn't fit into the language -- its syntax is all wrong, and the scoping rules you need/want to work with it are very different from the scoping rules Python enjoys. Me? I hate the whole lambda calculus, not because of what it is, but because of what many people think it is. They think that it's the whole of computer science, the ultimate way to express and reason about programs, when in reality it's merely a shabby and incomplete model of how Fortran fails to work. The first thing SICP has to do is teach everyone how bad the lambda calculus model is -- as part of teaching them about a language allegedly based on lambda calculus. I'm sorry, was my bias showing again? :-) >Russell -- -William "Billy" Tanksley From jwbnews at scandaroon.com Sun May 21 22:51:55 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 21 May 2000 19:51:55 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: In article , Fran?ois Pinard wrote: > "John W. Baxter" writes: > > > 8. Francois: "Why Scheme adopted case insensitivity is a mystery to > > me." > > > My guess is, as with domain names, timing, and the difficulty of > > writing > > lower case on KSR-33 Teletypes and upper-case-only glass teletypes. > > KSR-33 Teletypes? I am not sure if we really think the same thing, but > your > are referring to those machine guns working at 110 bauds? Those > engineering > wonders made up from the assembly 2500 distinct _mechanical_ pieces!? > With the paper tape reader/puncher option? I'm not sure such really > abound > nowadays. I once believed that Scheme was invented for the homo sapiens. > :-) No..the ones with reader/punches were ASR-33. ;-) "Keyboard send/receive; Automatic send/receive" Those are the ones...and they were followed with "glass teletypes" which were also uppercase only (and of course some expensive ones which weren't). And then the character-only displays went away (leading to increasingly silly graphical effects and finally to ads on web pages). For that matter, it looked for a while as if the "raceway" terminals would win out over the bitmapped (via a character-generator ROM). [In raceway, the beam traced out a pattern over each character position, with the beam turned on and painting non-background in those portions of the raceway pattern which would make the desired character.] >From Teletype, lower case showed up in the KSR-35 and ASR-35. --John (who also dealt with the Model 28 Teletypes (or were they Model 18s?) specialized for weather bureau use...symbols, not letters...and who dutifully trooped up to MIT's weather RADAR room with Prof Wurtele to try to "see" Sputnik....) [There were also machines like the TX-0, where the CPU had the job of painting white or not painting white at each and every bit position on the screen, for each and every refresh cycle.] -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From kn216 at my-deja.com Thu May 18 02:53:31 2000 From: kn216 at my-deja.com (kn216 at my-deja.com) Date: Thu, 18 May 2000 06:53:31 GMT Subject: Oracle+Zope problem Message-ID: <8g0417$7tu$1@nnrp1.deja.com> Hello I'm trying to get ZOracleDA (DCOracle) to accept some formatting options, but it doesn't work. Commands like cursor.execute("BREAK ON deptno") return with an 'Invalid SQL statement' - error. With Zope I do: BREAK ON deptno SELECT ... and it results in the same error. Any thoughts? Thanks, Kris Sent via Deja.com http://www.deja.com/ Before you buy. From DOUGS at oceanic.com Sat May 27 22:49:12 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 27 May 2000 16:49:12 -1000 Subject: making a string a given length? Message-ID: <8457258D741DD411BD3D0050DA62365907A1AF@huina.oceanic.com> [Z 3 Penguin asked:] > i need to > make a string > (like +ACI-abc+ACI-) a given number of bytes long. [to which Emile van Sebille replied:] > > Or, in 1.6: > > >>> "hello".rjust(20) > ' hello' > >>> "hello".ljust(20) > 'hello ' > To be complete, an example from what I wrote yesterday: line = string.center(string.join(spam,", "),61)[0:61] These three functions of the string module don't truncate, so if you want it no longer than "a given number of bytes" use the slice. -Doug- From effbot at telia.com Mon May 8 16:44:57 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 08 May 2000 20:44:57 GMT Subject: Arg. Silly question! References: <3913BBF0.5F255D1E@san.rr.com> Message-ID: Courageous wrote: > Arg. I'm getting a headache. :) > > (And I ordered my copy of Guido's Essential Python 2 days > ago, but don't have it yet). I assume you mean David Beazley's "Python Essential Reference"? From mwh21 at cam.ac.uk Tue May 30 16:35:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 May 2000 21:35:25 +0100 Subject: Is it just Syntactic Sugar ? References: <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> <20000530213957.E469@xs4all.nl> Message-ID: Johann Hibschman writes: > Thomas Wouters writes: > > > No, I have more faith in the idea that += is an *in place* add, for mutable > > types. > > But then it loses its most basic utility, namely working with > integers. An integer is not a mutable type. > > A simple rewrite is the only way to make sense of > > i += 1 -> i = i + 1 > > if i is an integer, given the existing python variable semantics. But it's not the only way to make sense of a.b.c[item(d)] += e which you'd like to be roughly equivalent to t1 = a.b.c t2 = item(d) t1[t2] = t1[t2] + e or a.b.c.__add_item__(item(d),e) depending on whether a.b.c is an instance that implement the appropriate magic or not. Cheers, Michael -- Arrrrgh, the braindamage! It's not unlike the massively non-brilliant decision to use the period in abbreviations as well as a sentence terminator. Had these people no imagination at _all_? -- Erik Naggum, comp.lang.lisp From matt at virtualspectator.com Tue May 30 06:05:00 2000 From: matt at virtualspectator.com (matt) Date: Tue, 30 May 2000 22:05:00 +1200 Subject: sort and delete ? Message-ID: <00053022342901.01027@localhost.localdomain> Hi, Is there a more "pythonic" way to do the following, which, before I make a mess is, suppossed to assess whether to throw elements out of a list and then actually do so. I use a rather strange, but database-like, list. a = [['egg', [1, 'ace', 3]], ['apple', [1, 'two', 3]], ['pear', [4, 'three', 6]], ['orange', [5, 'two', 1]]] x=[] for i in a: if i[0][1] in ('ace','three'): x.append(i) regards Matt From fredrik at pythonware.com Fri May 26 03:54:07 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2000 09:54:07 +0200 Subject: CGI Debugging References: <8gl95d$2n8$1@gxsn.com> Message-ID: <020401bfc6e8$4ccb2fc0$0500a8c0@secret.pythonware.com> richard_chamberlain at ntlworld.com wrote: > I'm having great difficulties getting Python to work via CGI. > > Is there anyway I can get the traceback on to the web page so I know what's > happening? the easiest way is to split your CGI module in two parts; use the following script as a wrapper, and place the program logic in a separate script ("my- script.main()" in this case): #!/usr/bin/env python import cgi, StringIO, sys, traceback try: import myscript myscript.main() except: print "Content-Type:", "text/html" print file = StringIO.StringIO() traceback.print_exc(file=file) print "
    "
        print cgi.escape(file.getvalue())
        print "
    " > I haven't got access to error logs so I can't look at it that way. From frankc at colconsulting.com Fri May 5 07:25:03 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Fri, 05 May 2000 07:25:03 -0400 Subject: Copyright and License References: <000601bfb662$d0d47ce0$d02d153f@tim> Message-ID: <3912AF8F.45FF9B5A@colconsulting.com> Tim Peters wrote: > > [Frank V. Castellucci] > > I'm looking for something more along the lines of the Python GPL. There > > is a Python accepted (Open Source) license, but it points back to the > > Python specific one. > > I don't understand what you're saying. Assuming nobody else does either, > that may explain why you're not getting the answer you want . > > There is only one CPython license, at > > http://www.python.org/doc/Copyright.html > > > I guess I can assume that changing the copyright > > owner in the statement is fine for now. > > You certainly cannot change the copyright owner! The only thing you're > required to do is to reproduce the copyright notice (verbatim) in your > documentation. As the page explains, there's no GNU copyleft intent here -- > you're merely being asked to acknowledge that your work incorporates Python, > which is itself under such-and-such a copyright notice. The real intent of > that appears to be to create some legal smoke so that Python's sponsoring > organizations can't be sued for your use of it. > > > And FYI: I am asking because of starting a open development project. > > That's fine. Fine too if it's a closed project. Python is free for all. > > even-the-military-ly y'rs - tim Tim, Thanks for the feedback , but it's not the point. I don't want to change the copyright owner on anything. This is for new code. Frank "A nod is as good as a wink to a blind horse" From thomas at xs4all.net Sat May 20 18:42:26 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 21 May 2000 00:42:26 +0200 Subject: CGI Authentication form passthrough question In-Reply-To: <8g73qs$206q$1@news.tht.net>; from darcy@vex.net on Sat, May 20, 2000 at 10:33:00PM +0000 References: <3C1077AC64755A57.0FB8B24AA3155646.CE4465C98A055096@lp.airnews.net> <3925E44A.33B90279@bigfoot.com> <8g73qs$206q$1@news.tht.net> Message-ID: <20000521004226.O13281@xs4all.nl> On Sat, May 20, 2000 at 10:33:00PM +0000, D'Arcy J.M. Cain wrote: > Don't use a form for the password. Use the built in login/password facility > in the Apache (You do use Apache, right?) web server. Actually, this authentication method isn't Apache-specific, it's part of the HTTP standard. It's very useful, but not necessarily for all occasions; for instance, 'forgetting' credentials is cumbersome, though most browsers 'forget' the username/password when the browser restarts, wether you want it or not. Browsers and webservers are also picky about where you want authorization, and it's tricky to make a single script sometimes require a password and sometimes not, unless you start writing the HTTP headers and decoding the responses yourself. Nothing's-perfect-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From emile at fenx.com Sat May 27 16:48:20 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 27 May 2000 13:48:20 -0700 Subject: making a string a given length? References: Message-ID: <024a01bfc81c$ec7fc820$1906a8c0@fc.fenx.com> Or, in 1.6: >>> "hello".rjust(20) ' hello' >>> "hello".ljust(20) 'hello ' Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Moshe Zadka To: Z 3 Penguin Cc: Sent: Saturday, May 27, 2000 1:46 PM Subject: Re: making a string a given length? > On Sat, 27 May 2000, Z 3 Penguin wrote: > > > For a python program to interface with gnutella, i need to make a string > > (like +ACI-abc+ACI-) a given number of bytes long. is there anyway to do this > > without having to write my own function? > > string.fill? > > > -- > http://www.python.org/mailman/listinfo/python-list > From pinard at iro.umontreal.ca Fri May 12 18:55:14 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 12 May 2000 18:55:14 -0400 Subject: plain text python source -> HTML syntax highlighted source In-Reply-To: Chuck Esterbrook's message of "Mon, 01 May 2000 09:30:00 -0400" References: <390D86D8.C2B85A45@mindspring.com> Message-ID: Chuck Esterbrook writes: > I know there's a program out there that reads python source and spits > out an HTML version with syntax highlighting. However, I don't remember > where I saw it and my searching and skimming on Parnassus missed it. > Does anyone know where I can get this? I merely use GNU `enscript' for that, like this: lines = os.popen('enscript -p- -Whtml -G -E%s %s' % (language or '', input)).readlines() The variable `language' contains the string `python' for Python code. If None, `enscript' will guess the language from the file extension. (I merely wanted to force `.cgi' to mean Python.) P.S. - For the curious, the above lines are taken from: http://www.iro.umontreal.ca/contrib/recode/lib/distroweb.py -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From claird at starbase.neosoft.com Thu May 18 03:36:04 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 May 2000 02:36:04 -0500 Subject: Internet Programming with Python References: <3_LU4.2949$86.52249@news2-win.server.ntlworld.com> Message-ID: In article <3_LU4.2949$86.52249 at news2-win.server.ntlworld.com>, richard_chamberlain wrote: >Hi All, > >I'm about to start a internet project and have decided to use Python. > >My local bookshop has this book instore, is it worth purchasing or is the >material too out of date? . . . Both, sort of. It's a good book, and Python's sufficiently conservative that you certainly can program from it success- fully with current software. On the other hand, there're a lot of newer features and changed organization that it, of course, doesn't cover. There's real value in the book. For many readers, there's even more value in one of the more recent books. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From itamar at maxnm.com Sun May 21 07:06:05 2000 From: itamar at maxnm.com (Itamar Shtull-Trauring) Date: Sun, 21 May 2000 14:06:05 +0300 Subject: Is unpickling data a security risk? Message-ID: <3927C31D.4022850@maxnm.com> I'd like to store a pickle somewhere on the Internet (specifically, on Freenet - http://freenet.sourceforge.net). Other people may be able to change this pickle to whatever they want to. At some point I'm going to load this data (or what it was changed to) and unpickle. Is this a security risk? That is, does the act of unpickling cause any code in the pickled object to be executed? If the data is not what I want I don't mind, my application will check that. -- Itamar S.T. itamar at maxnm.com From petersc at stud.ntnu.no Sat May 13 08:42:49 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Sat, 13 May 2000 14:42:49 +0200 Subject: correct round of reals? References: Message-ID: <391D4DC9.A561F3E1@stud.ntnu.no> "Dennis E. Hamilton" wrote: > > It seems easy enough to tell if IEEE rounding is being done in this > case. Convert some simple fractional values that have exact > representations in IEEE floating point and confirm that you get the > expected result. Hei Dennis! My concern is less about wether IEEE rounding is done on a specific platform but that I want to do IEEE rounding (to-nearest-integer-or-whatever-it-is-called mode) for platforms that do not export the rint(3) function. There is HAVE_RINT from the configure script (thanks to Guido for the configure magic) which tells me whether this function is available. Now I feel it is a good idea to provide a function rint which behaves exactly the same on those platforms where HAVE_RINT is not set. The problem lies int the "behaves exactly" part. > 2. A more important question may be, what you want the integer result > for? There is nothing sacred about the IEEE rounding rule although it > offers a kind of mathematical purity. If your desire is to preserve > exact arithmetic, you may be better of scaling everything to integers > (even the python long integer, if you need more than about 15 digits), > only showing decimal fractions in the output. If fractional > intermediate results are possible, you then have further questions to > answer concerning how to reduce intermediate results to integers for use > in further calculations. This surfaces all of the questions that we > sweep under the carpet by blindly using floating-point calculations. I > guess this is what people mean about the difference between accuracy and > precision! As said above I want math.rint to behave consistent across different platforms. More directly put I want to have deterministic behaviour for my python code. If I do math.rint(3.5) and get 4.0 I want to get it on all platforms. So what I want is determinism by consistency. I personally do not care about accuracy or precision. > The pyNum folks may have dealt with fine rounding control of the IEEE > floating-point unit, because control of the rounding mode is often > important in assuring the accuracy of numerical functions. You may have > to look in the C Libraries underneath pyNum for ideas of what you might > be able to use from there. I haven't looked myself so this is a wild > guess. Good idea. I should ask them. really-astonished-how-floating-point-arithmetic-turns- out-to-be-such-a-beast-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From effbot at telia.com Tue May 9 13:16:06 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 17:16:06 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: tony summerfelt wrote: > i think something like the following is pretty hard to beat: / line noise snipped ;-) / > which is basically a 5 line simple uniq program. and then he wrote: > correct me if i'm wrong, but a duplicate of the last line is > what's checked? well, isn't that what a "uniq" program is supposed to do? $ man uniq ... DESCRIPTION The uniq utility will read an input file comparing adjacent lines, and write one copy of each input line on the output. The second and succeeding copies of repeated adjacent input lines will not be written. Repeated lines in the input will not be detected if they are not adjacent. ... we cannot read perl, and we cannot read your mind... but I can try (reading your mind, that is). maybe this does what you want? import fileinput, sys uniq = {} for line in fileinput.input(): uniq[line] = None uniq = uniq.keys() uniq.sort() sys.stdout.writelines(uniq) From brand_hunt at my-deja.com Wed May 3 12:20:05 2000 From: brand_hunt at my-deja.com (Brand Hunt) Date: Wed, 03 May 2000 16:20:05 GMT Subject: Python for CGI w/Apache (httpdapi) Message-ID: <8epjj0$9qa$1@nnrp1.deja.com> Hi, I wrote a couple of Python CGI scripts that run fine on my Apache server, but when I ported them over to the httpdapi (python_module) I'm having trouble accessing certain environment variables. I used to use the os.environ dictionary to access the REQUEST_URI or DOCUMENT_URI environment variables, but now must use the method on the base class to obtain this information. My problem is that this information appears to be lost. When I wrote the CGI scripts without the httpdapi these environment variables (REQUEST_URI) would be set to the HTML file that I'm server- side including the CGI script from. Any help? Thanks, Brand P.S.) I can't find any other Python newsgroups, are there others that talk about just Python/CGI stuff? tia. Sent via Deja.com http://www.deja.com/ Before you buy. From phil at geog.ubc.ca Mon May 8 15:24:40 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 08 May 2000 12:24:40 -0700 Subject: Calling Python scripts from C/C++ program References: <8f6ra5$hca$1@nnrp1.deja.com> Message-ID: srvalipe at hotmail.com writes: > I am new to Python programming. I am writing a simple C++ application > that calls (embeds) a python script. I couldn't find good examples on > how to do this at www.python.org website. > > The following is my python script: > > def FibSeries(first=1, next=1, last=10): Here's a solution using CXX (http://CXX.sourceforge.net). Note that I put FibSeries into a file called myfun.py: callable.cxx: #include "Python.h" #include "CXX_Objects.h" #include #include using namespace Py; using namespace std; extern "C" void Py_Initialize(); extern "C" void Py_Finalize(); int main(int argc, char* argv[]) { Py_Initialize(); Module myfun("myfun"); Callable fib = myfun.getAttr("FibSeries"); Tuple argtuple(3); argtuple[0]=Int(2); argtuple[1]=Int(2); argtuple[2]=Int(30); Object output = fib.apply(argtuple); cout << List(output) << endl; Py_Finalize(); return 0; } Compiling and executing this give: callable 2 4 6 10 16 26 [2, 4, 6, 10, 16, 26] Regards, Phil Phil Austin INTERNET: phil at geog.ubc.ca (604) 822-2175 FAX: (604) 822-6150 http://www.geog.ubc.ca/~phil Associate Professor Atmospheric Sciences Programme Geography #217 University of British Columbia 1984 W Mall Vancouver, BC V6T 1Z2 CANADA From dworkin at ccs.neu.edu Wed May 3 19:48:11 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 03 May 2000 19:48:11 -0400 Subject: How to get terminal width? In-Reply-To: Doug Stanfield's message of "Wed, 3 May 2000 12:07:30 -1000" References: <8457258D741DD411BD3D0050DA62365907A13F@huina.oceanic.com> Message-ID: Doug Stanfield writes: > Please don't patronize me. My apologies. I didn't mean to patronize you in particular, just anyone that thinks that "runs on my redhat box" means "portable". If that's not you, and I came across as patronizing you, I am sorry. I have simply been bitten too many times by people writing software (or dispensing advice) that have that attitude. You may not think that way; I don't know. > My only point was to correct his statement that "... you don't get > it (COLUMNS) on contemporary Berkeley or Linux platforms." He was clearly using "contemporary Berkeley or Linux platforms" as examples to illustrate his point, which was that "the COLUMNS environment variable isn't universally available on UNIX platforms". He was correct in that, even if COLUMNS is available on Redhat. There's not much point in continuting this in any case, as a portable solution seems to already have been supplied. -Justin From moshez at math.huji.ac.il Tue May 16 00:11:57 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 16 May 2000 07:11:57 +0300 (IDT) Subject: Python vs Java : GUI, drag an drop In-Reply-To: Message-ID: On Mon, 15 May 2000, Jarek Wilkiewicz wrote: > At present I'm considering using Java, the 2D API and Java D&D API. > Can I accomplish something similar using Python ? What graphic libraries > would I use ? Does it make more sense than coding the GUI in Java? What operating system do you use? Are native widgets top priorities? It would be nice to know the constraints you're operating under. If you're on a UNIX system, or native widgets are not of the utmost importance, I'd recommend Gtk+, with very rich D'n'D API. Tkinter has an experimental D'n'D inside one application API -- I don't know if it's enough for you. If you want to code in Python and still use the Java UI libraries, you can use JPython. Be aware, though, that it is a bit of a resource hog. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From yuri_leikind at my-deja.com Fri May 26 15:03:17 2000 From: yuri_leikind at my-deja.com (yuri_leikind at my-deja.com) Date: Fri, 26 May 2000 19:03:17 GMT Subject: A Python Beginner on Win32 Message-ID: <8gmhpa$jq3$1@nnrp1.deja.com> Hi All, When I decide to know what Python is, I downloaded the installation for Win32, py152.exe, and ran it. It installed Python and Tcl/Tk. Okey. Then I tried to run IDLE to see what they mean by saying "Python GUI" . No way. It just doesn't want to find Tcl/Tk. It says: Traceback (innermost last): File "idle.py", line 3, in ? PyShell.main() File "I:\programs\Python\Tools\idle\PyShell.py", line 611, in main root = Tk() File "I:\programs\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {} ./lib/tcl8.0 I:/programs/Python/tcl8.0/library I:/programs/Python/Tools/library This probably means that Tcl wasn't installed properly. Whatever I did, copied tcl/tk to the places where python wanted to find the - nothing!!! Is there a GUI at all? Yuri Leikind Sent via Deja.com http://www.deja.com/ Before you buy. From jlj at cfdrc.com Wed May 17 17:53:29 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Wed, 17 May 2000 16:53:29 -0500 Subject: Question About Embedding into C++ Message-ID: <392314D9.70DCC8EB@cfdrc.com> Help! I've used SWIG to wrap a C++ library. The source files for my extension get compiled using the "-fPIC" flag to gcc to ensure that it produces position-independent code; the shared object is linked with the "-shared" flag. The end-product is a shared object. If I import this extension module using the stand-alone Python interpreter executable, all is well and everything works as expected. I should note that these are the standard Python executable and library (libpython1.5.a) installed with Red Hat Linux 6.1, if that matters. Now I would like to embed the Python interpreter in a C++ application, and from within that application, import the previously described extension module. But when I execute this code: PyRun_SimpleString("import MyExtensionModule"); the program shuts down and the error message (raised from Python) is: Traceback (innermost last): File "", line 1, in ? File "../FXPy/__init__.py", line 21, in ? File "../FXPy/fox.py", line 2, in ? ImportError: foxcmodule.so: undefined symbol: _Py_NoneStruct So I searched the web and read the Python FAQ, and I'm seeing hints of this problem in other settings (e.g. Gnumeric's Python plugin), but nothing conclusive. Can anyone clue me in to the basic problem? Remember, it works OK when "Python is on top" and I'm just running the stand-alone Python interpreter. Any suggestions are greatly appreciated! Thanks in advance, Lyle (jlj at cfdrc.com) From mwh21 at cam.ac.uk Sat May 13 09:13:55 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 May 2000 14:13:55 +0100 Subject: correct round of reals? References: <391BE774.95B2C26D@stud.ntnu.no> <006701bfbc05$04bfcbc0$0500a8c0@secret.pythonware.com> <391D1869.D452162B@stud.ntnu.no> Message-ID: Peter Schneider-Kamp writes: > Fredrik Lundh wrote: > > > > def rint(v, m=4503599627370496.0): > > if abs(v) > m: > > return v > > if v > 0: > > return (v + m) - m > > else: > > return (v - m) + m > > That is very nice and works fine in Python, but the > romans don't go home in that "C" language: > > #define MAX_DOUBLE_INT 4503599627370496.0 > double rint(x) double x; { > if (abs(x) > MAX_DOUBLE_INT) > return x; > if (x > 0) > return (x+MAX_DOUBLE_INT)-MAX_DOUBLE_INT; > else > return (x-MAX_DOUBLE_INT)+MAX_DOUBLE_INT; > } > > Using this rint in the mathmodule.c I get: > math.rint(0.7) == 0.700195 > > What's wrong? It's the C compilers charming belief that floating point arithmetic is associative - "ooh look the stupid luser doesn't neeed to both add and subtract that number from x". So you're fighting the optimiser. I've managed to come up with code that works with gcc at lower optimisation settings, but as soon as you crank it up, gcc manages to work out what I'm up to... I guess you could use functions in different object files to do this, but that's going too far. I'd guess there is some switch or pragma that will stop gcc reordering floating point operations, but it'll be compiler dependent. Joys. Anyone know a more general technique? what-fun-fp-is-ly y'rs M. -- 112. Computer Science is embarrassed by the computer. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From info at pythonware.com Mon May 29 08:59:30 2000 From: info at pythonware.com (PythonWare) Date: Mon, 29 May 2000 14:59:30 +0200 Subject: ANN: new sgmlop release (may 28, 2000) Message-ID: <001c01bfc96d$c9c03b60$0500a8c0@secret.pythonware.com> It's release week at the labs, and we'll start with something small but tasty: Secret Labs' sgmlop module is a fast replacement for the regular expression-based parsers used in Python's sgmllib, htmllib, and xmllib modules. A new version is now available from: http://www.pythonware.com/products/xml Changes since the last release include: - if a file ends with cdata, make sure all characters are sent to the callback - Unicode strings (under 1.6) are now translated to UTF-8 on the fly (future versions will be fully unicode-aware) - the 'close' method no longer accepts an optional argument. - recursive calls to 'feed' or 'close' now raises an exception. enjoy, the pythonware team "Secret Labs -- makers of fine pythonware since 1997." From effbot at telia.com Thu May 11 10:13:44 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 14:13:44 GMT Subject: Const-Correctness of Python/C References: <20000511114535146.AAA71.378@pcfue9> <391AB63D.E768D78D@cfdrc.com> Message-ID: Lyle Johnson wrote: > Some older C compilers wouldn't support the const keyword, so that could > be a problem. Note that Python 1.6 require ANSI C, and I think "const" support is required by the ANSI C standard. From nospam.newton at gmx.li Sat May 13 05:42:53 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Sat, 13 May 2000 09:42:53 GMT Subject: [FAQTS] Python Knowledge Base Update -- May 11th, 2000 References: <20000511143830.22000.qmail@synop.com> Message-ID: <391d1cbc.451350422@news.nikoma.de> On 11 May 2000 14:38:30 -0000, Fiona Czuczman wrote: > >Hello All, > >Below are the entries from the newsgroup that I've entered into >http://python.faqts.com today. Is there any particular reason why nearly all of your article is double-spaced? I find it a bit hard to read. Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From stephen at cerebralmaelstrom.com Mon May 15 15:03:05 2000 From: stephen at cerebralmaelstrom.com (Stephen) Date: Mon, 15 May 2000 19:03:05 GMT Subject: Python(path) and the location of the Python DLL. References: Message-ID: My second question was just where to change that -- to have my dll check in a different place in the registry for the .py/etc files. :) And I never said anything about shipping. 1.6 will no doubt be done by the time that i'm done with this, and i'll just be upgrading what i'm using throughout the development. Heck, this may never get done. Its a personal project to fill a software gap which has been irritating me for years. :) --S Warren Postma wrote in message news:wnUT4.20382$HG1.516944 at nnrp1.uunet.ca... > > "Stephen" wrote in message > news:XwOT4.8283$WS3.66942 at typhoon.we.rr.com... > > Hello, all. > > > > I'm working on embedding Python into a program i'm working on in > C++Builder. > > I got past the problem of importing VC++ DLLs into C++Builder by searching > > Dejanews, so now before I continue I have a couple questions... > > > > #1) I'll be using the latest version (1.6a2), but I don't want it to get > > involved with any current versions running on the same machine. Is there > > anything wrong with me renaming the DLL? > > This sounds scary. The Windows python implementation checks the Registry to > find the python path. If you have two dlls, they'll have PYD files and PY > files in the same directory, or else you'll have to build your own version > of the python dll, that checks somewhere else in the registry for it's path > and so on. Why not just have your installation program check for > incompatible DLLs and warn the user when Python is already installed and > it's a different version. One of the two versions is newer or better. > > Plus, I wonder, why are you making plans to ship alpha software as a > production release? Silly. > > Warren > > From mhammond at skippinet.com.au Sun May 14 19:56:40 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 14 May 2000 23:56:40 GMT Subject: Python Plans from ActiveState References: <51rthscplh93iuktpbn87lihguqo1rq5s8@4ax.com> Message-ID: wrote in message news:51rthscplh93iuktpbn87lihguqo1rq5s8 at 4ax.com... > "Mark Hammond" wrote: > > >It will be the core Python, plus some "key extensions" for the platform. > >Eg, for Windows, it will include the win32all series. > > I would very much like the Windows install to be free of registry > nonsense and hence be network (and person!) friendly. So would we all. It has been discussed alot, and the first alpha of 1.6 also tried to keep the main DLL out of the system32 directory, as a good first step down this path. However, it simply does not work when Python is embedded in _any_ other application that is not in the same directory as Python itself - eg, COM (ironically, the installer itself, which needs to use Python, couldnt even manage!) Consider a VB app that needs to use a components written in Python. VB knows nothing about Python, and definately not where its standard library or anything is. Without the registry, in this scenario, we can not effectively boot Python. > PYTHONPATH should be an environment variable, not a registry string. I disagree completely. This would be as bad as attempting to put Python on the global path. It is hard to do across platforms. It prevents multiple Python versions installed side-by-side (which is possible now - just not via the default installer). I agree the registry sucks, but IMO a global environment sucks even more! And finally, note that PYTHONPATH augments, and PYTHONHOME completely overrides, the registry. Thus, you are free to unzip an archive, setup one of these environment variables, and run without any registry settings. Indeed, in Python 1.6, if Python determines that it _can_ locate its core library, it completely ignores the core paths in the registry. This means, for example, that you can run a version of Python you built yourself, and runs independent of any installed version you may have and its registry settings. So for these reasons, I believe the installer does the right thing for the majority of people. If you dont fit into that majority, then you are free to use the other techniques available (ie, the environment variables) to create your own environment. Mark. From benpark at my-deja.com Fri May 5 20:08:46 2000 From: benpark at my-deja.com (benpark at my-deja.com) Date: Sat, 06 May 2000 00:08:46 GMT Subject: control kids' game plays Message-ID: <8evnq6$5hp$1@nnrp1.deja.com> My kids play games on our home windows95 computer all the time. I would like to control the times and durations of their playing. Is there any way to do it with python? Ben Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Wed May 24 15:56:17 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 24 May 2000 15:56:17 -0400 Subject: defined test? In-Reply-To: msoulier@nortelnetworks.com's message of "24 May 2000 18:01:12 GMT" References: <8gh5d8$hu3$1@bmerhc5e.ca.nortel.com> Message-ID: msoulier at nortelnetworks.com (Michael P. Soulier) writes: > Ok, I'm currently a Perl programmer who's looking into Python. I was > wondering, is there an equivalent of the defined() function in Python, > to test if a given variable name is defined? You surely can. For example: >>> def zorglub(): ... print locals().has_key('x') ... x = 3 ... print locals().has_key('x') ... >>> zorglub() 0 1 But I would advise against such trickery. What I often do is initialising variables to `None', which is some kind of neutral value, and check whether `x is None' or `x is not None', as needed. I did not find a case so far (and I surely wrote a lot of Python by now) where I _really_ needed to distinguish between None and not defined. Working around the difficulty invariably yields nicer code, and this is a worthy side effect in itself. You'll discover that Python is better than Perl, if you allow it to be! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mhammond at skippinet.com.au Tue May 9 22:39:18 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2000 02:39:18 GMT Subject: Win32/COM - returning multiple values References: <8f9brb$pps@newton.cc.rl.ac.uk> Message-ID: "Richard Brodie" wrote in message news:8f9brb$pps at newton.cc.rl.ac.uk... > One of the methods naturally returns an int and two strings. Now, I > had naively thought that these would be returned as an array. They would - sort-of - it would be a tuple. Thus you should be able to say: i, s1, s2 = ob.YourMethod() > However, it seems that what I have to do is to use NewEnum to > coerce it to an IEnumVARIANT interface, and then use > QueryInterface and Next on the client to recover the array. It sounds like the object is returning a collection. No idea why. By byref args generally work fine, especially if you have run "makepy". > Lucky I was able to protoype this all in Python ;) Have I really > got to jump through all these hoops though? If you really do need to, it shouldnt be Python specific. If you can post the code in your .idl, I will have a better idea... Mark. From tim_one at email.msn.com Sat May 6 15:02:39 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 6 May 2000 15:02:39 -0400 Subject: Copyright and License In-Reply-To: <8eum9g$oc4$1@slb2.atl.mindspring.net> Message-ID: <000101bfb78d$a61f3cc0$452d153f@tim> [Mark Hammond] > [And a question I dont want to raise - what really does this "copyright" > mean, in the open source world? It appears we are saying "we assert > copyright, but never intend actually enforcing it". The words of the > tim-bot still echo (paraphrased) - "if possible, put it in the public > domain" :-) As I said, I dont want to raise it :-] [Aahz Maruch] > The primary purpose is to prevent someone else from asserting copyright. And what if they do? If the original is public domain, anyone can continue using it, modifying it, etc. Everything I've released in Python has been explicitly public domain, and there's been no downside. The one Python-related thing I did with a copyright was the Emacs pymode, and I lived to regret that over several years, in a seemingly endless hassle to get the copyright assigned to the FSF (which finally succeeded late last year, after being "an issue" since mid '94(!)). If you assert copyright, you're making a legal claim. If you want to avoid lawyers, avoid making legal claims . ralph-griswold-put-the-icon-language-in-the-public-domain-and-has-had- a-happy-life-ever-since-ly y'rs - tim From pinard at iro.umontreal.ca Sun May 21 22:37:09 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 21 May 2000 22:37:09 -0400 Subject: Integer division (was: Case-sensitivity... (was: Damnation!)) In-Reply-To: Moshe Zadka's message of "Sun, 21 May 2000 21:42:31 +0300 (IDT)" References: Message-ID: Moshe Zadka ?crit: > On 21 May 2000, [ISO-8859-1] Fran?ois Pinard wrote: > > No doubt that I would not like having to revise existing code! But also, > > as the current `i / j' gives access to useful hardware instruction, a new > > `int(i/j)' might incur unwelcome overhead for something that once was faster. > Hardware instruction? Hardware instruction? Francois, you need a > theraputic session with gdb on Python. Try to single-step > python -c '1/2' > And see that the hardware instruction is lost in a sea of function calls > and jumps all over the place. You are surely right, and are exposing my naivety :-). But do not deprive me of all my dreams. Let's not give so soon into the thinking that Python might never be cleverly compilable. Who knows if things would not evolve in a direction that might allow such things, one of these days. Scheme is astonishingly compilable for a dynamically typed language (Python is another dynamically typed language). If Scheme was to influence Python design a bit, this might be an aspect to analyse and ponder. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Wed May 24 07:06:41 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 24 May 2000 07:06:41 -0400 Subject: Good ideas :-), no time :-( Message-ID: Hi, people. Yesterday, I had to read long shell scripts and complex Makefiles. Python is really corrupting me, because more I work with Python, more I consider that complex shell code is hard to read. So, I came with this "simple" idea, that we should have tools for converting Makefiles and shell scripts into specialised Python scripts. (And why not `sed' and `awk' as well, once on that road, the same as Perl once did.) Ah, my friends, all the nice things I could do if only I had more time :-). Who would give me a decent full-time salary, just so I could follow my own inclinations for free software in Python? :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From herzog at online.de Sat May 20 11:03:40 2000 From: herzog at online.de (Bernhard Herzog) Date: 20 May 2000 17:03:40 +0200 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> Message-ID: Courageous writes: > The occasions in which you really want to have variables/ > attributes which differ by case alone are quite rare. About > the only time I have ever seen this regularly is in some > types of code where accessors (in c++/java) differed from > private attributes only in case, ala: > > class Myclass > { > private int myvar; > int Myvar(); > } > > I can't really see any other real use of actual case sensitivity > in the language. Does anyone out there actually make use of > case sensitivity? Well, can think of several cases where case sensitivity is useful for me. One is the case you describe above. I prefer accessor methods call MyVar instead of get_my_var. Another is that I often name constants in ALL_UPPERCASE and sometimes I have local variables whose are all lowercase but otherwise the same as that of some constant. These variables would hide those constants, although it wouldn't be difficult to work around that. Yet another is that I also sometimes like to name instances of classes with lowercase versions of the (capitalized) class name. The argument usually used in favor of case insensitivity is that it is easier for beginners and the experiences with Alice seems to back that up. I don't have the URL handy at the moment, but it should be easy to find it from python.org. I keep wondering, though, whether the cultural background might influence this. In German for instance, all nouns are capitalized, not just names and the first word of a sentence. That might make it easier for a German student to learn a case sensitive language that for, say, an American student. I have absolutely no idea whether that's true, though. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From esj at harvee.billerica.ma.us Mon May 22 13:48:25 2000 From: esj at harvee.billerica.ma.us (esj at harvee.billerica.ma.us) Date: 22 May 2000 13:48:25 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: Guido van Rossum writes: > Here's a way to make your vote count: explain what it is about case > sensitive languages that you hate. Then we can have a discussion > about it. okay, here's why I don't like case sensitive languages. I program by voice. I know blind programmers that listen to code. An aural interface and case sensitivity are not a good match. --- eric From noone at do.not.use Sat May 13 15:09:37 2000 From: noone at do.not.use (Russell Turpin) Date: Sat, 13 May 2000 14:09:37 -0500 Subject: Augmented assignment (was RE: Why should I switch to Python?) References: <000101bfbca3$8a554b40$3f2d153f@tim> Message-ID: <391DA871.DDBAC4DE@do.not.use> Tim Peters wrote: > .. Python has a long & unbroken history of adding more "mere > syntactic sugar" with each release, and I don't think any > addition of that nature has been regretted, except for the > extent to which "lambda" snuck in on that basis. Who would regret lambda? Russell From glyph at twistedmatrix.com Tue May 16 13:16:30 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 16 May 2000 12:16:30 -0500 Subject: The REALLY bad thing about Python lists .. In-Reply-To: "Tim Peters"'s message of "Mon, 15 May 2000 23:32:38 -0400" References: <000501bfbee7$62318ac0$a2a0143f@tim> Message-ID: "Tim Peters" writes: > [Glyph Lefkowitz] > > ... > > If a platform doesn't adhere to a standard or does something in a > > really brain-damaged way, it should be fixed on that platform. I > > had this brought to my attention earlier today when someone on IRC > > was commenting that the % operator in perl and python carries the > > symantics from the C library of the platform in question, and > > sometimes that's wrong (off-by-one errors when it was being treated > > as 'remainder' rather than 'modulus' in negative numbers). > > ISO/ANSI C doesn't fully define what happens when (roughly) integer division > or % are handed negative numbers. The foibles of standards commitees will never cease to amuse me. Thank you for this little tidbit. > Python does fully define it (& forces the issue regardless of what the > platform C does). > Don't remember what Perl does. And don't care . Perl doesn't define it, at least in 5.005. Now I can be a hypocrite and trumpet python's mathematical superiority <0.5 wink>. > Python is generally *willing* to worm around platform bugs (look at all the > #ifdef'ed workarounds in the source!), but sometimes it's just more work > than anyone will volunteer. For example, making os.system() work > predictably under Win95 (where the MS system() is broken in several ways). I just think it's sad that every piece of software that wants to function in any reasonably cross-platform manner eventually becomes an #ifdef'd mess. *sigh*. I suppose that's C for you, and it shouldn't strike me as bad, but still... > See Starship for Vladimir Marangozov's PyMalloc, which may well become > Python's workaround for crappy platform mallocs one day; in 1.6, he's laying > a lot of the groundwork to make this possible. > > As to the remarks about whether it was worth the time to port Python to > Windows, note that Windows is Python's most heavily used platform now -- I > personally doubt Python would have survived if it only had its Mac and Unix > base since '91. Do you actually have a basis for that statistic? Considering that non-trivial parts of Red Hat Linux are actually written in Python, Blender is scriptable in python (and I use many of those utilities on my Debian system too)... pretty much everyone who uses Linux uses Python, whereas I've seen little evidence of Python used in widely-distributed Windows applications. (Also, remembering that TurboLinux, a RedHat derivative, is now the #1 OS in Japan...) > "software-sucks"-exempts-no-philosophy-ly y'rs - tim in-ten-years-we'll-all-be-running-EROS-2-on-sparc-one-billions-anyway-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From fiona at sitegnome.com Sat May 27 09:54:39 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 27 May 2000 13:54:39 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 27th, 2000 Message-ID: <20000527135439.8390.qmail@synop.com> Hi Guys, Below are the entries I've entered into http://python.faqts.com cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How can I reload things imported with 'from HUGO import *'? http://www.faqts.com/knowledge-base/view.phtml/aid/3281 ------------------------------------------------------------- Fiona Czuczman Michael Hudson import HUGO reload(HUGO) from HUGO import * or reload(sys.modules["HUGO"]); from HUGO import * (another reason not to use "import *"...) ------------------------------------------------------------- Is there anyway I can get the traceback on to the web page so I know what's happening? http://www.faqts.com/knowledge-base/view.phtml/aid/3282 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, David Currie The easiest way is to split your CGI module in two parts; use the following script as a wrapper, and place the program logic in a separate script ("my-script.main()" in this case): #!/usr/bin/env python import cgi, StringIO, sys, traceback try: import myscript myscript.main() except: print "Content-Type:", "text/html" print file = StringIO.StringIO() traceback.print_exc(file=file) print "
    "
        print cgi.escape(file.getvalue())
        print "
    " If there is an error while running the program it will be displayed. If the traceback does not appear in the result, then chances are you have a syntax error in your code. Set a debug mode that allows you to run the script locally without calling cgi.FieldStorage() and related stuff, and this should help you debug these errors. ------------------------------------------------------------- Is there a function returning the intersection of two lists? http://www.faqts.com/knowledge-base/view.phtml/aid/3283 ------------------------------------------------------------- Fiona Czuczman Penfold Example: l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] l3 should be [4,5] Solution: You could try using the ever useful kjbuckets module (find it on http://www.vex.net/parnassus). This implements mathematical sets and graphs which mean your below becomes as easy as kjSet([1,2,3,4,5]) & kjSet([4,5,6,7,8]) ------------------------------------------------------------- Where can I find information (code, hints...) about Python and Interbase? http://www.faqts.com/knowledge-base/view.phtml/aid/3260 ------------------------------------------------------------- Fiona Czuczman Anders M Eriksson Mr Alexander Kuznetsov is maintaining a thing called kinterbasdb which is an interface between Python and Interbase. You'll find it at: http://www.python.org/topics/database/modules.html From Jan.Kybic at epfl.ch Wed May 24 12:25:44 2000 From: Jan.Kybic at epfl.ch (Jan Kybic) Date: 24 May 2000 18:25:44 +0200 Subject: Cross-compiling Python Message-ID: Hi, I am trying to cross-compile Python on my Intel based Linux PC so that it runs on a ARM Linux machine which is so small (Psion S5), that compilation there is out of question. The configure script is not very useable for this purpose as it seems to ignore the --target and --host switches and even when I insist (by setting the environment variables CC,...), it still wants to run some tests locally and also in the installation phase it assumes it is running on the target machine. For the moment, I am fiddling with the Makefiles but it is not very productive. Has anyone here ever tried to cross-compile Python? Thanks for any help. Jan -- ------------------------------------------------------------------------- Jan Kybic BIG IOA DMT EPFL Lausanne, Switzerland or tel. work +41 (21) 693 5142 For PGP key see my WWW page. http://bigwww.epfl.ch/kybic From m.faassen at vet.uu.nl Tue May 30 07:21:25 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 11:21:25 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <39333CC3.32805F5@cosc.canterbury.ac.nz> Message-ID: <8h087l$bnc$4@newshost.accu.uu.nl> Fredrik Lundh wrote: > Greg Ewing wrote: >> Bugs can be fixed at any time. But if we don't speak up soon >> before what we see as a serious aesthetic mistake becomes >> entrenched, it will be too late. > if you think that keeping string.join in there is the most serious > design mistake in 1.6, you may be in for some really interesting > surprises... That of course doesn't make it any less true that we should stop " ".join() *now* before it is too late. If there are other more serious design mistakes, I suggest you point them out to us if you want our help fixing them. :) Since the debate about generalized 'join()' on lists can be fought on forever, what about following the earlier more pragmatic suggestion of somehow hiding 'join()' on strings and exposing it only through string.join(), making that the One Right Way to Do It? If 'string' suddenly is a pain to import, a builtin: sjoin() or whatever. " ".join() is just not making sense to a *lot* of people. I'm sure you can get used to it, but I had to blink a couple of hundred times first, myself. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From petersc at stud.ntnu.no Mon May 22 13:09:22 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 22 May 2000 19:09:22 +0200 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> <39271A25.A348E4B9@roguewave.com> <39295C88.EFEDE889@roguewave.com> <39295ED6.2EADA60C@stud.ntnu.no> Message-ID: <392969C2.86FB7C6A@stud.ntnu.no> Peter Schneider-Kamp wrote: > > I would be okay with internationalized grammars so I can compile a > German version of the interpreter (maybe called wuerge_schlange). There seem to be some difficulties with replacing identifiers by multiple words. (saa lenge som instead of while etc.). Just for fun a German grammar attached. it's-all-about-fun-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de -------------- next part -------------- *** Grammar Mon May 22 19:05:16 2000 --- Grammar.german Mon May 22 19:04:58 2000 *************** *** 33,71 **** small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt expr_stmt: testlist ('=' testlist)* # For assignments, additional restrictions enforced by the interpreter ! print_stmt: 'print' (test ',')* [test] ! del_stmt: 'del' exprlist ! pass_stmt: 'pass' flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt ! break_stmt: 'break' continue_stmt: 'continue' ! return_stmt: 'return' [testlist] ! raise_stmt: 'raise' [test [',' test [',' test]]] ! import_stmt: 'import' dotted_name (',' dotted_name)* | 'from' dotted_name 'import' ('*' | NAME (',' NAME)*) dotted_name: NAME ('.' NAME)* global_stmt: 'global' NAME (',' NAME)* #access_stmt: 'access' ('*' | NAME (',' NAME)*) ':' accesstype (',' accesstype)* #accesstype: NAME+ ## accesstype should be ('public' | 'protected' | 'private') ['read'] ['write'] ## but can't be because that would create undesirable reserved words! ! exec_stmt: 'exec' expr ['in' test [',' test]] ! assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] ! while_stmt: 'while' test ':' suite ['else' ':' suite] ! for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] ! try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break ! ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) # NB compile.c makes sure that the default except clause is last ! except_clause: 'except' [test [',' test]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT ! test: and_test ('or' and_test)* | lambdef ! and_test: not_test ('and' not_test)* ! not_test: 'not' not_test | comparison comparison: expr (comp_op expr)* ! comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' expr: xor_expr ('|' xor_expr)* xor_expr: and_expr ('^' and_expr)* and_expr: shift_expr ('&' shift_expr)* --- 33,71 ---- small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt expr_stmt: testlist ('=' testlist)* # For assignments, additional restrictions enforced by the interpreter ! print_stmt: 'schreib' (test ',')* [test] ! del_stmt: 'loesch' exprlist ! pass_stmt: 'passe' flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt ! break_stmt: 'brich_ab' continue_stmt: 'continue' ! return_stmt: 'zurueck' [testlist] ! raise_stmt: 'beschwoere' [test [',' test [',' test]]] ! import_stmt: 'importiere' dotted_name (',' dotted_name)* | 'aus' dotted_name 'importiere' ('*' | NAME (',' NAME)*) dotted_name: NAME ('.' NAME)* global_stmt: 'global' NAME (',' NAME)* #access_stmt: 'access' ('*' | NAME (',' NAME)*) ':' accesstype (',' accesstype)* #accesstype: NAME+ ## accesstype should be ('public' | 'protected' | 'private') ['read'] ['write'] ## but can't be because that would create undesirable reserved words! ! exec_stmt: 'fuehr_aus' expr ['in' test [',' test]] ! assert_stmt: 'sicherezu' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'falls' test ':' suite ('sonstfalls' test ':' suite)* ['sonst' ':' suite] ! while_stmt: 'solange' test ':' suite ['sonst' ':' suite] ! for_stmt: 'fuer' exprlist 'in' testlist ':' suite ['sonst' ':' suite] ! try_stmt: ('versuch' ':' suite (except_clause ':' suite)+ #diagram:break ! ['sonst' ':' suite] | 'versuch' ':' suite 'schliesslich' ':' suite) # NB compile.c makes sure that the default except clause is last ! except_clause: 'erwarte' [test [',' test]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT ! test: and_test ('oder' and_test)* | lambdef ! and_test: not_test ('und' not_test)* ! not_test: 'nicht' not_test | comparison comparison: expr (comp_op expr)* ! comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'nicht' 'in'|'ist'|'ist' 'nicht' expr: xor_expr ('|' xor_expr)* xor_expr: and_expr ('^' and_expr)* and_expr: shift_expr ('&' shift_expr)* *************** *** 84,90 **** testlist: test (',' test)* [','] dictmaker: test ':' test (',' test ':' test)* [','] ! classdef: 'class' NAME ['(' testlist ')'] ':' suite arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) argument: [test '='] test # Really [keyword '='] test --- 84,90 ---- testlist: test (',' test)* [','] dictmaker: test ':' test (',' test ':' test)* [','] ! classdef: 'klasse' NAME ['(' testlist ')'] ':' suite arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) argument: [test '='] test # Really [keyword '='] test From shapr at uab.edu Fri May 12 08:41:55 2000 From: shapr at uab.edu (Shae Erisson) Date: Fri, 12 May 2000 12:41:55 GMT Subject: Was Re: "stuff", a general request for help, now 'Ideas on correct use of PyUnit in Unit Tests' References: Message-ID: <391C0024.3BF9EFAD@uab.edu> Glyph Lefkowitz wrote: > As long as I'm encouraging people to download this thing, too; I am > getting started with PyUnit and regression testing ... but my tests > seem really random and arbitrary. Much appreciated would also be > comments on the style / structure of said tests (in the regr/ > directory) and pointers to better ones. I've read about JUnit and > PyUnit, but there doesn't seem to be much in the way of a description > of what makes a good test. > > Right now, writing tests takes 2x as long as writing the code > initially, and there have been more bugs in the tests than in the code > itself. I know that these can be a real resource for me, but I'm not > quite sure how. This is still a half done thought.. but I have been thinking about this recently.... I'm slowly writing a Python Refactoring Browser[1], and the thesis that is the primary documentation for the process of design and implementation of the first Refactoring Browser written in Smalltalk, mentions several things: refactorings are only 90% mathematically provably correct, so unit tests are used to assure that you have the same behaviour after a refactoring that you had before. that implies that: unit tests should work the same before and after a refactoring. the thesis also says: refactoring cannot preserve _all_ code functionality, any refactoring _will_ change the code. When I first started writing unit tests I had a very fine granularity, I would test each method with lots of input. That doesn't work because I'm not testing the 'behaviour,' I'm testing the code... If you ascribe to the Extreme Programming methodology, UnitTests come from User Stories. User Stories are 'functional requirements' that the client has given you. Therefore, I think UnitTests should not test the code, they should test that the functional requirements are passed. I can't think of any great examples at this moment, but I hope someone else can contribute some. As the issue of 'how to correctly construct unit tests' is alternately clear and confused to me, I would _really_ like to get more feedback from other people. Thanks, [1] http://bicyclerepair.sourceforge.net - no code nor any kind of homepage is up yet... but progress has been made. ps. If you would like pointers to any of the above mentioned info, I can furnish them. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre "Cry Haddock and let slip the Frogs of War!" From fredrik at pythonware.com Fri May 19 09:44:11 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 19 May 2000 15:44:11 +0200 Subject: Newbie: opening files. References: <39254013.C5B3834A@spamspamhotmail.com> Message-ID: <002f01bfc198$52d7d710$0500a8c0@secret.pythonware.com> Bart Holthuijsen wrote: > The following error message appears: > > C:\Stage\xalan>python open.py > Traceback (innermost last): > File "open.py", line 25, in ? > if __name__=='__main__': main() > File "open.py", line 13, in main > f = open('Yearend.xml','r') > TypeError: illegal argument type for built-in operation > > What am I doing wrong? from-import is a dangerous tool. don't use it unless you know exactly what you're doing ;-) >>> print open.__doc__ open(filename[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. >>> from sys import * >>> print open.__doc__ open(filename[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), ... >>> from os import * >>> print open.__doc__ open(filename, flag [, mode=0777]) -> fd Open a file (for low level IO). (in other words, there's another 'open' function in the os module, and since you import *everything* from that module into your own namespace, you can no longer access the original builtin...) for more info on from-import (and when it's okay to use it), see: http://www.pythonware.com/people/fredrik/fyi/fyi06.htm From effbot at telia.com Tue May 9 18:33:52 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 22:33:52 GMT Subject: MySQLdb + Python + quotes References: <3918809E.1D5F3CFE@rhk.dk> Message-ID: Lars Hoeyrup Jensen wrote: > I use the MySQLdb module to make Python interact with MySQL. I have a > problem, when I try to insert strings that contain special characters > (here I primarily think of quotes: ' and "). There _must_ be a smart > way to escape these characters. from the recent "BLOBS and python" thread: ... From: Oleg Broytmann Date: Fri, 5 May 2000 08:26:36 +0000 (GMT) Subject: Re: BLOBS and python On Thu, 4 May 2000, sp00fD wrote: > con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % image) con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % MySQL.escape(image)) ^^^^^^^^^^^^ !!! ... hope this helps! From kent at tiamat.goathill.org Mon May 22 15:59:41 2000 From: kent at tiamat.goathill.org (Kent Polk) Date: 22 May 2000 19:59:41 GMT Subject: urllib/ftpwrapper References: Message-ID: <959023972.859403@fezzik.endicor.com> On Sat, 20 May 2000 03:10:50 GMT, Guido van Rossum wrote: >Oleg Broytmann writes: > [...] >> and it hangs :( Almost all FTP URLs will hang, but there are some that >> not: ftp://sun.med.ru/ worked (at least for me), there is pretty standard >> wu-ftpd running there. Speaking of ftp hangs... I have a question regarding Python servers. Medusa/ZServer ftp server to be precise... The problem is that since there is no seteuid in Python (presumably because there appears to be no Posix seteuid), an ftp server responding to an Active mode ftp client currently would have to run as root in order to correctly service the request, as the server has to open an outbound port 20 socket to the client. Medusa currently just answers the Active request using a high port number. This appears to be incorrect and breaks most (all?) firewalled Active Mode clients since the firewall doesn't know how to watch for incoming ftp data port connections if they don't originate from port 20. What would be a suggested method to allow outgoing port 20 connections from a Python setuid'd server such as Medusa? Thanks From jbauer at rubic.com Tue May 9 18:46:22 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 09 May 2000 17:46:22 -0500 Subject: MySQLdb + Python + quotes References: <3918809E.1D5F3CFE@rhk.dk> Message-ID: <3918953E.964B83B0@rubic.com> Fredrik Lundh wrote: > from the recent "BLOBS and python" thread: > From: Oleg Broytmann > ... VALUES ('%s')" % MySQL.escape(image)) > ^^^^^^^^^^^^ !!! > hope this helps! > Same database, but different library. MySQLdb uses escape_string() vs. MySQL's escape(). At any rate the eff-bot ought to be busy getting SOAP released instead of responding to newsgroup postings. ;-) even-bots-should-understand-the-concept-of-division- of-labor--ly y'rs, Jeff Bauer Rubicon Research From calvin at studcs.uni-sb.de Sun May 7 04:35:21 2000 From: calvin at studcs.uni-sb.de (The Dude) Date: Sun, 07 May 2000 08:35:21 +0000 Subject: SSL on Windows? References: Message-ID: <39152AC9.AFBCF2FA@studcs.uni-sb.de> > Hi. I am going to do a favour for a friend tomorrow, scripting a > webpage so he gets email notification when something happens. The > wrinkle is that he uses a windows box. I was wondering, does the ssl > module come with the standard python-for-windows distribution, and if > not, where could I get it, and how could I install it? There is an SSL interface for Python. First you will need an SSL library, for example from www.openssl.org, then the SSL wrapper from http://home.att.net/~nvsoft1/ssl_wrapper.html You will need Perl for Win32 (http://www.activestate.com/ActivePerl) to install OpenSSL on Windows. From chibaA at TinterlogD.Tcom Sun May 14 22:28:13 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Mon, 15 May 2000 02:28:13 GMT Subject: regex's Message-ID: <391f606a.176428420@news1.on.sympatico.ca> Hi, For some reason, this segment of code doesn't do what it's supposed to do... (it's supposed to take any \ " 's from inputString, and return the same chacter preceeded with a \ to outputString). It works great for the ' and " characters, but it just won't do the \. Any idea why? def norm2mysqlinsert(inputString): # Used for insert and update in MySQL outputString = '' p=re.compile('^[\\\'\"]$') count = 0 for i in inputString: if p.match(inputString[count]): outputString = outputString + "\\" + inputString[count] else: outputString = outputString + inputString[count] count = count + 1 return outputString From jhauser at ifm.uni-kiel.de Wed May 31 20:41:21 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 01 Jun 2000 02:41:21 +0200 Subject: slice object, ellipsis usage? list[2:4:2, ...] what good are they? References: <39358C6A.7B86FAD2@uab.edu> Message-ID: <87og5mteq6.fsf@ifm.uni-kiel.de> The ellipsis is to my knowledge only used in Numpy, which has multidimensional data structures. So in a function which does not need to know how many dimensions array arguments can have a ellipsis construct can be used. HTH, Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From jkraska1 at san.rr.com Tue May 2 21:08:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 01:08:34 GMT Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F31A5.6452D256@tismer.com> Message-ID: <390F7CB5.8BD62851@san.rr.com> > Hey, this is just an incredible idea. > Java with first class continuations, let that > drop through your brains. 90 percent of java threads > would be replaced by microthreads. Quite. I corresponded with the Kiev implementors a while back, asking them why they hadn't added continuations to Java. They responded back with "impossible on the JVM". But that misses the point. Stacklessness adds performance boosts in certain areas of computing that can't be denied. C/ From effbot at telia.com Sat May 13 22:20:49 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 14 May 2000 02:20:49 GMT Subject: Arrgh! Please help. References: <391e07b9.88187366@news1.on.sympatico.ca> Message-ID: <54oT4.4117$wYl.206688256@newsb.telia.net> wrote: > I'm pulling my hair out as to why I get this error: it just means that value isn't a string. to figure out what value happens to be, try adding the following debug statement: > For this code: > if 1: > print "Content-Type: text/html\n\n" > print "whatever", > oL = "" > for key,value in rv.items(): print type(value) > oL = oL + value + "&" + "blah" > print "blah", > print "=", > print oL ... > And while I'm at it, is there any way to use consecutive print > statements, and NOT have spaces in the output? ( I know comma gets rid > of the \n, but not the spaces). how about: import sys write = sys.stdout.write write("sp") write("am") From matt at mondoinfo.com Sun May 7 16:09:24 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 07 May 2000 15:09:24 -0500 Subject: Static vars in Python? References: Message-ID: <070520001509244547%matt@mondoinfo.com> In article , jajs at NOSPAMretemail.es (Juanjo ?lvarez) wrote: > Hi all! > > It's posible to have in Python static vars (that is, vars in a function > that retain his value over calls to the same function)? Hi Juanjo, That's not possible directly. What's usually done is to use an object that has a __call__ method and can therefore be treated like a function. class foo: def __init__(self): self.counter=1 def __call__(self): print self.counter self.counter=self.counter+1 >>> thingThatBehavesLikeAFunction=foo() >>> thingThatBehavesLikeAFunction() 1 >>> thingThatBehavesLikeAFunction() 2 Regards, Matt From richard_chamberlain at ntlworld.com Fri May 5 03:09:29 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Fri, 5 May 2000 08:09:29 +0100 Subject: python's acceptance References: <39119D8E.C7CC047A@gssec.bt.co.uk> Message-ID: <6ruQ4.10265$Px3.198238@news2-win.server.ntlworld.com> Being able to distribute my Python apps a little easier would really appeal to me. I've recently written a little app for work, where I'd normally use VB, however to distribute I needed to install Python, and then win32all, and finally the actual python code. Can anyone point me in the right direction if I would to use an installer to do this work - i.e. what would I need to install and where. Also I used COM as a gui, where next I probably would use wxPython so any pointers on installing that would be useful. Thanks, Richard Alan Gauld wrote in message news:39119D8E.C7CC047A at gssec.bt.co.uk... > Speaking as an occasional Delphi programmer... > > Scott Hathaway wrote: > > 1. In making this transition, I have had trouble because I am not used to > > trying to layout gui's with pure code. > > It's not too bad once you get used to it - some squared paper > and a pencil helps to get the initial design down then after > that modify what's there, however... It took me a while to trust > the layout managers to put things in the right places but once > I got over that hurdle I didn't find it too bad. > > > If python could get a gui builder > > SpecTcl with the SpecPython add in works pretty well for me on > both Unix and windows. Have you tried that? > > > platform, it could easily give VB or Delphi a run for their money. I have > > recently looked at Boa Constructor that lays out wxPython code and lets you > > build a gui! This is awesome. > > I think glade can do the same but haven't really looked or tried > either - Spectcl does most of what I want. Usually i just > handcraft > it because I use python as a scripting tool for typing things > together, thus my GUI is usually a single window front end to > a commandline version of the program... > > > 2. It is nearly impossible for a newbie like me to build an .exe on the > > Windows platform with Python. > > Why do you need to? > Why not either distribute Python with your app (use an > intelligent > installer to check if its already there)? Unless you want to hide > the source code from prying eyes? > > Alan G. > > -- > ================================================= > This post represents the views of the author > and does not necessarily accurately represent > the views of BT. From arcege at shore.net Mon May 8 15:01:49 2000 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 08 May 2000 19:01:49 GMT Subject: [UNIX] Detaching from parent process References: Message-ID: Florian Weimer wrote: : I'm trying to implement a CVS loginfo script with Python. The script : has to fork to the background, because the parent process has to : release the repository lock. But it seems as if Python doesn't detach : completely from the parent process, because CVS exists only after the : lengthy operation has completed. : Currently I use the following code: : if os.fork() == 0: : os.setsid() : if os.fork() == 0: : os.close(0) : os.close(1) : os.close(2) : os.open("/dev/null", os.O_RDWR) : os.dup(0) : os.dup(0) : # Lengthy operation claiming the repository lock follows. It is likely that you've either found your solution or that someone (probably Donn Cave :) has piped up in an email to you. But you probably want to close the file descriptors (and files) before you call setsid(), in the child process, not the grandchild. If stdin/stdout/ stderr are still opened to the controlling terminal, then setsid() could still have a problem disassociating itself from the controlling terminal. It might not be that, but it sounds likely on some UNIX systems. -Arcege From andy at petdance.com Wed May 24 10:10:38 2000 From: andy at petdance.com (Andy Lester) Date: Wed, 24 May 2000 09:10:38 -0500 (CST) Subject: Python equivalent to Perl's warn/confess/die In-Reply-To: <392BE18F.D5F21F27@earthlink.net> References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> Message-ID: I looked in the Perl/Python phrasebook and didn't see anything that discusses an easy way to write warnings to the screen. For instance, in Perl if I wanted to write something to stderr to show where in my process I am, I'd say: warn "$n records read"; Now, I know I can say sys.stderr.write( '%s records read' % n ) But is there a module somewhere that encapsulates that so I don't explicitly send it to stderr? xoxo, andy -- Andy Lester, andy at petdance.com, http://www.petdance.com "Inflammable material is planted in my head It's a suspect device that's left two thousand dead." "Hey, is this the new Green Day?" From niels at endea.demon.nl Wed May 31 16:15:23 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Wed, 31 May 2000 22:15:23 +0200 Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934242B.ECFDBAAE@endea.demon.nl> <8h1k0q$h04$2@newshost.accu.uu.nl> Message-ID: <393572DB.7A951AB9@endea.demon.nl> Martijn Faassen schreef: > > I don't think it's possible to avoid this kind of newbie problem in any > case. I also think the 'couple of hours' is likely exaggarated; Ok, I was exaggerating, but I don't think that it's specifically a newbie problem. I still occasionally have similar problems when switching from one language to another. To stick to the same example: "if a = 1 or 2" does what it looks like in COBOL, although programmers rarely use that. A more realistic example is the infamous "if (a = 1)" in C. > > True, though it would seem hard to avoid to call || and && 'or' and 'and' > anyway. And it can't be *that* incredibly hard to learn about 'and' and > 'or's behavior. I can't say that I have ever had much trouble with it, but then I learned BASIC at around the same time I learned English. It might be a little harder for people who have used English all their lives. > I suppose we do need those HCI people to back all this > up with research, though. :) > > > BTW, my own observation is that many people have enormous problems > > understanding Boolean expressions with multiple operators, no matter how > > you write them. This is especially true if there is negation involved > > somewhere. > > I always seem to be able to rewrite my booleans to something I can > follow. I think it's a knack one picks up in programming. booleans can > definitely be made to look complex, though. > > >> Note that I'm not questioning the Alice result on case-sensitivity; > >> I'm sure case-sensitivity confused beginners. > > > I'm not sure Alice has much of a "result" to offer on the subject. As > > far as I can tell from the paper I have read, doing away with case > > sensitivity was just the nearest hack available, not a decision based on > > scientific analysis of the whole interface problem. > > True; I don't think there was done any double-blind research into this > phenomenon. It was just an anecdotal observation, perhaps in a more > controlled setting than ours, but probably still doesn't weigh much more > strongly than our own anecdotal observations. > > > I'd want to see some > > serious research before accepting sweeping statements like "Case > > sensitivity is a bug in programming languages intended for novice > > users.". (That should be taken to mean that I think the Alice project is > > not serious research; I just think it's far from conclusive on this > > issue. Even simple people aren't that simple.) > > Right -- and if you're going to learn programming, you're going to have > to learn about programming discipline; perhaps it's better to learn it > sooner than later, too, as you're going to need it anyway. Sure, but there is more to it than getting to a certain level in minimum time. It's also necessary to keep the frustration down to an acceptable level. However, I agree that that can better be done by providing things like a helpful editor and more appropriate error messages than by silently correcting errors. > I think one > of the most important things one can do to increase learnability of a > language is to increase orthogonality and readability. Programs will > always be tricky to write, but at least it should be possible to write > code one can read again later. Case-insensitivity only does potential > harm in that regard. 'or' and 'and' versus '||' and '&&' are probably > fairly neutral, though I do think 'or' and 'and' are slightly > prettier. :) I can only agree with that. > > Usability research on programming languages is probably tough to do; > you can do some testing showing non-programmers parts of a program > and asking them what it does and get results that way, but that doesn't > necessarily tell you one bit about how usable the language will be to > a programmer the next day, or the next month, or the next year. And *those* > experiments will be pretty hard to do in a clean fashion. That depends on how you define "clean". I'm fairly confident that there are methods that would produce more or less reliable results. The real problem is, what exactly does usability mean for a tool that has as many applications as a programming language. Is it even possible to define usability without assuming a particular purpose and a particular environment? -- Niels Diepeveen Endea automatisering From claird at starbase.neosoft.com Mon May 15 10:27:26 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 May 2000 09:27:26 -0500 Subject: Java vs Python References: <8fo465$2u5$0@216.39.141.21> Message-ID: In article <8fo465$2u5$0 at 216.39.141.21>, dana_booth wrote: >Huy Do wrote: > >HD: I would just like to know how serious python is taken in the IT industry and >HD: how it compares to something like Java. > >Larger companies probably do not take Python seriously. In the industry, . . . Larger companies like Intel, Motorola, Microsoft, Compaq, IBM, ...? See, for example, . That's a cheap shot on my part. Mr. Booth is right. Conservative (in some sense) MIS departments *are* wont to scorn Python. It can be tough getting approval from many of them to use Python for a project such as that under consideration here. It's worth it, though--*particularly*, I claim, for Web work. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From cut_me_out at hotmail.com Fri May 5 12:21:52 2000 From: cut_me_out at hotmail.com (Alex) Date: 05 May 2000 12:21:52 -0400 Subject: SSL on Windows? Message-ID: Hi. I am going to do a favour for a friend tomorrow, scripting a webpage so he gets email notification when something happens. The wrinkle is that he uses a windows box. I was wondering, does the ssl module come with the standard python-for-windows distribution, and if not, where could I get it, and how could I install it? Alex. From scarblac-spamtrap at pino.selwerd.nl Thu May 4 02:21:07 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 4 May 2000 06:21:07 GMT Subject: Best way to convert a list to a dictionary References: <76ZP4.2558$wYl.196706304@newsb.telia.net> <39111077.A4837441@teleatlas.com> Message-ID: Michael Husmann wrote in comp.lang.python: > d = {} > for k, v in your_list: > d[k] = v > > This example looks nice bus does not work with my Python 1.52. Trying to > get both elements from 'your_list' produces a TypeError exception: > > Traceback (innermost last): > File "", line 1, in ? > for (k,v) in l: > TypeError: unpack non-sequence That means that not all elements of l are tuples or lists as you said. What does l look like? -- Remco Gerlich, scarblac at pino.selwerd.nl "Early to rise, early to bed, makes a man healthy, wealthy and dead." -- TP From jerry_spicklemire at my-deja.com Sat May 20 19:28:25 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Sat, 20 May 2000 23:28:25 GMT Subject: Python is the Future, NOW! Message-ID: <8g772k$db0$1@nnrp1.deja.com> 2000/05/20 O ye of little faith, who harbor doubts in darkness, and disbelieve in Guido's Time Machine, check this out: http://www.sdmagazine.com/features/2000/06/f6.shtml Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Wed May 31 21:24:32 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2000 01:24:32 GMT Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <3935937F.CCF87258@stud.ntnu.no> Message-ID: <8h4e0g$pkc$3@newshost.accu.uu.nl> Peter Schneider-Kamp wrote: > Guido van Rossum wrote: >> >> Oh, and to top it all off, I'm going on vacation. I'm getting married >> and will be relaxing on my honeymoon. For all questions about >> PythonLabs, write to pythonlabs-info at beopen.com. > Gefeliciteerd bij de eerste stap naar de echtscheiding! > Gelukwensen met de bruiloft en veel plezier tijdens de wittebroodsweken. > just-hope-I-got-my-dutch-right-ly y'rs Yes-but-what-a-nasty-first-sentence-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkraska1 at san.rr.com Thu May 11 01:05:23 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 05:05:23 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> Message-ID: <391A4071.D8E4505C@san.rr.com> > > What I (as a perl programmer/python novice) really miss in python are > true closures. Is this a language feature yet? One marvelous thing > that python has, though, is reduce, ... Roger that, Ghost Rider. :)- C/ From lindatripp at whitehouse.gov Tue May 2 23:04:41 2000 From: lindatripp at whitehouse.gov (lindatripp at whitehouse.gov) Date: Wed, 03 May 2000 03:04:41 GMT Subject: Cheap Sex 2344 Message-ID: Want some Great Gay Oral Sex? We have 100's or Ads on our system as well, 500 Guys waiting to talk to you LIVE 1-on-1 1-473-468-4157 misjoowfelgimvfhfbwpkyrwyldhvwxlt From pete at visionart.com Fri May 26 17:09:53 2000 From: pete at visionart.com (Pete Shinners) Date: Fri, 26 May 2000 14:09:53 -0700 Subject: HowCanI: inlined exceptions Message-ID: <392EE821.714573DD@visionart.com> after working with python a bit, one thing i find myself needing to do really often is test an expression before i can use it one simple assignments/etc what i'd really,really like to do is define something that works like this def catch(expression, errcode=None): try: return expression: except: return errcode if __name__ == '__main__': name = catch(fields[1], 'Anonymous') age = catch(now-birth, 100) pet = catch(findpet(name, age)) or 'No Pet' i would really like to do this for myself, because i would use it extensively! i understand the problem here is that my "expression" is being evaluated before the function is getting called, so the exception is raised outside of my function. i'm just hoping there's some way to do this be defining a lot of 'magic' classes and default handling. i could make it work by passing the expression in quotes (so it is a string), but i'd prefer something a little cleaner this is a case where C-style macros are handy! but i know some python guru can come through for me in this case. (???) -- _____Pete Shinners______ pete at visionart.com From sabren at manifestation.com Wed May 3 08:44:39 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Wed, 3 May 2000 08:44:39 -0400 (EDT) Subject: [ANNOUNCE] Ransacker extendable search engine In-Reply-To: Message-ID: On Wed, 3 May 2000, Oleg Broytmann wrote: > > Ransacker is a scriptable, incrementally-double-indexed search engine > > written in python. > > What about i18n/localization? Can it index non-American texts? Um. I don't know... :) It currently uses the anydbm module... if your dbm supports non-American strings, it should work just fine. The only test it makes is whether or not the key corresponding to the page is a string.. I break the words down with a normal string.split() I don't have python 1.6 installed, so I don't know how it'll react to unicode... Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From dale at out-think.NOSPAMco.uk Thu May 18 19:14:19 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 19 May 2000 00:14:19 +0100 Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> Message-ID: <8g1tgn$ccf$1@supernews.com> Thanks for the replies. MD5 looks interesting. -- Dale Strickland-Clark Out-Think Ltd, UK Dale Strickland-Clark wrote in message news:8g1no6$8uc$1 at supernews.com... > I need a little checksum routine as part of a larger project. I've written > the one below, which basically works, but it only produces a 32 bit > checksum. I'd prefer a 64 bit checksum but don't know how to code it in > Python. I can't get 'logical and' with >31 bits to work. > > This code might look unusual but some of the files I'm checksumming have > long strings of binary zeros at the end which were having the effect of > clearing out the checksum. Also this code will handle files that are all > zeros and still yield a useful result. > > If there is a Python library with something suitable, I'll happily use that > instead. > > Thanks for any advice/help. > > def CheckSum(filepath): > > file = open(filepath, "rb") > > chksum = 0L > toggle = 0 > > allfile = file.read() > i = 0 > while i < len(allfile): > ch = allfile[i] > if ord(ch) > 0: > if toggle: chksum = chksum << 1 > chksum = chksum + ord(ch) > chksum = chksum & 0X7fffffff > toggle = not toggle > else: > chksum = chksum + 1 > i = i + 1 > > return chksum > > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > > > From darcy at vex.net Sat May 6 07:37:00 2000 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 6 May 2000 11:37:00 GMT Subject: My Server supports Python? References: <391305A4.98430BB0@swt.edu> Message-ID: <8f104r$2elb$1@news.tht.net> Shah, Navneet wrote: > I need to add some python programming on my website. > How do I check whether my server supports python programming? The simplest way is to just ask your ISP. A side benefit is that you may trigger them to go and install it if you pique the admin's interest. Sometimes these guys are busy and can't install everything but if they know there is interest (especially if they know they can use you as a resource if they have any questions) then that item might bubble up to the top of the list. Oh, and if not, http://www.vex.net/ definitely supports it. However, I am looking for Zope clients to help me get Zope working. :-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From neilh at scintilla.org Mon May 1 20:27:10 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 02 May 2000 00:27:10 GMT Subject: BOM should be ignored by Python References: Message-ID: > I believe this was discussed on python-dev, and decided that Python itself > should not handle BOM markers at all - simply leave them to the app. It > would be a little painful to change the Python file read semantics to > handle this only when reading the first 2 bytes of a disk-based file. > Further, Python would need to maintain the BOM read for a particular > stream, so it can be applied to later, potentially disjointed reads of the > file. Damn. I expressed this badly. I'm not interested in changing Python's file reading, just the way it handles Python scripts. Neil From gduzan at gte.com Mon May 15 15:08:14 2000 From: gduzan at gte.com (Gary D. Duzan) Date: Mon, 15 May 2000 15:08:14 -0400 Subject: Stackless/microthreads merge news References: <39185686.665174C0@tismer.com> <391C085A.58329C18@prescod.net> <391DA2A1.276EFFAA@tismer.com> <391DCB06.F115E629@san.rr.com> Message-ID: <39204B1E.21B204AD@gte.com> Courageous wrote: > > > Sure. Does Java support function variables? > > I believe the JVM can support this, as the > authors of Kiev implemented closures and remained > JVM-compliant. I only wish the *language* would > go the additional step of offering method pointers. > It's not like it's hard. They could even be reference > counted. In fact, is has been done in Pizza, a Java language superset and free compiler. They do parameterized types, too, which by itself is called GJ (Generic Java.) I haven't had to do much Java programming, but what I have done leads me to believe that Pizza, or at least GJ, could be a great sanity saver. http://www.cis.unisa.edu.au/~pizza/ Gary Duzan GTE Laboratories From aahz at netcom.com Thu May 25 10:15:07 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 May 2000 14:15:07 GMT Subject: Timing out URLs References: Message-ID: <8gjchb$pqv$1@slb7.atl.mindspring.net> In article , Ty K. Kroll wrote: > > Question: Is there any way to set a time-out interval when reading URLs. >I use urlopen to fetch the pages, but some end up hanging when I hit a slow >moving page. Is there any way to avoid this? Thanks. -Ty I wrote a patch for httplib that provided a default timeout, but Guido raised some questions about the correctness of it that I haven't had time to resolve. If anyone needs it, send me an e-mail; if I get more than a couple of requests, I'll post it. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From anonymous at abc.com Mon May 22 20:04:12 2000 From: anonymous at abc.com (anonymous at abc.com) Date: 23 May 2000 00:04:12 GMT Subject: chinese i-ching forecast anything http://iching.126.com Message-ID: <8gchts$315h$281@news.cz.js.cn> provided forecast Fortune/Stock Exchange/Contract Signing/Partnership/Official/Sport Race/ Lawsuit / Weather/ Calamity and more..... http://iching.126.com From dagchess at frognet.net Mon May 15 09:39:38 2000 From: dagchess at frognet.net (Nathan Gundlach) Date: Mon, 15 May 2000 09:39:38 -0400 Subject: Stand-alone Python Apps? Message-ID: Is there any way to create stand-alone apps in Python that I can use on Windows, Linux/UNIX, and Mac? Thanks in advance, From vetler at news.ifi.uio.no Mon May 8 09:15:36 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 08 May 2000 15:15:36 +0200 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <0867817EB1B3A76A.FBD93754A864D6FC.8AC91DCAEC51970E@lp.airnews.net> Message-ID: * Cameron Laird > In article , > Michael Hudson wrote: > >Glyph Lefkowitz writes: > . > . > . > >> > - age. the other "P" language[0] has been around a little longer.. right? > >> > >> I hear this tossed around a lot. How *much* longer? > > > >I think perl was born in 1987 and Python in 1991. Not sure about > >either of those though. > . > . > . > Larry was working on Perl in 1986. It acquired the > name and appeared as a 1.0 in the last month of 1987. > > Guido chose his project and its name in December 1989. > Executables existed during 1990. The first public > release was in 1991. geez.. have I been missing out on Python for this long! I have som catching up to do.. vr From zjagrantz at znrcanz.gcz.ca Sat May 13 01:00:50 2000 From: zjagrantz at znrcanz.gcz.ca (John A. Grant) Date: Sat, 13 May 2000 01:00:50 -0400 Subject: Python Script vs. Win32 SendTo References: <4_4T4.1115$Xl.103670@news.goodnet.com> Message-ID: <8finj2$kua20@nrn2.NRCan.gc.ca> "Tom Vrankar" wrote in message news:4_4T4.1115$Xl.103670 at news.goodnet.com... > I'm trying to write a python script that I want to place in Win32's SendTo > directory. I'm completely confused. I can drop shortcuts to various .exe files > in there, and they do what I want. But a .py script... I got nuthin'. > > I tried to edit the target of the shortcut to insert "python" (it's in my > PATH), but that seemed to just run python on the file I sent to the shortcut, > not the script referenced by the shortcut. I tried to define a new filetype > with an extention of .sendto, with an Open action that would run the command > line 'python script.py "%1"', but got same result. > > I can approximate what I want by creating a batch file, and dropping it's > shortcut in SendTo. I've editted the PIF to close on exit and run minimized, > but it's unsightly, and slow, and DOS-ifies the paths of the files I send to > it. > > Anyone have any suggestions for the "correct" way to write a sendto-able > script in python? Thanks for any ideas. "Send to" is no different than double-clicking the file. It launches the indicated application and delivers the file to it on the command-line. It's also the same as dropping the file onto a shortcut to the application. But even though the shell can ShellExecute a .doc file and it can also ShellExecute() a .txt file, it really doesn't know what to do if you drop a .txt file onto a shortcut to a .doc file, does it? What should it do - launch the .doc app or the .txt app? What file should be displayed - the .txt file or the .doc file? So you can't send a file to a shortcut to another file, only to a shortcut to an app. You said you tried: "python script.py %1" but it didn't work. It's possible that python only processes argv[1] and ignores argv[2]. Try it from the command-line and see if it does or not. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here From ejr at lotus.CS.Berkeley.EDU Wed May 10 12:44:34 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 10 May 2000 16:44:34 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <8fa2m4$98v$1@agate.berkeley.edu> Message-ID: <8fc3li$glj$1@agate.berkeley.edu> And Jeff Senn writes: - - > Like a Virtual Virtual Machine? [...] - Hm... I'll look. Note that it's related through main developer to the VM under Squeak. It looks cool, but far off. - the Transmeta stuff is great but I heard about it many years ago -- - why hasn't it taken over the world? Because they had to get the silicon working. ;) They got everything together for full x86 emulation much more quickly than AMD did, which is a good chunk of Transmeta's point (if it's complicated, do it in software). I'm more interested in IBM's take, one that doesn't require a transactional write buffer. Transmeta takes the must-exactly-emulate-x86 route, which is great for their intended market, but doesn't make as much sense for a VM- like system on top of an OS. I threw it out there as a note that you don't _need_ x86 hardware to run x86 code efficiently. - What are we going to run on the "smart-dirt"? Maybe x86 code, but - probably not. Right now they're working with Atmels. See the MacroMotes: http://robotics.eecs.berkeley.edu/~pister/SmartDust/ By the end of the week, we should have basic MAC layers for the radios, etc. x86 code as a execution model might make sense simply for the ease of use. Doesn't matter what the low-level hardware is. Don't forget that the smart-dirt is smart because it's fully networked. It can rely on someone else to translate the code for it. Some folks are investigating similar tacts for Java, both for itty devices (http://www.ri.silicomp.fr/adv-dvt/java/jcod/) and for centralizing management (http://kimera.cs.washington.edu/). This has serious potential in a pervasively networked environment. - > And yet other people might eschew virtual machines for intermediate - > representations that can be compiled quickly while keeping the - Indeed -- my goal is not performance. My primary research area is high performance computing, and my particular viewpoint is that it's only worth while if you can achieve it while keeping your sanity. ;) Most people in the field disagree. They still hack up one-off things in old Fortran dialects, not realizing that the _total_ time (development + runtime) is longer than the total time could have been... - It is to factor out the complexities of software development to make - it more accessible to more people on more types of devices/platforms. Exactly. The whole point behind HPC is to support the scientists who need it. They care about their sciences, not the language fad of the month. That's why I think a universal-ish VM-ish environment is a great idea... Other folks have taken a compilation-only view and either haven't gotten very far or have gone too far (SUIF, Zephyr), which is why I tend to think that anything usable needs to be directly interpretable (or at least compilable in a millisecond)... - > And then there are those folks who have been working on a Scheme - > interpreter to serve precisely this role, Guile. - - Yes. But again I wonder why Lisp/Scheme/... never took over the world - and things like Python, the other-P, VB, and (perhaps) Java, do seem to - take hold... Knowledge transfer and public posturing. Java has sooo many negatives in both language and implementation, but Sun did a great job not only in evangelizing but also getting documentation and non-trivial, _popular_ example code out the door. They were helped greatly by the web explosion. Perl is similar, and Python is starting to go that way. Java had the `advantage' of springing unto the world mostly formed after years of closed development, so it looks more revolutionary. People get less excited over evolutionary development. The Lisp / Scheme crowd focuses on more esoteric topics, and the blatant mathematical background scares people (unfortunately). As much as I used to deny that reasoning, it really seems true. Even the parentheses. Having to re-map your keyboard to keep from holding shift every few keystrokes is enough to make most people walk away. (Having to re-map your whole keyboard is fun. Wish I knew of a good APL environment for Unices.) (It's amusing that some of the main positives in the current top Java implementations came from a much more flexible and useful language, Self.) - [M]y best guess is that Python is as close as anything I've seen to - being the right balance of language features and power with user- - accesibility [...] I tend to agree, although I do prefer many aspects of Dylan. That's my lisp-ish background shining through... Some of the info about P3K makes me think it'll be pretty close, although missing some of the things I hold dear. (I prefer CLOS-style objects, keeping methods orthogonal to the object. I really feel it can give much more flexible, useful code and can be implemented efficiently. I need to put some code where my mouth is before I spout off too much, though. And it puts some interesting twists on introspection.) - [...] the VM implementation is quite good/simple and Chris's - stackless makes it even better [...] The VM is nice, but, as I said, I'm an HPC guy. I need compiled code (minimal execution overhead), preferably recompilable to handle irregular problems. I haven't dug through Python's core enough to say if this is sensible now, and I'm not likely to until P3K's development opens up a bit more... I use Python more as a glue language at the moment, but I'm starting to integrate it further to allow rapid prototyping of sparse matrix partitioning heuristics. And Chris's stackless + continuations is certainly great for Python, but I can't help feeling like it's the early-mid 90s all over again (and probably earlier eras). The quest for efficient continuation support was taken up, semi-solved, and then vanished into the ether. His patch makes it possible to bring it back from the dead and make it useful, or at least so I hope. - [...] and if only I could run the core of it on a small, raw - microprocessor with modest memory (or a SmartCard ... or even my - Palm!) I believe it would take over the world. Maybe not take over the world, but at least help out significantly in making computing accessible. And anything that makes the icky PalmOS forms API usable would certainly be welcome. Jason From emile at fenx.com Thu May 18 19:42:42 2000 From: emile at fenx.com (Emile van Sebille) Date: Thu, 18 May 2000 16:42:42 -0700 Subject: How to get volume name under Win32? Message-ID: <074701bfc122$d57310c0$1906a8c0@fc.fenx.com> Dale, It seems this came up recently with a legitimate way of getting directly to the label using win32 extensions, so you may want to look for that, but in the meantime, this gets you there with a little parsing: import os info = os.popen(r'dir x:\missing.ext').readlines() info[1] or at least here on win95 info[1] holds the volume name. HTH, Emile van Sebille emile at fenx.com Dale Strickland-Clark wrote in message news:<8g1tn6$cf2$1 at supernews.com>... > I can't find a function that'll tell me the volume name for a given drive > letter - on NT / Win2000 > > Can anyone help? > > Thanks > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > > > > -- > http://www.python.org/mailman/listinfo/python-list > From dfan at harmonixmusic.com Thu May 11 14:12:22 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 11 May 2000 14:12:22 -0400 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> <8feioj$fei$1@nyheter.chalmers.se> <8feld6$8h8$1@nnrp1.deja.com> Message-ID: Andrew Cooke writes: | In article <8feioj$fei$1 at nyheter.chalmers.se>, | d98aron at dtek.chalmers.se (Fredrik Aronsson) wrote: | > Well, using Haskells syntax, I would suggest | > map((\a,b,c -> a+b+c), p,q,r) | | what's that funny backslash for? It's a lambda, basically. -- Dan Schmidt | http://www.dfan.org From thomas at xs4all.net Fri May 19 06:07:21 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 19 May 2000 12:07:21 +0200 Subject: Checksum routine - new to Python In-Reply-To: <3924D14D.85BF9A35@stud.ntnu.no>; from petersc@stud.ntnu.no on Fri, May 19, 2000 at 07:29:49AM +0200 References: <8g1no6$8uc$1@supernews.com> <3924D14D.85BF9A35@stud.ntnu.no> Message-ID: <20000519120721.D13281@xs4all.nl> On Fri, May 19, 2000 at 07:29:49AM +0200, Peter Schneider-Kamp wrote: > 3) binascii.crc32: > obviously a crc32 algorithm with a nice documentation and > some ISO blur. I think that'd be the way to go. Except that it seems to be new in Python 1.6. At least, my standard-redhat python 1.5.2 doesn't have it. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From skodela at my-deja.com Wed May 3 15:17:54 2000 From: skodela at my-deja.com (Sindh) Date: Wed, 03 May 2000 19:17:54 GMT Subject: How do you send mail through python Message-ID: <8epu0e$ltq$1@nnrp1.deja.com> Hi folks I have been struggling to findout which module has the facilities for sending email through python. Would appreciate your help sreekant -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From intmktg at CAM.ORG Sat May 27 14:13:54 2000 From: intmktg at CAM.ORG (Marc Tardif) Date: Sat, 27 May 2000 14:13:54 -0400 (EDT) Subject: vars between classes In-Reply-To: <8457258D741DD411BD3D0050DA62365907A1AC@huina.oceanic.com> References: <8457258D741DD411BD3D0050DA62365907A1AC@huina.oceanic.com> Message-ID: Thanks, your suggested solution is exactly what I was looking for. As you hinted, I am still confused about a few basic aspects of oop. To make sure I understood your example, I have a couple more questions: - Do I need to declare "class_var = 0" in first? Everything still works as expected without it. - Do I need to declare "self.var = var" in __init__? Couldn't I simply use first.class_var throughout the code? Thanks for the help, Marc On Sat, 27 May 2000, Doug Stanfield wrote: > Maybe what you really want to do is the following. It may be you're > confusing class construction and inheritance and the effects of > instantiation: > > #!/usr/local/bin/python > > class first: > > class_var = 0 > > def __init__(self, var): > self.var = var > first.class_var = var > self.myMethod() > > def myMethod(self): > print "first:", self.class_var > second(self.var) > print "last:", self.class_var > > class second(first): > def myMethod(self): > print "second:", self.class_var > first.class_var = 3 > > def test(var): > first(var) > > if (__name__=='__main__'): > test(2) > > > From jcm at bigskytel.com Mon May 8 20:52:59 2000 From: jcm at bigskytel.com (David Porter) Date: Mon, 8 May 2000 18:52:59 -0600 Subject: A Mountain of Perl Books + Python Advocacy In-Reply-To: ; from db3l@fitlinxx.com on Mon, May 08, 2000 at 07:11:22PM -0400 References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: <20000508185259.B3681@bigskytel.com> * David Bolen : > > > Yet another aside, but I don't think you would have even mentioned this if it was Fredrik Lundh who did the posting. Or am I wrong? David From urner at alumni.princeton.edu Tue May 30 18:03:40 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 30 May 2000 15:03:40 -0700 Subject: Wondering about Domingo's Rational Mean book References: Message-ID: > >>> halley(2,3) # 3rd root of 10 to depth 10 ^^ 2 Sorry, typo. If anyone on comp.lang.python wants me to post source code for the giant root fractions, let me know. Don't worry, I won't clutter sci.math with such stuff. Kirby From phd at phd.russ.ru Wed May 3 09:11:48 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 3 May 2000 13:11:48 +0000 (GMT) Subject: [ANNOUNCE] Ransacker extendable search engine In-Reply-To: Message-ID: On Wed, 3 May 2000, Michal Wallace (sabren) wrote: > > What about i18n/localization? Can it index non-American texts? > > Um. I don't know... :) > > It currently uses the anydbm module... if your dbm supports non-American > strings, it should work just fine. The problem is not in DB, but in word splitter. > The only test it makes is whether or not the key corresponding to the > page is a string.. I break the words down with a normal string.split() Ah, yes. That is, if I patch your program, add setlocale - I may hope to see it works... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From alecdem at mit.edu Sat May 27 13:52:43 2000 From: alecdem at mit.edu (Alexander) Date: Sat, 27 May 2000 13:52:43 -0400 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <8goufe$17n$1@newsg4.svr.pol.co.uk> <39300308.69576FD@mit.edu> <8gp0fh$2g4$1@newsg4.svr.pol.co.uk> Message-ID: <39300B6B.C0789ECF@mit.edu> Makhno wrote: > >>> Does xrange create an array of numbers 1...1e8? > >> > >> Yes, it does > >> > >No, it doesn't. > > Well, if it did create an array Matlab-style, then that would account for > why the C routine was faster. That was just an example. actually I used range(1,10000) I also tryed while loop and it was not empty loop, in all of those cases C was ~100 times faster than Python From mwh21 at cam.ac.uk Thu May 4 16:35:28 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 May 2000 21:35:28 +0100 Subject: raw_input in loop References: <39103BAB.D2DB2EDB@gssec.bt.co.uk> Message-ID: robin.escalation at ACM.org writes: > "Robert Cragie" wrote: > > >There is also the msvcrt module - function kbhit() might be what you're > >after... > > > >http://www.python.org/doc/current/lib/msvcrt-console.html > > That's fine for WinXX, but how about other platforms? I hate to lock > myself into GatesLand solutions. On unix you can have lots of fun with termios; something like this? import termios import TERMIOS import select def kbhit(): oldattr = termios.tcgetattr(0) try: attr = termios.tcgetattr(0) attr[3] = attr[3] & ~(TERMIOS.ICANON|TERMIOS.ECHO) termios.tcsetattr(0,TERMIOS.TCSANOW,attr) while 1: r,_,_ = select.select([0],[],[],0) if r: return 1 else: return 0 finally: termios.tcsetattr(0,TERMIOS.TCSANOW,oldattr) This sort of thing's inherently unportable though. bear-in-mind-I-came-up-with-that-merely-by-playing-around -not-through-any-deep-knowledge-ly y'rs M. -- 58. Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From jkraska1 at san.rr.com Tue May 23 02:27:03 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 23 May 2000 06:27:03 GMT Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> Message-ID: <392A254E.1386C0D3@san.rr.com> > The programmer should be able to mark certain names as > "not-for-export." The `*' set would not export such names, though if the > module user were to import the name specifically, that would override the > "not-for-export" flag. Actually, perhaps it would be simpler to > automatically assume that anything not in the `interface' set is > "not-for-export." I'm not sure how much of an issue it is, really, but the idea has merit on its surface: the notion that there is somewhere betwixt manually importing a symbol at a time and simply importing everything. Of course I'm guessing you could probably fiat something like that now with an instance of a module-level class or some such. C/ From spam at spam.com Sun May 21 18:32:20 2000 From: spam at spam.com (Penfold) Date: Sun, 21 May 2000 23:32:20 +0100 Subject: Python Win32 and DDE Message-ID: Allo :-) I am interested in using Python as a DDE server for providing information to Excel formulae. I can successfully get Excel to request information from a server inside a formula eg =pythonServer|SomeTopic!SomeData Does anyone know how I can now, from within the server, notify excel that the data has changed. I am thinking of the way, for example, that Excel will automatically update stock quotes from a DDEServer like Reuters as they change. Alternatively, is there any other alternative for "pushing" data to Excel from within python (without python knowing the specific cell address to publish info to, in which case its trivial). Have a nice day!! Des dharland[removethisobviouscrap]ATtheglobe.com From jkraska1 at san.rr.com Thu May 11 00:15:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 04:15:34 GMT Subject: Why should I switch to Python? References: <000401bfbaf5$877f8b60$2aa0143f@tim> <391A2EE0.83128776@san.rr.com> Message-ID: <391A34C3.387B2C63@san.rr.com> Ben Wolfson wrote: > > On Thu, 11 May 2000 03:50:27 GMT, Courageous > wrote: > > >Tim Peters wrote: > >> > >> [Grant Griffin] > >> > Speaking of C, I find myself missing the "x=" operators, and "++". > >> > However, I understand and endorse the reasons Python omits them. > >> > >> While ++ makes little sense in a language with immutable numbers, += (& > >> friends) can make good sense. > > > >+= and -= would be nice, but I don't understand what you mean by > >"friends" or why python might need them??? > > The friends of += are -=, *=, /=, %=, |=, &=, ^=, >>= and <<=. Well shoot me in the head for using a C++ language-specific presupposition to get all confused over ordinary English. Yeah, I agree with you. Those would all be nice short hand. Of course I'm one of the few nuts on the planet that *likes* to use ? : : expressions in C. :)- C/ From etoffi at softhome.net Thu May 18 16:32:16 2000 From: etoffi at softhome.net (etoffi) Date: Thu, 18 May 2000 16:32:16 -0400 Subject: nntp programs request Message-ID: <39245350.D0B09F20@softhome.net> i need a program/script that downloads from an nntp server and puts the results into a standard format (i think its called mbox) -- thanks guy{s|do} (tee hee) From jkraska1 at san.rr.com Thu May 18 01:52:25 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 18 May 2000 05:52:25 GMT Subject: A PYTHON PREPROCESSOR References: Message-ID: <392385D1.31135956@san.rr.com> > I think the collective wisdom is "don't do this". Not because of > whitespace issues -- these can be dealt with, with some thoughts. It's > because it's not needed -- Python is *so* flexible right now, there's not > much you need macros for. The longer term effort might be to -- in conjunction with eval, apply, and friends -- give python true metalinguistic capability. That's quite possibly a larger bite than I can chew at the moment, though. :)- C/ From tim at pnorthover.freeserve.co.uk Thu May 11 15:07:00 2000 From: tim at pnorthover.freeserve.co.uk (Tim Northover) Date: 11 May 2000 20:07:00 +0100 Subject: class instance checking -- newbie Message-ID: I think I need to determine whether an object belongs to a particular class (specifically whether it is a MatchObject) and I couldn't find anything very useful in the documentation. Could someone possibly suggest an answer or point me at the correct part of the docs? Thanks. Tim N. From emile at fenx.com Thu May 4 13:33:40 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 04 May 2000 10:33:40 -0700 Subject: Editing a string Message-ID: <3911B473.9D9652F0@fenx.com> import string pr = string.strip(pr[:-1]) HTH Emile van Sebille emile at fenx.com wrote in message news:<8esagm$b5a$1 at nnrp1.deja.com>... > file=open('gs.txt','r') > pr='' > while 1: > line = file.readline() > if not line: > break > pr=pr+line > file.close() > print [pr] > > output: > ['attgctagcytr \012'] > > How can I delete the space and \012 without editing the file. Is there > a built-in function? > > thanks > k > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > From dgoodger at bigfoot.com Fri May 26 22:26:35 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Fri, 26 May 2000 22:26:35 -0400 Subject: Closing Output files In-Reply-To: References: Message-ID: on 2000-05-25 15:10, Michaell Taylor (Michaell.Taylor at reis.com) wrote: > To accomplish this it seems that I must close the file (as shown), but once > closed the same instance doesn't seem to write to it again even given a > sys.stdout=progress_stamp command. > What am I missing? Perhaps you forgot to reopen the file? Once closed, even assigning the file descriptor to sys.stdout won't let you write to it. If this isn't the case, perhaps show us the real code; it helps! :-) BTW, the in the algorithm you show, unless you explicitly disallow it (by some careful scheduling process, tricky business) you will have to take care of cases when two processes simultaneously try to write to the file. If it *can* happen, eventually it *will* happen. That's one reason why client-server approaches are useful. Also, why assign your output file to sys.stdout just to use print? Why not use progress_stamp.write()? It seems clearer and less error-prone. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From echuck at mindspring.com Sat May 20 22:58:22 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Sat, 20 May 2000 22:58:22 -0400 Subject: Searching for leaks Message-ID: <392750CE.6A01CE34@mindspring.com> I have memory leaks in my long running Python program which I assume are caused by circular references. Using my knowledge of the program, I eliminated some of these, but to no effect on the magnitude of leakage. I checked the FAQ for memory leaks, but just saw the GC entry. Using a GC package isn't an option since I expect others to be able to use this package without having to have a "special" version of Python. So my question is: Are there any tools, techniques or tips to help find memory leaks? For example, getting a count of all the various objects (broken down by type and class) could be really useful. -Chuck From emmanuel.viennet at lipn.univ-paris13.fr Sun May 7 08:53:45 2000 From: emmanuel.viennet at lipn.univ-paris13.fr (Emmanuel Viennet) Date: Sun, 07 May 2000 14:53:45 +0200 Subject: circular reference: canonical CPython approach please! References: <0SfQ4.15265$HG1.409453@nnrp1.uunet.ca> <20000504224450.C3309@xs4all.nl> Message-ID: <39156759.70F6CA13@lipn.univ-paris13.fr> May be you could take a look at WeakDicts, http://www.handshake.de/~dieter/weakdict.html Emmanuel -- Emmanuel Viennet: LIPN - Institut Galilee - Universite Paris-Nord 93430 Villetaneuse - France http://www-gtr.iutv.univ-paris13.fr/ From richard_chamberlain at ntlworld.com Thu May 18 02:27:46 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Thu, 18 May 2000 07:27:46 +0100 Subject: Internet Programming with Python Message-ID: <3_LU4.2949$86.52249@news2-win.server.ntlworld.com> Hi All, I'm about to start a internet project and have decided to use Python. My local bookshop has this book instore, is it worth purchasing or is the material too out of date? Thanks Rchard From chris.rowley at ntlworld.com Tue May 23 14:29:26 2000 From: chris.rowley at ntlworld.com (Chris) Date: Tue, 23 May 2000 19:29:26 +0100 Subject: Spam Server help needed Message-ID: I am a final year university degree student trying to implement a simple com/corba bridge using Python. At the moment I am having problems building and calling any Python COM code. Even code which other people have run with no problems is causing me problems. Are you familiar with the spam server? I have tried running it with no argument and everything appears ok. When I run with /test as an argument i get this response. My final year project is due in on Thursday. if you could point me in the right direction I would really appreciate it. This is the interactive window after running spamserver first with no argument and then with "/test" as an argument. >>> Registered: Python.SpamServerGPO doing direct tests... Created spam server added 2 cheese sandwiches added some strong beer contains 3 items: 3 cans of spam 2 Sandwichs of Cheese 6 Bottles of Chimay Rouge ditched the beer, we are at work here! Tests passed testing COM **** - The Python.SpamServer test server is not available Spam server code # copyright Andy Robinson 1997 # you may freely modify and reuse this under the same terms # as the main python licence # registration stuff modified and expanded by Harri Pasanen # thanks also to Mark Hammond and Greg Stein # modified 7/8/99 to demonstrate having all clients on a # machine work with the same SpamServer data. # Gordon McMillan from win32com.server.exception import COMException import win32com.server.util import win32com.client.dynamic import sys import pythoncom _cans = None class SpamServer: _reg_clsid_ = "{EC419091-35FC-11D3-9403-00609736B700}" _reg_desc_ = "Python SpamServer GPO" _reg_progid_ = "Python.SpamServerGPO" _reg_class_spec_ = "spamserver_GPO.SpamServer" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _public_methods_ = ['AddCan', 'GetCanCount', 'GetCanAt', 'DeleteCan', 'GetDescriptionList', 'GetCrosstab'] # you need to explicitly list the public methods for COM to work # spelling errors here lead to errors when you call CreateObject # from a client def __init__(self): "it keeps a collection of data - start with a sample object" global _cans if _cans is None: _cans = [SpamCan()] self.cans = _cans def GetCanCount(self): "return the number of objects held" return len(self.cans) def AddCan(self, contents = 'Spam', type = 'Can', qty = 3): "two uses, can just add a generic one, or one you created in a GUI" newOne = SpamCan() newOne.contents = contents newOne.type = type newOne.qty = qty self.cans.append(newOne) def DeleteCan(self,index): del self.cans[index] def GetCanAt(self, index): return win32com.server.util.wrap(self.cans[index]) def GetDescriptionList(self): # for a list view return map(lambda x:x.GetDescription(), self.cans) def GetCrosstab(self): # some example data for yout to play with return [['e.g.','cans','bottles','bags'], ['spam',5,4,3], ['spinach',0,1,2], ['beer',12,4,2]] class SpamCan: "just a simple 'packet' of data to play with" _public_methods_ = ['GetDescription'] _public_attrs_ = ['contents','type','qty'] def __init__(self): self.contents = 'spam' self.type = 'can' self.qty = 3 def GetDescription(self): return '%d %ss of %s' %(self.qty, self.type, self.contents) # each class needs a class ID. You can get these by typing: # import pythoncom # g = pythoncom.CreateGuid() # print g # in the interactive window, then pasting it into your code. def RegisterSpam(): # register them both - this must be called once for the # demo to work import win32com.server.register win32com.server.register.UseCommandLine(SpamServer) def UnRegisterSpam(): """ Unregister each server - use this before deleting the server to keep your registr tidy""" print "Unregistering COM server..." from win32com.server.register import UnregisterServer UnregisterServer(SpamServer._reg_clsid_ , "Python.SpamServerGPO") print "SpamServer Class unregistered." # and finally some test code def TestDirect(): # does some stuff to verify the class works IN PYTHON s = SpamServer() print 'Created spam server' s.AddCan('Cheese', 'Sandwich', 2) print 'added 2 cheese sandwiches' s.AddCan('Chimay Rouge', 'Bottle', 6) print 'added some strong beer' print 'contains %d items:' % (s.GetCanCount()) for item in s.GetDescriptionList(): print '\t' + item s.DeleteCan(0) print 'ditched the beer, we are at work here!' print 'Tests passed' def TestCOM(): try: SpamSrv = win32com.client.dynamic.Dispatch("Python.SpamServerGPO") print 'Python.SpamServerGPO class created from COM' except: print "**** - The Python.SpamServer test server is not available" return print 'cans:', SpamSrv.GetCanCount() print 'Adding a cheese sandwich', SpamSrv.AddCan('Cheese', 'Sandwich', 2) print 'Adding some beer:', SpamSrv.AddCan('Chimay Rouge', 'Bottle', 6) print 'cans: ', SpamSrv.GetCanCount() descr = SpamSrv.GetDescriptionList() for item in descr: print item print "The Python.Spamserver COM Server worked OK." if __name__=='__main__': """If they ran the whole script, register classes. Options also given to unregister and to test""" import sys if "/unreg" in sys.argv: UnRegisterSpam() elif "/test" in sys.argv: print "doing direct tests..." TestDirect() print "testing COM" TestCOM() else: RegisterSpam() Chris Rowley From paul_pelletier at iname.com Wed May 3 16:10:18 2000 From: paul_pelletier at iname.com (paul_pelletier at iname.com) Date: Wed, 03 May 2000 20:10:18 GMT Subject: Problem getting error info Message-ID: <8eq12s$po0$1@nnrp1.deja.com> Hi all! I'm using PyRun_SimpleFile from C++ and it returns -1 but PyErr_Occurred () returns 0 How can I know what happened? Thanks! Paul Sent via Deja.com http://www.deja.com/ Before you buy. From cg at gaia.cdg.acriter.nl Mon May 15 17:22:49 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 15 May 2000 23:22:49 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> Message-ID: <8fppr9$95f$1@gaia.cdg.acriter.nl> Christian Tismer said: >Glyph Lefkowitz wrote: >... >> Also; the hype that's used here is all about the "enterprise" >> (whatever that is) and how Java is basically the new COBOL. >> Continuations are a LISPish feature, and won't be appreciated, as far >> as I can tell, by the ex-COBOL community now coming into Java. > >This argument has hit me right between the eyes. >I may be changing targets again, not so sure, >but see Jeff Senn's post and my reply. >Rebuilding Python as a very tiny, scalable engine >for microcontrollers could be what we need, soon. > Gee, you're easy to influence. One Java-hater passes by, drops a couple of casual and largely incorrect remarks, and you immediately retarget... It's probably right that the ex-COBOL community is coming to Java. Luckily, they're not the only ones, and the fact that the COBOL guys are moving over doesn't immediately make a language worthless. Side note: I haven't followed the whole stackless discussion, but I don't understand why you can get C to follow your ideas without having to modify the sillicon machine it's running on, while for Java you would need to have to modify the software machine it's running on. But then, I'm a no-brainer doing Java... -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From tbryan at python.net Thu May 4 08:07:33 2000 From: tbryan at python.net (Thomas A. Bryan) Date: Thu, 04 May 2000 08:07:33 -0400 Subject: Deleting objects in Python 1.6 References: Message-ID: <39116805.86326A69@python.net> Michael Hudson wrote: > > Try this: > > >>> l=[[]] > >>> m=l[0] > >>> for i in range(100000): > ... m.append([]) > ... m = m[0] > ... > >>> del l > > (hint: it segfaults on my machine, unless I use a v. new Python) Interesting. I caused Python to segfault once on Solaris. I wonder whether this problem was the cause. Then again, your code works on my little Linux box... Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> l = [[]] >>> m = l[0] >>> for i in range(100000): ... m.append([]) ... m = m[0] ... >>> del l >>> ---Tom From dirckb at my-deja.com Thu May 18 01:35:26 2000 From: dirckb at my-deja.com (dirckb at my-deja.com) Date: Thu, 18 May 2000 05:35:26 GMT Subject: platform neutrality (was: The REALLY bad thing...) References: <000501bfbee7$62318ac0$a2a0143f@tim> <8fscjv$1vpj@drn.newsguy.com> Message-ID: <8fvvet$3j0$1@nnrp1.deja.com> In article , Glyph Lefkowitz wrote: > ... > Despite my blatant platform preference, I am VERY glad that python > deals with Win32. It allows me to reach a wider audience without > worrying about the specifics of the underlying platform, and I am > immensely greatful for that! (Not only that, but it allows me to > detect and cope with those places that it can't gloss over, manually!) In the midst of the inevitable Windows-bashing, I'm glad people still realize that Win32 is a viable platform. However, it is important to remember this: All operating systems suck - (Yes, even Linux sucks, admit it) - except AIX, which sucks raw eggs through a very thin straw http://linuxmafia.com/cabal/os-suck.html (yes-that's-a-sign-that-i-shouldn't-be-posting-at-this-hour) :-) :-o X-0 !-| N-/ d Sent via Deja.com http://www.deja.com/ Before you buy. From nospam.newton at gmx.li Sat May 27 01:53:57 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Sat, 27 May 2000 05:53:57 GMT Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> Message-ID: <392f60e8.260627511@news.nikoma.de> On Fri, 26 May 2000 06:26:23 -0700 (PDT), Darrell Gallion wrote: > rzantow at my-deja.com wrote: > : When a newsreader, browser, or mail program trashes > : the indentation from examples of Python source, it is a > : real pain in the hindlimbs to recover the original > : program logic. > > Don't use tabs in the source, then all is well. Try feeding this to python, then: if 1 == 1: print "This won't work" You'll get a SyntaxError if somebody removes all leading indentation. Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From ngps at madcap.dyndns.org Wed May 10 11:43:40 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 10 May 2000 15:43:40 GMT Subject: SSL on Windows? References: <39152AC9.AFBCF2FA@studcs.uni-sb.de> Message-ID: <8fc03c$1eg$1@coco.singnet.com.sg> According to The Dude : > There is an SSL interface for Python. First you will need an SSL > library, > for example from www.openssl.org, then the SSL wrapper from > http://home.att.net/~nvsoft1/ssl_wrapper.html > You will need Perl for Win32 (http://www.activestate.com/ActivePerl) > to install OpenSSL on Windows. M2Crypto at http://www.post1.com/home/ngps/m2 Gives you OpenSSL's crypto, SSL and S/MIME. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From dirckb at my-deja.com Fri May 26 16:50:55 2000 From: dirckb at my-deja.com (dirckb at my-deja.com) Date: Fri, 26 May 2000 20:50:55 GMT Subject: A Python Beginner on Win32 References: <8gmhpa$jq3$1@nnrp1.deja.com> Message-ID: <8gmo3a$oj6$1@nnrp1.deja.com> Check for extra copies of the tcl and tk dll's in your Windows, Windows/System, or Windows/System32 directories, and delete them. Here is some more information: http://www.pythonware.com/people/fredrik/fyi/fyi02.htm http://www.danbala.com/python/fixtk/ Sent via Deja.com http://www.deja.com/ Before you buy. From g2 at seebelow.org Sat May 20 02:52:42 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 20 May 2000 07:52:42 +0100 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <8g1as4$p9q$2@newshost.accu.uu.nl> <39245386.B350E309@sage.att.com> Message-ID: <3926363A.B1F@seebelow.org> Garry Hodgson wrote: > > Grant Griffin wrote: > > > (BTW, why to you Unix people > > separate your packager gizmo from your compression gizmo? Very > > strange...) > > not strange at all. these are two completely different > functions, and thus belong in different programs. Well, in the context of a 1970's-style command line OS, which synthesizes complex behavior by stringing primitive commands together, maybe so. But surely it causes you people a lot of typing. (Or maybe you people write a shell script to mitigate that.) But in the context of a modern GUI OS, it makes a lot more sense to have all such functionality built into a single program. I have never seen a Windows equivalent of "tar" (that is, a packager, less compression), nor have I ever wanted one: if you're packaging, you might as well compress; if you're doing both, they might as well both be in the same program. Perhaps the '70s approach saved a little disk space or whatever by not repeating tar's functionality in each compression program, but clearly that isn't worth the extra trouble it causes for users to have to repeatedly invoke tar every time they want to de-compresss a package. > it is the same reason people use functions and classes in > their programs, rather than: > > main() > { > ...80000 lines of code omitted... > } > > (and yes, i've seen programs like that.) Me too. But they seem to be written mostly by people who would rather write shell scripts than use do-it-all GUI programs. ;-) sane-people-must-seem-crazy-to-the-insane--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From Simon.Langley at uwe.ac.uk Fri May 19 09:38:57 2000 From: Simon.Langley at uwe.ac.uk (Simon Langley) Date: Fri, 19 May 2000 13:38:57 GMT Subject: Regular expressions in files Message-ID: <39254357.C7988097@uwe.ac.uk> Can regular expression matching be done on files? I'd like to read just as much of a file as is necessary to either be a (greedy) match of the re or until a match definitely can't be found. If a string is read from a file, tried for a match and fails can I tell whether it failed because a) without reaching the end of the string it didn't match or b) it didn't match by the end of the string but might have if the next line had been appended? That would solve the problem. Thanks, Simon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Simon Langley Email: Simon.Langley at uwe.ac.uk University of the West of England Bristol BS16 1QY England From mhammond at skippinet.com.au Fri May 5 09:48:47 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 05 May 2000 13:48:47 GMT Subject: pythonwin - python1.5/1.4 problem References: <39128F6C.9372FEF1@gmx.net> Message-ID: <3jAQ4.12021$v85.79859@news-server.bigpond.net.au> "Robert Kiendl" wrote in message news:39128F6C.9372FEF1 at gmx.net... > is there a newer pythonwin-source which doesn't rely on > python1.4-headers ? I dont believe there are sources to Pythonwin available that actually _do_ work with Python 1.4!!! go to http://starship.python.net/crew/mhammond/cvs.html, and you will find all the info you need to get access to the very latest (ie, todays!) version of all the win32 stuff... Mark. From neelk at brick.cswv.com Sat May 13 08:17:35 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 13 May 2000 12:17:35 GMT Subject: Python lists/vectors/??? References: <391CA714.3EB0E8B5@san.rr.com> <391CE91F.28119CC6@san.rr.com> Message-ID: Courageous wrote: > > Something I don't understand about python list[] structures: are > they o(1) on index or o(n)? This is puzzling to me, because it's not > obvious what performance to expect from them at first glance. You'd > think there would be a python list type, for linked lists, and > python array type, for vectors, but there's not. What's up with > that? They are O(1) arrays. list.append()ing to them is technically O(n), but a full resize is triggered only every hundred (or thousand for big lists) insertions because the resize leaves some slop. Neel From dgallion1 at yahoo.com Fri May 26 09:26:23 2000 From: dgallion1 at yahoo.com (Darrell Gallion) Date: Fri, 26 May 2000 06:26:23 -0700 (PDT) Subject: Another salvo in the indentation war? I hope not. Message-ID: <20000526132623.24647.qmail@web2002.mail.yahoo.com> rzantow at my-deja.com wrote: : When a newsreader, browser, or mail program trashes the : indentation from examples of Python source, it is a real pain in the : hindlimbs to recover the original program logic. Don't use tabs in the source, then all is well. --Darrell Gallion __________________________________________________ Do You Yahoo!? Kick off your party with Yahoo! Invites. http://invites.yahoo.com/ From cjc26 at nospam.cornell.edu Sun May 28 08:10:36 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 28 May 2000 12:10:36 GMT Subject: Scoping: Is Python and does it matter? References: <392C3782.3675@europa.com> <392d1d14$0$23937@wodc7nh0.news.uu.net> <39306b73$1_1@news.nwlink.com> Message-ID: * noone menulis: | | In Perl, the second 'print_X' would succeed because 'x' would be found in | the outer scope. Python scopes the var to the function due to the | assignment (it seems). One could use 'global', but then the assignment | would affect the module var (where in Perl, the assignment might be | my($x)=2, in which case the "global" x would not be modified). Well as you know Python only has two scopes, global and local. If you want nested scopes you can use a class instead: class incr_by: def __init__(self, incr): self.incr = incr def __call__(self, num): return num + self.incr print incr_by(4)(5) ==> 9 The class incr_by is like a curried function. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From aahz at netcom.com Tue May 23 11:20:42 2000 From: aahz at netcom.com (Aahz Maruch) Date: 23 May 2000 15:20:42 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <8ge7ka$ouo$1@slb6.atl.mindspring.net> In article , wrote: > >Basically, there are so many more fundamental changes being discussed -- >such as true garbage collection, type/class unification, lexical >scoping, rich comparisons, strong typing, a new iteration protocol -- >that I'm amazed and a little dismayed that something as relatively >trivial as case-sensitivity is dominating the discussion. Thing is, I don't think any of these changes directly impacts the "look" of Python code, particularly at the visceral level. And the "look" of Python is what sold many of us on the language, *particularly* those of us who were initially suspicious because of the whitespace straightjacket. Computer history is littered with examples of people who took a really great idea and in the name of "improvement" pushed it in the wrong direction. I for one would not want to see Guido's name added to that list. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Not everything in life has a clue in front of it...." --JMS From greg at cosc.canterbury.ac.nz Mon May 22 22:25:50 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 23 May 2000 14:25:50 +1200 Subject: Is unpickling data a security risk? References: <3927C31D.4022850@maxnm.com> Message-ID: <3929EC2E.C9DC734@cosc.canterbury.ac.nz> Itamar Shtull-Trauring wrote: > > does the act of unpickling cause any code in the pickled object to > be executed? No. As far as I'm aware, the standard pickle module doesn't pickle or unpickle code objects, for precisely this reason. So you should be safe. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From mikael at isy.liu.se Mon May 15 11:01:40 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 15 May 2000 17:01:40 +0200 (MET DST) Subject: Question In-Reply-To: <8fophf$e7n$1@fe1.cs.interbusiness.it> Message-ID: On 15-May-00 Piero Giacomelli wrote: > Sorry if I make the ultra-faq but where can I find a good online manual on > Python (better if downloadable) You find it at http://www.python.org together with other useful information. Happy browsing! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 15-May-00 Time: 17:00:39 This message was sent by XF-Mail. ----------------------------------------------------------------------- From moshez at math.huji.ac.il Fri May 12 02:29:51 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 12 May 2000 09:29:51 +0300 (IDT) Subject: class instance checking -- newbie In-Reply-To: Message-ID: On 11 May 2000, Tim Northover wrote: > I think I need to determine whether an object belongs to a particular > class (specifically whether it is a MatchObject) and I couldn't find > anything very useful in the documentation. Could someone possibly suggest > an answer or point me at the correct part of the docs? Are you sure that checking that it isn't None wouldn't satisfy you just as well? If I haven't read your mind correctly, look for "isinstance" -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From b.hall at irl.cri.nz Wed May 24 22:16:21 2000 From: b.hall at irl.cri.nz (Blair Hall) Date: Thu, 25 May 2000 14:16:21 +1200 Subject: Where has 'compile.py' gone? Message-ID: <392C8CF5.83927E88@irl.cri.nz> I have been trying to locate the compile.py tool for developing python extensions with Visual C++. It seems that the links to it are broken or not responding, for example: http://starship.python.net:9673/crew/da/Code/compile does not respond. Can anyone direct me to it? Thanks From robin at jessikat.demon.co.uk Mon May 22 05:10:44 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Mon, 22 May 2000 10:10:44 +0100 Subject: ANNOUNCE: Python CVS tree moved to SourceForge References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> Message-ID: <79PE+LAUmPK5Ew46@jessikat.demon.co.uk> In article , Robin Becker writes >In article <200005212205.PAA05512 at cj20424-a.reston1.va.home.com>, Guido van >Rossum > writes >>If you have an existing working tree that points to the cvs.python.org >>repository, you may want to retarget it to the SourceForge tree. This >>can be done painlessly with Greg Ward's cvs_chroot script: >> >> http://starship.python.net/~gward/python/ > >running win9x 1.5.2 I get this with Greg's script > > >C:\Python\devel\Python>python \python\rgbx\cvs_chroot.py :pserver:anonymous at cvs.python.sourceforge.net:/cvsroot/python >Finding CVS directories...FIND: Parameter format not correct >found 0 of them > >I can certainly see ./CVS though. Whoops :( I guess Greg's obsession with cvs tools doesn't extend to not using unix specific stuff to allow them to work with non unix architectures. I replaced find_cvs_dirs with def find_cvs_dirs (start_dir): from os.path import walk def visit(D,dirname,names): from os.path import join, isdir d = filter(lambda x: x=='CVS',names) if len(d): p = join(dirname,d[0]) if isdir(p): D.append(p) dirs = [] walk(start_dir,visit,dirs) return dirs -- Robin Becker From moshez at math.huji.ac.il Mon May 15 00:03:24 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 15 May 2000 07:03:24 +0300 (IDT) Subject: Can't Extend In-Reply-To: <0MGT4.7890$WS3.61292@typhoon.we.rr.com> Message-ID: On Sun, 14 May 2000, Pete Shinners wrote: > i'm finding i cannot create my own C extensions for python. > (this time checking with the FAQ) i'm stuck. using Visual C 6 > i am consistently getting this error. > > ImportError: dynamic module does not define init function (initincr) > > > as far as i can see, this is incorrect. there is a simple initincr > function. i'm assuming there is some sort of name mangling going on > during the compile/link Surround the init function with extern "C" {} -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From tom at parlant.com Mon May 15 17:07:26 2000 From: tom at parlant.com (Thomas Lane) Date: Mon, 15 May 2000 15:07:26 -0600 Subject: Tkinter tear-off menus Message-ID: <3920670E.B34EB21D@parlant.com> Is there any way to turn off the tear-off feature of menus in Tkinter in Windows 2000? I set "tearoff=0" when I create the menu, but it doesn't seem to have any effect. As usual, any help would be greatly appreciated. Thomas Lane tom at parlant.com From latrada at netscapeonline.co.uk Tue May 16 03:15:35 2000 From: latrada at netscapeonline.co.uk (latrada) Date: Tue, 16 May 2000 08:15:35 +0100 Subject: mxODBC and delete References: <3920530E.79AACCDC@mitre.org> Message-ID: <3920e7d9_3@plato.netscapeonline.co.uk> Peter, I can run a delete command on my setup (i've just checked). I suppose you've checked that ODBC set up ok? Can you run a select statement? I presume from below that you're connect with a user name and password - does this have authority to delete? Have you tried a different database? Richard Peter Leveille wrote in message news:3920530E.79AACCDC at mitre.org... > I have been using the mxODBC package for access to a database. This has > been working great, until a recent problem that I have had. When I try > running the following code, python just freezes up. Does anyone know > what I am doing wrong, or if there is another way to do it? > > >>> import ODBC.Windows > >>> db = ODBC.Windows.Connect('????????','???','??????') > >>> c = db.cursor() > >>> c.execute('DELETE FROM ???????') From m.faassen at vet.uu.nl Tue May 30 07:08:47 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 11:08:47 GMT Subject: *blink* That's neat. References: Message-ID: <8h07fv$bnc$3@newshost.accu.uu.nl> Fredrik Lundh wrote: [snip] > btw, usability research has shown that "and" and "or" are about the > worst names you can use for these operators. how about renaming > them in Py3K? ;-) The Alice project again, right? :) just-had-to-make-that-comment-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mhammond at skippinet.com.au Mon May 1 20:11:09 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 02 May 2000 00:11:09 GMT Subject: win32com: _NewEnum being cached References: <8ecta7$nn5$1@nnrp1.deja.com> <8ek84a$a19$1@nnrp1.deja.com> Message-ID: "Tom Hines" wrote in message news:8ek84a$a19$1 at nnrp1.deja.com... > M wish list for the next release includes not having to > call _NewEnum() explicitly, and having the option to use dynamic > dispatch in this case. Im not sure exactly what you mean - you want the _NewEnum() to work for dynamic dispatch objects - agreed. Im not sure what you mean by "not having to call _newEnum() explicitly"? You normally dont! But if you _do_ need a new enumerator object each time you loop over the object, I can see no way around it... Mark. From tsummerfelt1 at myspleenhome.com Tue May 9 12:52:28 2000 From: tsummerfelt1 at myspleenhome.com (tony summerfelt) Date: Tue, 09 May 2000 16:52:28 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: On 08 May 2000 19:11:22 -0400, David Bolen wrote: > although perhaps doing so is not always of benefit for long > term maintainability and manageability. this is a regular argument against perl programming. personally i think the point is moot, if you can program in perl, you can read your code. i can still ready all the uncommented c code i wrote ten years ago :) > lastline = None > > while 1: > curline = input.readline() > if not curline: break > > if curline != lastline: > uniq.append(curline) > lastline = curline correct me if i'm wrong, but a duplicate of the last line is what's checked? the code i posted (typos and all) the duplicate items could have been anyhere in the file: one one two three or: one two three one the perl's hashes make that possible > Aside from the obvious brevity win of the "while " notation of actually that code could have been turned into a oneliner easily enough > syntax) which has drawn me to Python over Perl. i like the idea of python for larger projects. > All lowercase text is inherently harder to read and parse visually, i've never understood this either :) i don't have any trouble. But for questions I really wanted answered, I make sure I puncuate properly. -- *---------------------------------------- | |http://members.home.net/tsummerfelt1 | |remove myspleen to email | *----------------------- From g2 at seebelow.org Fri May 12 18:06:08 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 23:06:08 +0100 Subject: python idioms: (was: a really cool python feature) References: <391A3FD4.25C87CB4@san.rr.com> <8fdfp8$ho0$1@slb0.atl.mindspring.net> <391BB0C4.398E@seebelow.org> Message-ID: <391C8050.1AE1@seebelow.org> Neil Schemenauer wrote: > > Grant Griffin wrote: > >Forgive a possible newbie FAQ, but is there a page of Python > >idoms like this? > > Python doesn't have too many idoms and that's a good thing. > string.join is not an idom. That function is for exactly that > usage. I guess by "idiom" I was thinking of "recurring little bits of code to do common operations, that experienced people know". In that sense this is an idiom, if also a library function. ("It's a floor wax?/It's a desert topping/No, it's both!) > The only problem would be finding it in the library > reference. Exactly. As a Python newbie, I am repeatedly faced with this problem. I'm finding that although the syntax of Python can be learned in a pretty short time, learning the library remains a big effort. (But it's a complex thing, so I guess there's no way around that.) > The only really useful idioms I can think of right now are: One gizmo I've frequently needed (which I dug out of Deja awhile back) is to print a dictionary sorted by its values. if-ronco-sold-idioms-i-bet-they'd-call-it-"the-idiomatic"- -ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From ej at ee.duke.edu Mon May 8 06:08:45 2000 From: ej at ee.duke.edu (eric jones) Date: Mon, 08 May 2000 10:08:45 GMT Subject: thread behavior with join() and import Message-ID: Hello, I'm curious as to why the following two threads behave differently. When the "time" module is imported within the worker thread, a join() on that thread blocks indefinitely. If however, the import outside of the worker thread, the join() occurs as I expected. Removing the join() on the second thread allows it to exit normally. Why don't "import" and join() play well together, and is there a remedy? I really need the import to occur within the worker thread because of some wxPython issues. I'm using 1.5.2. The behavior is the same on both RH6.1 and NT 4.0. thanks, eric ---------------------------------------------------------------------------- --------------- import threading ,time class without_import(threading.Thread): def run(self): time.sleep(.5) print 'worker: without done' class with_import(threading.Thread): def run(self): import time time.sleep(.5) print 'worker: with done' ############# this works fine wo = without_import() wo.start() wo.join() print 'main: without import done' ######## without join(), thread also terminates normally w = with_import() w.start() print 'main: with import done' """ ##### uncommenting this blocks indefinitely w = with_import() w.start() w.join() print 'main: with import done' """ From slinkp23 at yahoo.com Fri May 12 12:59:22 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 12 May 2000 12:59:22 -0400 Subject: Thread dummy References: <391BB583.B1B14C47@yahoo.com> Message-ID: <391C386A.518EB9B5@yahoo.com> Glyph Lefkowitz wrote: (nice code snipped) Thanks for the example, it's exactly what I wanted. Now I just have to make my design work the way I want. :) > >>> w=Thread(target=Waiter) > >>> w.start() > >>> Messenger() > Messenger: hi de ho > Messenger: Waiter got a message -> hi de ho > ### > > The way that second line of output appears is a bit of foreshadowing > of the nasty tricky things that await you down the path of > multi-threading. That doesn't look so nasty to me -- makes perfect sense: we're using the same output (stdout) for Messenger and Waiter! Just use separate file objects and it's fine. -- ................ paul winkler .................. slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From thomas at xs4all.net Tue May 16 15:48:47 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 16 May 2000 21:48:47 +0200 Subject: Compiled version when .cgi extension is used for scripts In-Reply-To: <8frtjc$1fpn$1@news4.isdnet.net>; from bn@7ways.com on Tue, May 16, 2000 at 06:34:53PM +0200 References: <8frtjc$1fpn$1@news4.isdnet.net> Message-ID: <20000516214847.Y13281@xs4all.nl> On Tue, May 16, 2000 at 06:34:53PM +0200, Bernard Niset wrote: > Our site is using python extensively and very succesfully. The only thing > is that I decided to name the cgis script with an extension in .cgi > instead of .py. The drawback of this decision is that no compiled version > is generated when a script is executed meaning that it needs a > recompilation on each execution. Scripts (the first file you start) are never stored in compiled form. Only modules you load (files you load with 'import') are stored, always as '.pyc'. If you want to benifit from this, make your script as lightweight as possible, putting all or most functionality in a separate module. Note that your script would have to be fairly lengthy before you to actually notice the difference between the two versions. > How can I generate a compiled version of the scripts and how should I name > them in order for the interpreter to take them into account. Unfortunately, compiled python scripts need to have the .pyc (or .pyo) extention for the interpreter to see them as such... If they have any other name, the python interpreter tries to interpret them as normal scripts instead. I'm not really sure why, but I guess the variance in bytecode versions is too great to make the python interpreter autodetect them... I think it would be neat if it could, though. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From greg at cosc.canterbury.ac.nz Mon May 15 21:36:00 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 16 May 2000 13:36:00 +1200 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> <391E9E84.D1A0D74A@prescod.net> <20000515182712.X13281@xs4all.nl> Message-ID: <3920A600.F80A60EC@cosc.canterbury.ac.nz> Thomas Wouters wrote: > > > 1000l 1000I 1000J > > *This* is the best argument for the use of J that I've heard so far. I don't see why capital I or J should be allowed at all. Mathematicians and electrical engineers always use lower case i or j for sqrt(-1). If only lowercase i were allowed, there couldn't be any confusion with l (unless you use a *really* strange font...) -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From neilh at scintilla.org Thu May 4 20:04:07 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Fri, 05 May 2000 00:04:07 GMT Subject: Copyright and License References: <39119033.8BC1A4EA@colconsulting.com> <8esgt5$p3l$1@netnews.upenn.edu> <3911D9F8.CC361B85@colconsulting.com> <391205C0.CCC8EA5C@san.rr.com> Message-ID: > Remember that, no matter what else, your license is worthless > if you don't pay the $25 and register the copyright. You do not have to register copyright and can not in most countries. To quote from the WIPO site (http://www.wipo.org/eng/main.htm): """The laws of almost all countries provide that protection is independent of any formalities, that is, copyright protection starts as soon as the work is created. """ Some countries may have required registration in the past but if they signed the Berne Convention then you automatically have copyright. Registration may make it easier to prove. Neil From alwagner at tcac.net Mon May 1 23:46:27 2000 From: alwagner at tcac.net (Albert Wagner) Date: Mon, 01 May 2000 22:46:27 -0500 Subject: Tk button enable/disable? Message-ID: <390E4F93.3ADF2ECD@tcac.net> I want to enable and disable buttons in Tk. I tried the following code but it only partially works: # Add a button box to the Open page self.openBBx = Pmw.ButtonBox(self.pad1, labelpos = 'w', frame_borderwidth = 2, frame_relief = 'groove', orient = 'vertical') self.openBBx.pack(side='right', padx=3) #add buttons to box self.newButton = self.openBBx.add('New', command=self.newDBrequest) self.openButton = self.openBBx.add('Open', command=self.openDBrequest, state='disabled') self.closeButton = self.openBBx.add('Close', command=self.closeDBrequest, state='disabled') self.deleteButton = self.openBBx.add('Delete', command = self.deleteDBrequest, state='disabled') Then later when conditions dictate: self.openButton.state = 'normal' self.closeButton.state = 'normal' self.deleteButton.state = 'normal' self.openButton.update() self.closeButton.update() self.deleteButton.update() They are initially disabled OK, but I cannot figure out how to later enable them. Any help greatly appreciated. -- Small is Beautiful From breiter at usf.Uni-Osnabrueck.DE Wed May 24 07:51:02 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 24 May 2000 11:51:02 GMT Subject: Good ideas :-), no time :-( References: Message-ID: <8ggfn6$dhd$1@newsserver.rrzn.uni-hannover.de> In article , Fran?ois Pinard writes: > Yesterday, I had to read long shell scripts and complex Makefiles. > Python is really corrupting me, because more I work with Python, more I > consider that complex shell code is hard to read. True. At least the bash. es or rc are probably a little better. > So, I came with this "simple" idea, that we should have tools for converting > Makefiles and shell scripts into specialised Python scripts. (And why not > `sed' and `awk' as well, once on that road, the same as Perl once did.) At least for the awk and sed commands the idea is not new. I documented it once on my advogato diary entry.... Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From jkraska1 at san.rr.com Sun May 28 22:25:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 02:25:43 GMT Subject: Stackless Python Question(s) References: Message-ID: <3931D5C5.80423806@san.rr.com> > I just read a little of what Stackless Python is...and though I do not > pretend to understand it "all" it looks to be a good thing. It's a completely wonderful thing as soon as you fall into an application area which truly needs it. > What are they good points and bad points about going stackless? The point of stacklessness is to allow rapid frameshifts and (virtually) arbitrarily deep recursion. The first class continuation, which is a snapshot of an execution frame at an arbitrary moment in time, is one obvious functionality which stacklessness enables. Continuations themselves allow programmers to build their own schedulers with incredible ease; this is allowing me to build a rapid prototyping simulation environment in python that just does incredible amounts of stuff for a very small linecount. Instead of timeslicing over actual time, I timeslice over sim- ulation primitives. Until you need exactly this, it can be hard to imagine how incredibly wonderful this is. > Will Python go that way totally? Well, only Guido can say, really. One snag is that I believe that it is impossible to implement stacklessness in JPython without altering the JVM. Plainly this means that stacklessness can't be done in Pure Java unless Sun, et al endorses it. C/ From glyph at twistedmatrix.com Thu May 18 16:09:02 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 18 May 2000 15:09:02 -0500 Subject: Java vs Python In-Reply-To: JRHoldem's message of "Thu, 18 May 2000 11:25:54 -0700" References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> Message-ID: Woohoo! actually steering back on topic ... I mostly have a lot of questions for the list here. JRHoldem writes: > Back to the topic of the thread...I think in some ways Java is > *better* simply because the industry supports and accepts it > more (although thanks to members of this community Python is > becoming more widespread [that's why I'm here now{tx Glyph}]). > > I don't claim to be a python expert by any stretch, however I > know alot about developing marketable software that needs to be > accepted by a broad audience. Certainly mainstream support from > a market "leader" (and I use the term loosely in this case) like > Sun should be a factor in choosing your platform... I question the wisdom of this statement, but I am afraid I can't openly dispute it. Part of the problem, I suppose, is the difficulty of demonstrating Python's advantage over Java and applicability to certain problem domains. Python can definitely be used to solve certain classes of problem better than Java, however. It's not just Java though, it's other heavily entrenched languages such as C++, Perl, and even Visual Basic. If you're just trying to solve a computing problem, and one tool will solve it better than another, why is it that IT managers have such a propensity to go for the tool which is "better supported", I.E. the one they've read about more recently, regardless of the actual merits of the tools? I know this is one of the things the Open Source "movement" was started to combat, and they've had some degree of success, but mainly that seems to come from the fact that people like Red Hat and VA Linux Systems are pouring TONS of money into marketing Open Source in general, and Linux specifically. I am afraid that entrenched, credible Open Source projects will start to get this kind of bizarre inertia, inspired by the marketing, while newer ones struggle in the same way that their "ancestors" did. > Programming is not a pure art in today's world, if it was then > maybe we could realistically compare Java and Python based on > pure performance standards. However, marketability, support and > breadth of knowledge base are all things any IT manager needs to > consider when picking the *best* software platform. The "support" argument strikes me as spurious. I've gotten much more support for Python from #python and this ng than I have from the Java equivalents ... and if you're small, support from Sun is unrealistic, if you're large, it's still overpriced and not really worth too much. (Same for the Linux-support versus Microsoft-support argument ... some commercial support is really excellent, but being "commercial" doesn't magically make it good.) Marketability? Hm. The thing that makes Java marketable is the tremendous amount of money that Sun has poured into getting it into every trade rag that they could possibly find. Fellow pythonistas, short of getting Guido to use the time machine for material gain is there any way we can effectively market Python as a competitor to a language / platform with that kind of agressive force behind it? "breadth of knowledge base" -- this ties into marketability. Employers see ads, they figure people are out there learning Java. Potential employees see ads, they figure that employers are looking for java. Where does one go (aside from the New York Times) to illustrate that there exists an employable pool of python programmers who know what they're doing? Better yet, is there some way to demonstrate the low learning curve of python? All I've heard so far is anecdotal evidence (and the CP4E paper even refers explicitly to that as a reason for believing python is easy to learn). My conclusion is obviously that Python needs more marketing ;-) hopefully it can have this without becoming evil. Is the PSA doing anything on this front? > P.S. Remarq is screwing up my Email address. For those who want > to continue any part of this conversation in email, I'd be glad > to learn and teach...jraddock at hotmail.com RemarQ does that for a reason. My mailbox has gotten ... more "interesting" of late ;-). Also ... this is the *python* list... and you know who Python is named for, right? spam-spam-spam-spam-spam-spam-spam-spam-wonderful-spam-lovely-spam-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From boncelet at udel.edu Sun May 7 23:30:57 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 08 May 2000 13:30:57 +1000 Subject: Vim and python syntax question Message-ID: <391634F1.3E47BDA5@udel.edu> When running vim with syntax coloring on, sometimes I get strong, dark colors and sometimes weak, pastel ones. I have no idea why the colors vary. Anyway, how can I always get the strong, dark colors? Or, does anyone have a python syntax file of which they are proud and willing to distribute? (I'm running Vim 5.6-11 on linux.) -- ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From copal at cifnet.com Tue May 16 19:32:12 2000 From: copal at cifnet.com (Ian Mondragon) Date: Tue, 16 May 2000 18:32:12 -0500 Subject: Objective-C + Python...? References: <391CE037.14B030E9@cifnet.com> <3dpuqpp3xb.fsf@newcnri.cnri.reston.va.us> Message-ID: <3921DA7B.961C5B89@cifnet.com> Andrew Kuchling wrote: > There was an Objective C SIG; see > http://www.python.org/sigs/objc-sig/. Unfortunately, the links to > actual code seem to have rotted. Anyone on the newsgroup still have > copies of the objc module? > > --amk thanks for responding. i actually found the sig later on that night & successfully downloaded the last version from the archives (ver. 0.55). if you want to get your hands on it, you can get ahold of it here: ftp://ftp.codefab.com/pub/incoming/PyObjC-0.55.tar.gz i know i'm going to be hacking (read: kludging) away at it. }-) -- __END__ Ian Mondragon == copal at cifnet.com $bigBoys->use(BSD); From tismer at tismer.com Tue May 2 15:31:51 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 02 May 2000 21:31:51 +0200 Subject: Newbie Question References: <39089928.47B55E1B@tismer.com> <87n1mfi9x4.fsf@mancala.semo.net> Message-ID: <390F2D27.F4A5D4D2@tismer.com> Aaron Malone wrote: > > Christian Tismer writes: > > > But if you want to be sure only to loose \n, and also might > > want to solve the problem that the list line might have no \n, > > you are better off with a loop, like so: (after reading) > > > > for i in range(len(mylist)): > > if mylist[i][-1:] == "\n": > > mylist = mylist[:-1] > > Correction: > > for i in range(len(mylist)): > if mylist[i][-1:] == "\n": > mylist[i] = mylist[i][:-1] Sure, sorry. The code was tested by the "brain interpreter" only, which is much too much forgiving :-) -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From dana at mmi.oz.net Wed May 10 11:19:37 2000 From: dana at mmi.oz.net (Dana Booth) Date: 10 May 2000 15:19:37 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <8fateo$5h1$1@216.39.141.21> <391A613B.2154@seebelow.org> Message-ID: <8fbum9$vhn$0@216.39.141.36> Grant Griffin wrote: GG: I have recently been doing some C, and I've found myself not declaring GG: variables, and leaving ";" off. When I began doing certain tasks in Python that I previously would've done in Perl I found myself ending lines with ";", but it didn't matter in that case. I still use Perl, but I like the "order" of Python, as opposed to the "chaos" of Perl, and so for any script that's larger than a couple of pages, I really would rather use Python. When I decided to learn a little bit of Python, I wrote a UNIX mail client. One thing that was glaringly obvious when I did that, was that Perl is much quicker parsing lines and searching regular expressions. I still use the mail client... Turned out sort of cool for a weekend project. :) -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From glyph at twistedmatrix.com Mon May 15 17:53:23 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 15 May 2000 16:53:23 -0500 Subject: The REALLY bad thing about Python lists .. In-Reply-To: Russell Turpin's message of "Mon, 15 May 2000 14:34:59 -0500" References: <39205163.EC104A@do.not.use> Message-ID: Russell Turpin writes: > Should Python lists be as fast on other platforms as they are on > Linux, where good OS memory management turned the second strategy > into the first? Personally, I see Python as "C with foam padding", an expression which I believe has been used before on this list. As such, I don't believe it should include a complete reimplimentation of libc. If a platform doesn't adhere to a standard or does something in a really brain-damaged way, it should be fixed on that platform. I had this brought to my attention earlier today when someone on IRC was commenting that the % operator in perl and python carries the symantics from the C library of the platform in question, and sometimes that's wrong (off-by-one errors when it was being treated as 'remainder' rather than 'modulus' in negative numbers). This is a simpler fix than reimplementing list allocation, but I *still* don't think it's python's bug: tell your libc maintainer to fix it. If they don't, switch platforms. There are plenty of free ones out there with correctly-functioning libcs, or ones that you can patch yourself. > Personally, I think those who have to develop under Windows suffer > enough already, and they should at least enjoy the same reasonably > fast Python as the rest of us! If you make dumb choices, you're likely to suffer. Most POSIX functionality is severely crippled (fork...) in Windows, and I wouldn't expect windows memory management to be much different. I don't think it's worth anyone's time to improve this situation. Of course, I wouldn't have thought it was worth anyone's time to port python in the first place, and I am SO glad that others disagree with me! :-) > Grateful-to-develop-on-a-real-OS'ly yrs, > Russell let-me-sing-in-the-same-chorous-with-you-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From irmen at --nospam--bigfoot.com Mon May 1 15:44:48 2000 From: irmen at --nospam--bigfoot.com (Irmen de Jong) Date: Mon, 1 May 2000 21:44:48 +0200 Subject: python.announce: what the h*ck? Message-ID: <8ekmqg$cck$1@news1.xs4all.nl> Hi What's up with c.l.python.announce? I haven't received any messages in that group for over two months now... Is it dead? Irmen From mwh21 at cam.ac.uk Sun May 14 15:32:43 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 May 2000 20:32:43 +0100 Subject: real-life identity and "==" References: <8fmu53$lrj$1@news.dtc.hp.com> Message-ID: weeks at golden.dtc.hp.com ((Greg Weeks)) writes: [schnipp] > Now, I agree that comparing the *contents* of lists is sometimes useful. > But "==" should not be the way to do it (just as "=" is not the way to copy > contents). > > In practice, it doesn't much matter. But it itches. So close! > > Greg > > PS: Java has a similar problem. For BitSets for example, the equals() and > hashCode() methods erroneously assume immutability. Again, so close. Common Lisp has eq, eql, equal and equalp which are all different ways of testing equality - and that's probably not enough for a completely general solution. There is a reason for this; equality is not as clearly a defined operation as one might think. BTW, eql is almost exactly what you are asking for in Python. unhelpful-ly y'rs m. -- 40. There are two ways to write error-free programs; only the third one works. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From shapr at uab.edu Thu May 25 18:37:12 2000 From: shapr at uab.edu (Shae Erisson) Date: Thu, 25 May 2000 22:37:12 GMT Subject: was Re: [PATCH] A compromise on case - now Python Debuggers References: <8gefi7$l7b$1@info3.fnal.gov> <392DA6D6.941CFCB7@codeit.com> Message-ID: <392DB09A.9DD6464F@uab.edu> Grakka wrote: > > Although easily readable error messages are something definitely needed, > imho, I am really not waiting for that feature as I am for using a > kick-butt python debugger.. have you tried the debugger in IDLE? it's pretty nifty, tho I dunno if it qualifies as kick-butt. YOu may want to read up on PythonWorks. plug-the-local-swedish-industry-ly y'rs -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr sIre From blues-l at cyberus.ca Fri May 5 11:10:27 2000 From: blues-l at cyberus.ca (blues-l at cyberus.ca) Date: Fri, 05 May 2000 11:10:27 -0400 Subject: ftp return format References: Message-ID: <3912E462.2E296390@cyberus.ca> Okay, probably a dumb question but could it be that the transfer should be set to binary mode and is using the default ascii mode? Richard Chamberlain wrote: > Hi, > > Although its not directly a Python question, I know you guys are probably > nice enough to answer it anyway ;) > > At work we run ftp to get files off an AS400 into a text file. These then > get imported into Excel to mess around with. > > I would like to be able to use Python's ftplib to get the file and then use > COM to import straight into Excel. > > The problem is then when I use ftplib I get the data back in a certain > format, I've also used the dos ftp command and I get the data the same way. > > We use a thing called Rumba FileTransfer which is obviously translating > somehow, anyone know how I can do the same? > > e.g. > > from python: > > 0183 > 0000100000000000000000000000000000000000K0000000000000K > 0184 > 0000300000013200000000000000000000000000000000013200000 > 0185 > 0000300001185200000000000000006M0000000000000118520006M > > from Rumba: > > 0183 1 0 0 > 0 -2 0 -2 > 0184 3 132 0 0 0 > 132 0 > 0185 3 11852 0 -64 0 > 11852 -64 > > I realise that it's fix delimited, but then I get stuck on the K and M which > crop up with negative numbers. > > Thanks, > > Richard From ljz at asfast.com Fri May 12 19:32:32 2000 From: ljz at asfast.com (Lloyd Zusman) Date: 12 May 2000 19:32:32 -0400 Subject: Schwartzian Transform in Python? References: Message-ID: Fran?ois Pinard writes: > Art Haas writes: > > > I'm looking for the Python way to do this [...] > > The "technique" called Schwartzian Transform by Perlers is as old as earth > (OK, OK! I agree we should put eternity in some relative context, here :-). > > I just wanted to say that I'm surprised that someone could so easily give > his name to such an old technique. I presume that there is some confusion > between the syntax and the method? Perhaps so ... and in this particular case there could very well also be some confusion between the ego and the method ... :) -- Lloyd Zusman ljz at asfast.com From frankc at colconsulting.com Thu May 11 18:46:11 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Thu, 11 May 2000 18:46:11 -0400 Subject: ANNOUNCE: Pyro 1.1 (distributed objects) References: <8ff875$3q4$1@news1.xs4all.nl> Message-ID: <391B3833.26EDAD18@colconsulting.com> What about object versioning? If someone changes a remote objects interface or data I may need to rely on earlier versions of the object. -- Frank V. Castellucci http://PythPat.sourceforge.net Pythons Pattern Package Irmen de Jong wrote: > > PYRO - Python Remote Objects - version 1.1 > > by Irmen de Jong - irmen at bigfoot.com > > WHAT IS PYRO? > > Pyro is an acronym for PYthon Remote Objects. It is a basic Distributed > Object Technology system written entirely in Python, and for use in Python > only. With this, it closely resembles Java's Remote Method Invocation (RMI). > It has less similarity to CORBA - which is a system- and language > independent Distributed Object Technology and has much more to offer than > Pyro or RMI. > > However, Pyro has some interesting features: > > - Naming Service which keeps record of the location of objects. The location > of the NS can be discovered using a broadcast mechanism, amongst others. > > - Support for Python types only restricted by those that the standard > 'pickle' module handles (all builtin types, and user created classes). > Objects as arguments are also supported when the code for those user > defined classes is also available on the server side. > > - Support for all Python argument types (variable argument lists and keyword > arguments, *args and **keywords). > > - Exceptions that occur in the remote object will actually be raised too on > the client, just as if the error occured locally. Pyro's exception > transportation mechanism makes this possible. > > - Proxy compiler which automates the task of creating wrapper (proxy) > classes. > > - Dynamic Proxies if you don't like to have pregenerated proxies. > > - Full source code in Python. > > The most important changes since the previous version (1.0) are: > > - Hierarchical naming scheme. Extended NS with hierarchical object naming > functions. This allows for more structured and controlled object naming > while being fully backwards compatible. > - Configuration files to easily specify a set of Pyro configuration items > - Fixed some bugs and made the protocol more stable and less sensitive to > weird data. > - More tests and cleaned up test code > - Documentation update > - A lot of other small changes and fixes. > > WHERE CAN I GET IT ? > > From my Pyro homepage: http://www.bigfoot.com/~irmen/pyro.html > > It comes with a Python-style license, but is otherwise free for > commercial and non-commercial use. > > REFERENCE: > >

    > Pyro 1.1 - Distributed Object system for Python (7-May-2000) > > -- > Irmen de Jong -- irmen @ > bigfoot.com From torppa at polykoira.megabaud.fi Wed May 10 07:40:46 2000 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 10 May 2000 11:40:46 GMT Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> Message-ID: <8fbhru$oc8$1@news.kolumbus.fi> In article <391914DD.BF2A2C32 at ecs.soton.ac.uk>, Jacek Generowicz wrote: >How would you rewrite the following code, in good >python style ? > >list1 = [ 1,2,3,4,5,6 ] >list2 = [ 6,5,4,3,2,1 ] > >count = 0 >for item in list1: > print item - list2[count] > count = count + 1 > >In other words, I want to loop through two lists, >performing some operation on elements in >corresponding positions . . . there must be a more >elegant way. It would be more elegant to build your lists as list of tuples l = [ ( 1,6 ), (2,5), (3,4), (4,3), (5,2), (6,1) ] for e in l: print e[0] - e[1] but if that is not possible, this looks a bit nicer list1 = [ 1,2,3,4,5,6 ] list2 = [ 6,5,4,3,2,1 ] for i in range(0,len(list1)): print list1[i] - list2[i] From ak42 at kurir.net Sat May 20 13:57:07 2000 From: ak42 at kurir.net (alex k) Date: Sat, 20 May 2000 17:57:07 +0000 Subject: command history in the interpreter? Message-ID: <3926D1F3.8D07DC60@kurir.net> hello i had python1.52 in linux/mandrake7. when i pressed the uparrow at the console i could access the command history, so to speak. just like in bash. now i use slackware7. i installed both python1.52 and python1.6 (the former replacing the latter). it didn't work in none of them. all of the arrowkeys type things like ^[[C ^[[D and such. the python interpreter in win98 (1.52 and 1.6) also don't give me the history function. anyone who has an idea on how to make that work again? it's so awkward now that i can't even edit the txt without deleting it (backspace). is that feature hidden somewhere in the interpreter, or did mandrake somehow add it themselves? thanks in adv. / alex -- . . ... ak42 at kurir dot net ... From chris.lada at westgroup.com Thu May 18 15:42:04 2000 From: chris.lada at westgroup.com (Chris Lada) Date: Thu, 18 May 2000 15:42:04 -0400 Subject: Nested Dictionaries Message-ID: <392446c9@wwwproxy3.westgroup.com> Is there some where of directly accessing information in a dictionary which occurs as part of another dictionary i.e.: inner = {'city':'This City','state':'This State'} outer = {'12345':inner} In order to access the 'city' information in the 12345 dictionary entry, I do the following: temp = outer['12345'] # yields the outer dictionary entry with the key '12345' tempCity = temp['city'] # yields the city value of the inner dictionary of the # outer dictionary entry with the key '12345' Is there an easier or more direct way of doing this ? Thanks, Chris From thomas at xs4all.net Fri May 19 07:38:49 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 19 May 2000 13:38:49 +0200 Subject: python 1.6a2 and openssl In-Reply-To: <39251EB0.AB239BF2@stroeder.com>; from michael@stroeder.com on Fri, May 19, 2000 at 01:00:00PM +0200 References: <20000518002020.14299.qmail@web111.yahoomail.com> <20000518100136.B13281@xs4all.nl> <39251EB0.AB239BF2@stroeder.com> Message-ID: <20000519133849.F13281@xs4all.nl> On Fri, May 19, 2000 at 01:00:00PM +0200, Michael Str?der wrote: > Thomas Wouters wrote: > > > > socket socketmodule.c -DUSE_SSL -I/usr/include/openssl -lssl -lcrypto > IMHO modern OpenSSL applications import the headers with name > openssl/[header file] => -I/usr/include should be sufficient. Indeed.. I (wrongly) assumed the openssl rpm had renamed the /usr/local/ssl/include directory to /usr/include/openssl... It is in fact the /usr/local/ssl/include/openssl directory, so the whole -I line is unnecessary. (provided you installed the rpm, or another package that places the include/libs in the same spot ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sh1232 at my-deja.com Tue May 16 18:11:44 2000 From: sh1232 at my-deja.com (sh1232 at my-deja.com) Date: Tue, 16 May 2000 22:11:44 GMT Subject: python web hosting Message-ID: <8fsh2i$796$1@nnrp1.deja.com> I've searched this forum but could not find a good list of web hosting company that support python. If your web hosting company (or know of one) supports python cgi, please post it to this thread. Thank you very much in advance. -sh Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Sun May 28 17:32:27 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 May 2000 21:32:27 GMT Subject: Java vs Python References: <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <8g1pca$drc$1@newshost.accu.uu.nl> <8gmd77$hq3$1@gaia.cdg.acriter.nl> Message-ID: <8gs39b$m7m$5@newshost.accu.uu.nl> Cees de Groot wrote: > Martijn Faassen said: >>The only place Python isn't known very well is the Netherlands. At least >>I feel this when I look at the state of nl.comp.programmeren, the Dutch >>programming newsgroup. (i.e. "how do I change the color of a button >>in VB??????!!") :) >> > With schools giving credits for doing your MCSE, the state of programming > in this country is indeed very bad. Luckily, Sun has come up with the > idea of doing a real developer conference (a novum for the Netherlands), > which was sort of fun to do (www.ideamachine.nl). Hm, neat. With a heavy focus on Java, I notice. :) > We could present > a bunch of Python talks next year - the conference is totally marketing > and M$ free, but for the rest most everything goes. Cool. I see they had some neat stuff on memetics and evolutionary computing. A few Python talks would be a good idea, indeed. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nick at spam_me_notvideosystem.co.uk Mon May 22 05:09:00 2000 From: nick at spam_me_notvideosystem.co.uk (Nick Trout) Date: Mon, 22 May 2000 10:09:00 +0100 Subject: Help! Tkinter Message-ID: <3928f98e@news.xtml.co.uk> I'm having trouble getting Tkinter to work. I've uninstalled and reinstalled Python/Tcl and looked at the FAQ but I cant find a relevant posting. I get: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter WHOOPS! Even though I think I have found a Tcl/Tk 8.0 installation, I can't seem to import the _tkinter extension module. I get the following exception: ImportError: DLL load failed: A device attached to the system is not functio ning. If you don't know how to fix this, consider searching the Python FAQ for the error you get; post to the comp.lang.python if all else fails. Read the source file FixTk.py for details. Traceback (innermost last): File "", line 1, in ? File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 8, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: DLL load failed: A device attached to the system is not functioning . Can anyone help please? Thanks, Nick. From richard_chamberlain at ntlworld.com Fri May 26 03:29:50 2000 From: richard_chamberlain at ntlworld.com (RS Solutions) Date: Fri, 26 May 2000 08:29:50 +0100 Subject: CGI Debugging Message-ID: <8gl95d$2n8$1@gxsn.com> I'm having great difficulties getting Python to work via CGI. Is there anyway I can get the traceback on to the web page so I know what's happening? I haven't got access to error logs so I can't look at it that way. Many thanks, Richard From rwallace at esatclear.ie Wed May 24 16:37:28 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Wed, 24 May 2000 21:37:28 +0100 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <8gf3ms$jce$2@newshost.accu.uu.nl> <392b1f96$0$2624@news01.syd.optusnet.com.au> Message-ID: <392C3D88.1F7C@esatclear.ie> Jeff Massung wrote: > > Arnold de Vos wrote in message > <392b1f96$0$2624 at news01.syd.optusnet.com.au>... > >Yep. As pointed out on this group from time to time, import from * can be > >harmful. > > I'm new to Python - I'm understand why it is harmful (finally ;) - but was > wondering, if it is that harmful, why have it to being with (what good can > come from using it)? I use it in all my Python code. > Also, what would be the harm in removing "passed down importing" (that's the > only way I could think of to state it)? If y imports z and z imports y, why > not have z have to import x to get the functionality of x, too? I use that in all my Python code too. I want to be able to get on with the job without worrying about trivial details, and one of the trivial details I especially want to not have to worry about is exactly what module the function or variable I need is in. C can do that; a language that couldn't would be a major step down for me. Yes, I understand the reasons why other people do it differently. In a really big project with multiple teams of programmers I'd probably do it differently too, but in the small-to-medium projects that I work on, I prefer the convenient way. -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From greg at cosc.canterbury.ac.nz Thu May 4 22:20:37 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 05 May 2000 14:20:37 +1200 Subject: How to get terminal width? References: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <8epl60$1b42$1@nntp6.u.washington.edu> <8es8fr$rjm$1@nntp6.u.washington.edu> Message-ID: <39122FF5.4D0B42D8@cosc.canterbury.ac.nz> Donn Cave wrote: > > | stty size > | > It looks pretty good to me! Ultrix 4.2, Digital UNIX 4.0, AIX 4.2, > HP/UX 10.20, FreeBSD 4.0, 2 versions of Linux and BeOS 4.5 pass Solaris too - just tried it. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From jcm at bigskytel.com Sun May 14 23:16:38 2000 From: jcm at bigskytel.com (David Porter) Date: Sun, 14 May 2000 21:16:38 -0600 Subject: A TYPICAL NEWBIE MISTAKE? In-Reply-To: <391F6844.E473FC2E@san.rr.com>; from jkraska1@san.rr.com on Mon, May 15, 2000 at 02:57:37AM +0000 References: <391F513B.CEA12592@san.rr.com> <391F6844.E473FC2E@san.rr.com> Message-ID: <20000514211638.D8348@bigskytel.com> * Courageous : > > I miss the colons all the time, too (as Mr. Pinard so > readily pointed out.... ha). Which brings me to the topic. > Sometimes colons seem syntactically unnecessary. For example: > > if : > statement > else: > statement > > Really, else doesn't need a colon, as far as I can tell > (I can see the need for the if, supposing you wan to > have the statement on the same line). > > Doesn't seem like "def" does, either. When using python-mode in Emacs (or jed), the colon facilitates auto-indention. Also, if you forget the colon, the next line will not be indented, so you will catch your mistake. david. From pdfernhout at kurtz-fernhout.com Sat May 13 11:50:15 2000 From: pdfernhout at kurtz-fernhout.com (Paul Fernhout) Date: Sat, 13 May 2000 11:50:15 -0400 Subject: VxWorks Port References: <007401bfbb4f$4d599430$3e2ca8c0@lexicon.jeeves.net> <14618.52922.343285.973127@malibu.aero.org> Message-ID: <391D79B7.7F447C62@kurtz-fernhout.com> Darrin- While I can't release the code (nor do I have it -- it was for a client), I ported Python to VxWorks on the MIPS about a year ago. It really didn't take more than a couple of days IIRC, although pretty much all I needed was the core interpreter, nor did I do any complex threading support (Mutexes, Queues, etc.) Doing that would take longer. I was already familiar with the implementation of other byte coded and semi-intepreted languages (Smalltalk, Lisp, Forth etc.) so your mileage may vary. Also, it took quite a bit longer later to SWIG code I wanted to link with the interpreter, so porting the interpreter is really just part of the effort. The reasons I used to justify it for the project wer: * Being able to test code interactively. * Being able to test code from scripts. * Providing end user scripting. * Allow some development to take place on a PC instead of the development platform. I think many of the configuration options I struggled with were related to getting Python compiling under GCC for MIPS, not related to VxWorks per se. There were a few questions, all resolved more or less by trial and error, staring with the Unix Port (don't try using the PC config options under VxWorks -- I did the first time and they were very confusing to start from). One big set of issues was deciding for each type of functionality if VxWorks/POSIX already supported it to avoid compile errors related to redeclarations. I think once it compiled it worked (although it always had some Python startup errors related to missing some desired libraries...) While I'm not sure this is the best approach, I created a directory under the source for files I didn't think I needed (merging all the files together from the various directories), and had a make file which compiled what was in the current directory. Then I moved modules I didn't think I needed out of the main source directory. I then just kept recompiling and changing options till I got something that worked (maybe making minor edits to a couple of files at some point). The valuable part of the effort is really this list of minimal files to include... Since VxWorks supports so many platforms, it is going to be a somewhat unique experience in any case. I think the real arguements for Python under VxWorks is: * testing * time-to-market * development on the PC * open endedness I think the size of the interpreter was around a few hundred K (300K?). Many embedded systems these days have megabytes of memory. Obviously, Forth is probably a better choice for an 68HC11 with 64K of memory. I never tried the advice on making a really tiny Python interpreter -- a few hundred K was fine for this project. But I'd love to see such configuration options as part of the standard distribution. -Paul Fernhout Kurtz-Fernhout Software ========================================================= Developers of custom software and educational simulations Creators of the Garden with Insight(TM) garden simulator http://www.kurtz-fernhout.com Jeff Collins wrote: > > I don't know about VxWorks, but I have ported python to Brightstar > Engineering's PPC-823 based embedded platform. The port was fairly > straightforward for both of their supported operating systems: the > POSIX-compliant RTOS (called "pkernel") Linux. > > During my (unreleased) port of Python-1.5.1 to the palm, I was able to > significantly reduce the size of the code itself - down to approx > 160K. That's still quite large by palm standards, but small by python > standards. As the port of 1.5.2/1.6 continues, I'm finding ways to > reduce the size of the source (then will examine the memory model to > find ways of reducing the use of the heap). This will hopefully > benefit all embedded applications. > > Jeff > > Darrin Edelman writes: > > Hello all, > > > > I have seen a couple of posts and mentions of porting Python to VxWorks. I > > am wondering if anyone can point me toward one of these ports or give me > > more information. > > > > As a side note, I am wondering how large the interpreter is -- is it really > > reasonable to put it into an embedded environment? > > > > Thanks in advance, > > -Darrin > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > From zxmar05NOzxSPAM at student.uni-tuebingen.de.invalid Mon May 15 07:48:30 2000 From: zxmar05NOzxSPAM at student.uni-tuebingen.de.invalid (Eduard Hiti) Date: Mon, 15 May 2000 04:48:30 -0700 Subject: Can not remove file in windows because of "permission denied" References: <8fmo5k$e5u$1@news.uni-paderborn.de> <391f2eba$0$20207@wodc7nh6.news.uu.net> <391F3F89.6A1B024@san.rr.com> Message-ID: <264eb0d0.78baf683@usw-ex0106-046.remarq.com> I had success with renaming locked files on the command line (not with explorer). The renamed file remains locked, but you can use the file name for a new file. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From m.faassen at vet.uu.nl Thu May 4 12:08:07 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 May 2000 16:08:07 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> Message-ID: <8es797$p76$1@newshost.accu.uu.nl> Thomas Wouters wrote: > On Thu, May 04, 2000 at 12:02:22PM +0000, Don Tuttle wrote: >> If Activestate really wants to endear itself to the Python community, why >> not develop a centralized repository for all the widely scattered Pyton >> modules? This would fill a great need at a relatively low cost to them. > Widely scattered ? Which modules are those ? As far as I know, most can be > found in the Vaults of Parnassus (www.vex.net/parnassus). That database does not contain the modules itself, just links to them. Not that this ever bothered me much; I think Parnassus is great and check the 'latest' entries frequencly. It'd be nice if parnassus could be extended so it could keep local copies of modules. Also nice would be somekind of distutils integration. Tim Middleton, the secret force behind the Vaults, knows about both ideas. I've been toying with the idea of implementing a Zope-based version of the Vaults eventually myself. That should be able to offer some interesting features. (hm, just got a weird idea: test the module through the web! obviously this is hopelessly insecure, but..) But right now time does not permit me. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mwh21 at cam.ac.uk Mon May 1 18:39:27 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 May 2000 23:39:27 +0100 Subject: Python Compiler References: <8F26DEAB4joshtinamecom@209.208.0.7> <8F27B8A37joshtinamecom@209.208.0.7> Message-ID: josht at iname.com (Josh Tompkins) writes: > Would this type of compiler result in any kind of speed increase? Even > though it runs like it's in an interpreter, does the translation to pure > machine code increase speed? About 20%, apparently. Depends quite a lot on what you're doing, I'd imagine. See: http://www.mudlib.org/~rassilon/p2c/ Cheers, M. -- ... but I guess there are some things that are so gross you just have to forget, or it'll destroy something within you. perl is the first such thing I have known. -- Erik Naggum, comp.lang.lisp From greglandrum at earthlink.net Wed May 24 10:30:10 2000 From: greglandrum at earthlink.net (greg Landrum) Date: Wed, 24 May 2000 14:30:10 GMT Subject: Python equivalent to Perl's warn/confess/die References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> Message-ID: <392BE833.EC8EBBA5@earthlink.net> Andy Lester wrote: > > I looked in the Perl/Python phrasebook and didn't see anything that > discusses an easy way to write warnings to the screen. > > For instance, in Perl if I wanted to write something to stderr to show > where in my process I am, I'd say: > > warn "$n records read"; > > Now, I know I can say > > sys.stderr.write( '%s records read' % n ) > > But is there a module somewhere that encapsulates that so I don't > explicitly send it to stderr? You could write your own. Put this in a file called warn.py which lives somewhere in your PYTHONPATH: import sys __warningDest = sys.stderr def warn(msg): __warningDest.write(msg + '\n') then you can do: from warn import warn warn('beware the Jabberwock') -greg -- greg Landrum (greglandrum at earthlink.net) Software Carpenter/Computational Chemist From cpr at emsoftware.com Fri May 12 21:38:43 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Sat, 13 May 2000 01:38:43 GMT Subject: Learning pyton on the front page of Amazon! References: Message-ID: Note that your "front page" at Amazon is constructed dynamically based on what you've purchased in the past. (E.g., I just bought a couple editions each of Homer's The Iliad and The Odyssey, and so I'm presented with a bunch of Greek classic texts.) So if you've been buying Python books, ... -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Roman Milner" wrote in message news:F06131AF0B967595.1026AF0276251AB4.96F74700B5B9EE30 at lp.airnews.net... > I just noticed that learning python is on the main front page of > amazon.com - it's just about the first thing you see! > > ^Roman From just at letterror.com Sun May 28 13:20:46 2000 From: just at letterror.com (Just van Rossum) Date: Sun, 28 May 2000 18:20:46 +0100 Subject: Not well supported on the Mac? In-Reply-To: Message-ID: At 9:14 AM -0700 28-05-2000, Kirby Urner wrote: >In a thread starting at: >http://forum.swarthmore.edu/epigone/geometry-research/pefrorsken > >Clifford J. Nelson advises me to forsake a Python-based >approach for another language called Clean, because >"Python is not supported well for the Mac." > >I thought I'd run that by comp.lang.python, as well as >the Python edu-sig. Given the importance of Mac technology >in the schools, limitations re Python on that platform >are of some relevance to the "Computer Programming for >Everyone" (CP4E) thread. > >Please reply cc: pdx4d at teleport.com -- no need to post a >reply to the thread mentioned above, as that's a pure >geometry research list and doesn't need to get bogged >down in technical discussions re Mac OS, Tkinter, IDLE >or whatever (I've already posted enough along those >lines, will maybe summarize feedback I get re Mac). Python is in general pretty well supported on MacOS. However, Tk(inter) and therefore IDLE are not so good, due to lack of interest: Jack & I don't use Tkinter ourselves, and it's up to others to improve the situation... Just From mturatti at my-deja.com Tue May 30 04:24:58 2000 From: mturatti at my-deja.com (Maurizio Turatti) Date: Tue, 30 May 2000 08:24:58 GMT Subject: tkinter module on a Sgi Message-ID: <8gvtsg$rbo$1@nnrp1.deja.com> Hi, I installed the python 1.5.2 package from freeware.sgi.com but when I import Tkinter it doesn't find the _tkinter module. Should I download and compile the source or is the precompiled module "hidden" somewhere into the tarball? thanks, M.T. Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Thu May 18 18:13:00 2000 From: cut_me_out at hotmail.com (Alex) Date: 18 May 2000 18:13:00 -0400 Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> Message-ID: > If there is a Python library with something suitable, I'll happily use > that instead. Maybe. How about crc? import binascii binascii.crc_hqx ('asentuhaonthu', 1092) Or MD5? import md5 md5.new ('naoethuanotehu').digest() Alex. From Gareth.McCaughan at pobox.com Wed May 31 17:41:21 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 31 May 2000 22:41:21 +0100 Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <8h34v4$7ac$1@nnrp1.deja.com> Message-ID: <868zwqbdoe.fsf@g.local> Remco Gerlich wrote: > There exists some mathematical proof, by Ronald L. Graham, about an upper > bound to a certain question of Ramsey theory (I don't know more about this, > this is from some web page I saved once). It uses a rather large number. .. > To get Graham's number, you take x = 3^^^^3. Next, you set x to 3^^^...(x > ^'s)...^^^3. Repeat 63 times. .. > Now *that's* a large number. You forgot to mention that the actual answer (for which Graham's number is an upper bound) is conjectured to be 6. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From dworkin at ccs.neu.edu Thu May 11 14:00:32 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 11 May 2000 14:00:32 -0400 Subject: python idioms: (was: a really cool python feature) In-Reply-To: Grant Griffin's message of "Fri, 12 May 2000 08:20:36 +0100" References: <391A3FD4.25C87CB4@san.rr.com> <8fdfp8$ho0$1@slb0.atl.mindspring.net> <391BB0C4.398E@seebelow.org> Message-ID: Grant Griffin writes: > > BTW, the usual way to do that is > > > > string.join(somenames, ", ") > > > > Forgive a possible newbie FAQ, but is there a page of Python idoms like > this? The problem is what you consider an idiom. The case above might require a standard idiom in other languages, but when you have a standard library function that does all of the work, documenting it elsewhere as an "idiom" seems pointless. In other words, the answer to your question is "The standard Python Library Reference." -Justin From kno at jtan.com Wed May 17 11:42:39 2000 From: kno at jtan.com (Matt Dunford) Date: Wed, 17 May 2000 15:42:39 GMT Subject: seeking volunteer position References: <3921691e.793513@news> Message-ID: Strange email address... Anyway, if you're willing to volunteer for documentation, check out www.gnu.org They have many projects under their wing. eat at me.com (harrfy) writes: >Hello, all >My name is Anthony Waterman. I am learning to program in python after >having taken some C. I'd like to know if any open source developers >need any help on their projects. I am an excellent writer and I can >write documentation, test, offer feedback, etc. Please e-mail me at >tonyw54 at home.com if anyone would like some help. >Thanx :-) -- From aruth at intercation.com Wed May 10 09:24:54 2000 From: aruth at intercation.com (Adam Ruth) Date: Wed, 10 May 2000 07:24:54 -0600 Subject: Any module or library for full-text indexing? References: <391854D9.89285A9B@do.not.use> Message-ID: <8fbo0l$1dc0$1@news.aros.net> I use Swish++, http://www.best.com/~pjl/software/swish/. It's got the perfect combination of speed and ease for me. Plus, while it can be used for the web (that's where I use it), it's not web-centric and can therefore be used for any application. -- Adam Ruth InterCation, Inc. www.intercation.com "Russell Turpin" wrote in message news:391854D9.89285A9B at do.not.use... > I'm looking for a Python module that does full text > indexing, ie, that extracts a set of significant words > from a text document, and searches for a candidate word > in a list of words so extracted. The module should > solve the following problems: > > COMMON WORD MANAGEMENT. No one wants to index on common > words such as "the," "of," and "what." Ideally, a module > that does full-text indexing would have some tool for > managing the set of words that are defined as "common." > Words not commonly in a dictionary, such as "Noam" and > "Chomsky," are significant and should be indexed. > > COGNATES. The module should have some way of identifying > variations of the same word when searching the index, > ie, "goose" would also match on "geese," "mouse" on > "mice," and "456" on "four-hundred fifty-six." This > requires the module to have or make use of a language > dictionary in some form. (I would be more than happy > with noun cognates. Yeah, the number example is hard, > and not required.) > > The package does not need to implement a persistence > mechanism, nor manage the indices and their referents. In > other words, the core functions I am looking for are: > > extract_significant: text -> word_list > find: word, word_list -> set of hits > > These would be trivial functions if not for the > linguistic aspects as described above, and it is > precisely these problem for which I'm hoping to find a > solution. Of course, if the module goes further, that > is great. > > If there is no existing Python module for this, I would > be interested in any C package that could be adapted > toward this end. In this case, I would try to wrap the > C package as a Python module, and make it available for > other Python programmers. > > If there is no C package, I'll consider anything that > can run on a Linux box. > > If there is no package that does this, I'll go out > on the glacier and eat ice worms. > > Thanks! > > Russell From urner at alumni.princeton.edu Mon May 29 01:18:32 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 28 May 2000 22:18:32 -0700 Subject: Clifford Algebra References: <8gsehu$btl@gap.cco.caltech.edu> <8gsnem$fmu@gap.cco.caltech.edu> Message-ID: >The code itself probably won't help you learn the concepts. It goes too >low-level when the power of Clifford algebra is in the generality of >expression. Playing with the code (hooking it up to PyOpenGL for instance) >will be helpful and fun, though. > >> Kirby Hey, drop me a note if you have anything I can look at, if ya'd be so kind. I agree that code alone will not make everything crystal clear. However, I think a low level approach would help balance what I'm finding on the web, which rarely stoops to the level of numeric examples (something all linear algebra books do, if they're designed to teach, and not just show off how "high level" the author is). Kirby From francis at robinton.demon.co.uk Fri May 12 08:12:29 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Fri, 12 May 2000 13:12:29 +0100 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> <5v+rnIBnysG5Ewoc@robinton.demon.co.uk> <391C7B1D.2D3D@seebelow.org> Message-ID: In article <391C7B1D.2D3D at seebelow.org>, Grant Griffin writes >My complaint with Python as a learning language is that it spoils you. >Just as it's hard to convice BASIC users of the need to declare >variables in C, it will be hard to convince young Python programmers of >the need to do that and all kinds of other stuff when they proceed to >learn other languages. Yes, just like the difficulty of persuading children to move on from simple noun-verb(-noun) sentences to ones using clauses and phrases etc. I strongly believe in learning on a basis of need rather than because someone else thinks it would be good for me. Of course if we want to keep programming an arcane art practised in secret by the initiated then Python is very bad for us:) Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From jkraska1 at san.rr.com Mon May 8 03:52:48 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 08 May 2000 07:52:48 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <391645E3.3B850279@san.rr.com> <39165663.666406EB@san.rr.com> Message-ID: <3916731B.D5BFFB4D@san.rr.com> > >>> a = "a" > >>> eval("'a' is a") > 1 So, it would appear that the limit would be uneval'd strings, potentially taken from the user or a file. I suspect that even if you can't eval strings, this is probably one of the reasons why the intern() function exists. You can grab a string from a non constant external source, and attempt to give it identity, based on previously existing known string identities. Very cool indeed. This isn't something c or c++ can do for you, either. C/ From hgg9140 at seanet.com Fri May 26 18:14:36 2000 From: hgg9140 at seanet.com (Harry George) Date: 26 May 2000 15:14:36 -0700 Subject: Java vs Python References: <391F88EB.D25BB0F8@san.rr.com> <392E4285.D0F72C75@darmstadt.gmd.de> Message-ID: Robb Shecter writes: > Courageous wrote: > > > > 1. Which is more maintainable ? > > > > Python. No comparison. > > I wonder about this. Python is much more maintainable in a practical way, > because of the interpreter and reflective language features. A good Java IDE > like IBM Visual Age can make up for most of that, though. No way. In recent code I ported from java to python, the LOC dropped by c. 50%. A visual IDE isn't going to make up for that, esp. when you add in the time for code reviews. Maybe the LOC delta won't be that large in all cases, but it is worth considering in your discussions. -- Harry George hgg9140 at seanet.com From tim_one at email.msn.com Wed May 17 02:03:06 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 17 May 2000 02:03:06 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: Message-ID: <000501bfbfc5$939bff80$b52d153f@tim> [Fran?ois Pinard, with a continued fraction algorithm] > ... > I do not think GCD is necessary, but I did not prove this to myself. Take heart, it's not. For adjacent pairs a c -, - b d in a cf expansion, a*d - b*c alternates between +1 and -1, which is an easy inductive proof (provided you start with two for which this is true, as is the case for the usual starting pair 0/1 and 1/0). So anything dividing both a and b (or c and d) divides a*d - b*c = 1 too, so they're relatively prime. > ... > residual = 1.0 / residual Note that this step can introduce a small error on each iteration, due to the vagaries of floating-point arithmetic. To do this with complete accuracy requires sticking to rational arithmetic throughout. bot-good-enough-as-is-for-all-sane-purposes!-ly y'rs - tim From hschroeder at gmx.net Thu May 18 16:17:20 2000 From: hschroeder at gmx.net (Henning Schroeder) Date: Thu, 18 May 2000 22:17:20 +0200 Subject: PyBalsa? References: <8f7ih8$cj2$1@nntp6.u.washington.edu> <8g1b86$rpm$1@nntp6.u.washington.edu> Message-ID: Donn Cave wrote: > Quoth Donn Cave : > ... [ re expeditious processing of mail ] > | ... I think MxTextTools might be a good > | compromise to think about, it's a generic lexical analyzer that can > | quickly chop up stuff in formats like RFC822, leaving the interesting > | parts of the logic up there in the Python layer. > Just to follow up, I did try that - replaced rfc822 & mimetools with > an MxTextTools based module. Results were good, roughly twice as fast, > but I don't know if that's good enough to write home about, since it's > functionally stripped down compared to rfc822 and mimetools and not the > perfectly scientific comparison Sounds very interesting. Could you send me the code? I would like to use and improve it for my project. Besides rfc888 & mimetools are only one side of the problem while processing mails with Python. Try decoding base64/quoted-printable MIME parts with Python and you will see that you have to wait a unacceptable amount of time on computers with medium perfomance.... :-( But oassing encoded strings to a C module for this tasks wouldn't be the best sollution. There would be too much overhead. A complete C-module for messages would be more efficient. I looked at a couple of MIME libraries and found MIME++ (aka MIMEpp in KDE support package). It looks very complete and has a object-oriented interface. But I don't know how to SWIG C++-classes :-( Can anyone give any hints? Henning From no at spam.net Mon May 8 22:06:08 2000 From: no at spam.net (Tom Vrankar) Date: Tue, 09 May 2000 02:06:08 GMT Subject: Python, Palm, on Windows Message-ID: I'm working my way up to programming on the Palm platform by leveraging Python to prepare data on the desktop (just figured out how to manipulate the Windows registry to "install" files). I'm now up the point where I want to be able to operate on data inside a Palm via a PC's serial port (for example, to use my Windows PC at the office to add and extract individual files, er, databases, without a full-blown HotSync). I've read about pilot-link and pyrite. I'd like to try them but haven't found any Windows-binaries of the core. Anyone know a site where I can get it (and odds that it'll be recompiled for use with python1.6)? -- --------------------------------- Tom Vrankar twv at ici.net http://home.ici.net/~twv/ Rhode Island, USA From echuck at mindspring.com Fri May 19 17:14:26 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 19 May 2000 17:14:26 -0400 Subject: csvdb.py References: <3923906A.2ED5ED96@axis.com.au> <39242BB3.A9972507@python.org> Message-ID: <3925AEB2.99FF0FFF@mindspring.com> Guido van Rossum wrote: > > John Lehmann wrote: > > > > This is a class for manipulating data dumped in csv format, eg, by > > microsoft excel.... > > Rather than posting your code to the newsgroup, why not put it on a web page > and register it with the Vaults of Parnassus? > http://www.vex.net/parnassus/ > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) Also, if you search for CSV there you will find several other CSV modules. My guess is that they all do something, but none of them do everything, however, I haven't finished going through them yet. My point is that you might want to examine the others in comparison with yours and determine if there could be some teamwork/synergy. Or at least ideas. :-) -Chuck ____________________________________________________________ http://webware.sourceforge.net From cut_me_out at hotmail.com Mon May 8 10:37:57 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 May 2000 10:37:57 -0400 Subject: Dynamic Class Injection and friends References: <8f6gut$4sg$1@nnrp1.deja.com> Message-ID: There is a slight indentation error in examples/dci_samp.py. Pretty cool idea, though. Alex. From wware at world.std.com Wed May 3 08:23:57 2000 From: wware at world.std.com (Will Ware) Date: Wed, 3 May 2000 12:23:57 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> Message-ID: arkconfused at hotmail.com wrote: > Sorry for being rude or an A$$, but the question of where computer > technology will be in the next 5-10 years is crazy! And the comment > that Python will be a string presence I must disagree. Python will be a float presence, I think, or possibly a list-of-dictionaries presence. Sorry, it was too tempting. > if you have learned from > historical events, things like BETA, Mac, and Python have and will > disappear. ... I see Python being the BETA, > and Perl being the VHS... Programming languages address nearly-eternal human concerns, and this accounts for their staying power. The history of libraries goes back almost as far as the history of writing. Ancient civilizations like the Phonecians (sp?) and Babylonians had records relating to trade, real estate, the disposition of estates of the deceased, shipping manifests, as well as textbooks and fictional works. Towns larger than two or three family farms cannot exist without computation, via abacus or paper and pencil or stylus and clay tablet. Today we're lucky to have desktops with web access. A new programming language involves an investment of mental energy by many thousands of people. People have big flame wars over the relative merits of languages; language camps become firmly entrenched. When language implementations are open-sourced, it means that no matter what happens in the commercial world, any sufficiently dedicated programmer can keep using the language. I myself have several CDR disks with py152.tgz on them, just in case the economy collapses and the web stops working. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From phd at phd.russ.ru Tue May 16 04:21:10 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 16 May 2000 08:21:10 +0000 (GMT) Subject: pyApache install In-Reply-To: <3920bd41.265731151@news1.on.sympatico.ca> Message-ID: On Tue, 16 May 2000 chibaA at TinterlogD.Tcom wrote: > I'm having problems figuring out how to install pyApache. Actually, > the root of it might have something to do with problems getting the > compiled apache server to run. If anyone has successfully recompiled > apache with pyapache (or.. even recompiled apache), could you lend me > a hand here? I did it many times, pretty successfully. > Basically, if I try and run ./configure, everything goes well (and > seemingly imports modules & stuff fine), the installation finishes, > and the apache directory & executables are all there. I go to run > apachectl start - and it gives me an unable to start message. If I > just try running ./httpd, it just says segmentation fault. Any more details? Any error message? > Any ideas? I'm running RH6.1, I have the rpm version of apache > 1.3.9-4 running already (but I killed the process while trying the > rebuilt one). I compiled (with and without pyapache) using apache > 1.3.9 (and for kicks, tried 1.3.12 as well) - but the same problem > each time (segmentation fault). When I type gcc -v, it returns gcc > version egcs-2.91.66 (which I assume is new enough - came with RH6.1). May be it is TOO new? I use gcc-2.7.2.3 and 2.8.1... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From garytNOgaSPAM at garyt.force9.co.uk.invalid Tue May 2 09:04:18 2000 From: garytNOgaSPAM at garyt.force9.co.uk.invalid (garyt) Date: Tue, 02 May 2000 06:04:18 -0700 Subject: IDLE & Win 95 References: <390c1265.4105818@news.force9.net> <390DDB26.BC4DF853@sec.noaa.gov> Message-ID: <12a6405e.9023a470@usw-ex0104-026.remarq.com> Hi, >From the readme "An older version of IDLE is distributed with Python 1.5.2" In any case I can't get either IDLE to work. Perhaps I should just start again from scratch. I just wondered if there were any steps that I'd missed. Thanks for taking the time to respond. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From hzhu at rocket.knowledgetrack.com Mon May 22 21:31:01 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Tue, 23 May 2000 01:31:01 GMT Subject: Continuous fraction (was Re: Decimals to fraction strings) References: Message-ID: Seeing that the thread of fractional representation does not die, I wrote a little program that will convert between fractions and floats to given precision (within machine range). It contains its own test. """ Convert between float, continuous fraction and fractions The optional variable num_term holds the max number of terms. Todo: Need precision-checking. list[20:] is probably meaningless """ def to_float(list): "Convert to float from continuous fraction" x = 0. for i in range(1,len(list)+1): x = 1./(list[-i] + x) return 1./x def to_contfrac(x, num_term=20): """Convert to continuous fraction from float """ list = [] for i in range(num_term): a = int(x) list.append(a) x = x - a if abs(x) < 1e-9: break x = 1./x return list def to_frac(list, num_term=4): "Convert to fraction from continuous fraction" list = list[:num_term] x, y = 0, 1L for i in range(1,len(list)+1): x = x + list[-i]*y x, y = y, x return y, x def test(x, num_term): a = to_contfrac(x, num_term); print a, to_float(a) for n in range(1, num_term): b = to_frac(a, n) print "%25s %.16f" % (b, b[0]/float(b[1])) print "-"*40 if __name__ == "__main__": test(0.6667, 7) from math import pi test(pi, 16) -- Huaiyu Zhu hzhu at knowledgetrack.com KnowledgeTrack Corporation Tel: 925 738 1907 7020 Koll Center Parkway, Suite 110 Fax: 925 738 1039 Pleasanton, CA 94566 From m.faassen at vet.uu.nl Tue May 30 19:56:02 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 23:56:02 GMT Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <8h1ama$nd8$1@newshost.accu.uu.nl> <39343C7D.3099D6AF@tismer.com> Message-ID: <8h1kei$h04$4@newshost.accu.uu.nl> tismer Kaun wrote: >> > That photo isn't a fake, is it? >> Of course it's a fake. You didn't see any mention of the PSU in that FAQ >> either, did you? This is all going exactly according to plan. We need >> to be prepared for the Whitespace Invasion in 2010. > Doesn't look like a fake. Strong back, weak mind, that's > the picture that has been drawn by one of his early > employers. Maybe we should not take the mind part too seriously :-) All good fakes don't look like a fake. That sez nutting! >> And-what-about-Gordon-McMillan-hm?-ly yours, > Wanna picture? Gordon looks like a wise Indidana, a very tall > and very pretty guy, dark skin, white hair, soundy deep voice, > absolutely lovely to talk to, and I can assure your he is one > of the greatest guys and best friends I ever met - ly - chris I met him on the last Python conference! I met *you* at the last Python conference! I just was worrying about his part in the *conspiracy*, what with the time machine and all. I didn't see anything about him in the FAQ, so it must be a pack of lies, really. :) And-Gordon's-a-great-guy-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From loewis at informatik.hu-berlin.de Mon May 29 11:31:16 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 May 2000 17:31:16 +0200 Subject: how to update objects? References: <8F437ADE8mikecat@192.168.10.38> Message-ID: noemail at nowhere.hades (Mike Cat) writes: > I update a class with 'reload (module)'. > How can I update the instances too? You'd have to find the instance one-by-one. If you manage to get hold of them, you can set their __class__ attribute to the new class: >>> class A: ... def doit(self):print "old" ... >>> a=A() >>> class A: ... def doit(self):print "new" ... >>> a.doit() old >>> a.__class__=A >>> a.doit() new Regards, Martin From zxmar05NOzxSPAM at student.uni-tuebingen.de.invalid Fri May 12 13:02:41 2000 From: zxmar05NOzxSPAM at student.uni-tuebingen.de.invalid (Eduard Hiti) Date: Fri, 12 May 2000 10:02:41 -0700 Subject: Filtering web proxy References: <8dgigi$89e$1@nntp.Stanford.EDU> <20000510223302.A10511@mnot.net> Message-ID: <09487ed2.2023d149@usw-ex0104-032.remarq.com> There is the classic 'Proxomitron', which has nothing to do with Python, but can do things with HTML you wouldn't believe. Runs on Win32. Find it at http://members.tripod.com/Proxomitron. Also there is WBI from IBM. It's not so much a finished product but a library for JAVA with the most extensive support for parsing and rewriting incoming and outgoing HTTP I've ever seen. There are a couple quite impresive demos for this library. You can look at it at http://www.almaden.ibm.com/cs/wbi/. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From python at channel21.com Wed May 10 13:22:32 2000 From: python at channel21.com (Channel21 Python Team) Date: Wed, 10 May 2000 13:22:32 -0400 Subject: Custom adduser function... Message-ID: <81DD38F43381D111BA3E00A076A0998A45A059@XENON> ok - RedHat 6.2 need to have a function w/ 2 args (username,password) which will create a system account w/ the username and passwd passed in... any ideas? From mskott at image.dk Fri May 19 10:33:22 2000 From: mskott at image.dk (Martin Skřtt) Date: Fri, 19 May 2000 14:33:22 GMT Subject: PostgreSQL from Python 1.5.2 References: <3924599A.9CEB3FB1@xenon.spb.ru> Message-ID: Dmitry Rozmanov writes: > Hi. > > I'd like to connect to Postgresql on Debian Linux box from Python from > Windows95 box. All I have found it is PyGres module, but it contanes .c > file that must be compiled. I don't have any C compiler on windows. If you havent't got a Windows compiler then try and install the postgreSQL ODBC driver on your windows box and use the PythoN-ODBC binding to access your database. -- Martin Sk?tt mskott at image.dk 'In a certain sense, all decent programming languages are equally powerfull' Dr. Alan Turing From cwr at crash.cts.com Sat May 20 18:51:07 2000 From: cwr at crash.cts.com (Will Rose) Date: 20 May 2000 22:51:07 GMT Subject: Damnation! References: Message-ID: <8g74sr$2kba$1@thoth.cts.com> Moshe Zadka wrote: : BTW: Case-insensitivity a show stopper? This boggled me. I mean, case : sensitivity/insensitivity is the most minor feature of programming : language. Type declerations, memory management, and even whitespce seem : like much more earth shaking issues. I don't like Python's treatment of whitespace, but I can live with it. Other issues I can just get used to; there seems to me nothing outre in its type declarations, and I don't care what sort of memory management it uses (over a minimally effective threshold, which Python certainly has). However, if I'm going to be reading a lot of Python code, I want the stuff to be readable. No-ones paying me to program in Python, so I'm free to drop the language if it's too much trouble; what I don't want to happen is to spend a year or so's free time working with it, and then find that my code is obsolete. I just don't have the spare time, or the spare interest, to rewrite and debug that much code. If Py3K is going to be fundamentally incompatible with Python, may I suggest a name change to make the shift in emphasis clear? Will cwr at cts.com From sjoshi at ingr.com Fri May 26 18:24:19 2000 From: sjoshi at ingr.com (sjoshi at ingr.com) Date: Fri, 26 May 2000 22:24:19 GMT Subject: Help! SMTPlib Message-ID: <8gmti4$sf5$1@nnrp1.deja.com> Hello I'm trying to use the smtplib for sending mail, and I keep getting error: (10061, 'winsock error') when I try just to connect to the localhost. thanks Sunit Sent via Deja.com http://www.deja.com/ Before you buy. From rjroy at takingcontrol.com Fri May 26 13:41:04 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Fri, 26 May 2000 17:41:04 GMT Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> <392DF787.6658FCE1@home.com> Message-ID: <392eb619.141603984@news1.on.sympatico.ca> On Thu, 25 May 2000 22:03:19 -0600, Ivan Van Laningham wrote: >Hi All-- > >Alan Daniels wrote: >> >> On 25 May 2000 08:56:38 GMT, Remco Gerlich >> wrote: >> >> [snip...] >> >Why the problem with multiple lines and an extra variable here and there? >> >> Yes, but the short version reminds me very much of one of my favorite >> python idioms: >> >> lines = open("some_file", "rt").readlines() >> > >If you don't want the newlines, you can do this: > >alist=open("some_file","rt").read().split() might not work too well with text like: this is a test to see what will happen if I do a split on this file I think I will get a lot more elements than I bargained for Bob > >in 1.6. > >-ly y'rs, >Ivan >---------------------------------------------- >Ivan Van Laningham >Axent Technologies, Inc. >http://www.pauahtun.org/ >http://www.foretec.com/python/workshops/1998-11/proceedings.html >Army Signal Corps: Cu Chi, Class of '70 >Author: Teach Yourself Python in 24 Hours > From noone at do.not.use Mon May 15 16:02:18 2000 From: noone at do.not.use (Russell Turpin) Date: Mon, 15 May 2000 15:02:18 -0500 Subject: The REALLY bad thing about Python lists .. References: <39205163.EC104A@do.not.use> Message-ID: <392057CA.88B6F3A5@do.not.use> Russell Turpin wrote: > Should Python lists be as fast on other platforms > as they are on Linux, where good OS memory > management turned the second strategy into the > first? Obviously, that should be "good malloc() memory management." The question stands: does GNU m/re- alloc() use buddy list allocation? Russell From effbot at telia.com Tue May 16 14:46:29 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 16 May 2000 18:46:29 GMT Subject: No, it's a list, really! References: <75F7304BB41CD411B06600A0C98414FC0A412C@ORSMSX54> Message-ID: <9IgU4.7738$Za1.120057@newsc.telia.net> Daley, MarkX wrote: > I am getting terribly confused. Here is the code I am using for an SQL DB > query (this may look familiar to those who have helped me in the past): ... > servername = ['ServerA', 'ServerB', 'ServerC'] ... > for index in servername: ... > ..., servername, ... = result[item] # oops! ... > servername.append(index) From scorder at incigna.com Tue May 16 14:15:54 2000 From: scorder at incigna.com (Sam Corder) Date: Tue, 16 May 2000 14:15:54 -0400 Subject: TypeError: attribute-less object (assign or del) Message-ID: I'm using the windows script control to allow scripting in a VB project that I am working on. My app exposes a website object which users can script different things like clicking a link or looking for text (feedback). It works fine using VBScript but I want to use a more feature full language like Python. The problem is I keep getting a "TypeError: attribute-less object (assign or del)" error when trying to assign a value to an input text box. Does anybody have any clues? Thanks, Sam Corder From paul at prescod.net Fri May 12 09:34:18 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 12 May 2000 09:34:18 -0400 Subject: Stackless/microthreads merge news References: <39185686.665174C0@tismer.com> Message-ID: <391C085A.58329C18@prescod.net> Christian Tismer wrote: > > ... > > I've been looking quite closely at their code. > This is quite a task. Stuff is well written, > but it is much if you are not used to it. I have been wondering for a while if it would be possible to merge the Python interpreter with a Java VM so that Python and JPython themselves could be merged. I think it would be cool to have a single implementation with access to all Java classes and all Python extensions too. That would be the ultimate glue language! I would guess that the Python compiler would generate JVM byte codes with a few optimization bytecodes that could be "turned off" to be compatible with standard byte codes. > .... Java > is explicit about what exceptions can be thrown where, > and not declaring the right "throws" list is a syntax > error. > ... > The only thing that could be done is to capture > continuations, store them in variables and call them > later. This still gives the stack sharing problems > which were quite hard to solve for Python. I don't follow. Isn't it usual to use variables as continuations? I would expect: interface continuation{ public Object apply( Object[] ) throws throwable; } -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Art is always at peril in universities, where there are so many people, young and old, who love art less than argument, and dote upon a text that provides the nutritious pemmican on which scholars love to chew. -- Robertson Davies in "The Cunning Man" From jkraska1 at san.rr.com Mon May 8 00:39:53 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 08 May 2000 04:39:53 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> Message-ID: <391645E3.3B850279@san.rr.com> You shouldn't be if your using them like enums. Your not even > doing string comparisons. Python is byte compiled. Strings that > appear in the source are interned. Comparing two interned > strings is just a pointer comparison. Oh, I see what you're saying. So if I compare mymodule.ALPHA to an attribute thay may or may not be set to mymodle.ALPHA, I can do an identity-compare. Nifty. Thanks. C/ From phd at phd.russ.ru Fri May 19 04:18:39 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 19 May 2000 08:18:39 +0000 (GMT) Subject: urllib/ftpwrapper In-Reply-To: <200005182202.PAA12809@cj20424-a.reston1.va.home.com> Message-ID: Hello! On Thu, 18 May 2000, Guido van Rossum wrote: > Hm... Tricky... The voidresp() call is needed in the ftp protocol to > consume the '226 Transfer complete' message it sends after the > transfer is complete. However you will only get that after the > transfer is indeed complete. This is what the comment in webchecker > refers to. Ah, well... > If you don't make the voidresp() call, you can't reuse the open ftp > connection for something else. Since urllib tries to cache ftp > connections, tht would be a bad thing... > > So I believe it's necessary. Yes, I see now. > I presume that your robot is not reading all the data off the > connection, is that right? That's probably why it hangs on "almost Cannot beleive it's just so simple :( My robot uses urllib.urlretrieve; and any test program hangs. Just run in python: fname, headers = urllib.urlretrieve("ftp://starship.python.net/") and it hangs :( Almost all FTP URLs will hang, but there are some that not: ftp://sun.med.ru/ worked (at least for me), there is pretty standard wu-ftpd running there. > all" FTP URLs. The proper fix would be the same as in webchecker -- > read the rest of the data. I beleive URLopener.retrieve eats all data... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From torppa at polykoira.megabaud.fi Wed May 10 05:30:43 2000 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 10 May 2000 09:30:43 GMT Subject: Python, cgi and redirect References: <39191ca8.537672021@news.ramk.fi> Message-ID: <8fba83$hls$1@news.kolumbus.fi> In article <39191ca8.537672021 at news.ramk.fi>, Teemu Keskinarkaus wrote: >Is there simple cgi module for python that can do redirect?? Now I'm >doing redirect in cgi-script like this: > >print "Status: 302 Moved" >print "Location: http://url.to.somewhere" > >That works fine except I get 'Premature end of script headers' errors >in apache error_log everytime I use that script.(but browser is >redirected to url I give) Is there something missing or is there >ready cgi/web module to do stuff like that?? There might be module somewhere, but it is so simple that I see no need for it. Headerterminator (empty line) and body is missing from your cgi script, add something like. Dunno if the body is necessary. print print '302 go away' print '

    go away

    ' -- Jarkko Torppa torppa at staff.megabaud.fi Megabaud Internet-palvelut From emile at fenx.com Tue May 9 12:03:21 2000 From: emile at fenx.com (emile at fenx.com) Date: Tue, 09 May 2000 09:03:21 -0700 Subject: Converting a Binary Message-ID: <391836C9.77CC3DFF@fenx.com> You mean like this? >>> print chr(65) A Emile van Sebille emile at fenx.com AMR wrote in message news:<8f98bk$a6c28 at esiami.tsai.es>... > Good afternoon, > > What module I need to convert a number to binary?, > I can't find a function in Python build 126 > > Thank you, > > -- > Alvaro Mart?nez > Optichrome Computer Systems Espa?a, S.A. > > Tel. (+34) 917 242 670 Fax. (+34) 917 130 360 > > alvaro at ocse.infonegocio.com > http://www.optichrome.com > > > -- > http://www.python.org/mailman/listinfo/python-list > From dieter at handshake.de Sat May 27 04:34:29 2000 From: dieter at handshake.de (Dieter Maurer) Date: 27 May 2000 10:34:29 +0200 Subject: Case sensitivity redux -- with measurements! References: Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes on 25 May 2000 02:00:55 GMT: Thank you for "casechecker". > Out of ~36K lines of Python code in 137 modules, there were 12,243 > named identifiers. There were 35 ambiguous identifiers, and there were > never more than 2 versions of the same name. I applied it to my code: 8450 names; 67 collisions. Most of them are purposeful, resulting from naming conventions: Constants: all uppercase Classes: starting with uppercase letter functions/methods: starting with lowercase letter objects: usually short, all lowercase names, preferable similar to the class name. "Collisions" make up for less than one percent in my code, but I would like not to consider them collisions but useful naming of related objects. Dieter From cjc26 at nospam.cornell.edu Sat May 13 22:15:36 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 14 May 2000 02:15:36 GMT Subject: Arrgh! Please help. References: <391e07b9.88187366@news1.on.sympatico.ca> Message-ID: * chibaA at TinterlogD.Tcom menulis: | I'm pulling my hair out as to why I get this error: | | For this code: | if 1: | print "Content-Type: text/html\n\n" | print "whatever", | oL = "" | for key,value in rv.items(): | oL = oL + value + "&" + "blah" | print "blah", | print "=", | print oL | | I get this result: | Traceback (innermost last): | File "./update_user.py", line 58, in ? | oL = oL + value + "&" + "blah" | TypeError: illegal argument type for built-in operation | | WHY??? It seems like it maybe trying to add the variables & elements Looks like the values in rv are not strings. How is rv defined? | like numbers... but I don't know another way to glue together a | string. You can use the % operator. Instead of oL = oL + value + "&" + "blah" you can write oL = oL + "%s&blah" % value The "%s" means that the value of the variable value will be inserted into the string at that point as a string. | And while I'm at it, is there any way to use consecutive print | statements, and NOT have spaces in the output? ( I know comma gets rid | of the \n, but not the spaces). Use sys.stdout.write() instead. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "One man's nirvana is another man's map." icq 68165166 From Gareth.McCaughan at pobox.com Sat May 13 17:11:55 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 13 May 2000 22:11:55 +0100 Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com> Message-ID: <86zopu6tpg.fsf@g.local> "Courageous" wrote: > Okay, I downloaded the python source, as I had to know how > lists were implemented in python. Does nobody care that > pushing onto a so-called python "stack" is actually O(n)? > Am I the only person who cares about O(1) versus 0(n)? If what you want is a stack, then pushing and popping on a stack implemented with Python lists is O(1) amortised time. (The top element is the *last* one, not the first.) Linked lists are hardly ever faster than resizing vectors. For applications where you really need Lisp-style conses, build them out of 2-element lists or tuples and make your own printing functions. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From cut_me_out at hotmail.com Wed May 17 21:56:54 2000 From: cut_me_out at hotmail.com (Alex) Date: 17 May 2000 21:56:54 -0400 Subject: A PYTHON PREPROCESSOR References: <392345E4.6F94832E@san.rr.com> Message-ID: Hi, Courageous. What do you want to use a preprocessor for? I can't think of any uses that can't be affected in python itself. Alex. From corg at copernic.com Tue May 16 15:03:57 2000 From: corg at copernic.com (Gaetan Corneau) Date: Tue, 16 May 2000 15:03:57 -0400 Subject: Python to be Renamed! Message-ID: Good one :) What about this one: http://www.segfault.org/story.phtml?mode=2&id=3905b40e-05c0a760 ______________________________________________________ Gaetan Corneau Software Developer Copernic.com http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Les T?l?tubbies, c'est de la musique d'ascenseur pour les yeux" From andrew at andrewcooke.free-online.co.uk Fri May 5 09:03:54 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Fri, 05 May 2000 13:03:54 GMT Subject: Deepcopies of trees Message-ID: <8eugrg$o9c$1@nnrp1.deja.com> Hi, When I do a deepcopy of a structure without circular links, are all objects inside dictionaries passed to __setstate__ fully instantiated? If this is true of the code (which I can look at myself, I know), is it also a design decision (ie will it always be so)? Alternatively, can anyone suggest appropriate solutions for the following problem: I have a tree in which each node has a link to its parent. This is not absolutely necessary, but makes other code simpler. I need to copy a subtree from one part of the tree to another. This must be a deep copy as the tree will later be manipulated. However, of course, the deep copy must not copy parent objects (actually, only the parent of the top node of the subtree, but it seems simplest to keep the solution general). So I am thinking of writing a __getstate__ that removes the parent link from the dictionary and a __setstate__ that sets the parent of subnodes as "self". This last step requires that the subnodes exist - hence my question. I wouldn't even ask this, except that deepcopy *can* copy circular links, so it *must* (I think!) in *at least that case* call setstate with dictionaries that point to objects that do not "fully" exist (ie haven't had setstate called) On the other hand, I may be horribly confused ;-) Cheers, Andrew http://www.andrewcooke.free-online.co.uk/index.html Sent via Deja.com http://www.deja.com/ Before you buy. From phil at geog.ubc.ca Wed May 3 16:51:25 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 03 May 2000 13:51:25 -0700 Subject: New article on Python Dev Center References: <391058E8.9234C610@oreilly.com> Message-ID: "Stephen R. Figgins" writes: > Articles are coming in slowly, but I have put one up today. It is the > first in a 6 month series on Numerical Python. > > http://www.oreillynet.com/python/ > > I would love any feedback you care to give. > > Stephen Figgins > fig at oreilly.com Nicely done. I'll be using Numpy/Dislin in a 3rd year and graduate classes this fall, so these mini-tutorials are immediately useful to me. Under potential future topics: wrapping legacy Fortran/C numerical code may be too advanced for this series, but if not, I think a side-by-side comparison of pyfort and CXX-Array on a fortran or c function would be extremely useful. In particular, I don't think enough people realize what can be done with the new CXX-4.2 release. Regards, Phil Phil Austin INTERNET: phil at geog.ubc.ca (604) 822-2175 FAX: (604) 822-6150 http://www.geog.ubc.ca/~phil Associate Professor Atmospheric Sciences Programme Geography #217 University of British Columbia 1984 W Mall Vancouver, BC V6T 1Z2 CANADA From tbryan at python.net Thu May 4 08:37:23 2000 From: tbryan at python.net (Thomas A. Bryan) Date: Thu, 04 May 2000 08:37:23 -0400 Subject: Problems with HTMLgen tables References: <3dnzbdty.fsf@jumbo.skott.dk> Message-ID: <39116F03.B3A8E137@python.net> "Martin Sk?tt" wrote: > Can you help me solve the problem? (Red Hat 5.2, Python 1.5.1) Yes. > html-table.py: > #!/usr/bin/env python > import string, HTMLgen > data = 'netstats/data.dat' > fil = open(data, 'r') > fila = fil.readlines() > doc = HTMLgen.SimpleDocument(title='Interface statistik for ppp0') > table = HTMLgen.Table() > table.body = [] > doc.append(table) > for line in fila: > inf = string.strip(line) > table.body.append(inf) > > doc.write("data.html") The problem is in the line that reads inf = string.strip(line) You probably want inf = string.split(line) # this makes the most sense to me or inf = [string.strip(line)] You could also fix the problem at the point where you append to the table.body. table.body.append([inf]) The table.body is a list of lists. Each list in table.body is a (table) row. Each element of the nested lists is a (table data) column in that row. You were appending plain strings returned by string.strip. ---Tom From guido at python.org Thu May 18 10:51:54 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 18 May 2000 14:51:54 GMT Subject: A PYTHON PREPROCESSOR References: <392345E4.6F94832E@san.rr.com> Message-ID: <39242DE6.45BDA355@python.org> Glyph Lefkowitz wrote: > Inlining of methods! > > Since python variable name / method lookup is so expensive, I believe > this would be a significant speedup. Comments? But this would require compile time type analysis. Typically, when you see code of the form ``obj.method(arg)'', *you* (the programmer) have a good idea of what the class of obj would be at run-time -- but the poor Python parser does not share this knowledge. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From intmktg at Gloria.CAM.ORG Sun May 21 22:24:28 2000 From: intmktg at Gloria.CAM.ORG (Marc Tardif) Date: Sun, 21 May 2000 22:24:28 -0400 Subject: compiling pyapache on freebsd In-Reply-To: References: Message-ID: On Sun, 21 May 2000, Titus Brown wrote: > In article you write: > >I'm trying to install the python module with apache 1.3.12 on FreeBSD 3.4. [snip] > you need to make sure you have the readline library installed; > it should just be '-lreadline' but you might have to compile it, > if not. It's GNU. Thanks, that worked. I also had to link the pthread libs, but your suggested hinted me on fixing this problem. The compilation went fine and I'll see if it works as I learn more about python. > And, of course, you can always check out PyWX -- pywx at idyll.org -- > although it isn't for Apache ;). What is this PyWX you mention? Although you give an email address, it sounds more like you mean it to be a module or a web server. I went to www.idyll.org and there's nothing there apart from two images which don't show up on lynx. I also searched Parnassus and the FreeBSD ports for anything simlar, but nothing came up. Even altavista and deja didn't return anything useful, so where can I find information about this PyWX? Marc From jsboyle at my-deja.com Tue May 16 11:47:48 2000 From: jsboyle at my-deja.com (jsboyle at my-deja.com) Date: Tue, 16 May 2000 15:47:48 GMT Subject: OpenDX Python Wrapper -- any interest? References: <20000515112219.C1304991@vislab.epa.gov> Message-ID: <8frqiu$cln$1@nnrp1.deja.com> In article <20000515112219.C1304991 at vislab.epa.gov>, Randall Hopper wrote: > A while back I wrote a Python wrapper for OpenDX I would be very interested in such a module . I have been waiting for a message like this since DX became open source (but too lazy to do anything myself) JIm Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Tue May 30 07:21:03 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 30 May 2000 13:21:03 +0200 Subject: auto increment operator?? In-Reply-To: ; from wlfraed@ix.netcom.com on Mon, May 29, 2000 at 08:49:36PM -0700 References: <3933001E.D63F1A46@uniserve.com> Message-ID: <20000530132103.A469@xs4all.nl> On Mon, May 29, 2000 at 08:49:36PM -0700, Dennis Lee Bieber wrote: > The x++, x-- type operators were naturals for C, as C was sort > of a super-assembly in its origins; and the original C hardware > incorporated instructions just for increment/decrement. Actually, this isn't true. C had the auto-increment operators because B had it, and B (and C ? i forget) were first developped on the PDP-7. The PDP-7 did not have the auto-increment assembler instruction -- the PDP-11 did, but B and C didn't get ported to that machine until later. Not that it isn't a very helpful operator, in C, regardless of the underlying assembler :-) I would like to see the +=-style operators in Python, as they (imho) clearly fit in, and using '+= 1' is not that much more typing than '++'. It also stays an assignment statement, and it still *looks* like an assignment operator. I hope Guido or someone with Guido's ear (or permission) in time grabs Michael Hudsons' patch and incorporates it into the CVS tree... Hopefully even before 1.6, but I'm not putting up any bets ;-P -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From db3l at fitlinxx.com Fri May 26 19:13:42 2000 From: db3l at fitlinxx.com (David Bolen) Date: 26 May 2000 19:13:42 -0400 Subject: Dictionaries and Threads References: <3926A8EF.C3C1914B@jslove.net> <8gm2on$2ju$1@slb6.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > In article <3926A8EF.C3C1914B at jslove.net>, Jay Love wrote: > > > >Are dictionary lookups threadsafe? > > > >ie, can I lookup and retrieve an item in a dictionary while another > >thread is adding an item? > > In general yes, if you do it in single lines of code: Actually, I've been wondering about this sort of thing myself. If I understand correctly, under normal execution the interpreter will relinquish control and permit a context switch every 'n' bytecode instructions (n is configurable, but defaults to something like 10). So is this suggestion just because the average line of code can be encoded in less than 10 bytecodes (but what if the first 9 bytecodes were used up in prior instructions) or is there some underlying protection going on with data access? -- -- 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 vetler at news.ifi.uio.no Mon May 8 09:12:42 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 08 May 2000 15:12:42 +0200 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> Message-ID: * Cameron Laird > In article , > Glyph Lefkowitz wrote: > . > . > . > >has, you can't do anything. Now, python has some nifty quirks too (my > >code is riddled with __setattr__ and __getattr__. I LOVE them!) but I > >seriously doubt there will ever be a JPerl. > . > . > . > There already is. > > That is, if I understand you correctly, you're speculating > that Perl's undeniable squirrelliness precludes construc- > tion of "a toolkit for creating Java-Perl applications" > . > In fact this page is somewhat dated; JPL is farther along than > is apparent from this write-up. look, a flying pig vr From slinkp23 at yahoo.com Mon May 8 16:18:09 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 08 May 2000 16:18:09 -0400 Subject: Online database implementations Message-ID: <39172101.79DF206C@yahoo.com> Hi, I need advice and/or working code for putting together a user-maintained web-based database. Something very much akin to the Vaults of Parnassus - code for which is NOT available... I asked. :-( Tim-o'-the-Vaults said his code is so messy that he doesn't want to release it and he thinks it would take me less time to write my own. I want my database to be: --searchable --browsable by categories --up and running with a minimum of work (yeah right). --have a web interface for users to add/update entries without my intervention I've searched the vaults for online CGI database systems, and haven't found anything ready-made in python, though I do see a lot of tools I could make use of... Another good example of the kind of thing I wantt to do is at http://www.happypenguin.org/ but the author of that site says, again, his code is a mess. Plus it's written in Perl, not my first choice. What about Zope? Is there Zope code to do this kind of thing? If so, are there any zope hosts who will provide free hosting for a project like this? I notice that both Parnassus and the linux game tome use an SQL server as the back-end and have a web interface to that. This would slow me down a bit since I don't know SQL and would have to learn it first! I'm wondering if that's really necessary for a database of about 1000 items (currently growing maybe 3% per month) that doesn't change very much (probably only a few updates or additions per day). Couldn't I just make a class for database entries, and pickle them? Will this be enormously slower to search and access? Will it run like a dog if the database swells to 10,000 items? What if I generate static HTML pages from the database, and only use CGI for updating the database, and regenerate the html files when changes are entered? This would reduce the speed requirements for the database engine, and could make browsing faster for the user since pages could be cached by the browser. Also it would simplify mirroring the site. The site I want to use this for is at http://sound.condorow.net/ and is currently maintained by hand, by the heroic Dave Phillips. -- ................ paul winkler .................. slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From tim_one at email.msn.com Tue May 9 02:55:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 9 May 2000 02:55:09 -0400 Subject: A Mountain of Perl Books + Python Advocacy In-Reply-To: <20000508185259.B3681@bigskytel.com> Message-ID: <000301bfb983$840f1ae0$592d153f@tim> [David Bolen, argues for posting in mixed case] [David Porter responds] > Yet another aside, but I don't think you would have even mentioned > this if it was Fredrik Lundh who did the posting. Or am I wrong? Doubt it. Who's got time to beat their head against a Swedish bot? Give your fellow David credit for avoiding clearly unwinnable battles . may-as-well-ask-tim-to-close-a-msg-"sincerely"-ly y'rs - tim From herzog at online.de Mon May 15 18:36:05 2000 From: herzog at online.de (Bernhard Herzog) Date: 16 May 2000 00:36:05 +0200 Subject: python improvements (Was: Re: New Language) References: <8fpfoj$e0m$1@nntp6.u.washington.edu> <8fpnc6$o8u$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Russell E. Owen wrote: > [snip] > > - class methods (e.g. ClassName.doSomething(...)). Often useful where > > global functions might otherwise be wanted. By requiring the class name > > one gets namespace protection and categorizes the function as relevant > > to objects of the given class. > > Hm, how would this provide you with more namespace protection than the > current module system? By being in the same module, a function also > gets categorized as relevant to objects of the classes defined in the > module, too.. I used to think this too, but recently I actually had a situation where class methods would have been useful. I had a list of classes, so the classes were effectively anonymous and I didn't know where each class came from, yet I wanted to get some class specific information that I wanted to compute at that time and not at class creation time (when the class statement is executed). I couldn't just instantiate the classes to get at real methods because the constructors required some arguments I couldn't supply at that time and while it's possible to get at the module the class was defined in[1] but I didn't want to rely on that. In that situation, real class methods would have been useful and cleaner than any other solution. In the end, I fell back to normal class attributes that are computed at class definition time because it works well enough for the time being. [1] e.g. sys.modules[classobj.__module__] to get the module or classobj.method.im_func.func_globals to get the globals dict -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From cg at gaia.cdg.acriter.nl Fri May 26 13:08:14 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 26 May 2000 19:08:14 +0200 Subject: Java vs Python References: <391F88EB.D25BB0F8@san.rr.com> Message-ID: <8gmb1u$hbn$1@gaia.cdg.acriter.nl> Warren Postma said: >I'd accept lower performance, use SOAP instead of COM+/MTS From what I've >read and seen, Microsoft's MTS "object runtime environment" is extremely >fast. Writing COM components in Visual C++ can be a pain in the butt, but >if all you really need is performance, and you don't need flexibility, it's >definitely going to scale up nicely. > Up to a 4-way Xeon, that is. Not up as in "up to an Sun UE10000" or "up to an IBM S80" or "up to an IBM S/390". That's the place where EJB's come in handy, scaling from your Linux development box to that IBM Big Iron. On the original question: if it's not about raw performance, I'd say take a good hard look at Zope and take a good hard look at Enhydra. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From eviltofu at rocketmail.com Sat May 6 11:02:46 2000 From: eviltofu at rocketmail.com (Jerome Chan) Date: Sat, 06 May 2000 15:02:46 GMT Subject: HDI: find the length of floats, ints? Message-ID: How do I find the byte length of a float, double or an int? Or are all standard python float, double, ints, etc are of a fixed format? x = 1 len(x) doesn't seem to work. do I need to use import struct x = 0 len(struct.pack('@i',x)) From loredo at spacenet.tn.cornell.edu Thu May 11 14:27:08 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Thu, 11 May 2000 14:27:08 -0400 Subject: python idioms: (was: a really cool python feature) References: <391A3FD4.25C87CB4@san.rr.com> <8fdfp8$ho0$1@slb0.atl.mindspring.net> <391BB0C4.398E@seebelow.org> Message-ID: <391AFB7C.66C669E5@spacenet.tn.cornell.edu> Howdy- Jak Kirman has compiled a Python/Perl phrasebook that has many of what you might call "idioms": http://starship.python.net/crew/da/jak/cookbook.html It seems to have suffered a bit from starship's recent mishaps.... -Tom Loredo From spamfranke at bigfoot.de Tue May 16 16:33:46 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 16 May 2000 20:33:46 GMT Subject: Code sanity checker? References: Message-ID: <392ab038.8565885@news.btx.dtag.de> [Sorry if this is a repost, my newsreader produced some error messages] On Mon, 15 May 2000 01:02:38 +0300 (IDT), Moshe Zadka wrote: >No, but it wouldn't be too hard to catch the common cases with the >``parser'' module. Phewh...too lazy to fiddle around with those nested tuples, so I just wrote a real dumb one - using the token stream. Find the code below. Stefan -------------------------- #! /usr/local/bin/python # Script ddcheck version 0.0.1, 16-May-2000 # Written and released to the public domain by # Stefan Franke (franke at meso.net). # The code is provided as-is, so use at your own risk. # Improvements are welcome. """Script ddcheck.py -- check another Python script for double definitions USAGE: ddcheck Checks if the given Python script conains multiple class or function with the same name inside the same scope. 'Scope' is defined rather dumb in this case - it just means the same indentation level. Since it is perfectly valid to write code like, let's say, class C: def f(): pass if 1: def f(): pass by far not all possible conflicts are found. """ __version__ = 0, 0, 1 import token, tokenize interesting_tokens = [token.INDENT, token.DEDENT, token.NAME] class DefChecker: def __init__(self): self.was_def = 0 self.error_count = 0 self.scope_stack = [{}] def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if type in interesting_tokens: self.check(type, token, srow) def check(self, type, name, line): if type == token.INDENT: self.scope_stack.append({}) self.was_def = 0 elif type == token.DEDENT: del self.scope_stack[-1] self.was_def = 0 else: # type == token.NAME if name in ["class", "def"]: self.was_def = 1 else: scope = self.scope_stack[-1] if self.was_def: if scope.has_key(name): self.error(name, scope[name], line) self.error_count = self.error_count +1 else: scope[name] = line self.was_def = 0 def error(self, name, line1, line2): print "Definition of '%s' in line %d is overwritten in line %d." %( name, line1, line2) if __name__ == "__main__": import sys checker = DefChecker() try: fname = sys.argv[1] print "Checking file '%s'..." %fname tokens = tokenize.tokenize(open(fname, "r").readline, checker.tokeneater) print "%d error(s) found." %(checker.error_count) except IndexError: print "Usage: ddcheck " From markx.daley at intel.com Thu May 18 16:43:32 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Thu, 18 May 2000 13:43:32 -0700 Subject: How to create an .exe file from a python script Message-ID: <75F7304BB41CD411B06600A0C98414FC0A413C@ORSMSX54> http://starship.python.net/crew/gmcm/index.html This link will provide you with a pretty good wrapper that gives you a one-file installer executable. I'm pretty sure it's win32. - Mark -----Original Message----- From: Ralf Claus [mailto:ralf.claus at t-online.de] Sent: Thursday, May 18, 2000 1:09 PM To: python-list at python.org Subject: How to create an .exe file from a python script Hello, i try to solve the following problem : How can i create a stand alone "win32" executable file from a python script? Where can i get an example? I am happy for any suggestion. From samschul at pacbell.net Fri May 12 18:34:45 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Fri, 12 May 2000 22:34:45 GMT Subject: Win32 Serial comms package - where is it??? References: <8fhrda$2esq$2@news1.wire.net.au> Message-ID: <8fi0u4$6p$1@nnrp1.deja.com> Go to http://www.vex.net/parnassus/ and do a search on "serial". Several packages will show up, the one you are looking for and a newer one based on Mark Hammond's work. Sam Schulenburg In article <8fhrda$2esq$2 at news1.wire.net.au>, "Steven Adams" wrote: > Hi, > > Does anyone know whereabouts the Serial communications package maintained by > Roger Burnham is? > > in 'Python Programming on Win32' they say it can be downloaded from > http://www.marshallsoft.com but that doesn't exist - any clues? (I did some > searches on the net but couldn't find anything helpful there either) > > are there any other comparable packages? > > thanks in advance > > Steven > > Sent via Deja.com http://www.deja.com/ Before you buy. From aa8vb at yahoo.com Mon May 15 11:22:19 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 15 May 2000 11:22:19 -0400 Subject: OpenDX Python Wrapper -- any interest? Message-ID: <20000515112219.C1304991@vislab.epa.gov> A while back I wrote a Python wrapper for OpenDX, complete with callbacks to Python and exceptions thrown across the DXL layer. Before I devote any time toward preping, packaging, and posting it, I thought I'd first see if any others are interested in this tool (e.g. to build Python apps which use DX for graphics/visualization under-the-hood). For those that don't know, OpenDX (formerly IBM Data Explorer) is an industrial-strength scientific/data visualization package, now open-source: http://www.research.ibm.com/dx/ http://www.opendx.org/ -- Randall Hopper aa8vb at yahoo.com From thiele at muc.das-werk.de Wed May 17 13:01:56 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 17 May 2000 19:01:56 +0200 Subject: pickle with constant filesize Message-ID: <3922D084.2D389F1@muc.das-werk.de> Hallo! I want to pickle different instances (with different datas) of a class to a file. But I how can I realize that every file has exact the same size (every time when I pickle such a instance of a class)? How can I calculate the size of the pickle file? class Myclass: def __init__(self): self.a = 0 self.b = 0 self.c = [] ... x1 = Myclass() x2 = Myclass() x1.c = [1] x2.c = [1,2,3,4,5] Any Ideas? Thanks Thomas From moshez at math.huji.ac.il Sun May 21 14:42:31 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 21 May 2000 21:42:31 +0300 (IDT) Subject: Integer division (was: Case-sensitivity... (was: Damnation!)) In-Reply-To: Message-ID: On 21 May 2000, [ISO-8859-1] Fran?ois Pinard wrote: > No doubt that I would not like having to revise existing code! But also, > as the current `i / j' gives access to useful hardware instruction, a new > `int(i/j)' might incur unwelcome overhead for something that once was faster. Hardware instruction? Hardware instruction? Francios, you need a theraputic session with gdb on Python. Try to single-step python -c '1/2' And see that the hardware instruction is lost in a sea of function calls and jumps all over the place. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From thomas at cintra.no Sat May 27 13:21:19 2000 From: thomas at cintra.no (thomas at cintra.no) Date: Sat, 27 May 2000 17:21:19 GMT Subject: PyXML-0.5.4 and Site-Packages Message-ID: <392fa459.764858@news.c2i.net> Hi, I`ve tried to install PyXML-0.5.4 ( actually PyXML-0.5.3 and python-xml-0.5.1.rpm too with same result ) on my Mandrake 7.0 Linux-box without luck. No erros during python setup.py build or setup.py install. The xml-folder has a __init__.py file with the __all__ : .... -line. When I try to use anything but the xml-folder, like "from xml.sax import *" I get a "no module named sax"-error. Then I tried to add a xml.pth in the site-packages-folder, looking like : xml xml/parsers xml/sax xml/unicode ... No change. I`ve tried to install this package before without luck. I just gave up in the end. But now it`s a vital part of a project, not some private messing around, so I need it to work. Is there a way around the site-package method of doing it? Any tips, hints? Thanks. Thomas From bn at 7ways.com Tue May 16 12:34:53 2000 From: bn at 7ways.com (Bernard Niset) Date: Tue, 16 May 2000 18:34:53 +0200 Subject: Compiled version when .cgi extension is used for scripts Message-ID: <8frtjc$1fpn$1@news4.isdnet.net> Our site is using python extensively and very succesfully. The only thing is that I decided to name the cgis script with an extension in .cgi instead of .py. The drawback of this decision is that no compiled version is generated when a script is executed meaning that it needs a recompilation on each execution. How can I generate a compiled version of the scripts and how should I name them in order for the interpreter to take them into account. Thanks in advance for your help, ----------------------------------------- Bernard Niset 7Ways development team http://www.tldnames.com ----------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid.address at 127.0.0.1 Fri May 5 17:57:55 2000 From: invalid.address at 127.0.0.1 (David) Date: Fri, 05 May 2000 21:57:55 GMT Subject: [ANNOUNCE] wxPROs References: <39103702.9EBA14FE@eq.uc.pt> <8esoej$ee6$1@nntp6.u.washington.edu> Message-ID: <39134354.7775029@news.telus.net> On Thu, 04 May 2000 14:01:08 -0700, "Russell E. Owen" wrote: >In article <39103702.9EBA14FE at eq.uc.pt>, Pedro Vale Lima > wrote: >>Thanks for all the work put into wxWindows. It's the __BEST__ python GUI >>toolkit. I wish you all the fame and fortune. >I am curious. Could you say more about why you feel it is better than, >say, Tkinter? I'm just now trying to settle on a windowing toolkit and >would like something easy to use, powerful and robust. I'm sure others >are in the same boat. I'll jump in and say that, for me, wxPython works the way I expect a GUI API to work. My experience of Tk is that it's more a slow accumulation of hodge-podge than a carefully crafted API. wxWindows was a clean start, and it shows. To and for me, YMMV. I also like the native GUI gadgets of wxPython. It's distracting to not have one's normal GUI being presented. Things "don't look right" and "don't feel right" in Tkinter. IMHO, YMMV, etc. From francis at robinton.demon.co.uk Thu May 11 11:07:19 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Thu, 11 May 2000 16:07:19 +0100 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> Message-ID: <5v+rnIBnysG5Ewoc@robinton.demon.co.uk> In article <391A2E7C.818CB3C5 at san.rr.com>, Courageous writes >Speaking of O'Reilly... _Programming Python_ sucks, if you ask me. The >organization of the book is bizarrely different than most all other >programming books, And just possibly, that makes it a good book for programming virgins. Now as I think Python is a good language to start with that is OK by me. Perhaps you should simply say that experienced programmers learning Python are not part of that books potential readership? Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From glyph at twistedmatrix.com Thu May 18 15:36:54 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 18 May 2000 14:36:54 -0500 Subject: A PYTHON PREPROCESSOR In-Reply-To: Guido van Rossum's message of "Thu, 18 May 2000 14:51:54 GMT" References: <392345E4.6F94832E@san.rr.com> <39242DE6.45BDA355@python.org> Message-ID: Guido van Rossum writes: > Glyph Lefkowitz wrote: > > > Inlining of methods! > > > > Since python variable name / method lookup is so expensive, I believe > > this would be a significant speedup. Comments? > > But this would require compile time type analysis. > Typically, when you see code of the form ``obj.method(arg)'', > *you* (the programmer) have a good idea of what the class of > obj would be at run-time -- but the poor Python parser does > not share this knowledge. Hmm. It would be possible to do inlining of functions, though, right? I suppose this isn't quite the same thing as inlining methods, but it would still be helpful. (and with the extra "self" argument, you can make it *behave* like inlined methods) -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From jkraska1 at san.rr.com Mon May 22 19:34:19 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 22 May 2000 23:34:19 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> Message-ID: <3929C490.1E72D0EB@san.rr.com> Ben Cornett wrote: > > this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". That is, perhaps, the most apropos 'flame' I've seen in a long, long time. :)- C/ From dfan at harmonixmusic.com Wed May 17 18:20:48 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 17 May 2000 18:20:48 -0400 Subject: Bit length of int or long? References: <392317CF.D6F878F5@python.org> Message-ID: Fran?ois Pinard writes: | Guido van Rossum ?crit: | | > def bitl(x): | > assert x >= 0 | > n = 0 | > while x > 0: | > n = n+1 | > x = x>>1 | > return n | | Sounds rather slow, especially for big numbers. Well, you can always do something like this: def bitl(x): assert x >= 0 n = 0 while x > 256: n = n + 8 x = x >> 8 while x > 0: n = n + 1 x = x >> 1 return n -- Dan Schmidt | http://www.dfan.org From m.faassen at vet.uu.nl Wed May 31 12:47:38 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 May 2000 16:47:38 GMT Subject: OT: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <392EEEE3.2D37@seebelow.org> <393403D7.CAA8AB7D@sage.att.com> <_t1Z4.29279$WS3.338373@typhoon.we.rr.com> Message-ID: <8h3fna$76s$1@newshost.accu.uu.nl> Stephen Hansen wrote: [snip] > My problem with tar was not remembering the 'zxvf' part, but instead > remembering exactly how the file was either a) spelled, b) capitolized, or > c) punctuated(sp?). Even with an 'untar' script to do it, I just might > forget to capitolize a letter or put a '-' in the wrong place. Modern shells (at least on Linux) have filename completion. You just press the tab, and if the few characters you typed in are unique, it's going to expand to the full filename. If they aren't, pressing tab again can get you a listing of the options. A shell with such completion is a very different beast in feel as one that doesn't have it. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From effbot at telia.com Sun May 28 08:33:58 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 28 May 2000 12:33:58 GMT Subject: flock on windowsnt References: <392B9607.7250A905@yahoo.co.jp> Message-ID: tkssato at yahoo.co.jp wrote: > I want to use a function such as "flock()" on WindowsNT. > > On unix, it seems "fcntl" module is available. > > Is there any way on NT ? import msvcrt msvcrt.locking(fileno, mode, size) for more info, see: http://www.deja.com/=dnc/getdoc.xp?AN=589808979 From effbot at telia.com Sat May 13 13:35:55 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 13 May 2000 17:35:55 GMT Subject: correct round of reals? References: <000001bfbcfc$83147640$212d153f@tim> Message-ID: <%ngT4.7166$Za1.112009@newsc.telia.net> Tim Peters wrote: > That's pretty! I like it. thanks! > > (this assumes IEEE doubles) > > And inherits the rounding mode in effect. that's on purpose, of course. quoting from SUSV2: NAME rint - round-to-nearest integral value SYNOPSIS #include double rint(double x); DESCRIPTION The rint() function returns the integral value (represented as a double) nearest x in the direction of the current rounding mode. The current rounding mode is implementation-dependent. > Unclear whether Peter wants that, or wants to force > nearest/even. well, he wants to emulate "rint" for platforms that don't support it natively, so I think his only remaining problem is to port our python code to C... (see his other post). From jkraska1 at san.rr.com Tue May 16 01:47:32 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 16 May 2000 05:47:32 GMT Subject: The REALLY bad thing about Python lists .. References: <000401bfbee7$60c96f40$a2a0143f@tim> Message-ID: <3920E19F.BFAC44A1@san.rr.com> > Python deliberately overallocates by a small amount; this is a deliberate > optimization for the cases Moshe identified; it works very well. BTW, for those who are interested, but don't have the time to look, here is the actual behavior: #define ROUNDUP(n, PyTryBlock) \ ((((n)+(PyTryBlock)-1)/(PyTryBlock))*(PyTryBlock)) static int roundupsize(n) int n; { if (n < 500) return ROUNDUP(n, 10); else return ROUNDUP(n, 100); } I'm curious, looking at this, why we're not able to access the initial sizes and growth rates directly? While such needs are rare, and therefore shouldn't be added syntatic weight for the everyday user, I'd think there would be some benefit in allowing the complexity fiends some level of access with relatively little cost (is the extra overhead of keeping a growth rate attribute on the vector structure a burden? come now). C/ From andreas.st-pierre at t-online.de Wed May 3 18:21:28 2000 From: andreas.st-pierre at t-online.de (Andreas St. Pierre) Date: Thu, 04 May 2000 00:21:28 +0200 Subject: [ANNOUNCE] wxPROs References: <39103702.9EBA14FE@eq.uc.pt> Message-ID: <3910A668.6F122F74@t-online.de> So Di I! But will Wxwindows and WXPython remain free ? I read that the WXDesigner will be charged money for, when used on another platform but Linux. Pedro Vale Lima schrieb: > Robin Dunn wrote: > > > Hi all, > > > > It is with great pleasure that I announce the formation of a new company, > > wxPROs, which is dedicated to providing support, training, and consulting on > > wxPython and wxWindows. Besides myself, several of the core wxWindows > > developers will be involved so we can truly provide comprehensive support > > across both the Python and C++ toolkits. > > Thanks for all the work put into wxWindows. It's the __BEST__ python GUI > toolkit. I wish you all the fame and fortune. > > pedro lima From debl.nospamm at world.std.com Mon May 1 20:02:35 2000 From: debl.nospamm at world.std.com (David Lees) Date: Tue, 02 May 2000 00:02:35 GMT Subject: COM question References: <390CDC8B.779DB0C3@world.std.com> <390D16B7.B2524B@world.std.com> <8_9P4.3745$Px3.100662@news2-win.server.ntlworld.com> <390DACB0.9FCA96B3@world.std.com> Message-ID: <390E1B0E.D973BEEF@world.std.com> Yes you are correct about the version. You imply that something has to have VBA for me to be able to talk to it using Python? I thought I could start up word from Python by just knowing it's COM name? In fact, I can find the CLSID in the registry, but have no idea how to use that in place of "word.application". Anyway, I installed python on my new machine which has Word 2000 and have no problem getting the win32com.client.Dispatch("Word.Application") example to work with it. David Lees Benoit Goudreault-Emond wrote: > > In article <390DACB0.9FCA96B3 at world.std.com>, David Lees wrote: > > I have Word 7.0a, which I see references to with the Norton Registry > > Browswer. I am flying blind, not really understanding how COM objects > > are denoted in the registry though. > > > > David Lees > > Word 7.0a == Word 95. A port of Word 6 to 32 bits (although MS would like > you to believe otherwise... Well, OK, they added a few small things). > > It doesn't have VBA; you'll have to create a Word.WordBasic object (I think) > and work with that, passing it WordBasic statements. > > Good luck! > > -- > Benoit Goudreault-Emond > CoFounder, KMS Group ; Student, B. Comp. Eng, Concordia University > ``Being too close to a fireball can worry a man --- to death.'' > -- Zeb Carter in "The Number of the Beast" by Robert A. Heinlein > > Note: the "From:" address is not correct to protect myself against spam. > My actual e-mail address is: ``bge AT crosswinds DOT net'' From sreekant at uklinux.net Tue May 16 12:05:23 2000 From: sreekant at uklinux.net (Sreekant Kodela) Date: Tue, 16 May 2000 16:05:23 GMT Subject: Python / CGI / E-mail problem References: <3920E594.F3F2E4CD@uklinux.net> Message-ID: <3921B6D3.745325B5@uklinux.net> Thanks. I will try that one. Sreekant ben at co.and.co wrote: > Sreekant Kodela wrote: > > Hi there > > > > I am trying to send automated emails to the people who joined the > > mailing list. I am using the smtplib and sending the mail but my users > > came back to me that they can see the code. I tried to mail it to my > > self and hotmail was ok but pop/kmail was showing the code. I am using > > the following method. Is there anything stupid I'm doing!! > > > > hdr='From: xxxxx'+smtplib.CRLF+'SUBJECT: xxxxxx'+smtplib.CRLF > > hdr2='StokZilla > For anything else than a plain text message, you need to pack the body > in MIME-headers, telling the MUA how to render the content. > In your case, you need to tell the MUA its a HTML-message. > The headers should contain > Content-Type: text/html; charset=iso-8859-1 > > Take a look at the MimeWriter-module. > > Greetings, > -- > ben . de . rydt at pandora . be ------------------ your comments > http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From breiter at usf.Uni-Osnabrueck.DE Thu May 11 10:06:46 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 11 May 2000 14:06:46 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> Message-ID: <8feepm$csg$3@newsserver.rrzn.uni-hannover.de> In article , adsharma at sharmas.dhs.org.nospam (Arun Sharma) writes: > On 9 May 2000 12:14:04 GMT, Bernhard Reiter wrote: >> [For using the BSD license.] >> > There's no danger that you'll get ripped off in a serious way. >> > GNU is pushing a particular ideology for software, but short of >> > that most everyone just wants to avoid getting sued. >> >> This sentences are flawed. If you do not use a strong Free Software >> license other Companies might lock up your code and make money from >> your work. > > No one can lock up my code. Big companies lock up *their* code. They'll > just be mixing it with mine. I don't particularly care if they make some > money using my code. True, the big companies can lock up the final product which has their and your code in it. If their product gets distributed broadly, they can lock up users through what people call an "industry" standard. > I've seen these license debates go no where, because facts and opinions > get mixed up. The first three sentences in my previous paragraph are facts. > The last one is an opinion. > My personal opinion is that GPL'ed projects hinder further commercial > innovation by explicitly prohibiting that. Yes, I know the free > beer/speech argument. I also know that companies can survive by providing > support for GPL'ed projects, but they don't have enough of an incentive > to innovate. This is your opinion and I respect it. In my opinion not using Free Software hinders important innovations and solution we need. I would agree with you that the commercial software market in a largely Free Software World is smaller than in a largely close software world. I justed wanted to explain why the GPL is so popular. And what the differences to other licenses are. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From fiona at sitegnome.com Thu May 11 10:38:30 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 11 May 2000 14:38:30 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 11th, 2000 Message-ID: <20000511143830.22000.qmail@synop.com> Hello All, Below are the entries from the newsgroup that I've entered into http://python.faqts.com today. cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- Where can I find documentation for TKinter? http://www.faqts.com/knowledge-base/view.phtml/aid/2717 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, Ivan Van Laningham You could start by looking here -> http://www.python.org/topics/tkinter/doc.html While /F's documentation is invaluable, online and free, there are two other books which may help clarify the situation. 1) If you're at a beginning level, try the final 8 chapters of my _Teach Yourself Python in 24 Hours_. 2) If you're at a more advanced level take a look at John Grayson's _Python and Tkinter Programming_. John's writing style is appealing, he covers the topics in admirable depth, and he gives clever and entertaining examples. ------------------------------------------------------------- Is there a progress bar given by Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/2718 ------------------------------------------------------------- Fiona Czuczman Robert Hicks, John Grayson This comes from John Grayson's book "Python and Tkinter programming". """ A basic widget for showing the progress being made in a task. """ from Tkinter import * class ProgressBar: def __init__(self, master=None, orientation="horizontal", min=0, max=100, width=100, height=18, doLabel=1, appearance="sunken", fillColor="blue", background="gray", labelColor="yellow", labelFont="Verdana", labelText="", labelFormat="%d%%", value=50, bd=2): # preserve various values self.master=master self.orientation=orientation self.min=min self.max=max self.width=width self.height=height self.doLabel=doLabel self.fillColor=fillColor self.labelFont= labelFont self.labelColor=labelColor self.background=background self.labelText=labelText self.labelFormat=labelFormat self.value=value self.frame=Frame(master, relief=appearance, bd=bd) self.canvas=Canvas(self.frame, height=height, width=width, bd=0, highlightthickness=0, background=background) self.scale=self.canvas.create_rectangle(0, 0, width, height, fill=fillColor) self.label=self.canvas.create_text(self.canvas.winfo_reqwidth() / 2, height / 2, text=labelText, anchor="c", fill=labelColor, font=self.labelFont) self.update() self.canvas.pack(side='top', fill='x', expand='no') def updateProgress(self, newValue, newMax=None): if newMax: self.max = newMax self.value = newValue self.update() def update(self): # Trim the values to be between min and max value=self.value if value > self.max: value = self.max if value < self.min: value = self.min # Adjust the rectangle if self.orientation == "horizontal": self.canvas.coords(self.scale, 0, 0, float(value) / self.max * self.width, self.height) else: self.canvas.coords(self.scale, 0, self.height - (float(value) / self.max*self.height), self.width, self.height) # Now update the colors self.canvas.itemconfig(self.scale, fill=self.fillColor) self.canvas.itemconfig(self.label, fill=self.labelColor) # And update the label if self.doLabel: if value: if value >= 0: pvalue = int((float(value) / float(self.max)) * 100.0) else: pvalue = 0 self.canvas.itemconfig(self.label, text=self.labelFormat % pvalue) else: self.canvas.itemconfig(self.label, text='') else: self.canvas.itemconfig(self.label, text=self.labelFormat % self.labelText) self.canvas.update_idletasks() ------------------------------------------------------------- Is there a simple cgi module for Python that can do redirect? http://www.faqts.com/knowledge-base/view.phtml/aid/2741 ------------------------------------------------------------- Fiona Czuczman Jarkko Torppa, Teemu Keskinarkaus, Apache FAQ, Fredrik Lundh Using: print "Status: 302 Moved" print "Location: http://url.to.somewhere" Results in: 'Premature end of script headers' errors in apache error_log whenever the script is used. However, the browser is redirected to url. Solution: There might be a module somewhere, but it is so simple that it is not necessary. Headerterminator (empty line) and body is missing from your cgi script, add something like. Dunno if the body is necessary. print print '302 go away' print '

    go away

    ' Documentation: Here's what the apache FAQ has to say about this message: http://www.apache.org/docs/misc/FAQ.html#premature-script-headers "What does it mean when my CGIs fail with "Premature end of script headers"? "It means just what it says: the server was expecting a complete set of HTTP headers (one or more followed by a blank line), and didn't get them." ------------------------------------------------------------- Is there a way to escape special characters when inserting a string into a database? http://www.faqts.com/knowledge-base/view.phtml/aid/2742 ------------------------------------------------------------- Fiona Czuczman Lars Hoeyrup Jensen, Paul Boddie You can use: >>> import MySQLdb >>> MySQLdb.escape_string("""some '"' quotes""") 'some \\\'\\"\\\' quotes' Alternate: Rather than using Python's value substitution in strings as suggested, it should be possible to use "bind variables" in MySQLdb like this: cursor.execute("SELECT * FROM MY_TABLE WHERE MY_COLUMN = %s", (my_column,)) Note the use of the Python/C style "%s", but note also that we aren't using such "placeholders" with Python's % operator - an additional tuple parameter is required. As a result, the database module should process the values in the tuple and hopefully get the database to bind the values to the query (or action) accordingly. This is all just speculation on my part, however, as I have never really done any work with MySQL, but I do remember something about this in the MySQLdb documentation. Other database modules use different syntax for the placeholders; for example, Sybase products prefer "?", and replacing the placeholders in the above example would indeed make it work on Sybase products. I would discourage the use of simple string substitution when building queries. After all, the database modules are there to make the handling of all kinds of values, and the issues surrounding them (such as quote escaping) transparent. If your database module doesn't support this kind of functionality then I would recommend either improving it so that it does, or finding another which does; I wouldn't consider modules which are deficient in this respect as being suitable for serious work. ------------------------------------------------------------- How can I create an object at runtime, giving its module and class name? http://www.faqts.com/knowledge-base/view.phtml/aid/2743 ------------------------------------------------------------- Fiona Czuczman Fred Gansevles, Courageous, Martin Valiente The simpelest way, without having to figure out which part of the "stringWithFullNameOfTheClass" is the module and which part is the class is to pass them both to a function, i.e. def classFromModule (module, className): mod = __import__ (module) return getattr (mod, className) You can use this as follows: c = classFromModule (ModuleOfTheClass, NameOfTheClass) o = c () or, even: o = classFromModule (ModuleOfTheClass, NameOfTheClass)() -- Instructive Comment -- (Courageous wrote) A partial answer, without the module capability, using a different solution than above: o=eval(className)() In the other language that I'm familiar with, "eval" is expensive, so I'm pretty sure the other poster's answer is better. This is here for instructive purposes. Python eval() can be used to interpret any valid python expression which is currently in the form of a string. You probably should only make very judicious use of this function, but still... From torgojr at my-deja.com Thu May 4 07:44:45 2000 From: torgojr at my-deja.com (Torgo Jr) Date: Thu, 04 May 2000 11:44:45 GMT Subject: Newbie Q: Win32, COM, Dispatch, Oracle OLE References: <8ek444$5br$1@nnrp1.deja.com> <8emn5n$107$1@nnrp1.deja.com> Message-ID: <8ernr9$l7g$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > > >>> oraS.__dict__["_builtMethods_"] > > {'CreateDatabasePool': > 549c70>, 'GetDatabaseFromPool': > 54dfa0>} > > >>> # Why doesn't it see the GetDatabaseFromPool call???? > > Good question. You are correct in that it has seen it OK. > > My guess is that Oracle is giving us some bad information. > > There are 2 ways we can proceed: > > * Run makepy over the typelib, and mail me the relevent generated > functions you show above. Then I can tell you some magic to type in that > will confirm or deny my suspicions. > > or > * Try using "dumb dispatch": > >>> from win32com.client.dynamic import DumbDispatch > >>> oraS = DumbDispatch("OracleInProcServer.XOraSession") > > And see you go... > > Mark. DumbDispatch gives the same error. I'll play around with makepy later since messing around with Python is not a priority thing for me (I already wrote what I was going to write in Python in JScript). Thanks again for the assistance. -- "Did I mention I'm immense and immortal?" Joel Robinson Sent via Deja.com http://www.deja.com/ Before you buy. From rumjuggler at home.com Sun May 7 19:31:31 2000 From: rumjuggler at home.com (Ben Wolfson) Date: Sun, 07 May 2000 23:31:31 GMT Subject: Future of the Python Linux Distribution References: Message-ID: <59vbhsko0k6gglr7ki61tbfch0eept58vk@4ax.com> On Mon, 8 May 2000 00:55:37 +0200 (MET DST), Vetle Roeim wrote: >> map, lambda, apply, filter. Obfuscation at your fingertips. :-) Using >> {}.update(), I believe it's possible to write programs that use only >> expressions; no statements. > >Yes, of course. But I have a feeling many people don't use these >functions, unless they have taken a course on functional programming ;-) map, filter and reduce are pretty easy to figure out without knowing any functional programming, actually. You just need to get sufficiently bored with for loops. The problem is that once you put them in, your code's legibility decreases if they're combined with one another. I doubt I could parse this if I hadn't written it: from operator import add,indexOf list=open('ceci ne pas un playlist.m3u').readlines() open('mp3s','w').write(reduce(add, map(lambda a: a[1+a.find(',':]\ filter(lambda e, l=list:indexOf(l,e)%2, list)))) and it's pretty simple. >It's often very useful to use these functions, but they provide solutions >not easily available in more popular programming languages, such as C and >Java. I refrain from mentioning C++ in the previous sentance, because C++ >actually has those functions (except lambda), although many people don't >know about them. I know about for_each and copy_if, which are what I assume you mean as analogues of map and filter, but what corresponds to apply? -- Barnabas T. Rumjuggler The world is turning into a cesspool of imbeciles. -- Harlan Ellison From meh9 at cornell.edu Tue May 2 12:48:01 2000 From: meh9 at cornell.edu (Matthew Hirsch) Date: Tue, 02 May 2000 12:48:01 -0400 Subject: How many is "too many" with lists? References: <8emtqt$dsf$1@nntp9.atl.mindspring.net> Message-ID: Generating the list is slow. I'm accessing each element with a for loop. I was just curious. Matt In article <8emtqt$dsf$1 at nntp9.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article , > Matthew Hirsch wrote: > > > >I'm building a list of lists each holding a combination of nCk where n > >is the total number of numbers and k is the number you are choosing. > >For example, I have 27 numbers, 0-26. Looking at all combinations of 6 > >taken from this sample produces 27!/(27-6)!6! =296010 different > >combinations stored in the original list. > > So what's slow? Generating the list or manipulating the list after it's > created? > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> > http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "Laws that restrict speech are an abomination for a simple reason. > They're like a poison gas; they seem to be a good weapon to vanquish > your enemy, but the wind has a way of shifting." -- Ira Glasser From aahz at netcom.com Mon May 29 06:10:08 2000 From: aahz at netcom.com (Aahz Maruch) Date: 29 May 2000 10:10:08 GMT Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> <8glvki$1sp$1@slb7.atl.mindspring.net> <392f608b.260535311@news.nikoma.de> Message-ID: <8gtfm0$hnd$1@nntp9.atl.mindspring.net> In article <392f608b.260535311 at news.nikoma.de>, Philip 'Yes, that's my address' Newton wrote: >On 26 May 2000 13:53:22 GMT, aahz at netcom.com (Aahz Maruch) wrote: >> >> It was a design decision to consider [].sort() >> and [].reverse() to work on the original list because the programmer >> should *always* explicitly request a copy of what may be a 100K element >> list. > >But can I request a copy of the sorted list without giving the copy a >name, since I haven't got the comma operator available to me? Not without a function call. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From dgallion1 at yahoo.com Wed May 31 09:25:47 2000 From: dgallion1 at yahoo.com (Darrell Gallion) Date: Wed, 31 May 2000 06:25:47 -0700 (PDT) Subject: Python decentralized Message-ID: <20000531132547.4159.qmail@web2001.mail.yahoo.com> Has anyone thought about decentralizing the Python resources? A system like Gnutella might be the way to get started. http://news.cnet.com/news/0-1005-200-1983259.html?tag=st Bring-on-the-asteroid-ly yr's darrell ===== Darrell Gallion __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ From andrew.henshaw at gtri.gatech.edu Tue May 30 02:55:09 2000 From: andrew.henshaw at gtri.gatech.edu (Andrew Henshaw) Date: Tue, 30 May 2000 02:55:09 -0400 Subject: Pioneering indentation (was Case-sensitivity: why -- or why not?) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> Message-ID: <8gvalm$d9q$1@news-int.gatech.edu> William Tanksley wrote: ...snip... >A quick comment: Python has very little in the way of innovation. It >brings together many tried-and-true mechanisms in a very elegant manner. >Not even indentation is a true innovation; it was pioneered by ABC before >Python was born. In a quick search, I couldn't find the earliest reference to the ABC language, so you may be correct; however, the Occam programming language also uses indentation to indicate code blocks. I started using Occam in 1984(maybe - definitely by 1985). I believe that the first Occam implementation was developed by 1982. By the way, I prefer Occam's indentation rules. Two spaces, no tabs. Andrew Henshaw From Norbert.Klamann at pobox.com Tue May 2 05:44:54 2000 From: Norbert.Klamann at pobox.com (Norbert.Klamann at pobox.com) Date: Tue, 02 May 2000 09:44:54 GMT Subject: Examples of 'Python Programming on Win32' Message-ID: <8em82k$gs7$1@nnrp1.deja.com> Hello all, does anyone have a copy of the examples for 'Python Programming on Win32' by M.Hammond /A.Robinson handy ? These files vanished in the starship crash ... -- Norbert Klamann Klamann Software & Beratung GmbH Erftstadt Germany Klamann.Software at pobox.com Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Wed May 10 23:40:51 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 03:40:51 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> <391a14f7$0$28399@wodc7nh1.news.uu.net> Message-ID: <391A2CA0.DD579E14@san.rr.com> > Nah. It's complicated because it's conflicted. I can at the same time both see and not see your point. Perhaps you should expand on this. In some ways, the GPL is quite clear: the owner retains the copyright in it's entirety, and is providing you with a license, under very strict conditions: you obtain a license to use the product if you agree that the product that you make based on this product will likewise be free and open software. If you disagree, you get no license, and you are violating copyright PER SE if you make use of the GPL'd product. The problem lies in interpretation of what consitututes use of the code, and so forth, I suspect... ??? C/ From glyph at twistedmatrix.com Thu May 11 21:27:12 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 11 May 2000 20:27:12 -0500 Subject: A Mountain of Perl Books + Python Advocacy In-Reply-To: erik_wilsher@my-deja.com's message of "Thu, 11 May 2000 11:34:57 GMT" References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> <8fe5t1$mgf$1@nnrp1.deja.com> Message-ID: erik_wilsher at my-deja.com writes: > Having read this, and also noticed a request for > some sort of "unique" flag for lists in the > python todo-list, I added a sortlist class to my > bisect module. > > Using this class we can reduce the above program > to: > > -------- > #!/usr/bin/env python > "uniq.py --Read lines from input file, and write > sorted output to file" > > import fileinput,bisect,sys > > uniq=bisect.sortlist(fileinput.input(sys.argv[1])) > open(sys.argv[2],'w').writelines(uniq.list()) > -------- Okay; I don't have this modified bisect.py, so I can't test this, but here goes: (documentation omitted ... who needs documentation when you're talking about perl? :-P) --- import fileinput,bisect,sys open(sys.argv[2],'w').writelines(bisect.sortlist(fileinput.input(sys.argv[1])).list()) --- So there. Two lines of python for the whole thing. :-) and-i-didn't-even-have-to-make-it-more-than-80-characters-long-'ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From aahz at netcom.com Tue May 23 09:36:01 2000 From: aahz at netcom.com (Aahz Maruch) Date: 23 May 2000 13:36:01 GMT Subject: Zope/Python vs Java (was Re: Java vs Python) References: <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F@lp.airnews.net> Message-ID: <8ge1g1$29v$1@slb1.atl.mindspring.net> In article <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F at lp.airnews.net>, Roman Milner wrote: > >I think any major web project should consider Zope. It has >transformaed the way I think of web development. FWIW, I work at a >moderate sized telco and we do all of our web sites in Zope. I really like the idea of Zope. I'm less satisfied with the results I've seen from using Zope. Maybe we're just not as good as I think we are, maybe we're using the wrong architecture to build apps in Zope, but as far as we can tell, our big problem is in getting Zope to run reliably as a front-end for database operations. We haven't had much luck getting help from Digital Creations, either, even though we've offered money. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Not everything in life has a clue in front of it...." --JMS From aahz at netcom.com Tue May 2 20:28:01 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 May 2000 00:28:01 GMT Subject: Database Programming References: <#UCgPEJt$GA.230@cpmsnbbsa03> Message-ID: <8enrqh$beu$1@slb6.atl.mindspring.net> In article <#UCgPEJt$GA.230 at cpmsnbbsa03>, lexberezhny wrote: >hi, > You can use the 'for' loop: > >for item in table: > database.query('INSERT INTO format_prices >(time,open,high,low,close,volume) VALUES >('+item[0]+','+item[1]+','+item[2]+','+item[3]+','+item[4]+','+item[5]+')') A better variation on that theme: for item in table: item = tuple(item) database.query(""" INSERT INTO format_prices (time, open, high, low, close, volume) VALUES ( '%s', '%s', '%s', '%s', '%s', '%s' ) """ % item) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From emile at fenx.com Sat May 13 14:06:21 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 13 May 2000 11:06:21 -0700 Subject: Fun with primality testing References: Message-ID: <0d0701bfbd06$05185f40$1906a8c0@fc.fenx.com> Well, *that* was fun. I've never used regular expressions, and had been meaning to read the how-to, so this was a good excuse. In working this out, I modified the code to see if I could follow how things changed, and when I thought I understood, I tried: if not re.match(r'(11+)\1\1+$', '1'*n): thinking: it's got to match three times anyway. What bothered me was that '+' would grab the whole thing, then start backing off to find the match. I have visions of that happening byte by byte. Now I'm wondering if the additional match helps or hurts? I've timed it, but not much difference. The single match is marginally faster. However, making the first group less greedy, makes it twice as fast: if not re.match(r'(11+?)\1+$', '1'*n): and special casing the range helps too: for n in [2]+range(3,1000,2): Maybe-I-could-have-used-these-for-y2k-mods?-ly y'rs, Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Fran?ois Pinard To: Sent: Friday, May 12, 2000 4:16 PM Subject: Fun with primality testing > Hi, people. > > For your mere enjoyment! Here is Python code which prints primes below 1000. > At the local Perl mongers meeting, someone showed this nicety to me. > > > import re > for n in range(2, 1000): > if not re.match('(11+)\\1+$', '1'*n): > print n > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > > > > -- > http://www.python.org/mailman/listinfo/python-list > From stephen at cerebralmaelstrom.com Tue May 30 05:56:15 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Tue, 30 May 2000 09:56:15 GMT Subject: *blink* That's neat. References: Message-ID: <3fMY4.28915$WS3.322429@typhoon.we.rr.com> Quinn Dunkan wrote in message news:slrn8j6u23.cn2.quinn at hedono.ugcs.caltech.edu... > On Tue, 30 May 2000 07:19:02 GMT, Stephen Hansen > wrote: (big snip of me being a dork) > >Okay, there's really no point to this post.. I was just surprised and had to > >tell someone, and my roommate really, really, REALLY didn't care. Not that > >anyoen here does either, but you can't give me an agitated look :) > > But we can write agitated followups :) > > Your roommate is probably just thinking "how am I going to finish this > microprocessor design if this guy keeps babbling on about boolean operator > preceedence?" I'm tired. That's about the only thing I can say in response after actually READING what I posted and then shaking my head in shame :) What I actually wanted was: if (case != 0) and (case != 1): ... Basically, after being up WAY too long and reading that whole thread on Friendlier Error Messages until my eyes crossed, I got to coding (bad idea) and wanted to make all my code look pretty and readable... So I re-wrote the above a few times just trying out differentways. ;) "if case not in [0,1]" is awfully neat, but my favorite was "if case is not 1 and case is not 0:"... Then I thought it was repetative so tried to make it not so.. and somehow reality warped and I ended up in my own little universe. Its fun here. Lots of purple. Everythings purple. --S (hiding) From cmfinlay at SPAMmagnet.com.au Wed May 3 00:31:55 2000 From: cmfinlay at SPAMmagnet.com.au (cmfinlay at SPAMmagnet.com.au) Date: Wed, 03 May 2000 14:31:55 +1000 Subject: How do I ignitalize a list please? Message-ID: How do I initialize a 'list' please? I read that a list is the only array that can be modified in standard python. (to put it simply) i = 1 mags[0] = 0 mags[1] = 1 print mags[i] doesn't work. Please reply here or at cmfinlaySPAM at magnet.com.au From vinyard at arlut.utexas.edu Wed May 24 15:57:10 2000 From: vinyard at arlut.utexas.edu (Edward S. Vinyard) Date: Wed, 24 May 2000 14:57:10 -0500 Subject: What's in a name? Message-ID: On Wed, 24 May 2000, Thomas Thiele wrote: >> 1. Remove a (potential) hurdle for new programmers. > >I really don't undersytand why case-sensitivity should be a hurdle? > >Is orthography a hurdle to learn reading and writing? Case-sensitivity by itself is probably not a hurdle. Learning to recognize the (possibly implicit) convention a specific library, module, or programmer uses to convey semantic information using case might be more difficult, especially for someone who is not familiar with a language or common conventions. Ed From jkraska1 at san.rr.com Thu May 11 02:06:55 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 06:06:55 GMT Subject: Python threads: backed by OS threads? Message-ID: <391A4EDE.EC2BB3AB@san.rr.com> Okay, I simply have to know for sure that Python threads are backed by full operating system threads. To wit: if I create multiple Python threads on a machine with multiple CPUs, I should be expecting take advantage of the additional CPU's, correct? C/ From phd at phd.russ.ru Wed May 17 04:11:28 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 08:11:28 +0000 (GMT) Subject: PyApache - scripts now not working In-Reply-To: <3921da5c.338718661@news1.on.sympatico.ca> Message-ID: On Tue, 16 May 2000 chibaA at TinterlogD.Tcom wrote: > Which is incredibly puzzling, because I never used anything relating > to dates. I suppose it's choking on the mysql api for python, but I > don't understand why? Any ideas? May be you have problems with shared libraries... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From wware at world.std.com Tue May 23 11:02:21 2000 From: wware at world.std.com (Will Ware) Date: Tue, 23 May 2000 15:02:21 GMT Subject: Graphical User Interface application References: Message-ID: Jilani Khaldi (jilanik at tin.it) wrote: > I wonder if it is possible to write graphical user interface applications > using Python, like in VB? If yes, what do I need then? Try this: http://www.python.org/topics/tkinter/ -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From chris at araidesign.com Wed May 17 17:22:04 2000 From: chris at araidesign.com (Chris Arai) Date: Wed, 17 May 2000 14:22:04 -0700 Subject: Newbie: Python suitability question References: <3921EFC8.53C372FC@araidesign.com> <667216D9BFABB429.CA0032F6AE6E8A3B.BD167DB25BA1D151@lp.airnews.net> Message-ID: <39230D7C.FA34A1B1@araidesign.com> Hi Cameron, Thanks for the help. The way the embedded app is set up it won't work as a command line executable that could be made into an extension, called once each loop. The reason is that the embedded app has it's own loop of data gathering from sensors and processing that data (and previously gathered data.) Therefore the embedded app must some how be static and be able to be re entered at a particular point (the beginning of the data acq loop, not "main()") in order to be an extension. You are right, the main form of communication from the embedded app is the display memory bitmap. To the embedded app would be the key strokes. In the deliverable form of the embedded app the display memory is piped directly out to the display via an on board LCD controller. The keypad is also managed by an onboard controller. I am thinking that if I extend python with the embedded app that I will have to run it as a thread. Is this possible? I have never done threaded programming before. If this is an appropriate method, then how do I communicate between the two threads? Via files? What is a good reference for learning how to do this? My original thought was that embedding python was the way to go. Once every data acq loop the python module is called, but the same problem arises of being static. It seems to me that this method also requires threads. Another issue that I forgot to ask was how to debug this concoction. Will DDD which supports gcc and python (I think) allow source debugging of both the gcc and python sides? Is there another debugger that you would recommend? Thanks again for the help. Chris Cameron Laird wrote: > Yes, Python is good for this role. > > I have a strong bias toward extending rather than > embedding Python for cases such as yours. Are you > saying that it's possible to identify a command-line > (-like) application at the heart of this, and you > want Python to manage screen display, configuration, > ...? That's perfect for an architecture in which > Python manages the embedded application. Or does the > deliverable embedded application really communicate > only through a displayable memory bitmap? > > I'll say this a different way: I don't understand > the deliverable's communications, in isolation. It's > only prudent to tackle that first, before specifying > details of the connection between the application and > Python. > -- > > In article <3921EFC8.53C372FC at araidesign.com>, > Chris Arai wrote: > . > . > . > >I am contemplating using python to act as a graphical interface to an > >embedded application that will be cross compiled for a 68K micro > >controller. The reasons I (think) I want to use python are: > > > >1. I need to create a simulator for the target embedded system for rapid > >development. > >2. I'm in a hurry and lazy and want to create a simple GUI quickly. > >3. I can easily (??) port from Linux to Windows. > > > >The outline is that I need to simulate the graphical display that the > >embedded app will have and to feed the app keypad inputs via mouse > >clicks. So the embedded app is running and creating a memory map for > >its graphical display, which python then redraws for the desktop, while > >mouse clicks to the buttons are passed to the embedded app. The > >questions I am having difficulty answering are: > > > >1. Do I embed python in my app? Or... > >2. Do I extend python with my app? > >3. Will I need to use threads to do this? > > > >My guess is that I will have to embed python. Thus my app will start, > >call python to create the GUI, and then the app continues it's > >processing in a loop which on each cycle of the loop updates python with > >the new display info and also grabs inputs that were made to the python > >GUI. Is this possible? > > > > > >AND last of all, is this an appropriate use of python, or is there a > >better way? > . > . > . -------------- next part -------------- A non-text attachment was scrubbed... Name: chris.vcf Type: text/x-vcard Size: 224 bytes Desc: Card for Chris Arai URL: From s.schwarzer at ndh.net Sun May 7 18:53:06 2000 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Sun, 07 May 2000 23:53:06 +0100 Subject: Python and CGI security Message-ID: <3915F3D2.FA510453@ndh.net> Hello, Beside the usual rules mentioned in the documentation of the cgi module, are there more "automatic" security checks available in Python (e. g. similar to Perl's -T switch)? Thank you in advance for your answers :-) Stefan From jvickroy at sec.noaa.gov Mon May 1 15:25:24 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 01 May 2000 13:25:24 -0600 Subject: mxODBC -- InterfaceError: SQL type (code -9) not implemented Message-ID: <390DDA24.12F4A73A@sec.noaa.gov> Hello all, I am using the mxODBC extension with Python 1.5.2 to interact with MS SQL Server 7 on Win NT 4.0. The following interactive session illustrates the problem: >>> >>> connection = ODBC .Windows .connect (dsn = 'my_dsn', user = 'me', password = 'apwd') >>> cursor = connection.cursor() >>> cursor .execute ('select * from est') >>> result = cursor .fetchone() Traceback (innermost last): File "", line 1, in ? InterfaceError: SQL type (code -9) not implemented >>> If I use the SQL Server Query tool, the above select statement returns a result set. Furthermore, if I instead, interactively, connect with a different SQL Server database, the above session connect, execute select, fetchone also works. Any ideas about the cause of this (code -9) error would be appreciated. Thanks for your time. From pinard at iro.umontreal.ca Wed May 17 21:26:16 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 May 2000 21:26:16 -0400 Subject: Bit length of int or long? In-Reply-To: Dan Schmidt's message of "17 May 2000 18:20:48 -0400" References: <392317CF.D6F878F5@python.org> Message-ID: Dan Schmidt ?crit: > Well, you can always do something like this: > def bitl(x): > assert x >= 0 > n = 0 > while x > 256: > n = n + 8 > x = x >> 8 > while x > 0: > n = n + 1 > x = x >> 1 > return n I'm saving these ideas. Thanks to all. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jkraska1 at san.rr.com Tue May 16 10:17:55 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 16 May 2000 14:17:55 GMT Subject: The REALLY bad thing about Python lists .. References: <000401bfbee7$60c96f40$a2a0143f@tim> <3920E19F.BFAC44A1@san.rr.com> <8fr6p0$p93$1@nntp9.atl.mindspring.net> Message-ID: <39215941.C2721511@san.rr.com> > http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=342411242&fmt=text > > And I quote nearly fully "Blechh! Creeping featurism!" Well, to be honest, I was more surprised at the implementation itself; ever since I can remember, I've never seen an allocation in advance vector without it storing its own growth rate........ BTW, I missed what you meant by your generators comment. I fail to see how this would be necessary if every list per se had a growth_rate element attribute, although you'd think the more necessary thing would be the initial size hint, actually. Albeit, perhaps as the other poster noted, the realloc is making it cheap most of the time. C/ From gmcm at hypernet.com Wed May 24 18:46:55 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 24 May 2000 22:46:55 GMT Subject: extending Python on NT References: Message-ID: <392c5bdf$0$18626@wodc7nh1.news.uu.net> Ryan Donahue wrote: >I want to write some C extensions, but the docs I have seen do not very well >explain how to do it on NT with Visual C++. The docs at python.org point to a >url that has the compile.py file, which apparently creates a .dsw file for >you. However, the url is no longer valid. Just create a dll, link with the multithreaded dll version of the C runtime and export the extension's initxxx function. It's kind of nice to rename the .dll to .pyd, but not necessary. - Gordon From ben at co.and.co Tue May 16 16:41:33 2000 From: ben at co.and.co (ben at co.and.co) Date: Tue, 16 May 2000 20:41:33 GMT Subject: Python / CGI / E-mail problem References: <3920E594.F3F2E4CD@uklinux.net> <3921C3C8.90A5E7C9@uklinux.net> Message-ID: <1oiU4.47074$z%.50348@afrodite.telenet-ops.be> Sreekant Kodela wrote: > Hi there > > I tried using the MimeWriter but failed. Do you have any simple exampe by > any chance. > > thanks > sreekant I've never used smtplib nor MimeWriter, and it appears MimeWriter isn't necessary at all. Try this one, as a test (fill in the obvious ones): ---------------------------------------------------------------------- #!/usr/bin/python import smtplib your_email_address = '____' your_server = '127.0.0.1' test_message = '''From: %s\r To: %s\r Subject: ILOVEYOU\r MIME-Version: 1.0\r Content-Type: text/html; charset=iso-8859-1\r Content-Transfer-Encoding: 8bit\r Content-Disposition: inline\r \r \r \r \r

    Hello %s

    \r \r \r ''' % (your_email_address, your_email_address, your_email_address) con = smtplib.SMTP(your_server) con.sendmail('From: %s' % your_email_address, 'To: %s' % your_email_address, test_message) con.quit() --------------------------------------------------------------------- Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From aahz at netcom.com Tue May 30 16:33:20 2000 From: aahz at netcom.com (Aahz Maruch) Date: 30 May 2000 20:33:20 GMT Subject: Using strings with ' in them in SQL-queries References: <39342055.1301760@news.c2i.net> Message-ID: <8h18ig$8af$1@slb3.atl.mindspring.net> In article <39342055.1301760 at news.c2i.net>, wrote: > >I need to insert strings with ' in them in query-strings. I`m using >the PostgreSQL-database. > >If I try stuff like this : > >db = _pg.connection(....) >db.query('insert into test (id, name) value (1, 'fdsfds''fdsf') ') > >That works ok. But the string I need to insert I get from a variable. >I cannot seem to use a variable in the query-string. Is there any way >around this? How can I handle characters in strings that may >comprimise the requirements of a valid sql-statement?? def sqlize(s): return string.replace(s,"'","''") db.query("insert into test (name) value ('%s')" % sqlize(foo)) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Have you coined a word today? --Aahz From tjreedy at udel.edu Tue May 30 13:30:24 2000 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 30 May 2000 13:30:24 -0400 Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> Message-ID: <8h0to8$nvr$1@news.udel.edu> "Amit Patel" wrote > * Methods on objects: > > We have to resolve the issue of "self" being a magic argument. 'self' isn't. The first arg, whatever named, is. Your proposal would mandate that this arg be named 'self', which is not the case now. I usually just use 's'. > . You could "reparent" an > object on the fly to change its class. Or you could use > prototype-based programming techniques, as in Self. One can more or less do this now. I posted a simple Self class a couple of years ago to demonstate Pythons flexibility. Terry J. Reedy From hwkMueller at t-online.de Tue May 9 16:55:47 2000 From: hwkMueller at t-online.de (HWMueller) Date: Tue, 09 May 2000 20:55:47 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> <3917f55c.842808@news.btx.dtag.de> <3917f685.115228@news.btx.dtag.de> Message-ID: <39187a5c.562679@news.btx.dtag.de> >Huh? Backslashes (\) are fine for me. The problem occurs with >non-spacing accents only ( ? ` and ^ ; hopefully we see the same >characters here: an up, down and circumflex accent). > aargh...sorry, my mistake. As you told it, the accents are the problem. --HW From dpk7386 at rit.edu Mon May 15 00:35:53 2000 From: dpk7386 at rit.edu (David P. Kleinschmidt) Date: Mon, 15 May 2000 00:35:53 -0400 Subject: __getattr__ in C++ Message-ID: Hi all. Just a real quick question: I'm writing a Python module in C++ that provides a number of classes. Believe it or not, this is actually working pretty well. I'm wondering, though, should __getattr__ increment the reference count before it returns the appropriate attribute, or not? - Dave From chibaA at TinterlogD.Tcom Wed May 10 17:25:14 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 10 May 2000 21:25:14 GMT Subject: HELP! Simple question re: dictionaries References: <3919b810.430052072@news1.on.sympatico.ca> Message-ID: <3919d323.436983308@news1.on.sympatico.ca> Sorry.. forgot to ask another thing related to this: 1. For the example below, how would I refer to JUST the key, value referred to in the iteration of the for loop? for key,value in argumentList.items(): print ? 2. Additionally, you can access a certain element of a list by using a numerical subscript (like [1] - like an array). If, let's say, there's one key & corresponding value in a dictionary, then how would I reference that value - to let's say - print it out? Finally... if you know of a website that I could visit to get the specs of syntax, please let me know (so I can stop asking these simple questions!). Thanks again for your help, kc On 10 May 2000 20:34:09 +0100, Michael Hudson wrote: >chibaA at TinterlogD.Tcom writes: > >> Hi, >> >> I just want to write a for statement to go through each element of a >> dictonary. I would have assumed it would look something like this >> (argumentList being the dictonary): >> >> for ___ in argumentList: >> # whatever... >> >> ... but I'm not sure of the exact syntax. If anyone knows, could you >> let me know? Thanks! > >for key,value in argumentList.items(): > # whatever ... > >is pretty idiomatic... > >Cheers, >M. > >-- >34. The string is a stark data structure and everywhere it is > passed there is much duplication of process. It is a perfect > vehicle for hiding information. > -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From aahz at netcom.com Thu May 25 11:02:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 May 2000 15:02:26 GMT Subject: case-sensitivity compromise proposal References: <4.3.1.2.20000523075551.014d9e70@phear.dementian.com> Message-ID: <8gjfa2$qd9$1@slb7.atl.mindspring.net> In article <4.3.1.2.20000523075551.014d9e70 at phear.dementian.com>, Steven D. Arnold wrote: > >How about a pragma to indicate whether a given Python module was >case-insensitive? Since Python is case-sensitive now, and to assist with >backward compatibility, I propose that case-sensitivity should be the >default. Furthermore, we can arrange some way that a user can permanently >turn on case-insensitivity (or case-sensitivity) as the default for them, >in which case only programs with the opposite pragma would behave in the >non-default way. The big problem is with a case-sensitive module called by a case-insensitive program. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From m.faassen at vet.uu.nl Thu May 18 08:02:11 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 12:02:11 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: <8g0m43$gd2$4@newshost.accu.uu.nl> Francis Glassborow wrote: [snip] >>C++ and Perl both require more self-discipline than is posessed >>by 99% of the programming population (myself included). > Actually that remark applies to any language used to write substantial > amounts of code. Sure, but it applies *more* to languages like C++ or Perl than to Python, still. :) > Any fool can write unreadable code in any language. That doesn't mean it's not far easier to write unreadable code in some languages. > Writing code that is unreadable to someone who is fluent in a language > is probably a sign of incompetence. Not being able to read the code of a > competent programmer probably indicates your own level of inadequacy. Yes, but with some languages, it's easier to become fluent. This is pretty easy to make clear; just take a look at assembly language, and why almost everybody avoids programming in it (I don't believe portability arguments are the main reason :). > If you want your opinions respected, respect the tools used by others. Of course. Doesn't mean the tools aren't different, still. > Or, to put it another way: 'Bad workman blame their tools.' Good workmen can also pick the best tools for the job. They can also recognize bad tools. This is not to imply that Perl and C++ are bad tools. C++ is a good tool if you need a reasonable level of OO style abstraction and lots of speed and memory efficiency, for instance. Another requirement is that you need to know it incredibly well. :) I'd agree that being judgemental about programming languages doesn't help, but withholding your judgement doesn't help either. I think it's sensible to judge that C++ is very hard to use well, if your requirement is maintainable code. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From chibaA at TinterlogD.Tcom Thu May 11 18:16:12 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Thu, 11 May 2000 22:16:12 GMT Subject: number base conversion? (ASCII to Hex) References: <391b2bd5.66612734@news1.on.sympatico.ca> <20000511180636.A3265@better.net> Message-ID: <391b30db.67898943@news1.on.sympatico.ca> Alright... I'm still confused (probably because I'm not asking the right question). hex(word('1')) requires (I'm assuming) an integer/character input - and word[1] provides a string. So it won't work. Here's the root of what I'm trying to do (maybe it'll explain why I'm trying to do this: I'm creating a script which outputs a call to another python script with arguments. The second program reads in values in CGI format - so I have to output all of the arguments in this fashion. Maybe there's a mod that already does this (CGI does not - that only goes the other way). kc On Thu, 11 May 2000 18:06:36 -0400, William Park wrote: >On Thu, May 11, 2000 at 09:54:26PM +0000, chibaA at TinterlogD.Tcom wrote: >> How would I go about getting the base-16(hex) value of a character, >> into a string? >> >> take character word[1] (for example) >> and retrieve the hex value of 31 >> and assign it to value hexValue in an ascii format (ie. as the number >> 31). > >hex(ord('1')) > >--William > From phil at geog.ubc.ca Mon May 8 15:34:08 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 08 May 2000 12:34:08 -0700 Subject: Calling Python scripts from C/C++ program References: <8f6ra5$hca$1@nnrp1.deja.com> Message-ID: Phil Austin writes: Delete the unnecessary #include Regards, Phil From fdrake at acm.org Tue May 30 20:47:41 2000 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 30 May 2000 20:47:41 -0400 (EDT) Subject: __builtins__ In-Reply-To: References: Message-ID: <14644.24877.246081.290522@cj42289-a.reston1.va.home.com> Huaiyu Zhu writes: > It looks like that I have to use > __builtins__.min (1,2) > > in the interpreter but > __builtins__['min']([1, 2]) > > in a module. Why is this so? > > This arises in the context of redefining min in a module. Try: import __builtin__ # no 's' __builtin__.min(...) This will work in both contexts. __builtins__ (with the 's') is an implementation detail and need not be used in source code. -Fred -- Fred L. Drake, Jr. From tim_one at email.msn.com Mon May 15 23:32:38 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 15 May 2000 23:32:38 -0400 Subject: The REALLY bad thing about Python lists .. In-Reply-To: Message-ID: <000501bfbee7$62318ac0$a2a0143f@tim> [Glyph Lefkowitz] > ... > If a platform doesn't adhere to a standard or does something in a > really brain-damaged way, it should be fixed on that platform. I > had this brought to my attention earlier today when someone on IRC > was commenting that the % operator in perl and python carries the > symantics from the C library of the platform in question, and > sometimes that's wrong (off-by-one errors when it was being treated > as 'remainder' rather than 'modulus' in negative numbers). ISO/ANSI C doesn't fully define what happens when (roughly) integer division or % are handed negative numbers. Python does fully define it (& forces the issue regardless of what the platform C does). Don't remember what Perl does. And don't care . Python is generally *willing* to worm around platform bugs (look at all the #ifdef'ed workarounds in the source!), but sometimes it's just more work than anyone will volunteer. For example, making os.system() work predictably under Win95 (where the MS system() is broken in several ways). See Starship for Vladimir Marangozov's PyMalloc, which may well become Python's workaround for crappy platform mallocs one day; in 1.6, he's laying a lot of the groundwork to make this possible. As to the remarks about whether it was worth the time to port Python to Windows, note that Windows is Python's most heavily used platform now -- I personally doubt Python would have survived if it only had its Mac and Unix base since '91. "software-sucks"-exempts-no-philosophy-ly y'rs - tim From urner at alumni.princeton.edu Tue May 30 14:30:43 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 30 May 2000 11:30:43 -0700 Subject: Compact syntax for 0-matrix? References: <3931D5F1.B1DEAA76@mit.edu> <61v3js0e35og41utcmv64cg5r82jlvjpus@4ax.com> Message-ID: <5i08jsgh4oe53sjgpu5q23tcc10gpus2v8@4ax.com> kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) wrote: >Kirby Urner writes: >> >> Here's another function I like OK: >> >> def zeromatrix(n,m): >> output = [] >> for i in range(n): output.append([0]*m) >> return output > >Or, more shortly, > > def zeromatrix(m, n): > return map(lambda x: [0]*x, [n]*m) > >It seems more time-consuming, though ;) > >-- >KAJIYAMA, Tamito Yes, that's very compact, really tests one's understanding of lambda. I'm thinking this "zeromatrix" exercise might be a good one for Python learners -- certainly it has been helpful to me. Kirby From lexberezhny at email.msn.com Tue May 2 19:54:55 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Tue, 2 May 2000 19:54:55 -0400 Subject: Database Programming References: Message-ID: <#UCgPEJt$GA.230@cpmsnbbsa03> hi, You can use the 'for' loop: for item in table: database.query('INSERT INTO format_prices (time,open,high,low,close,volume) VALUES ('+item[0]+','+item[1]+','+item[2]+','+item[3]+','+item[4]+','+item[5]+')') I hope this helps. - lex ----- Original Message ----- From: Arnaldo Riquelme Newsgroups: comp.lang.python Sent: Tuesday, May 02, 2000 6:54 PM Subject: Database Programming > I'm very new to Python, and I've been playing with it quite a bit. > Most of the stuff I've done includes lots of SQL and C shell staff. > > I have a tab delimitted file that looks like this ( foo.prn) > ========================================================= > 19990222 86.8750 88.1250 86.6250 87.9375 24994 > 19990223 87.6875 87.8750 86.6250 87.3750 16288 > 19990224 87.0000 87.6875 85.7500 85.7500 18013 > 19990225 84.7500 85.0000 83.3750 84.4375 25336 > ========================================================= > > I want to insert this file to database table called format_prices with > fields (time,open,high,low,close,volume) > I'm using mxODBC module in win32. > > I created a function that reads the file and puts the contents into a list > ====================================================== > def read_his_file(s): > #make sure we are in the d:\__newstocks__ directory > import os, string, sys > os.chdir("d:\__newstocks__") > lines = open(s).readlines() > > #get rid of new line character and white spaces > lines = map(string.split, lines) > table = [] > > #get rid of the header > lines = lines[1:] > for i in lines: > prn = i[:-1] > table.append(prn) > > return table > ======================================================= > > Now I get this list [['19990222', '86.8750', '88.1250', '86.6250', > '87.9375', '24994'].......] > > How do I loop thru the list and insert the date into format_prices? > Is there some docs or tutorial that talks about issues like manipulating > database with python.? > > In advance ,thanks a lot for all your help. > > > Arnaldo > > > From phd at phd.russ.ru Tue May 23 05:27:09 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 23 May 2000 09:27:09 +0000 (GMT) Subject: urllib/ftpwrapper In-Reply-To: Message-ID: Hello! Yes, this fixed the problem! What's more, this fixed other problem - in my database of monitored URLs there are some FTP URLs, that didn't hang urllib, but returned 'ftp error'. With your patch for urllib the error was no more. Last night I ran the robot, and got no one hang or error (I've got other errors, but they are certainly not related here - random timeouts, DNS problems, etc - usual bunch of Internet problems :). I hope to see the patch in 1.6. Thank you very much! On Sat, 20 May 2000, Guido van Rossum wrote: > I played with this a bit and found that ftp.python.org works but > starship.python.net hangs... Then I had a sudden idea: maybe these > ftp daemons only send the 226 message once the data socket has been > closed! > > The following change works for me: in urllib.py, class addclosehook, > method close(), move the call addbase.close(self) to the top of the > method, so the data socket gets closed before the hook (which waits > for the 226 code on the control socket) is called. > > def close(self): > addbase.close(self) > if self.closehook: > apply(self.closehook, self.hookargs) > self.closehook = None > self.hookargs = None > > Let me know if this fixes your problem (with no other changes to > urllib). Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From phd at phd.russ.ru Tue May 16 06:15:16 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 16 May 2000 10:15:16 +0000 (GMT) Subject: socket programming In-Reply-To: <8fr4vf$k96$1@nnrp1.deja.com> Message-ID: On Tue, 16 May 2000 tiddlerdeja at my-deja.com wrote: > A server application can bind to a socket and listen for connections > (e.g. smtp:25). Is it possible, say for testing purposes, for another > program to bind to the same socket at the same time and monitor the > data i/o ? It is impossible. Who and by what means will demultiplex data stream? Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From dieter at handshake.de Mon May 22 17:57:44 2000 From: dieter at handshake.de (Dieter Maurer) Date: 22 May 2000 23:57:44 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: Guido van Rossum writes on Sun, 21 May 2000 02:01:37 GMT: > (1) Randy Pausch, a professor at CMU, found, when teaching Python to > non-CS students in the context of Alice (www.alice.org), that the > number one problem his students were having was to remember that case > matters in Python. (The number two problem was 1/2 == 0; there was no > significalt number three problem.) Hm, wasn't that easy: all case matters in Python. Naming conventions are, however, (I think) not well documented and, at least for module names, inexistant or not adhered to. In my view, the way out should not be to give up case sensitivity but to document and adhere to simple naming conventions. > (2) I've met many people who are experienced and accomplished Python > programmers but who still, when referring to Python modules or > functions in an informal context (e.g. email), make up their own case > conventions. E.g. people will write me about the String module or > about FTPLib. It this really a reason to have the same variability in formal as in informal contexts? > I also know some of the things I plan to do to make the transition > painless and to make the usual problems with case insensitivity more > palatable. E.g. I may add a case insensitivity feature to IDLE which > makes sure that all identifiers are written in a consistent case, I Oh no! Either I have case insensitivity and can use it (inconsistent writing for the same object, such that I do not need to always consult a dictionary) or I have case sensitivity and can use that (giving similar but different objects names different only in case). But having case insensitivity but being forced to use the names as if the language were case sensitive seems really ill for me. Dieter From mjackson at wc.eso.mc.xerox.com Thu May 4 23:00:49 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 5 May 2000 03:00:49 GMT Subject: How to get terminal width? References: <391234A6.1AB90028@rubic.com> Message-ID: <8etdh1$a9t$2@news.wrc.xerox.com> Jeff Bauer writes: > Donn Cave wrote: > > Quoth newsbunny at noether.freeserve.co.uk (Martin P Holland): > > | stty size > > | > > | just gives the rows and columns here (linux) but may be this is > > | not standard. > > > > It looks pretty good to me! Ultrix 4.2, Digital UNIX 4.0, AIX 4.2, > > HP/UX 10.20, FreeBSD 4.0, 2 versions of Linux and BeOS 4.5 pass on > > this one, and that's all I can dig up to try, so it looks to me like > > the best bet so far. Easiest to handle in Python, too. > > Donn/Martin: > > It fails on Solaris 2.6 (and probably other versions of Solaris): > > $ stty size > unknown mode: size Depends on the path. Fails for /usr/bin/stty (probably the most common default); works for /usr/ucb/stty. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson In judging others, folks will work overtime for no pay. - Charles Carruthers From mfletch at tpresence.com Tue May 2 20:16:08 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 2 May 2000 20:16:08 -0400 Subject: Simple Schedule Demonstration was(RE: Submitted for your perusal. ..) Message-ID: Regarding tight-loop-based scheduler in the submitted code, as discussed offline... Here is a simple scheduler using the time module. Only wakes up at specified intervals, allows for specifying start and stop times, provides information regarding previous and current times and the current cycle number. Hope this helps, Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: schedule.py Type: application/octet-stream Size: 3532 bytes Desc: not available URL: From rgb122 at my-deja.com Tue May 9 13:52:59 2000 From: rgb122 at my-deja.com (rgb122 at my-deja.com) Date: Tue, 09 May 2000 17:52:59 GMT Subject: Load Arbitrary Script as Module? References: <8f9bs3$b9u$1@nnrp1.deja.com> Message-ID: <8f9j9i$jtk$1@nnrp1.deja.com> > driver = __import__("C:\\Stuff\\sample") Thanks. What are the rules regarding case-sensitivity on an NT filesystem? I tried: m = __import__("Z:\\Desktop\\pyTemplate\\Tags\\Script") But get an error: "NameError: Case mismatch for module name Z:\Desktop\pyTemplate\Tags\Script" As far as I can tell, that's the exact case, at least according to the command prompt. -Rob Sent via Deja.com http://www.deja.com/ Before you buy. From wware at world.std.com Sat May 27 09:37:00 2000 From: wware at world.std.com (Will Ware) Date: Sat, 27 May 2000 13:37:00 GMT Subject: Microthreads: wait( duration ) with minimal processor overhead, u References: <392F494E.AB935747@san.rr.com> Message-ID: Courageous (jkraska1 at san.rr.com) wrote: > Eh? These are *microthreads*. Using thousands and thousands > of "normal" threads will clobber your cpu. And yet in a very > simple test of microthreads, I was able to spawn up 10,000 of > them and watch them finish in under 3 seconds flat. Quite > remarkable. When I said "normal sleeping threads", I was unclear. I wasn't referring to sleeping OS threads (e.g. Posix threads), I meant "sleeping microthreads as they are already implemented in uthread4.py". I thought he was working on a non-problem, since we had gone to some pains to ensure that the kinds of threads I mentioned didn't poll. It turns out, however (and this is the issue he was actually addressing), timers and queues that are blocking user threads maintain internal threads to poll the condition which will unblock the user threads. > I'll be a monkey's uncle if the author of the uthread library > doesn't know all about how normal threads work... Originally I hacked together an early microthread implementation by editing the code in eval.c. Several people pointed out that the much cleaner approach was to use Chris Tismer's stackless Python (which, to this day, contains deep dark mysteries beyond my mortal ken). Eventually the two converged, and a little later Just stepped in and made the whole thing even cleaner and more idiomatically Pythonic. By now, I'm a symbolic figurehead, relegated to cutting ribbons at the openings of shopping malls. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From effbot at telia.com Mon May 8 14:46:19 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 08 May 2000 18:46:19 GMT Subject: OT [Way OT]: Unicode Unification Objections References: <3915C869.1B387972@videon.home.com> Message-ID: <%XDR4.6318$Za1.97517@newsc.telia.net> Fran?ois Pinard wrote: > > A similar situation holds in almost every written language. We often > > dump Latin or French words into English text. Even though they may be > > written in the same alphabet, we usually want them to *look* different > > from ordinary English words. > > The situation is just not similar. I do not have a strong, perpetual need > that the look be different, and the truth is that as a French reader, I > honestly do not mind much if we use the same characters. on the other hand, if you tell me that I should start sorting swedish names in ISO Latin 1 order (or german, or english, etc), or that leaving out the dots and rings when comparing strings won't hurt anyone, I'll reach for my revolver. > I'm not saying that Japanese are right or wrong about unification. This is > their problem and their decision. afaik, ISO 10646 has been adopted as a japanese national standard, so I assume they've made up their mind on this one. From olipt at mayo.edu Sun May 28 21:35:07 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Sun, 28 May 2000 20:35:07 -0500 Subject: DECREFing and PyArray functions in C Extensions In-Reply-To: References: Message-ID: > > OK! Lets say I have a Python program with a NumPy array and a loop, > and for efficiency reasons I decide to write the loop as an extension, > like this: > > static PyObject * > foo(PyObject *self, PyObject* args) > { > PyArrayObject *array; > double* a; /* C ptr to the NumPy array data field */ > > if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) { > return NULL; /* Error indicator */ > } > > ... /* Check if array has right dimension, etc. */ > > n = array->dimensions[0]; /* Get the length of the array */ > a = (double*) array->data; /* Set the pointer to the NumPy data */ > > for (i=0; i x = (double) i/(n-1); > a[i] = f(x); > /* more general: *(array->data+i*array->strides[0]) = f(x) */ > } > > Py_INCREF(Py_None); return Py_None; > } > > where f is some function. I don't need to DECREF array in this > example since PyArg_ParseTuple does not increase the reference count, > right? No DECREF needed, since no call to PyArray_XXXXX was made. You are using a borrowed reference from the PyArg_ParseTuple command. You haven't missed a beat... -Travis From cwr at crash.cts.com Mon May 29 11:32:39 2000 From: cwr at crash.cts.com (Will Rose) Date: 29 May 2000 15:32:39 GMT Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> <392f60e8.260627511@news.nikoma.de> <8gs2u0$m7m$4@newshost.accu.uu.nl> <3931fb92.45603755@news.nikoma.de> <8gu1u5$bks$2@newshost.accu.uu.nl> Message-ID: <8gu2in$hqe$1@thoth.cts.com> Martijn Faassen wrote: : Philip 'Yes, that's my address' Newton wrote: : [snip] :>> If-malicious-somebody's-start-removing-stuff-all-code-is-lost-ly yours, :> However, removing indentation is more common than removing random :> characters such as '{' or '}' (or, with Pascal, 'BEGIN'), wouldn't you :> agree? For example, if someone writes HTML without remember that two or :> more spaces get treated as one? :> We're talking about what happens in real life. Indentation is more often :> smashed than characters are lost. : That's true, but in real life I haven't seen much indentation smashing of : Python source yet. Source code is usually transmitted in more durable : formats; after all if you smash the indentation in C you might get something : still compilable, but not something very readable. And the thing about source : code is that it should be human-readable, otherwise we can just as well : transmit binaries. It's not a problem with C unless you are trying to patch code and check the results; otherwise, you just feed the C code through indent to get your preferred style. I do that with most code anyway. However, it's not a major problem with Python, either. If you are moving Python code through some system that roaches whitespace (a lot of news systems used to) just uuencode it (or use MIME?). Will cwr at cts.com From vinyard at arlut.utexas.edu Wed May 31 12:09:50 2000 From: vinyard at arlut.utexas.edu (Edward S. Vinyard) Date: Wed, 31 May 2000 11:09:50 -0500 Subject: "non-essential difficulty" - case enforcing? In-Reply-To: <39352F52.B5A5B462@uab.edu> Message-ID: >In summary, case-enforcing seems like it could be a solution, I just >don't know how it would work :) Consider these possible difficulties: class a: x = 0 def a(): return 1 a = 2 or class A: x = 0 b = 0 b = A How do you handle these situations without forcing a variable to be of a fixed type (class, function, instance) over the course of its lifetime? Ed From sbarron at ansic.net Tue May 16 19:39:04 2000 From: sbarron at ansic.net (Scott) Date: Tue, 16 May 2000 19:39:04 -0400 (EDT) Subject: Decimals -> Fraction strings, my solution In-Reply-To: Message-ID: Hi, Oh yes this is much much better. I realized my way was terribly ineffici ent when doing fractions like 17/64. Your method speeds it up immensely. Thanks! Scott On 16-May-00 Fran?ois Pinard wrote: > kain at cableadmin.com (Scott) writes: > >> def gcd (numer, denom): >> """Return the greatest common denominator of two numbers""" >> if denom % numer == 0: >> return numer > >> p1 = plist (numer) >> p2 = plist (denom) >> p1.reverse () >> for x in p1: >> if x in p2: >> return x > > Hi, people. I prefer the following definition for GCD: > > def gcd(a, b): > while a: > a, b = b % a, a > return b > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard ---------------------------------- E-Mail: Scott Date: 16-May-00 Time: 19:35:26 This message was sent by XFMail ---------------------------------- From petersc at stud.ntnu.no Fri May 5 02:29:19 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 05 May 2000 08:29:19 +0200 Subject: Examples of 'Python Programming on Win32' References: Message-ID: <39126A3F.650ECD7D@stud.ntnu.no> Tim Roberts wrote: > > I would disagree with this statement. It's not that you have a memory > LEAK, it's that your algorithm is a memory HOG. Consider: Hei Tim! Thanks for the hint. Now I just do without the array (list of lists) and calculate the values in place when needed. Thanks for the help, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From ivanlan at home.com Mon May 22 15:49:03 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Mon, 22 May 2000 13:49:03 -0600 Subject: translating Perl Cookbook? References: <12113.000523@satunet.com> Message-ID: <39298F2F.3E3856D0@home.com> Hi All-- steven2 at satunet.com wrote: > > Hi, > > Just wondering if anybody is interested in translating the recipes > (and as much as the other code snippets) from The Perl Cookbook into > Python. > You shouldn't restrict it to snippets from the Perl cookbook. I, for one, would really like to see valuable resources from *anywhere* translated into Python. For instance, I would *really* like to see h2n turned in to Python. I keep meaning to start on this myself, but every time I look at the h2n source my eyes glaze over and my brain starts to hurt really, really bad;-( Metta, Ivan ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From jkraska1 at san.rr.com Fri May 26 23:58:25 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 27 May 2000 03:58:25 GMT Subject: Java vs Python References: <391F88EB.D25BB0F8@san.rr.com> <392E4285.D0F72C75@darmstadt.gmd.de> Message-ID: <392F4892.9E1ABE04@san.rr.com> > No way. In recent code I ported from java to python, the LOC dropped > by c. 50%. A visual IDE isn't going to make up for that, esp. when > you add in the time for code reviews. Maybe the LOC delta won't be > that large in all cases, but it is worth considering in your > discussions. I don't have tons and tons of python experience yet, however I agree with you. The code is small, manageable, and better yet, infinitely readible. It's a pleasure reading python. C/ From rumjuggler at cryptarchy.org Sun May 21 13:27:23 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 21 May 2000 17:27:23 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: <9c7gis4lsea7ju3bidsjmhcq33j2mtcmgh@4ax.com> On Sun, 21 May 2000 02:01:37 GMT, Guido van Rossum wrote: >(1) Randy Pausch, a professor at CMU, found, when teaching Python to >non-CS students in the context of Alice (www.alice.org), that the >number one problem his students were having was to remember that case >matters in Python. (The number two problem was 1/2 == 0; there was no >significalt number three problem.) I just don't understand this. I suppose I have to accept it, but it mystifies me. At my high school practically no one who took the computer science class (AP; we used C++) had trouble after the first day with case sensitivity, and most of us, including me, had never programmed before. -- Barnabas T. Rumjuggler Policeman: So sir, did the suspect have four arms, each one holding a sword, and was she wearing a girdle adorned with severed hands, her whole body covered in the blood of past victims? Mr Flynn: Well, it was overcast and everything, so it was hard to say for certain, you know? -- John Flynn on apihna From wware at world.std.com Fri May 26 09:08:56 2000 From: wware at world.std.com (Will Ware) Date: Fri, 26 May 2000 13:08:56 GMT Subject: [PATCH] A compromise on case - another suggestion References: <34575A892FF6D1118F5800600846864D35F585@intrepid> Message-ID: Simon Brunning (sbrunning at trisystems.co.uk) wrote: > [regarding Nick M's proposal for error messages] > I envision this being enabled by default, to help newbies like > myself. Expert users should be able to disable the check via a > command line option if they wish. Is there any performance hit to the clearer error messages? I would think (not having studied the patch) that, for code with no errors in it, the penalty would be only for testing the error, not for how it would be processed if it did happen. If that's right, there's no incremental performance cost for the improved error messages. Assuming experts don't have such brittle egos as to find the extra information offensive, it'd make sense to enable them all the time. If it's correct at all, the no-additional-performance-hit reasoning should also apply to people who want to hook in fancier near-miss-detection functions (swapping letters, leaving a letter out, etc). Python could be the world's first dyslexia-friendly programming language. Cool. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From neelk at brick.cswv.com Sun May 21 09:26:31 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 21 May 2000 13:26:31 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fsgon$jei$1@newshost.accu.uu.nl> Message-ID: Cameron Laird wrote: > In article , > Neel Krishnaswami wrote: > > > >semantics are de-facto defined by a single implementation. JPython > >would be a really good thing if only because it helps keep CPython > >honest about what's intended and what's an interpreter quirk. > > Already true. JPython *has* been "a really good thing ... because ..." Er, sorry, that's what I meant -- you see the results of a little too-hasty editing. Neel From zessin at my-deja.com Tue May 23 16:20:01 2000 From: zessin at my-deja.com (Uwe Zessin) Date: Tue, 23 May 2000 20:20:01 GMT Subject: [PATCH] Identifiers with '?' References: <392a054a.556160620@news.nikoma.de> Message-ID: <8gep52$ik$1@nnrp1.deja.com> In article , Michael Hudson wrote: > nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) writes: > > > On 21 May 2000 20:33:07 +0100, Michael Hudson wrote: > > > > >Tee hee. I have on my machine built (in the last few days) a Python > > >that allows one to use identifiers containing +, *, !, ?, & and @. > > >This means you have to space your operators properly, but is IMHO > > >quite a cool mod. I can clean it up and post the patch for that if > > >anyone's interested... > > > > Why not add '$' to that to cater to people from the VMS (or even > > BASIC) world? SYS$LOGICAL and all that (or whatever they look like). > > Easy as pie: > > [mwh21 at atrus build-aug]$ ./python > Python 1.6a2 (#16, May 23 2000, 09:54:00) [GCC 2.95.2 19991024 (release)] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) > >>> sys$logical = 1 > >>> sys$logical > 1 That would be a nice feature, because the $ is usually used in system- defined names on OpenVMS. Can we ask (cry at) Guido to allow $s in names? I don't want to put that into the OpenVMS port now and risk an incompatibility if he decides to give the $ a different meaning later. -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From rumjuggler at cryptarchy.org Sat May 27 00:48:32 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 27 May 2000 04:48:32 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> <392DD013.6E44EFF4@san.rr.com> <392E299B.9D8D0D54@san.rr.com> Message-ID: <69luisou9qfqdd82505p3b04s6s2gds62m@4ax.com> On Sat, 27 May 2000 03:22:31 GMT, "Chris Ryland" wrote: >Then wouldn't that be "Dum hoc ergo proper hoc"? (Cum is with, not during.) With or when. Or although. -- Barnabas T. Rumjuggler For the world, I count it not an inn, but an hospital, and a place, not to live, but to die in. -- Thomas Browne From claird at starbase.neosoft.com Fri May 19 08:56:35 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 May 2000 07:56:35 -0500 Subject: Newbie: Python suitability question References: <3921EFC8.53C372FC@araidesign.com> <667216D9BFABB429.CA0032F6AE6E8A3B.BD167DB25BA1D151@lp.airnews.net> <39230D7C.FA34A1B1@araidesign.com> Message-ID: In article <39230D7C.FA34A1B1 at araidesign.com>, Chris Arai wrote: . . . >The way the embedded app is set up it won't work as a command line executable >that could be made into an extension, called once each loop. The reason is >that the embedded app has it's own loop of data gathering from sensors and >processing that data (and previously gathered data.) Therefore the embedded >app must some how be static and be able to be re entered at a particular >point (the beginning of the data acq loop, not "main()") in order to be an >extension. > >You are right, the main form of communication from the embedded app is the >display memory bitmap. To the embedded app would be the key strokes. In the >deliverable form of the embedded app the display memory is piped directly out >to the display via an on board LCD controller. The keypad is also managed by >an onboard controller. > >I am thinking that if I extend python with the embedded app that I will have >to run it as a thread. Is this possible? I have never done threaded >programming before. If this is an appropriate method, then how do I >communicate between the two threads? Via files? What is a good reference >for learning how to do this? > >My original thought was that embedding python was the way to go. Once every >data acq loop the python module is called, but the same problem arises of >being static. It seems to me that this method also requires threads. . . . You're right. Embedding python *is* the right thing for you to do. My guess is that extend- ing is also possible, but more trouble in this case. Do you have pthreads in your environment? If so, Python can be built with a rich collection of thread-management constructs, including condition variables for communicating change- of-state, as well as Events, Semaphores, and Queues. Where *is* Thread programming explained well? Hmmm. *(the eff-bot guide to) The Standard Python Library* has useful examples. David Beazley's book is an accurate reference. It *does* seem as though there's a tutorial waiting to be written ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From embed at geocities.com Mon May 15 11:07:35 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 15 May 2000 11:07:35 -0400 Subject: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) References: Message-ID: > > if yes: > print "yes" > > Guido didn't want 10 ways (or even 2) to spell things, so the colon is > mandated for all. > > I'd like it if IDLE, or PythonWin would automatically insert the colon: I Type: if abc Result: if abc: _ <- cursor position At the exact moment you hit enter on the above line, the editor would check for the colon and, if not in a comment, add that colon for me. Same with "for", and other places like that. Warren From borcis at geneva-link.ch Tue May 30 05:24:22 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Tue, 30 May 2000 11:24:22 +0200 Subject: Compact syntax for 0-matrix? References: Message-ID: <393388C6.B528E2BC@geneva-link.ch> Kirby Urner wrote: > > I've used Numeric Python some. However, in a teaching > context, I don't want to hide anything from view. > NumPy doesn't always meet my criteria in this regard, > even though it is fast and useful. I'm not doing > really big matrices, and speed isn't really important. Mmm.. I am playing along lines a bit similar to yours, (e.g. polyhedra), and I have found Numeric quite useful for one particular bit : doing away with the complexities of specifying projective transforms by combinations of rotations, translations, scalings, etc..., using rather the 3-transitivity of the projective group, to specify a transform by choosing 3 points together with 3 target points to which the transform should map them. I find this hugely more transparent (this is 2D; in 3D, i guess you'd need 4 points). Numeric serves to solve the corresponding linear equations - of course, you could also code it. Boris From pj at sgi.com Thu May 4 22:57:30 2000 From: pj at sgi.com (Paul Jackson) Date: 5 May 2000 02:57:30 GMT Subject: How to get terminal width? References: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <8epl60$1b42$1@nntp6.u.washington.edu> <8es8fr$rjm$1@nntp6.u.washington.edu> Message-ID: <8etdaq$7992e$1@fido.engr.sgi.com> "stty size" isn't defined on my Irix box, but: tput cols works on each of my Irix, SuSE and TurboLinux boxes, issuing simply the number of columns. -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From emile at fenx.com Thu May 18 15:47:46 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 18 May 2000 12:47:46 -0700 Subject: Nested Dictionaries Message-ID: <392448E2.B28DF89D@fenx.com> outer['12345']['state'] Emile van Sebille emile at fenx.com Chris Lada wrote in message news:<392446c9 at wwwproxy3.westgroup.com>... > Is there some where of directly accessing information in a dictionary which > occurs as part of another dictionary i.e.: > > inner = {'city':'This City','state':'This State'} > outer = {'12345':inner} > > In order to access the 'city' information in the 12345 dictionary entry, I > do the following: > > temp = outer['12345'] # yields the outer dictionary entry with the key > '12345' > > tempCity = temp['city'] # yields the city value of the inner dictionary of > the > # outer dictionary entry with the key > '12345' > > Is there an easier or more direct way of doing this ? > > Thanks, > Chris > > > > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From MSteed at altiris.com Fri May 12 10:33:29 2000 From: MSteed at altiris.com (Mike Steed) Date: Fri, 12 May 2000 08:33:29 -0600 Subject: pkzip-like utility script for python that uses zlib? (embedde d python) Message-ID: <65118AEEFF5AD3118E8300508B1248774CB2EC@ALTNET> > From: Warren Postma [mailto:embed at geocities.com] > Sent: Friday, May 12, 2000 8:21 AM > To: python-list at python.org > Subject: pkzip-like utility script for python that uses zlib? > (embedded > python) > > > I have an embedded controller running Python, and I can > compile zlib into the application. What I'm wondering is, > is there a pre-written script that will provide either a > tar+gz or PkZip like functionality on top of ZLIB? [...] Hi, If you can build zlib into the application, can you not also hack in info-zip as well? Python it ain't, but I think it will do what you want. Or perhaps I am misunderstanding your requirements. http://www.info-zip.org/pub/infozip/ > Warren Postma -- M. From grisha at ispol.com Sat May 13 10:35:26 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Sat, 13 May 2000 10:35:26 -0400 Subject: mod_python - testers needed! Message-ID: OK People - The very first version of mod_python is available at http://www.modpython.org/ I don't think this is time for an official release announcement quite yet, but I would like to make it known to the world that it is out there and that I need help testing it, as well as any other kind of feedback. Enjoy! -- Gregory (Grisha) Trubetskoy grisha at ispol.com From effbot at telia.com Tue May 9 15:59:21 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 19:59:21 GMT Subject: OT [Way OT]: Unicode Unification Objections References: <3915C869.1B387972@videon.home.com><%XDR4.6318$Za1.97517@newsc.telia.net> Message-ID: Fran?ois Pinard wrote: > > I'll reach for my revolver. > > I'm not going to tell you that, ever! :-) don't worry -- the most dangerous weapon I own is an old water pistol. From erno at iki.fi Thu May 25 19:47:31 2000 From: erno at iki.fi (Erno Kuusela) Date: 26 May 2000 02:47:31 +0300 Subject: Modifying the environment References: <75F7304BB41CD411B06600A0C98414FC0A415B@ORSMSX54> Message-ID: >>>>> "Daley," == Daley, MarkX writes: Daley,> Hello, everyone! Here is a subject someone has to have Daley,> covered at one time. How do I modify the environment Daley,> using Python in such a way that the changes stay after the Daley,> Python script executes? I'm sure there's a way, I just Daley,> haven't uncovered it yet. If I use os.environ or Daley,> os.putenv(), the changes only last as long as I remain in Daley,> Python. Even the DOS window protects it's own copy of the Daley,> environment! it's the way environment variables work. there's nothing much you can do about it. the processes you start will inherit your environment though. if you really really wanted to, you could probably attach to your parent process like a debugger attach to another process, and prod its memory space. but i'll leave that as an exercise for the reader :). -- erno From sabren at manifestation.com Sun May 21 15:12:25 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sun, 21 May 2000 15:12:25 -0400 (EDT) Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <000101bfc351$56439460$e92d153f@tim> Message-ID: On Sun, 21 May 2000, Tim Peters wrote: > I'm wholly comfortable with 1/2 == 0 myself, but am equally comfortable with > rationals, floats, constructives or BCD, and can easily see why 1/2 == 0 is > a bad idea for computer newbies (more, it seems a bad idea for just about > everyone except system programmers -- which we both were when this decision > was made). So I'm not just flaming Randy . Somewhere, back in time, I used a programming language (turbo pascal? GW-BASIC?) that had three division operators. % was modulus \ was integer division / yielded a decimal number Maybe the last two were reversed, but I think "x/y" did what a newbie would expect, and people who always wanted an integer could typecast or use the \ operator. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From adjih at crepuscule.com Thu May 4 02:29:01 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 4 May 2000 06:29:01 GMT Subject: THE answer? References: <8ea0ao$fro$1@nnrp1.deja.com> <8ea9uu$rh0$1@nnrp1.deja.com> <8ecad6$bun$1@ites.inria.fr> <8ecref$lck$1@nnrp1.deja.com> <8ehnvs$m0h$1@ites.inria.fr> <8eieq8$ees$1@nnrp1.deja.com> <8el1mf$gu4$1@ites.inria.fr> <8epre0$ilj$1@nnrp1.deja.com> <8eqofg$jno$1@nnrp1.deja.com> Message-ID: <8er5bd$eo$1@ites.inria.fr> mdefreitas at sikorsky.com wrote: >> I think we need to send PyRun_File a COPY of the global >> dictionary, no? If so, how do we create a copy of a dictionary. >> I couldn't find anything like that in C/API document.. > OK, forget that... I think I have the real answer here... rather than > copy the global dictionary, I'll just create one with the necessary > elements for each recursive call. This is the final answer which seems > to work: > [...solution...] Ok, it looks like __builtins__ is the only thing required (?). Thanks for the info. Note that you could have written part of this in Python (same for handling arguments), with something like this (not checked): def runScript(commandAsString): argList=string.split(commandAsString) fileName=argList[0] newLocalDict={ "argList": argList[1:] } newGlobalDict={ "__builtins__": __builtins__ } try: result=execfile(fileName, newGlobalDict, newLocalDict) except: #XXX:TODO: handle/print traceback here. return None return result It's easier in Python :-) > This works, and each recursive call to the interpreter has a fresh set > of global vars. You will note the lack of error checking and memory > cleanup. Here is my more complicated version... Is my error checking OK? Probably... -- Cedric From embed at geocities.com Thu May 4 09:18:34 2000 From: embed at geocities.com (Warren Postma) Date: Thu, 4 May 2000 09:18:34 -0400 Subject: n = lambda x: print x Message-ID: In a moment of perverse glee, I decided to type the statement in to see what it does. The question I wondered was, if Python accepted this: n = lambda x: print x What would it do with this: n = (lambda x: print x,y) Is the comma part of the print statement, or would n become a tuple of two values? :-) Is the first construct s pecifically disallowed in the python grammar somehow? print is a bit of a weirdball function in that it is invoked without parenthesis. (The most BASIC-like feature of Python). Could we in fact say that if fewer exceptions to rules makes a language simpler then the PRINT statement is a bad idea and a PRINT( x,y,z) function would have been a much better idea? Why did Guido not parenthesize arguments to PRINT when designing Python? Look, a Syn! Otherwise, this language is perfect. ;-) I love Python. Warren From brent.fulgham at xpsystems.com Mon May 15 12:12:12 2000 From: brent.fulgham at xpsystems.com (Brent Fulgham) Date: Mon, 15 May 2000 09:12:12 -0700 Subject: Embedding Python in c++ Message-ID: > > hi > > I want to use Python as a scriptinglanguage in my c++-framework. > But I just can find the libaries I need to get it running. > Im working under linux with Python 1.5 > > greetings > Charistoph Schemmann > Hi, Titus Brown and I have gotten Python to work as an embedded language in the C-based AOLserver (web server). I wrote the extension module in C++, and it probably has examples of most of what you need, plus examples of how to work with Python alongside C, C++, and Tcl. What a mess! :-) See http://pywx.sourceforge.net for details. Basically to embed Python inside your framework you will need to do a bit of Python extension as well. There are good examples in the Python source distribution as well. Good luck, -Brent From alvaro at ocse.infonegocio.com Mon May 22 12:10:18 2000 From: alvaro at ocse.infonegocio.com (AMR) Date: Mon, 22 May 2000 18:10:18 +0200 Subject: Microsoft-style format strings References: Message-ID: <8gblr7$gas4@esiami.tsai.es> Try with this, With this you have what you want. You can slice what you want. Problably there are other function more similar to the Vb format, but I'm waiting for other answer because I've tried and I can't. >>> from time import * >>> asctime(localtime(time())) 'Mon May 22 18:05:26 2000' I hope it helps, -- Alvaro Mart?nez alvaro at ocse.infonegocio.com "Andy Robinson" escribi? en el mensaje news:PGECLPOBGNBNKHNAGIJHAEADCCAA.andy at reportlab.com... > Has anybody written anything analogous to the > VB-style format function? > > This would be able to do > format("$#,##0.00", someAmount) > or > format("ddd dd-mmm-yyyy", someDate) > > Hoping-to-save-an-hour-or-two-ly y'rs, > > Andy Robinson > From m.faassen at vet.uu.nl Fri May 5 11:08:39 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 May 2000 15:08:39 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> <8es797$p76$1@newshost.accu.uu.nl> Message-ID: <8euo5n$akg$3@newshost.accu.uu.nl> Don Tuttle wrote: > [Martijn] >> I've been toying with the idea of implementing a Zope-based version of the >> Vaults eventually myself. That should be able to offer some interesting >> features. (hm, just got a weird idea: test the module through the web! >> obviously this is hopelessly insecure, but..) >> >> But right now time does not permit me. > Zope (being a Python app) sounds like a good idea. But since I've never > used it let me ask, is Zope the best tool for the job? It's definitely versatile enough, though there's a learning hump, of course. For instance, Zope isn't only about creating objects; it talks well to relational databases. But I'm definitely biased. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From john at nwjohn.jf.intel.com Fri May 12 10:57:00 2000 From: john at nwjohn.jf.intel.com (John Villalovos) Date: 12 May 2000 07:57:00 -0700 Subject: Easy way to print numbers with thousand separators? References: <391B4F36.57EE6313@fenx.com> Message-ID: <8fh63s$ds8$1@nwjohn.jf.intel.com> Thanks! But now when using a Red Hat 6.2 system when I type: import locale I get the following: Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux\ (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import locale Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/locale.py", line 4, in ? from _locale import * ImportError: No module named _locale >>> I can see the locale.py, locale.pyc, & locale.pyo files in /usr/lib/python1.5/ Is there a configuration file option that will make it work? Thanks, John In article <391B4F36.57EE6313 at fenx.com>, wrote: >>>> import locale >>>> locale.setlocale(locale.LC_ALL,"") >'English_United States.1252' >>>> print locale.format("%12.2f",1234567.89,1) > 1,234,567.89 > >Emile van Sebille >emile at fenx.com > >John Villalovos wrote in message >news:<8ffdtg$dav$1 at nwjohn.jf.intel.com>... >> I was wondering if there was an easy way to print numbers with thousand >> separators in them? >> >> For example I want to print the number: 1234567890 >> as: 1,234,567,890 >> >> I know I can write a simple little program to do it but I was hoping that there >> was already something in the libraries to do this. >> >> Thanks, >> John >> -- >> http://www.python.org/mailman/listinfo/python-list >> > From m.faassen at vet.uu.nl Tue May 30 11:40:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 15:40:50 GMT Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> Message-ID: <8h0ne2$70i$2@newshost.accu.uu.nl> Fredrik Lundh wrote: > Martijn Faassen wrote: >> > btw, usability research has shown that "and" and "or" are about the >> > worst names you can use for these operators. how about renaming >> > them in Py3K? ;-) >> >> The Alice project again, right? :) > nope. they're not the only ones out there who thinks that > programming languages are user interfaces. Well, programming languages are user interfaces of a kind, for that class of users that is or wants to be a programmer (which may or may not be Everybody). >> just-had-to-make-that-comment-ly yours, > yeah, HCI people cannot be very smart if they don't under- > stand how computers work, can they? better ignore them. I'm not claiming we should ignore HCI people. You were the one who started with the silly usability research comment. :) But if certain HCI people produce research that shows 'and' and 'or' are about the worst names for these operators, then I'd indeed question that research and those particular HCI people. There isn't actually such research, is there, though, I assume? Note that I'm not questioning the Alice result on case-sensitivity; I'm sure case-sensitivity confused beginners. It's just that the Alice result is not the whole picture; there is the consistency of spelling argument, and the desire for certain idioms that make use of case, for instance. Then the debate starts on whether those advantages of case-sensitivity outweighs the advantage case-insensitivity brings to beginners. Anyway, we've all gone through that 5 times already. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ivanlan at home.com Thu May 25 13:49:02 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Thu, 25 May 2000 11:49:02 -0600 Subject: [JPython] how do I get at the environment in JPython? References: <392D65B3.269A563B@hydrogen.stx.com> Message-ID: <392D678E.FED06A27@home.com> Hi All-- Chris Gokey wrote: > > HI everyone, > > I'm trying to access environment variables in jpython... I've tried several things: > > 1) > import os > os.environ['MD_PATH'] > ? mdp=os.environ['MD_PATH'] should work if all you want to do is read it. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From sblakey at freei.com Wed May 17 14:42:28 2000 From: sblakey at freei.com (sblakey at freei.com) Date: Wed, 17 May 2000 11:42:28 -0700 (PDT) Subject: fcntl.flock problems on FreeBSD Message-ID: <20000517184228.19805.qmail@c391458-a.sttln1.wa.home.com> I'm having some trouble with flock in the fcntl module on a FreeBSD 4.0 box. Most of the flock operations work perfectly (LOCK_SH, LOCK_EX, LOCK_UN), but LOCK_NB seems to alway raise a Bad file descriptor error. Is this a bug in the fcntl module or a knwon deficiency of FreeBSD? Does this OS not support non-blocking file locks. I've implemented a workaround (this has to get out the door today), but it feels like just that, a workaround. Does anybody know what's wrong here? I replicated the problem in the interactive shell. $ python Python 1.5.2 (#2, Mar 12 2000, 12:38:38) [GCC 2.95.2 19991024 (release)] on freebsd4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import fcntl >>> fd = open('lock', 'w') >>> fcntl.flock(fd.fileno(), fcntl.LOCK_SH) >>> fcntl.flock(fd.fileno(), fcntl.LOCK_EX) >>> fcntl.flock(fd.fileno(), fcntl.LOCK_UN) >>> fcntl.flock(fd.fileno(), fcntl.LOCK_NB) Traceback (innermost lasr): File "", line 1, in ? IOError: [Errno 9] Bad file descriptor >>> -Sean Blakey From jcm at bigskytel.com Fri May 12 20:30:53 2000 From: jcm at bigskytel.com (David Porter) Date: Fri, 12 May 2000 18:30:53 -0600 Subject: Distro for IBM OS/390 In-Reply-To: <391bf7b1@wwwproxy3.westgroup.com>; from chris.lada@westgroup.com on Fri, May 12, 2000 at 08:26:23AM -0400 References: <391bf7b1@wwwproxy3.westgroup.com> Message-ID: <20000512183053.B15594@bigskytel.com> * Chris Lada : > Does anyone know if there is a Python distribution for IBM's OS/390 ? > If there were, I think it would be mentioned here: http://www.python.org/download/download_other.html which it isn't. david. From glyph at twistedmatrix.com Wed May 17 16:08:49 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 17 May 2000 15:08:49 -0500 Subject: The REALLY bad thing about Python lists .. In-Reply-To: "Tim Peters"'s message of "Wed, 17 May 2000 02:03:12 -0400" References: <000601bfbfc5$95612f20$b52d153f@tim> Message-ID: "Tim Peters" writes: > [Tim] > >> ISO/ANSI C doesn't fully define what happens when (roughly) > >> integer division or % are handed negative numbers. > > [Glyph Lefkowitz] > > The foibles of standards commitees will never cease to amuse me. > > Thank you for this little tidbit. > > The next iteration of C has threatened to "fix" this, by mandating Fortran's > original mistake (truncation, as opposed to Python's floor). By "threatened" you don't mean "already mandated but it hasn't been implemented yet", do you? Please say this is still open for discussion :-) > BTW, have you "served" on a stds committee? It's, umm, educational. [ comittee-nonsense snipped ] Wow. Come see the ANSI Standards Comittees perform "USENET, live and in concert!"... although the anecdotes I've heard about the Common Lisp and ANSI C standards committees jibe with this altogether too much :-\ > > Do you actually have a basis for that statistic? > > The only *hard* statistic Guido has is the download stats from > python.org, where the number of Windows downloads routinely beats > the number of all others combined (last stats I saw were from last > August, where Windows was "winning" by an easy factor of 2) Well, speaking of lame anecdotes, :), now that I'm writing software in python, this is the way my conversations go with potential users: Me - "I've got some more of the code done. Do you guys want to try it out?" Linux User - "Sure. Do I need python installed?" Me - "Type 'python'. Does anything happen?" Linux User - "Yeah, a >>> prompt comes up." Me - "OK, just download the software." (5 minutes later) Linux User - "Got the file; ... what do I do with it?" Me - "On the command line, tar xvzf mysoftware.tar.gz, then cd mysoftware; ./run" Linux User - "OK, it's running. Thanks!" Windows User - "What do I need?" Me - "Well, first you'll need WinZip ... download it from www.winzip.com" (20 minutes later) Windows User - "OK installed. What else do I need?" Me - "You need Python: go to www.python.org, download it, and install it." (20 minutes later) Windows User - "Grr. OK installed. It asked me about tcl/tk but I didn't install that." Me - "No, you need that. Uninstall and then reinstall and install that too." (5 minutes later) Windows User - "Augh! Done. OK now what?" Me - "Download mysoftware.zip, and double-click on it. That should open up WinZip...." (the windows user will almost always become frustrated at this point and forget about it, being "just a user" and confused by all this high-falutin terminology of "archives" and "virtual machines", assuming that WinZip works at all. I need to build a friggin' installer soon so this stops happening.) The point being, of course, more Linux users have tar than Windows users have WinZip, and more Linux users have Python than Windows users do; but I am sure that GNU tar is downloaded less than WinZip. I have yet to encounter a Linux user (regardless of distribution) who doesn't have python installed, although most don't know that it's there. Given how many really useful utilities are written in it, and how many environments depend on it, it's becoming a basic component of most modern linux distros. > not-admitting-that-a-little-known-part-of-python-startup-sends- > email-to-python.org-whenever-python's-invoked-ly y'rs - tim putting-python-in-a-chroot-jail-with-no-network-access- from-now-on-(and-i'd-like-to-see-you-do-that-on -windows-)-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From mss at transas.com Thu May 11 15:07:43 2000 From: mss at transas.com (Michael Sobolev) Date: 11 May 2000 23:07:43 +0400 Subject: Data::Dumper output reader Message-ID: <8ff0dv$e45$1@anguish.transas.com> I need to read a lot of information produced by perl Data::Dumper module. If I understand correctly, these files can easily be eval-ed in perl, so something like an interpreter for a subset of perl language is needed. :) Does anybody know how to deal with such information? I would not want to write a parser for that... Thanks, -- Mike From dalke at acm.org Tue May 9 21:38:24 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 9 May 2000 19:38:24 -0600 Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: <8faebj$c46$1@slb6.atl.mindspring.net> Ben Wolfson wrote: >lines.sort() >for line in lines: > if line not in uniqlines: > uniqlines.append(line) > out.write(line) >out.close() > Since you've sorted the lines, you don't need the "line not in ..." That gives you order n-squared performance. Since you already sorted the lines, a better one is: lines.sort() prev = None for line in lines: if line != prev: out.write(line) prev = line Andrew From echuck at mindspring.com Thu May 18 09:25:00 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Thu, 18 May 2000 09:25:00 -0400 Subject: [PyWX] Re: Choice of language References: <3921523B.F93EF787@mindspring.com> <14625.32542.132486.760008@marzipan.emphatic.com> <20000516122416.H21435@cns.caltech.edu> Message-ID: <3923EF2C.CE91FB08@mindspring.com> Titus Brown wrote: > > -> Chuck Esterbrook writes: > -> > Given the success, maturity, functionality and stability of the > -> > Python programming language, as well as the ease of embedding and > -> > extending it, has anyone in the Latte community considered creating > -> > a Python version of Latte? > -> > -> Well it certainly sounds like you have! > > [ munch ] > > I'm not sure what Chuck was suggesting: there are two options, right? > > Write a Latte parser in Python; this would let many Web servers > incorporate it easily, not the least of which would be AOLserver. > > Separately, adapt the Latte language to a Pythonesque syntax, which it > sounded like Chuck was suggesting. > > I am very much in favor of the first; the second sounds a bit more > difficult to do cleanly. I agree with Titus. I wasn't planning on mixing existing Latte syntax with Python code, although anyone who wants to do it can certainly pursue it. :-) I was looking for people's thoughts on the subject, which I got. There's another approach besides Latte which is the ASP/PHP/JSP approach (which I'll call *SP) characterized by <%= %> for expressions and <% %> for statements. I've been thinking more about Latte vs.*SP and my impression is that Latte is geared more towards writability and readability of source for use in creating documents where as *SP is geared more towards programmatic, dynamic pages dished out by a server. However, there is certainly overlap in the two systems. I certainly like the readability of Latte _content_ (e.g., the body text and so on) but the code definitions with all their \s and {}s (mostly the \s) looks pretty horrendous. Plus, as I stated, I try to avoid implementing new mini-languages if I can help it (e.g., I prefer to use Python). However, the Latte language does something special which is to allow regular content in the middle of the source code which gets included verbatim. I guess this is what makes it embeddable and what therefore makes it non-amenable to just saying "hey, substitute Python in there and it'll be better" (you *can* say that when you look at PHP). I have an idea for an alternate version of Latte that would have cleaner syntax, less syntax and use Python for function definitions, but I need to work out the ideas. I'll follow up within the next week when I've got something presentable. -Chuck ____________________________________________________________ http://webware.sourceforge.net From kcazabon at home.com Wed May 3 00:51:16 2000 From: kcazabon at home.com (Kevin Cazabon) Date: Wed, 03 May 2000 04:51:16 GMT Subject: How do I ignitalize a list please? References: Message-ID: <8fOP4.198284$Dv1.2498252@news1.rdc1.bc.home.com> This is covered very well (as well as most other aspects of Python) in the documentation, specifically the Tutorial. However, in brief, you simply need to create the empty list first, as follows: list = [] list.append("spam") for i in range(42): list.append(i * 42) i[12] = "Eggs" >>>i[12] Eggs ############### However, if you simply say that list=[], you cannot then assign to list[12] because it doesn't exist yet. You have to append X number of objects to the list, or create the list with that many elements in the first place using a "range" loop. Kevin. wrote in message news:kSUtN6=fLIxjJNG0pGTq25a0tuiY at 4ax.com... > How do I initialize a 'list' please? > I read that a list is the only array that can be modified in standard > python. > > (to put it simply) > > i = 1 > mags[0] = 0 > mags[1] = 1 > print mags[i] > > doesn't work. > > Please reply here > or at cmfinlaySPAM at magnet.com.au From kuncej at mail.conservation.state.mo.us Mon May 15 11:59:34 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Mon, 15 May 2000 10:59:34 -0500 Subject: HTMLgen-erated by HTMLParser References: <391EF971.5964@seebelow.org> Message-ID: > So, has anybody ever written a > thing using HTMLParser that automatically translates HTML into HTMLgen > code? That would be neat. But the quick'n'dirty way is to use HTMLgen's DocumentTemplate class --Jeff From sbrunning at trisystems.co.uk Fri May 19 07:41:58 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 19 May 2000 12:41:58 +0100 Subject: HTML search engine written in Python - is there one? Message-ID: <34575A892FF6D1118F5800600846864D2F0636@intrepid> I need something that will build an index of the text content of a number of HTML files, and allow you to nun queries on the index. Does anyone know of such a thing, or am I going to have to write my own? -- Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From wtanksle at dolphin.openprojects.net Tue May 9 21:30:47 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 10 May 2000 01:30:47 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39184C59.DD33AA67@tismer.com> <8fa2m4$98v$1@agate.berkeley.edu> Message-ID: On 9 May 2000 22:15:32 GMT, Edward Jason Riedy wrote: >And Jeff Senn writes: > - Several times I have considered what it would be like to have a > - 'simple-unified-VM' that supported continuations (if not full > - continuations -- then at least micro-threading) and could run Python, > - Java Script, Ruby, ... [Visual] Basic?, Perl??, ... Java????... >Like a Virtual Virtual Machine? See http://www-sor.inria.fr/projects/vvm/ . Interesting. I was thinking of OTA, the spec used in Europe for smart cards and terminals. It's built for decent speed and tiny size on very low-resource systems. >And yet other people might eschew virtual machines for intermediate >representations that can be compiled quickly while keeping the >information necessary for advanced optimizations (see the slim binary >work at http://www.ics.uci.edu/~franz/SlimBinaries.html and the >pubs under publications.html). I've always liked this, but there's essentially no documentation, and the only source code is a MESS. Someone's written a parser for these in C++; hopefully they'll write some documentation as well. ANDF is a more standardised version of this (it's also a lot less functional). >Jason -- -William "Billy" Tanksley From m.faassen at vet.uu.nl Fri May 5 16:48:51 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 May 2000 20:48:51 GMT Subject: What's gives with Activestate? References: <8tdQ4.83821$cZ.185121@typhoon.southeast.rr.com> <20000504161923.P11481@xs4all.nl> <39120F04.7B396522@oreilly.com> <8euocr$akg$4@newshost.accu.uu.nl> <8ev7kd$87t$1@hammer.msfc.nasa.gov> Message-ID: <8evc3j$dr4$1@newshost.accu.uu.nl> Andrew McDowell wrote: > What ever happened with the Trove Project? > (http://www.tuxedo.org/~esr/trove/) It went to SourceForge. SourceForge now apparently implements parts of Trove. I'm not deeply familiar with Trove, but SourceForge has an extensive categorization system which is apparently derived from Trove. I don't know what the underlying source code is, and whether it'd be reusable in Vaults 2.0. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Shiv at pspl.co.in Tue May 9 09:44:42 2000 From: Shiv at pspl.co.in (Shiv Shankar Ramakrishnan) Date: Tue, 9 May 2000 09:44:42 -0400 (EDT) Subject: Python on 64 bit/IA-64 ... Message-ID: Hi, Has there been any work done to make Python take advantage of a full 64 bit environment? More specifically is anyone working on an Intel IA-64 port of Python? In particular if one were to change the sources for this then which data model would one follow - LP64 or LLP64 (P64)? Which model have people used for existing 64 bit platforms if they did a port? AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited precision (emulation). Floating points are m/c dependent but mostly doubles. So this is what I think might be good for IA-64 - Pointers - All 64 bit. Int - 64 bit. Long - As it is now. Floating Point - double (As now) or should it be long double? Making floating points long double will get better precision but then the results might differ from the double based ones. Any comments? Also any general advice on doing a 64 bit port of Python. Things to watch out for? Pitfalls etc ... Please note that I am not making any promises about an IA-64 port as of now :-) Thanks, Shiv P.S. If you something significant to say please cc a copy to me by E-mail also. From mwh21 at cam.ac.uk Wed May 17 16:36:49 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 May 2000 21:36:49 +0100 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: ge at nowhere.none (Grant Edwards) writes: > In article , Michael Hudson wrote: > > >Noisily; it's been a while since I played with this kind of thing, but > >hopefuly this will give you some idea: > > Oh my Gaawwd. > > That was amazingly perverse. Glad to be of service :-). > I've always disliked C++, and everyday I stumble across new > reasons... It was my first proper programming language (I learnt it when I was about 17; I'd played with logo and basic on the Amstrad PCW when I was 12 or so, I guess), which may have something to do with my ability to wring perversity even from Python... I could cope with C++ if I was the only person on the earth allowed to write in it, if you see what I mean. Cheers, M. -- The ability to quote is a serviceable substitute for wit. -- W. Somerset Maugham From nospam at sorry.com Sun May 14 18:01:53 2000 From: nospam at sorry.com (Keygrass) Date: Sun, 14 May 2000 22:01:53 GMT Subject: (gulp) newbie question - portablity of python References: <8fmtjo$3ub$0@216.39.141.21> Message-ID: Oh, I see now. I have to install Python. I certainly don't mind installing Python on my home computer; no problem there. But I don't have access to install Python at the unix workstation at my job. :-( They use unix on the Sun systems, I believe. I could ask a network adminstator if he or I could install Python. But ... I don't think it will receive a warm welcome since many files (I strongly believe they are text based, but I am not 100% sure) are highly sensitive. I figured they don't want any unnecessary program lurking on the hard drives, regardless of the benevolence Python could do for us. Well, I suppose I will eventually have to ask. But until then, I need to first back up my claim with a reliable Python program. Thanks, I appreciate it. -cb -------------------------- dana_booth wrote in message news:8fmtjo$3ub$0 at 216.39.141.21... > Keygrass wrote: > > K: So ... my question is this: Is this really too good to be true? What I want > K: to do it write the program on my Win98se (at home) and then use that .exe > K: or .bat file (or whatever extension it is) at work which uses unix. > > TCL/TK also is very portable, and I have written several GUI front ends in > TCL that call on Python for the "real" work. Both the TCL and Python scripts > are written and tested on my Linux workstation. When they're ready for prime > time, I move them to an OpenBSD server, where they'll reside for the Windows > users. > > The computer that you intend to run Python on must have Python installed, > that's all. If you include propriotory stuff like absolute pathnames, i.e., > "c:\program files\..., etc., that's up to you, but other than that, the code > is portable. > > K: Basically, I want a build a program that will replace words and number on > K: another file. For example, if I had a file called "Outdoor_sports" that > K: contained the word "baseball bat", I would want my program to change it so > K: it would say "football". > > Really easy. Good luck! > > -- > > ----- > Dana Booth > Tacoma, Wa., USA > > key at pgpkeys.mit.edu:11371 From spamfranke at bigfoot.de Mon May 22 19:06:59 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Mon, 22 May 2000 23:06:59 GMT Subject: First different char in two strings? Message-ID: <392abd40.10218183@news.btx.dtag.de> What's the fastest way to find the first different character inside two strings? Stefan From pinard at iro.umontreal.ca Wed May 17 17:47:38 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 May 2000 17:47:38 -0400 Subject: AI and Python In-Reply-To: Peter Norvig's message of "Wed, 17 May 2000 14:13:10 -0700" References: <39230B65.EB54DC2B@norvig.com> Message-ID: Peter Norvig ?crit: > You make a good observation that AI and operations research have a > large overlap in the problems they address: basically, what is the > right program or policy to decide what to do in a complex, uncertain > environment? It is a crime that the fields developed independently with > little interaction, but in the last five or ten years this has changed, > and AI now encompasses OR techniques, and is much better suited for > dealing with real-world programs. Surely no crime here. That various fields synergise is undoubtedly a good thing. What I did not like much, retrospectively, is all the fuss AI people were making all along. Can Python do AI? I'm not sure what AI means. OK, yes, Python can! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From cut_me_out at hotmail.com Thu May 4 13:37:46 2000 From: cut_me_out at hotmail.com (Alex) Date: 04 May 2000 13:37:46 -0400 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <75F7304BB41CD411B06600A0C98414FC0A40FD@ORSMSX54> Message-ID: > > release. Is it painful? You bet. Just ask Billy -- the translation > > from old symbol names to new names broke the compile for weeks. But > > once it was all over, I had fixed no less than 14 bugs that would > > *never* become apparent until after I'd released the code to the > > public. Most of the bugs were bound to be of the "intermittent" type > > too, so I was particularly pleased at the end result. > > If your problems are solved by this kind of mindless busy work, you > have much bigger problems that any amount of hungarian notation will > ever fix. I good primer on writing maintainable code is recommended. > Try _Programming_with_Dick_and_Jane_. I'll never try Hungarian notation, as I'm too lazy. But I am curious about which elementary programming techniques you think could have helped this person find his 14 mysterious bugs. Alex. From corg at copernic.com Wed May 10 10:48:50 2000 From: corg at copernic.com (Gaetan Corneau) Date: Wed, 10 May 2000 10:48:50 -0400 Subject: SystemError: NULL result without error in call_object Message-ID: Mark, > If the object is attempting to return an array of COM objects (ie, > IDispatch or IUnknown pointers), then this is a bug in the > COM extensions recently fixed (I think I posted exactly when only a > couple of days ago...) I'm using 1.5.2 and win32all-129 with the latest patch. Is that supposed to be OK, or should I look for a specific file? Yesterday night, I have been able to narrow down the problem to two lines of code in my implementation of the "Next" function in my enumerator. If I set the variant type to "variant", and put my IDispatch interfaces in, it *almost* work: instead of receiving an IDispatch in each iteration of my "for" loop, I get a single element tuple containing the IDispatch: (>,). I tried setting the variant type to "integer" and returned integers, but in Python, I still got single element tuples containing my values. Do you know what I'm doing wrong? Thanks, ______________________________________________________ Gaetan Corneau Software Developer Copernic.com http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Les T?l?tubbies, c'est de la musique d'ascenseur pour les yeux" From rspy at hotmail.com Fri May 26 15:05:01 2000 From: rspy at hotmail.com (Grzegorz Dostatni) Date: Fri, 26 May 2000 12:05:01 -0700 Subject: Pmw and Tkinter Message-ID: <8gmege$8p8$1@pulp.srv.ualberta.ca> Hello... I'm new to Python. I'm working on a project that uses Tkinter and Pmw. Here's my question: Is it possible to set the minimum size of the window? How? I tried using width and height attributes. Those work fine as long as there is nothing on the window. (I'm using a grid layout). As soon as I put a button, the window resizes itself... What am I doing wrong? I thought of using the 0'th row and column to put an invisible object of given size (something 1x n pixels) to guarantee a minimum size. Thanks in advance Grzegorz Dostatni From jkraska1 at san.rr.com Sat May 13 10:00:59 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 14:00:59 GMT Subject: Python lists/vectors/??? References: <391CA714.3EB0E8B5@san.rr.com> <391CE91F.28119CC6@san.rr.com> Message-ID: <391D60B3.10DD25F1@san.rr.com> Neel Krishnaswami wrote: > > Courageous wrote: > > > > Something I don't understand about python list[] structures: are > > they o(1) on index or o(n)? This is puzzling to me, because it's not > > obvious what performance to expect from them at first glance. You'd > > think there would be a python list type, for linked lists, and > > python array type, for vectors, but there's not. What's up with > > that? > > They are O(1) arrays. list.append()ing to them is technically O(n), > but a full resize is triggered only every hundred (or thousand for big > lists) insertions because the resize leaves some slop. I noticed that (I have the code). That's the way I would have done it, too. I was more concerned about people pushing/popping python lists not realize that it was O(n). C/ From steffen.ries at sympatico.ca Thu May 4 07:36:33 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Thu, 04 May 2000 11:36:33 GMT Subject: opaque data stream References: <008e01bfb424$d673d140$2801000a@iel.ie> Message-ID: "Shaun" writes: > im figuring out how to use the xdrlib module.....and id like to know what an > "opaque data stream is?" Opaque data is a sequence of bytes (either variable or fixed length) which is passed without being interpreted. i.e. the data is not modelled as an array or structure of some defined type. (see RFC 1832 for more details) hth, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From mhammond at skippinet.com.au Thu May 11 11:10:24 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 May 2000 15:10:24 GMT Subject: SystemError: NULL result without error in call_object References: Message-ID: "Gaetan Corneau" wrote in message news:C5A7720BDEB7D3118A5200E018C200A037F6DF at EXCHANGE... > > You _always_ get a tuple of that size, even when you request only 1. > I don't understand. Look at the following: >>> from win32com.client.dynamic import Dispatch >>> ie = Dispatch("internetexplorer.application") >>> ie.Navigate("www.copernic.com") >>> doc = ie.Document >>> for link in doc.Links: ... print link ... >>> link > >>> > This uses IEnumVariant, and links are IDispatch, not tuples. I don have to > write: > print link[0] The for loop in Python internally calls IEnumVARIANT::Next(1), and unpacks it. Similarly, you can say: doc.Links[5] And internally we will call Next() to skip to the 5th element and read it. EnumVARIANT::Next always returns a tuple. The magic stuff for an IDispatch object (which internally calls Next) unpacks this tuple for you... Does that make more sense? > > Have you determined exactly > > what causes the "null result without error" message? One > > guess is that you setup the > > variant as VT_DISPATCH, but leave a NULL pointer in the > > variant. > That's what I thought, but it is not the case. I really return the correct I checked the code, and that is indeed impossible. I would really like to know how this happened, even if it was a bug in your code, just for the sake of stability... Mark. From mhammond at skippinet.com.au Wed May 10 09:25:29 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2000 13:25:29 GMT Subject: __getattr__ and extend COM object References: <8fa4p1$8jf$1@nnrp1.deja.com> <8fbm4k$top$1@nnrp1.deja.com> Message-ID: wrote in message news:8fbm4k$top$1 at nnrp1.deja.com... > So, should I be doing: > mod = gencache.EnsureModule('{C51A6141-884F-11D2-92D2-0010A4F29F27}', > 0, 1, 0) Yep. > If my GUID for my COM object changes, I need to change my python script? > Can I not just use some string to represent my COM object? So that if > my GUID changes I don't have to change my python script? Unfortunately not. This is the ID of the type library. They dont have names. Path names would obviously be worse. Just dont change the typelib GUID :-) AFAIK, VB etc would all have the exact same issue (except they wouldnt actually _show_ you the GUID :-) > Also, what would: > mod._WhateverMakePySaysItIs > > by in this example? Dunno - check out the source file that makepy generated. There will be a number of classes, and one should be easily identifiable as the one you want - it will have "def" statements for all the methods, and tables for all the attributes... Mark. From pj at sgi.com Thu May 18 18:11:45 2000 From: pj at sgi.com (Paul Jackson) Date: 18 May 2000 22:11:45 GMT Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> Message-ID: <8g1pr1$ch5ff$1@fido.engr.sgi.com> Dale wrote: |> I need a little checksum routine Do either of the md5 (128 bit) or sha (160 bit) modules suit your needs? -- def CheckSum (filepath): """ Sample CheckSum() routine, using md5 """ import md5 return md5.new(open (filepath).read()).digest() -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From olipt at mayo.edu Mon May 22 11:23:37 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Mon, 22 May 2000 10:23:37 -0500 Subject: Case sensitivity/insensitivity In-Reply-To: <39260CB6.464EE302@san.rr.com> References: <39260CB6.464EE302@san.rr.com> Message-ID: > I can't really see any other real use of actual case sensitivity > in the language. Does anyone out there actually make use of > case sensitivity? > I know it may not be the critical time yet, but since many have voiced their opininon, I will too. Case sensitivity is very useful when using Python as a mathematical programming languauge especially in an interactive setting. I use it constantly and would be very disappointed if it went away. For example, mathematics notation often expresses the Fourier transform of a lower case variable as a capital variable. This is a very powerful and convenient way to remind the user which domain the samples are taken from. I often use the same construct in Python code and would have to change a lot of code. I'm not sure what all the hubbub about case insensitivity is about. Everybody uses mixed case in writing all the time. Capital letters have a purpose in many communication languages, why should capital and lowercase be indistinguishable in computer languages? --Travis From kc5tja at garnet.armored.net Wed May 3 16:13:22 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 3 May 2000 20:13:22 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> <390FCEF3.919A5DBC@stud.ntnu.no> Message-ID: In article <390FCEF3.919A5DBC at stud.ntnu.no>, Peter Schneider-Kamp wrote: >Sorry for disagreeing, but if you ever got your fingers into >artificial intelligence you'd see that a significant part of >the community is using LISP, a language similar to Python in >being high level. And believe me, for some things LISP is >still prime time. LISP is also used quite heavily in the telecommunications industry as well, from what I understand. A large number of telephone switches run on them. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From fwang2 at yahoo.com Wed May 3 14:21:41 2000 From: fwang2 at yahoo.com (oliver) Date: Wed, 3 May 2000 14:21:41 -0400 Subject: signal module question Message-ID: hi, I think two or more alarms can be installed, say, one alarm is fired up at 10 seconds interval, the other one 30 seconds interval. My question is can i use one handler to deal with both alarms? If the answer is yes, then inside the handler, I need some ways to distinguish which alarm is triggered (10 sec or 30 sec?). After going through the reference page on "signal" module, it seems that handler can only take two arguements, how to "tell" handler more info on the alarm it is handling? Thanks oliver From c.evans at clear.net.nz Sat May 20 00:02:38 2000 From: c.evans at clear.net.nz (Carey Evans) Date: Sat, 20 May 2000 04:02:38 GMT Subject: Bit length of int or long? References: <000201bfc066$85951380$872d153f@tim> <000b01bfc14d$7c7ef1c0$6401a8c0@home> Message-ID: <87zopl50o1.fsf@psyche.evansnet> "Darrell Gallion" writes: > Assuming it never hurts to ask. > >>> x=0xffffffff > >>> x >> 1 > -1 > > Wouldn't 0x7fffffff be nice, maybe even a rotate function. There's been previous threads about this. Unsigned shift right seems to be quite useful for some cryptographic functions. I found when rewriting crypt() in Python that nearly all the right shifts were by constants, so I could write something like ((t >> 18) & 0x3fff) to trim off the sign bits. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "The risk of U.S. national security resting in the hands of adults who play with children's toys during office hours is left as an exercise to the reader." - Bruce Martin in RISKS From b.hall at irl.cri.nz Tue May 23 23:45:16 2000 From: b.hall at irl.cri.nz (Blair Hall) Date: Wed, 24 May 2000 15:45:16 +1200 Subject: NumTut installation problems Message-ID: <392B5049.39166BDA@irl.cri.nz> I have been attempting to install the 'NumTut' package on my Windows95 laptop. I have (I think) the correct installation of Python 1.5.2 and the Numeric extensions. I have also seen a series of messages on SourceForge concerning a very similar problem, however, I am still stuck. The follwing is a copy of my PythonWin interactive window: > >>> from Numeric import * > >>> from NumTut import * > Traceback (innermost last): > File "", line 1, in ? > File "C:\Program Files\Python\NumTut\__init__.py", line 14, in ? > greece = pickle.load(open(os.path.join(_dir, 'greece.pik'), 'rb',1)) / 256.0 > File "C:\Program Files\Python\Lib\pickle.py", line 826, in load > return Unpickler(file).load() > File "C:\Program Files\Python\Lib\pickle.py", line 495, in load > dispatch[key](self) > File "C:\Program Files\Python\Lib\pickle.py", line 659, in load_global > klass = self.find_class(module, name) > File "C:\Program Files\Python\Lib\pickle.py", line 669, in find_class > raise SystemError, \ > SystemError: Failed to import class array_constructor > from module Numeric > >>> > Can anyone shed some light on what this actually means?! (This is my first tentative look at Python - not a good start!) I might add that testview.py and view.py (which come with the NumTut package) seem to work just fine. Many thanks Blair Hall From jwbnews at scandaroon.com Tue May 30 16:29:59 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Tue, 30 May 2000 13:29:59 -0700 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> Message-ID: In article <39340B3B.5769B898 at yale.edu>, Paul Magwene wrote: > Oddly enough, I found the most exciting part of this announcement (other > than the news that Guido et al. will be devoting their full efforts to > Python) to be the fact that I can now put a face to the name "Tim > Peters" (see http://www.pythonlabs.com/team.html ). To me, the most exciting part was the vacation, wedding, honeymoon, etc for Guido and the lady. Best wishes! --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From 340083143317-0001 at t-online.de Sun May 28 14:14:46 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Sun, 28 May 2000 20:14:46 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: <8grnj1$sb3$13$1@news.t-online.com> Late answer, but here i go: 1. By bringing the department of our bank into argument, i was saying, that even very conservative - thinking organizations are starting to use your (as it is) quite innovative programming language, because of the advantages it has. For a bank, one of the most important points is reliability in the IT systems, which, amongst others, can be achieved by a quite strict set of programming rules. If these rules completely break with some new programming language, or even with a new version of the language, it will have to be reconsidered it the language is going to be used. If the language itself provides for possibilities to write unreadable code (which case-insensitivity does, see below), it will be extremely difficult to share code with external programmers (we work a lot together with external consultants), i can assure you of this fact from experience. 2. in your mail, you are kind of mixing up a computer language (Python) with spoken/written language (english), i don't get the point here. I mean, if you were critisizing me for my spelling, i could bother or not, depending on whether i've slept well or not. With a computer program, that's a totally different point: a program will run correctly or not, depending ONLY on the correct syntax & semantics of the program. It's not a question of tolerance. 3. Removing case - sensitivity wouldn't reduce errors in any way, in contrary, it will add a new and more difficult class of errors: those where one uses the same identifier (possibly written with different case ...) with two different meanings. For example, one uses a class 'Error' from library a, and the function 'error' from library b, case-insensitivity will be a great source of annoayance here. You are trading syntax errors (easy to cope with) for possible semantic errors (extremely difficult to cope with) 4. the point, that bothers me most about case insensitivity, is, that consistency in the spelling of identifiers will be lost. That means, because case doesn't count any more, why should a programmer enforce any kind of rules in the use of type case ? Why should one even consider using the same case for the same identifier in different places ? What would the right typing be anyway, if Python doesn't check it anymore ? I find programs extremely hard to read, when they don't use consistent case for, say, class names, method names & so on. 5. there are quite a lot of cases, where i would have to invent 'unnatural' names for identifiers, just because the word i want to use is already used by a class name, for instance. 6. Any wide-spread computer language in use today uses case-sensitive identifiers. Oth, the only case - insensitive language i know of (pascal) doesn't produce any real-world projects and even has it's case-sensitive followup (Modula-2), by the same author (Niklaus Wirth). Lisp is another case - i didn't use it for some time already, but as i remember, the standard common lisp had case-sensitivity, and the syntax of the language allows for totally different naming schemes (with hyphens, for example). Ok, i hope that's enough to stop you claiming that i don't have or that there arent't arguments against case - insentivity On the other point, that has been discussed in the list, about promoting integer divisions to float or something other: I don't get the point here. I mean, during my college time, we have been bored with stuff about groups and rings, just to see in the later courses, that that kind of stuff can be quite useful. So, why should a division between integers leave the set of integer numbers, but no so a muliplication ? Ok, it's more 'natural' to say 'ok, 1/3 is 1/3, a rational number, that is (note that it's NOT the floating point representation 0.3333..., that's only an approximation). The point is, again, that a programming language is NOT a natural language (COBOL tried this already and failed laughable), but used for programming. And in programming, i will need an integer division all around, it were annoying if i would have to use some other function/operator, whatever. And then, i mean, once told, one shouldn't forget that 1/2 == 0. A person forgetting that all the time should propably learn something else. CP4E, to be honest, i have my vague doubts about that. In some way you are postulating the same level of intellectual potential for everyone, but that's another question you might have investigated for a longer time already. The strong point about C is, that it succeeded with an absolutely minimum set of language features to be capable of everything a programmer needs. The syntax, to a beginner, looks extremely crude. But in all my time at the university and after that, in profession, whenever i've seen a beginner to start programming, it was with C ( not C++, get me right here! ). What i want to say with that, it doesn't matter so much how 'resistant' the language is against first-time-programmer's errors, but 1. how logical the language is. 2. how much it helps the programmer to detect errors. 3. how little the number of syntactic constructs is (for that reason, C++ certainly is NOT a beginner's programming language) Ok, don't take all this personally, i like Python very much - but i hope that will remain so... Thomas From rgb122 at my-deja.com Wed May 10 10:50:47 2000 From: rgb122 at my-deja.com (rgb122 at my-deja.com) Date: Wed, 10 May 2000 14:50:47 GMT Subject: Load Arbitrary Script as Module? References: <8f9bs3$b9u$1@nnrp1.deja.com> <3X8S4.3482$wYl.200101376@newsb.telia.net> Message-ID: <8fbt02$5ge$1@nnrp1.deja.com> The line: exec source in vars(module) was giving me trouble since it tried to evaluate the filename as a python statement. I replaced it with: execfile(source, vars(module)) which seems to be working fine (for the few test I've done so far). Thanks, Rob In article <3X8S4.3482$wYl.200101376 at newsb.telia.net>, "Fredrik Lundh" wrote: > rgb122 at my-deja.com wrote: > > Is there a way to load a module given a full filepath? Something like: > > > > driver = LoadModule("C:\\Stuff\\sample.py") > > driver.someFunction() > > start here: > http://www.deja.com/=dnc/getdoc.xp?AN=621152936 > > and add something like: > > def import_file(filename): > name = os.path.splitext(os.path.basename(filename))[0] > return do_import(name, filename) > > driver = import_file("c:/Stuff/sample.py") > driver.someFunction() > > hope this helps! > > > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From rupole at compaq.net Wed May 17 20:07:00 2000 From: rupole at compaq.net (Roger Upole) Date: Thu, 18 May 2000 00:07:00 GMT Subject: [Q] how to find process id on windows? (anyone have killProcName .py?) References: <857F15D7E3D8D3118D290008C7CF05862707EB@mail-naeast1.brooks.com> <8fv3di$4su$1@nnrp1.deja.com> Message-ID: killProcName.py should be in the Python\win32\scripts folder. (again, it doesn't works on 95 or 98). Roger Upole "John Nielsen" wrote in message news:8fv3di$4su$1 at nnrp1.deja.com... > Even though it sounds simple, it's rather involved. > > Here is a python COM object that works on NT and W2K: > > john > > ----------- > > import win32pdh, string, win32api > from win32com.server.exception import COMException > import win32com.server.util > import win32com.client.dynamic > > #to generate guids use: > #import pythoncom > #print pythoncom.CreateGuid() > > class pyperf: > # COM attributes. > _reg_clsid_ = '{763AE791-1D6B-11D4-A38B-00902798B22B}' > #guid for your class in registry > _reg_desc_ = "get process list and ids" > _reg_progid_ = "PyPerf.process" #The progid for this class > > _public_methods_ = ['procids','proclist' ] #names of callable > methods > def __init__(self): > self.object='process' > self.item='ID Process' > def proclist(self): > try: > junk, instances = > win32pdh.EnumObjectItems(None,None,self.object, > win32pdh.PERF_DETAIL_WIZARD) > return instances > except: > raise COMException("Problem getting process list") > def procids(self): > #each instance is a process, you can have multiple processes > w/same name > instances=self.proclist() > proc_ids=[] > proc_dict={} > for instance in instances: > if proc_dict.has_key(instance): > proc_dict[instance] = proc_dict[instance] + 1 > else: > proc_dict[instance]=0 > for instance, max_instances in proc_dict.items(): > for inum in xrange(max_instances+1): > try: > hq = win32pdh.OpenQuery() # initializes the query > handle > path = win32pdh.MakeCounterPath( > (None,self.object,instance, None, inum, self.item) ) > counter_handle=win32pdh.AddCounter(hq, path) > #convert counter path to counter handle > win32pdh.CollectQueryData(hq) #collects data for the > counter > type, val = > win32pdh.GetFormattedCounterValue(counter_handle, win32pdh.PDH_FMT_LONG) > proc_ids.append(instance+'\t'+str(val)) > win32pdh.CloseQuery(hq) > except: > raise COMException("Problem getting process id") > > proc_ids.sort() > return proc_ids > > if __name__=='__main__': > import win32com.server.register > win32com.server.register.UseCommandLine(pyperf) > > > > > In article > <857F15D7E3D8D3118D290008C7CF05862707EB at mail-naeast1.brooks.com>, > "Lee, Jaeho" wrote: > > Hello, > > > > I want to find process id from process name. I read about > 'killProcName.py' > > shows how to do that, in 'python programming on win32'. But I could > not find > > it. Anyone can point me where I can find it? Or could you let me know > how to > > find process id from process name (on NT 4.0)? > > > > Thanks in advance, > > Jaeho Lee > > > > > > -- > nielsenjf at my-Deja.com > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From cwstan at 8bpsinet.8com Fri May 19 10:13:09 2000 From: cwstan at 8bpsinet.8com (Chuck) Date: Fri, 19 May 2000 14:13:09 GMT Subject: Guitar tuning program References: Message-ID: <39254b99.9018932@news.bpsinet.com> Seems to me it would be far more efficient and practical to just purchase one of the $15.00/20.00 tuners and use that. Hell, you can throw that in your guitar case or gig bag and always have it with you. From warpcore at freenetname.co.uk Tue May 9 20:17:09 2000 From: warpcore at freenetname.co.uk (matt) Date: Wed, 10 May 2000 01:17:09 +0100 Subject: jpython + win2k Message-ID: <8fa9tj$8bo$1@gxsn.com> Anyone know if jpyhton works on this platform??? From spamers at must.die Sun May 21 09:24:50 2000 From: spamers at must.die (Fernando) Date: Sun, 21 May 2000 13:24:50 GMT Subject: MySQL module for win32 Message-ID: <03ffisc6bk9u1cqdfu3rd4d7s47objnsn1@4ax.com> Hi! Where can I find a binary distribution of the MySQL module? O:-) TIA //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From dalke at acm.org Tue May 2 00:09:07 2000 From: dalke at acm.org (Andrew Dalke) Date: Mon, 1 May 2000 22:09:07 -0600 Subject: Discrepency between JPython and CPython References: Message-ID: <8elk83$qgp$1@slb7.atl.mindspring.net> Neel Krishnaswami asked: >Why is this? Don't they [Java] just use IEEE-754 like everybody else? The relevent paper I know of is "How Java?s Floating-Point Hurts Everyone Everywhere" http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf which claims: > Abstract: > Java?s floating-point arithmetic is blighted by five gratuitous mistakes: > 1. Linguistically legislated exact reproducibility is at best mere > wishful thinking. > 2. Of two traditional policies for mixed precision evaluation, Java > chose the worse. > 3. Infinities and NaNs unleashed without the protection of floating-point > traps and flags mandated by IEEE Standards 754/854 belie Java?s claim > to robustness. > 4. Every programmer?s prospects for success are diminished by Java?s > refusal to grant access to capabilities built into over 95% of today's > floating-point hardware. > 5. Java has rejected even mildly disciplined infix operator overloading, > without which extensions to arithmetic with everyday mathematical types > like complex numbers, intervals, matrices, geometrical objects and > arbitrarily high precision become extremely inconvenient. Don't ask me about the topic - I just parrot. Bwack! Andrew want a cracker! Andrew dalke at acm.org From neelk at brick.cswv.com Sun May 14 15:33:09 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 14 May 2000 19:33:09 GMT Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com><391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> Message-ID: Fredrik Lundh wrote: > Robin Becker wrote: > > which is clearly not O(1); arguing that making accesses O(1) is 'the > > right thing to do' will get short shrift from the complexity experts who > > will want to know about the overall usage. > > iirc, the ABC interpreter (written by Guido) used "theoretically > ideal" implementations for all built-in datatypes. the fact that > he went for simplicity in Python might tell us something... I thought the ABC interpreter used AVL trees for nigh-everything. They have O(log N) performance for most operations, which is ok is you know that your users are newbies (who tend to assume that every built in operation takes a small amount of time), but does make real performance kind of sluggish. Neel From cfelling at iae.nl Thu May 18 20:14:51 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 19 May 2000 02:14:51 +0200 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newshost.accu.uu.nl> <3923DB30.D6C88628@stud.ntnu.no> Message-ID: <8g211r$29e$1@animus.fel.iae.nl> Peter Schneider-Kamp wrote: > Martijn Faassen wrote: >> In the case of 'foo'.join() this stops making sense: >> I join the list of strings with spaces. >> >> ' '.join(list) > Well how about this: > The space joins the elements of the list. > ' '.joins(list) O Peter, please let's keep Python imperative:) So what about: Hey SpaceMan, please join this string, will you? And ofcourse SpaceMan will do a different job then Mr NewLine himself. >> lots-of-instinctive-language-analysis-ly yours, A little knowledge wouldn't hurt though:) In the new objectivied usages of join, actually *different* joins are used. We have a transitive and an intransitive usage of join. In the old form it was clear what join was used, so this didn't cause any extra ambiguity. >>> join(list, space) ### transitive ~> Join these strings with a space. We merely let the computer do the work, and even with the rejected alternative new form: >>> list.join(space) ### intransitive ~> Strings, group together with a space in between. ### transitive ~> Strings, become united by this space. there is no problemo as both readings result in the same end state. But elas, in the currently much debated form: >>> space.join(list) ### intransitive ~> Space, become a member of this list. ### transitive ~> Space, unite the strings in this list. we have two different readings, both valid from a linguistic point of view, but the first is clearly not wat the interface designer had in mind:( To make things worse, the intransitive usage of join is listed first in my dictionary, implying it's the more occurring form. So either we prepare, and do a field study showing that the transitive reading is by far the predominant reading of this particular snipped, or we ban it! O, and I use this "Space, unit..." form because python is an imperetative language, so I prefer to use the imperative form of the verb in question. And as it is not a imperatative statement in general, but addressed to a specific thing, I attract its attention first by calling its name loud. O, and yes I'm aware that I didn't play fair with the list.join part. I should have transcribed it like: List, group together your strings with a space in between. List, make your strings united by a space. -- groetjes, carel From fiona at sitegnome.com Fri May 12 11:15:22 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 12 May 2000 15:15:22 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 12th, 2000 Message-ID: <20000512151522.2635.qmail@synop.com> Hi, Below are the entries that I've entered into http://python.faqts.com for today. cheers, Fiona ## New Entries ################################################# ------------------------------------------------------------- What are the keys for auto-completion? ie. selecting one item in the scrollbox with a keystroke? http://www.faqts.com/knowledge-base/view.phtml/aid/2769 ------------------------------------------------------------- Fiona Czuczman Neil Hodgson, Mark Hammond You choose the selected item with the tab key. You can move up and down with the cursor keys: up, down, page up, page down, home, end. Typing characters moves the selection to the first item that starts with the string typed since the auto-completion appeared. Alt+/ or Ctrl+Space do auto-expand (no list - just looks for similar words in the same buffer) ------------------------------------------------------------- What's the best way to obtain seeds for random number generators? http://www.faqts.com/knowledge-base/view.phtml/aid/2770 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, Mike Steed, Ivan Van Laningham, Will Ware, Paul Jackson RFC 1750 provides a whole lot of information on this topic: http://www.faqs.org/rfcs/rfc1750.html "Computer clocks, or similar operating system or hardware values, provide significantly fewer real bits of unpredictability than might appear from their specifications." Depending on how serious you are about randomness, you may want to use a hardware source (e.g., an audio input device). See 8.7 in the following document: http://www.faqs.org/faqs/cryptography-faq/part08/ Also, under linux, see /dev/random. random.c claims: * This routine gathers environmental noise from device drivers, etc., * and returns good random numbers, suitable for cryptographic use. Will Ware wrote: If you really need a lot of randomness, and you don't mind spending an evening or two with a soldering iron, I once made up a pretty good random bit generator circuit, described at: http://world.std.com/~wware/hw-rng.html You can bring the bits in one of the pins of your printer port. I have some information about a Linux device driver for the thing, if you're interested in pursuing it, that was developed by some students who recently used the circuit for a course project. ----------------- A Random Number web site from SGI is: http://lavarand.sgi.com/ ------------------------------------------------------------- How can I extract just the links in a web-page or html-document? http://www.faqts.com/knowledge-base/view.phtml/aid/2771 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh In addition to the question: It would be nice if relative links like'Logo in a page at http://www.test.site.org became "http://www.test.site.org/source/test_pyt.tgz" in the end too ... Solution: from the eff-bot archives: # # extract anchors from an HTML document # # fredrik lundh, may 1999 # # fredrik at pythonware.com # http://www.pythonware.com # import htmllib import formatter import string import urllib, urlparse class myParser(htmllib.HTMLParser): def __init__(self, base): htmllib.HTMLParser.__init__(self, formatter.NullFormatter()) self.anchors = [] self.base = base def anchor_bgn(self, href, name, type): self.save_bgn() if self.base: self.anchor = urlparse.urljoin(self.base, href) else: self.anchor = href def anchor_end(self): text = string.strip(self.save_end()) if self.anchor and text: self.anchors.append((self.anchor, text)) if __name__ == '__main__': URL = "http://www.pythonware.com" f = urllib.urlopen(URL) p = myParser(URL) p.feed(f.read()) p.close() print "anchors =", p.anchors print "title =", p.title ------------------------------------------------------------- How do I copy one object into another without having them refer to each other? http://www.faqts.com/knowledge-base/view.phtml/aid/2772 ------------------------------------------------------------- Fiona Czuczman Emile van Sebille, Thomas Thiele You could create a separate instance, or provide a copy function as part of the class. >>> a = A('bragi') >>> b = A('') >>> b.name = a.name >>> b.name 'bragi' >>> a.name = 'stini' >>> b.name 'bragi' >>> >>> class A: def __init__(self,name): self.name = name def copy(self): retval = A(self.name) # other copy functions return retval >>> a = A('bragi') >>> b = a.copy() >>> b.name 'bragi' >>> a.name = 'stini' >>> b.name 'bragi' >>> Or, you could use copy.copy and copy.deepcopy. >>> class X: ... def __init__(self): ... self.a = 5 ... >>> x = X() >>> list = [x] >>> cl1 = copy.copy(list) >>> cl2 = copy.deepcopy(list) >>> list[0].a = 6 >>> list[0].a 6 >>> cl1[0].a 6 >>> cl2[0].a 5 ------------------------------------------------------------- How do I change the mouse pointer to the default 'wait' icon during a short operation in tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/2773 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, John Grayson Use: root.config(cursor="wait") root.config(cursor="") Or: Look at page 369 of John Grayson's book. You might want to look at Pmw's BLT busy cursor for a full busy cursor implementation. From klent at iislands.com Sat May 6 15:03:37 2000 From: klent at iislands.com (Klent) Date: Sat, 06 May 2000 19:03:37 GMT Subject: Viewing JPG's Message-ID: <39146C88.E07A9AA@iislands.com> I am working on a project where I need to open a window in Tkinter. and display a seris of jpgs. I downloaded and installed the jpg libs and the Imaging libs. but the show() command won't display the images. Is there an easy way to do this? Or am I on the right track even? Help would be greatly appriciated. Klent From lars.lundstedt at telia.com Thu May 4 12:35:50 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Thu, 04 May 2000 16:35:50 GMT Subject: SV: Best way to convert a list to a dictionary References: <76ZP4.2558$wYl.196706304@newsb.telia.net> Message-ID: Thank you! Justin Sheehy skrev i diskussionsgruppsmeddelandet:vndn1m7blnq.fsf at camelot-new.ccs.neu.edu... > "Lars Lundstedt" writes: > > > I have a list where each element is another list with two elements. > > What is the best way to convert this to a dictionary? > > Something like this would probably be simplest: > > d = {} > for k, v in your_list: > d[k] = v > > -Justin > > > From claird at starbase.neosoft.com Tue May 16 10:49:51 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 16 May 2000 09:49:51 -0500 Subject: Coping with compiler bigotry (was: python improvements (Was: Re: New Language)) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> Message-ID: <93109BC19D02F3BF.854854E2F762E49A.D3B996F71038FA91@lp.airnews.net> In article , Neel Krishnaswami wrote: . . . >With an interactive read-eval-print loop, run-time is just as good as >compile-time, IMO, because you can test your system incrementally, as >you build it. . . . "[R]un-time is just as good as compile-time ...": you're not from around here, are you? That's my attempt at wry humor. Are you able to get through to traditional MISers with that parti- cular insight? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From benpark at my-deja.com Fri May 5 21:25:26 2000 From: benpark at my-deja.com (benpark at my-deja.com) Date: Sat, 06 May 2000 01:25:26 GMT Subject: control kids' game plays References: <8evnq6$5hp$1@nnrp1.deja.com> <39136E16.C8B441B2@san.rr.com> Message-ID: <8evs9s$9uv$1@nnrp1.deja.com> What is the average weight of pythons? My kids are very tough fighters. In article <39136E16.C8B441B2 at san.rr.com>, Courageous wrote: > > > My kids play games on our home windows95 computer all the time. I would > > like to control the times and durations of their playing. Is there any > > way to do it with python? > > Yes. By an enormous 400 pound python. Don't feed it for a month. > Tell your kids if they don't play when you tell them, you'll lock > them in the room with the snake. > > See, python can even create well disciplined kids. > > *blink blink* > > C/ > Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Sun May 21 22:53:41 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 21 May 2000 22:53:41 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: neelk@brick.cswv.com's message of "21 May 2000 18:39:07 GMT" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) ?crit: > Perhaps you should look at languages that are case-insensitive, and > see if people have the problems you suspect they might? Large bodies > of source code for Common Lisp, Scheme and Dylan are available under > open-source licenses. Furthermore, Dejanews has archives of all of these > languages' newsgroups. You can read the code for yourself and check the > archives to see if anyone else has had problems with case-insensitivity. Perhaps I should do that. But perhaps as well, I do not have the free time I would need to compile a thesis on this topic. The fact that I do not drive an extensive research does not automatically mean that my experience and opinions are worthless. I even dare to think that I did contribute to free software in various ways, along all these years, without necessarily having to resort to the usual academic means. There are other ways. > Suspicions are most easily dispelled/confirmed via evidence The evidence of one is not necessarily the evidence of the other. I'm grown up enough to know that :-). Some evidences are also more credible :-). > and taking the trouble to do this has the pleasant side-effect that you > can either cease expending effort worrying, or move directly to taking > positive action to correct the problem. I'm not sure I understand you fully. My overall feeling is that our goal, here, is more about _not_ correcting a false problem, than having to take positive action for correcting a problem which might not have to be. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From m.faassen at vet.uu.nl Fri May 12 18:07:00 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 22:07:00 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> Message-ID: <8fhva4$h5i$1@newshost.accu.uu.nl> Steven D. Arnold wrote: [snip] > 1. I'd like an equivalent to perl's "use strict" pragma. It's annoying to > have to be so paranoid about making a typo in a variable name. I'd like > the compiler to be able to catch those errors for me. How exactly would this work? It would seem hard to make this work right in a dynamic language, but perhaps I'm missing some simple strategies. I'm not familiar enough with 'use strict' in Perl to know what Perl is doing in this respect. It'd be nice to have a bit more compile-time checking, but Python's extremely dynamic, so this would seem very hard to do in the general case. Perhaps for local and variables it'd be possible, but attributes are tougher; we have __getattr__(), after all. > 2. I'd like the ability to specify that a certain parameter or variable is > of a given type. [snip] Ooh, lots of us would! Join the types-SIG. :) This is not a small project, and has many consequences, though the run-time variety would be easier to do than the static-type checking variety. (which would report type errors during compile-time). We have OPT, ERR and DOC reasons for doing type checking: OPT -- the interpreter/compiler uses the type declarations to make our code run faster. The more static the type checking, the better. ERR -- we get more robust code as the types are checked. It's nice when this happens during compile-time, though run-time can also be helpful. DOC -- we get more readable code as we can see which types go into a function. You seem to want DOC and ERR mostly. There's also a counter force, let's call it RAD: RAD -- we want to develop our systems rapidly. We want interfaces that can deal with lots of inputs, without having to think about it a lot. Dynamic typing helps us set these up without hassle. > 3. I'd like to allow for the formal declaration of protocols a la > Objective-C. A protocol is a set of method calls that an object can claim > to support or not. [snip] Ah, these are also called 'interfaces' in other languages. See again the types-SIG for this, though its agenda has been changed some so interfaces aren't the central part of the discussion. I do expect a form of interfaces to emerge at one point, possibly first from the Zope community, see this page: http://www.zope.org/Members/jim/PythonInterfaces/Interface And click on 'release information'. Also study the types-sig information on www.python.org for much more on these topics. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From embed at geocities.com Wed May 17 15:01:44 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 17 May 2000 15:01:44 -0400 Subject: pickle with constant filesize References: <3922D084.2D389F1@muc.das-werk.de> Message-ID: I would make your own wrapper class for Pickle, called Fickle, and I would basically build a guestimate of average size of a pickled object, and then have to live with when my guestimate is wrong, since any limit you choose can become wrong if you put enough data into it. Rather than that, why not consider using the struct or xstruct modules to pack your data into fixed binary structures, since that is more realistic than hoping that your arbitrary-pickled-object will always fit in a certain size or less? Warren From btang at pacific.jpl.nasa.gov Mon May 1 13:15:45 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Mon, 01 May 2000 10:15:45 -0700 Subject: Linux Processes from Python HOW-TO? References: <8ecpch$j73$1@nnrp1.deja.com> <20000428234608.L11481@xs4all.nl> Message-ID: <390DBBC1.12EADB7@pacific.jpl.nasa.gov> Thomas Wouters wrote: > > On Fri, Apr 28, 2000 at 07:39:00PM +0000, chris_barker at my-deja.com wrote: > > > Has anyone written a HOW-TO or tutorial that explains how to start and > > manipulate other processes with Python. I imagine it's trivial if you > > are familiar with the Linux/Unix process model, but I get very confused > > about when to use: > > > system > > popen and it's variants > > exec and it's variants > > fork > > etc. > > Well, it's detailed in most books about UNIX, and in most books about > operating systems in general. (At least on the programming level.) I dont > know any HOWTO-level explanation of it, but I'm happy to supply you with > some short descriptions. I'll do it in the reverse order of what you listed, > though, because it's easier that way ;) > > First, the basics: under UNIX, and most current operating systems, a running > program consists of one or more processes. A single program, or a single > task, is usually a single process, but it's possible for several processes > to communicate with eachother, to share workload. Each process has its own > memoryspace, invisible to other processes, and it can only access its own > memoryspace. > > To create a new process, you use the system call fork(). It duplicates the > current process, copies all of its memory, instruction pointers, function > stack, everything. The only difference between the two processes is the > process-id (pid), and the return code of fork(): In the new process, the > 'child', fork returns 0. In the original process, the 'parent', fork() > returns the pid of the newly created child process. (If fork() fails, it > wont create a child process, of course, and the return code will signify an > error.) > > Because fork() creates an exact duplicate of the old process, you can't use > it to start a new program. You use one of the 'exec*()' calls for that. This > system call *replaces* the calling process by a new process, running a new > program as indicated by the first argument to the exec() call. If exec() > returns anything, it's always an error, because if it succeeds, the process > that called it will be gone. The new process isn't really a new process, > though, because it will have the pid of the old one. It'll just be running a > different program ;) > > The difference between the various exec*() calls is fairly subtle, and a bit > strange from a Python point of view: they are mostly about how to pass the > arguments: the execl*() calls take a variable number of arguments, > whereas the execv*() calls take a pointer to a list of arguments. The > exec*p() calls search the environment variable PATH for the name of the > executable, whereas the other exec*() functions expect the name of the > executable to be a full path to the program. And lastly, the exec*e() > calls also take an argument that list the environment variables that > should be passed to the new program, whereas the other calls pass the same > environment as the current process has. > > These two system calls are all that is necessary to create as many and as > varying processes as you wish. None the less, the Standard C Library > provides a few funky and helpful functions that save you a lot of time in > the common cases: > > system() is a library call that takes a single string describing the program it > should start, and the arguments it should get. It forks() and exec()s for > you, and then waits for the child to exit (using one of the wait() calls) > and returns the exit code. You dont have particularly much control over how > the string is executed, other than via the standard 'shell' commands: system > always starts /bin/sh with your string as argument. > > popen() and it's friends are similar functions, but instead of running the > string you pass and returning the exitcode, it starts the new process with > its standard input or standard output (or both, in the case of popen2) > connected to the calling process (using a UNIX 'pipe', hence the first p in > popen()). This way, the calling process can pass data to the program just as > a user would type it on a computer, or read data that the new program writes > to the terminal. > > So, basically, if you simply want to run a command and dont care much about > runtime influence, you usually use system(). If you need to pass it some > data for it to work on, for example 'gzip' or some other program that works > on the input stream, you use popen(). And if you want more control over > things, or if you simply want your python process to do two tasks at once, > or you wish to start a lot of programs in a specific order, or other > complicated things, you use fork() and exec() manually. > > > I'm really hoping someopne has written this up! > > Well, I just did, didn't I ? ;) There are a lot more details I didn't > mention, by the way: threads (processes that share their memory space); > redirecting stdin, stdout and stderr somewhere specific, or to another > process; creating pipes and sockets yourself; how to avoid deadlocks in > popen2; shared memory; controling ttys, how to see the difference between a > simple pipe and a real user, and how to fool programs that try to see that > difference; UNIX session ids; setuid() and other ways to change the current > process's permissions; And probably a lot more ;P Nevertheless, I hope this > helps a bit :-) > > If you need more info than this, either read a UNIX manualpage for one of > those functions, or if you prefer readable material, buy a good book on UNIX > programming. They usually start with a good explanation of processes, the > memory layout, pipes, sockets and networking. Some even cover shared memory. > > Drained-ly y'rs, > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! Can this process manipulation be done for Windows 95 or 98? From mjhand at concentric.net Thu May 18 16:46:33 2000 From: mjhand at concentric.net (Manus Hand) Date: Thu, 18 May 2000 14:46:33 -0600 Subject: Python3k extended grammar References: Message-ID: <392456A9.993FB15C@concentric.net> This is a dumb question, and I know I shouldn't be following Roy's post with it, since my question is only tangentially related, but.... (By the way, I agree with Roy that the less new syntax and fewer new keywords the better! Anyway, as to my own question....) It was with a large degree of alarm that I read that "the language (Py3K) will be somewhat incompatible." There didn't seem to be anyplace at python.org that explains this any further. Maybe it has been rehashed before, but could the scope of Py3K be spelled out for those of us who fear it? Things like talk about having to declare variables and their types and having to specify function return types scare me. They scare me to death. I love Python, but if stuff like that becomes required, I will stick with 1.6 forever. If someone will reassure me that I won't *have* to use typing and declaration, then I will be happier. Much. One of the features I love about (and rely on) in Python is complete type freedom. I have countless functions that accept different types as parameters and return differently typed results. A function that usually returns an integer could return a None (or a list or a class instance, or who knows), etc., etc. Maybe I'm just weird, but "if type(theVar) == type([])" (or "assert" in place of "if"), etc., is all the typechecking I ever wanted. I'm a runtime flexibility (dynamic code generation, etc.) addict and I know I'm not alone. Again, I apologize for intruding on Roy's posting, but it would put my mind at ease if Py3K were spelled out somewhere. If the right place to look for Py3K details is in the type-sig (which is where Roy found stuff), let me know and I'll look there. I hate bothering the group with something most of you already know, but well, I'm scared. And seeing that Roy found that Py3K might introduce all sorts of new syntactic constructs like -> for "returns" (talk about asking to confuse anyone coming from C/C++!!) and (presumably) reserved words, like "Integer," etc., it makes me think I might have *reason* to be scared. Thanks for any responses, Manus From effbot at telia.com Mon May 22 10:55:09 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 22 May 2000 14:55:09 GMT Subject: Help! Tkinter References: <3928f98e@news.xtml.co.uk> Message-ID: Nick Trout wrote: > I'm having trouble getting Tkinter to work. I've uninstalled and reinstalled > Python/Tcl and looked at the FAQ but I cant find a relevant posting. > > I get: > > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import Tkinter > WHOOPS! Even though I think I have found a Tcl/Tk 8.0 installation, > I can't seem to import the _tkinter extension module. > I get the following exception: > ImportError: DLL load failed: A device attached to the system is not functio > ning. > If you don't know how to fix this, consider searching the Python FAQ > for the error you get; post to the comp.lang.python if all else fails. this might help: http://www.pythonware.com/people/fredrik/fyi/fyi02.htm From johngrayson at home.com Tue May 30 19:40:09 2000 From: johngrayson at home.com (John Grayson) Date: Tue, 30 May 2000 23:40:09 GMT Subject: Pmw.initalise() probs References: Message-ID: <8h1jgm$4c6$1@nnrp1.deja.com> In article , Brian Fritz wrote: > I just downloaded and installed the pmw tarball on my NT box. Everything > looked pretty straight forward so I'm a bit mystified by the error I'm > getting. The "import" seems to be finding the library but I can't call > the "initialise" function which seems to be a common call in all the > examples I've looked at. > > > PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) > > >>> import Pmw > > >>> root = Pmw.initialise() > > Traceback (innermost last): > > File "", line 1, in ? > > AttributeError: initialise > > The version of Pmw is 0.8.4. > > I had the same problem using the console shell and I have added the path > to the directory I installed Pmw into to the PYTHONPATH registry entry. > > Maybe it was the long weekend... Am I missing something here? > > TIA! > > Brian > > Brian, You can't use Tkinter with PythonWin (Pmw is pure Tkinter). If you want to use Tkinter, you'll have to run the Win32 version of Python, not PythonWin... Sorry! John Sent via Deja.com http://www.deja.com/ Before you buy. From z3penguin at penguinpowered.com Sat May 27 20:03:33 2000 From: z3penguin at penguinpowered.com (Z 3 Penguin) Date: Sat, 27 May 2000 20:03:33 -0400 Subject: coverting numbers to strings Message-ID: <8gpnqb$ki7$1@bob.news.rcn.net> i want to convert an integer to a string contaning the bytes for that value, i.e > a=300 > b= func(a) > for i in len(b): ... print ord(b[i]) ... 1 44 > -- ----- Z 3 Penguin z3p at z3penguin.org () (o_ //\ <-\_/ This is a virus that works on the honor system. Send this .sig to everyone in your address book and randomly delete some of your files. From neilh at scintilla.org Tue May 23 01:11:34 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 23 May 2000 05:11:34 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net><8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com><3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: > > Some of us want 'case insensitivity' to lessen sloppiness by allowing > > only one capitalisation of each name. > > Orderly naming of modules is a matter of convention. If the conventions > are inadequate, these might be improved where they need to be. Tainting a > whole language around a few inadequacies would be a gross over-reaction. 'tainting'? I don't see how I'm corrupting Python. Moshe's example follows what I want, which is editWin = CreateWindow() editwin = editWin.WithToolBar() to give me a clear error message: line 2: "editwin" is an incorrect capitalisation of "editWin", preferrably with a red underline under the 'w' and 'W' Neil From mwh21 at cam.ac.uk Sun May 14 19:40:14 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 15 May 2000 00:40:14 +0100 Subject: Adventures in Currying References: <1pDT4.7832$Lp1.191508@typhoon2.ba-dsg.net> Message-ID: nickm at mit.edu (Nick Mathewson) writes: > I've noticed that about 2/3 of the times I use lambda in Python, I'm > really just asking for curried functions.[*] With this in mind, I > started writing up currying operators of various degrees of > complexity. I give them below, in their approximate evolutionary > order. They are all classes designed to turn python functions into > curried functions. > > They're all tested with 1.5.2, but rely on undocumented attributes of > function and code objects. Therefore, they may break on 1.6, and are > certain to break in JPython. Are you aware of my bytecodehacks package? One of the modules in it is "xapply", which basically curries functions. You can see it here: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/bytecodehacks/bytecodehacks/xapply.py?rev=1.9&content-type=text/x-cvsweb-markup&cvsroot=bytecodehacks and read about it here: http://bytecodehacks.sourceforge.net/bch-docs/bch/module-bytecodehacks.xapply.html (sorry for the long lines!) If you thought your code was hairy, you haven't seen xapply._xapply_munge - which is certainly the hairiest piece of Python code I've ever written, and quite possibly ever read. It seems this hairiness is inherent in the problem. The key difference with my module is that def f(x,y): return x+y type(xapply.xapply(f)) gives "function" - so calling it is as fast as calling any other function. I think it should work with 1.6 (can't think why not anyway); it hasn't a hope with JPython. i-sense-another-of-my-kind-ly y'rs M. -- If i don't understand lisp, it would be wise to not bray about how lisp is stupid or otherwise criticize, because my stupidity would be archived and open for all in the know to see. -- Xah, comp.lang.lisp From yemartin at garage.co.jp Thu May 25 05:42:38 2000 From: yemartin at garage.co.jp (Yves-Eric Martin) Date: Thu, 25 May 2000 18:42:38 +0900 Subject: Looking up caller's namespace Message-ID: <392CF58E9D.DF41YEMARTIN@smtp.garage.co.jp> Hello Python gurus, I need your help for a problem my little Python knowledge cannot solve. In short, what I want to do is to access, from a function in a module, an object of the caller. The catch is that I don't want to pass it as an argument to the function, but to look it up in the caller's namespace. (See note 2 for why I want to do that). A simple addition example. Usually, I would pass all arguments in the call to the function as in the following: --- mymodule.py --- def myadd(y,z): return y+z ------------------- ----- test.py ----- >from mymodule import myadd a,b=3,4 print myadd(a,b) ------------------- But what I want is something like: --- mymodule.py --- def myyadd(y): z=__caller's_namespace__['b'] # The spooky lookup... return y+z ------------------- ----- test.py ----- >from mymodule import myadd a,b=3,4 print myadd(a) ------------------- I have looked through docs and list archive, but I could not find the right way to do this "__caller's_namespace__['b']" lookup. Have I used the wrong keywords or is there no straightforward way to do that? Any hint on this would be greatly appreciated. Thanks. Note 1: I am currently using the following workaround (which may actually be nicer than what I am trying to do, but it does not answer my question about accessing caller's namespace): --- mymodule.py --- def myadd(y,z): return y+z ------------------- ----- test.py ----- import mymodule def myadd(a): return mymodule.myadd(a,b) a,b=3,4 print myadd(a) ------------------- Note 2: Why do I want to do this? I am working on an internationalization project for Zope, and we are going for a gettext approach. The problem is that the language to which to localize depends on a REQUEST object present in the current namespace. And to minimize internationalization work, we want to replace a 'string' by _('string'), not by _('string', REQUEST). Hence my problem... -- Yves-Eric Martin Digital Garage Inc. yemartin at garage.co.jp From breiter at usf.Uni-Osnabrueck.DE Tue May 9 07:59:03 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 9 May 2000 11:59:03 GMT Subject: Copyright and License References: <000801bfb8b9$f0fc7280$b12d153f@tim> <8f6sbs$ih0$1@nnrp1.deja.com> Message-ID: <8f8ui7$sgp$1@newsserver.rrzn.uni-hannover.de> In article <8f6sbs$ih0$1 at nnrp1.deja.com>, Sam Schulenburg writes: > I have placed code in the public domain just to protect me from any > company that I work for claiming that the knowledge used is their > property. If you created the code while working for a company they still might have a legal handle to claim the code. (Depending on your local law and the contract you have had with them.) If they can legally claim it, your putting the code under Public Domain would have been illegal. So retrospectivly code might become non PD again. I am not sure who would be liable, if anybody could be help liable at all it will be you. IANAL, Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From brand_hunt at my-deja.com Wed May 3 22:20:25 2000 From: brand_hunt at my-deja.com (Brand Hunt) Date: Thu, 04 May 2000 02:20:25 GMT Subject: Python for CGI w/Apache (httpdapi) References: <8epjj0$9qa$1@nnrp1.deja.com> Message-ID: <8eqmot$i25$1@nnrp1.deja.com> The dictionary returned doesn't contain the keys "DOCUMENT_URI" or "REQUEST_URI". I don't know how to get httpdapi to import these environment variables along with the others. Any ideas? Thanks, Brand In article , Erno Kuusela wrote: > > You can httpdapi.RequestHandler.build_cgi_env(), which returns a > dictionary. > > if you want to turn these into real environment variables, you can > just loop over the returned dict and stuff them into the os.environ > dictionary. > > -- erno > Sent via Deja.com http://www.deja.com/ Before you buy. From shapr at uab.edu Wed May 31 17:38:14 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 31 May 2000 21:38:14 GMT Subject: slice object, ellipsis usage? list[2:4:2, ...] what good are they? Message-ID: <39358C6A.7B86FAD2@uab.edu> I recently came across the slice object, and the ellipsis. I would guess that list[5:11:2] would pull every second item from that slice of the list, so I think I can dig a slice object. But, what's up with multiple slice objects being legal in a single slice? Take for example: list[5:23:2, ...] what the heck is that supposed to mean? What good is an ellipsis? what can I do with one? what's the meaning actually supposed to be? I realize that it's a built-in type like None, and therefore, I can assign any symbolic meaning I wish to assign to it. But, how did it get there? -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From Peter_Halvorson at nfuel.com Mon May 15 20:46:52 2000 From: Peter_Halvorson at nfuel.com (Halvorson, Peter) Date: Mon, 15 May 2000 17:46:52 -0700 Subject: popen2 + passwd Message-ID: Is it just me or does o.write look odd? It seems to be writing to the output end of the pipe. In any case, if it is a tty problem, the simplest expect-like solution may be to use the telnetlib.py to fire off a telnet session. Something like the following (you may have to fix the prompts provided to match your system, you may get a false hit on the shell prompt since it's a little short). peter import sys from telnetlib import Telnet host = 'yourhost' login = 'root' password = 'xxxxxxx' shellprompt = '# ' dialog = [ ('login: ', login), ('Password: ', password), (shellprompt, 'passwd bin'), ('New password: ', '12345ASD'), ('Repeat new password: ', '12345ASD'), (shellprompt, 'exit') ] telnet = Telnet(host) for prompt, response in dialog: sys.stdout.write(telnet.read_until(prompt)) telnet.write(response + '\n') telnet.close() sys.exit(0) From abrahams at mediaone.net Mon May 1 23:10:06 2000 From: abrahams at mediaone.net (Dave Abrahams) Date: Tue, 02 May 2000 03:10:06 GMT Subject: Python/C interface proposals Message-ID: I propose some simple changes to the Python header files which would make it much easier to write "clean" wrappers in C++. The first change I propose would make it possible to forward-declare any struct in the Python headers. This could be done by changing declarations of the form: typedef struct {...} Name; to: typedef struct Name {....} Name; I'd also like to move these type declarations into separate header files so that users of my "clean" wrappers will not be inadvertently affected by the functions declared in the global namespace. More imporantly, I'd like to drop the macros into separate headers so they won't collide with (and change the meaning of) names in client code. Naturally, the standard header files would still include all the neccessary headers to produce the same results they do today. I'd be happy to supply the manpower to make these changes, but I thought first I'd float a trial balloon so that the entire Python community can shoot the idea down ;) Wishfully, Dave From jim at interet.com Thu May 25 09:13:38 2000 From: jim at interet.com (James C. Ahlstrom) Date: Thu, 25 May 2000 09:13:38 -0400 Subject: Pass by reference? References: <8ghcq1$opl$1@supernews.com> Message-ID: <392D2702.2F0C72FF@interet.com> Dale Strickland-Clark wrote: > > How do I pass a value by reference so the called routine can update it? You pass in a list with the value in it. Then you can change the value in the list. JimA From cut_me_out at hotmail.com Fri May 5 14:52:09 2000 From: cut_me_out at hotmail.com (Alex) Date: 05 May 2000 14:52:09 -0400 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: Thanks, Michael. Alex. From embed at geocities.com Mon May 1 15:52:36 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 1 May 2000 15:52:36 -0400 Subject: Class Factories in Python: How? References: Message-ID: > If this is the main problem, there may be a way around it. Could you do > something like this: > > def marshalstruct_factory(newattributes): > class newclass(marshalstruct): > pass > newclass.attributes = newattributes > newclass.lookups = binstruct_lookup(attributes) > newclass.fieldcount = len(attributes) > return newclass Wow that works! Thanks! All this comes of course from the fact that Classes are first-class Objects in python. Isn't that COOL?! This, and the 'metaclasses' stuff definitely makes my head hurt, yet it's somehow beautiful also. Warren From pinard at iro.umontreal.ca Mon May 8 13:49:02 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 08 May 2000 13:49:02 -0400 Subject: OT [Way OT]: Unicode Unification Objections In-Reply-To: Kevin Russell's message of "Sun, 07 May 2000 15:07:28 -0500" References: <3915CD00.C73DA43B@videon.home.com> Message-ID: Kevin Russell writes: > Actually, this is a very good point. But the problem is more with APL > than with Unicode. I'm not so sure. The problem might be with Unicode. If they are ready to nicely support APL, dingbats and the script for Klingon language, maybe they should _also_ give a thought at properly supporting Japanese... P.S. - Take me with a smiley, here! I'm quoting you out of context. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jjlucsy at concentric.net Tue May 2 13:52:17 2000 From: jjlucsy at concentric.net (Joel Lucsy) Date: Tue, 2 May 2000 13:52:17 -0400 Subject: calling class constructors through calldll References: <390EEF59.521610B9@mitre.org> Message-ID: <%AEP4.16330$Ie5.2823293@news-west.usenetserver.com> No, and it depends on the compiler you're using. I've used a modified calldll to do this using the MSVC6 compiler. MSVC passes the "this" pointer in a register instead of on the stack. As for any other compiler your guess is as good as mine. If you need more info, let me know. I got it working, but decided it was more work than it was worth. Joel Lucsy (jjlucsy at concentric.net) "Peter Leveille" wrote in message news:390EEF59.521610B9 at mitre.org... > I am calling a class constructor in a dll using calldll. The problem is > that this then causes python to try and write to an illegal memory > address (i.e. 0x00000018 or 0x00000000c). Should I be able to call a > class constructor through calldll? From tismer at tismer.com Sat May 13 15:41:18 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 13 May 2000 21:41:18 +0200 Subject: Stackless/microthreads merge news References: <39185686.665174C0@tismer.com> <391C085A.58329C18@prescod.net> <391DA2A1.276EFFAA@tismer.com> Message-ID: <391DAFDE.FB996560@tismer.com> Glyph Lefkowitz wrote: > > Christian Tismer writes: > > > > interface continuation{ > > > public Object apply( Object[] ) throws throwable; > > > } > > > > Sure. Does Java support function variables? > > COntinuations must be callable objects, and I need to > > be able to split them off of a running context at any > > time. Is that possible without changing Java? > > Of course not! That might have the unintended side-effect of > increasing programmer productivity! :-P > > If you tell a java programmer that you want "function variables", they > will tell you that it's easy ... a list of "function variables" would > only require that you rewrite your code like this: > > interface FunctionObject { > Object funcall (Object[] f); > } > > class AddFunctionObject implements FunctionObject { > Object funcall (Object[] args) { > double a = ((Number)args[0]).doubleValue(); > double b = ((Number)args[1]).doubleValue(); > return new Double(a+b); > } > } > > Vector v = new Vector(); > FunctionObject f = new AddFunctionObject(); > v.addElement(f); > > ... later ... > > Enumeration e = v.elements(); > while (e.hasMoreElements()) { > FunctionObject f = (FunctionObject) e.nextElement(); > Object[] args = {new Integer(5), new Integer(3)}; > Object result = f.funcall(args); > } Kotz! > this being roughly equivalent to the python code: > > v=[lambda x,y: x+y] > > ... later ... > > for f in v: > result=f(5,3) > > But of course, java is "better", because it's "really object oriented" > and in "real" languages, code isn't a first class object, or storable > in variables. A disturbing number of Java programmers believe that > Smalltalk is this way too, and that block closures were just a weird > abberation that nobody uses. (This is an oversimplified version of the > Java version, of course. You'd have to swaddle everything in 5 > different try { } catch (){} blocks before it would actually compile.) We should give some torture to Java's inventors: * force them to use it themselves * (like forcing fast food producers to eat their own stuff) > If you want to do this reflectively (I.E. use the method foo.bar on > some object rather than writing your own code) it's possible, but it > would be brittle (dependant upon strings for linking at runtime, so > you don't get any lovely compiler checks for your code... and with the > amount of typing you need to get anything done in java, you need those > checks), slow (the linking would be re-done each time, since you'd be > calling the reflective string methods), and hard (you STILL wouldn't > be able to say foo.bar, you'd have to say "foo.getClass(),'bar', or > similiar). Not to mention the fact that if I wrote it here it would > be so insanely verbose that internet customers in europe would be > yelling at me for wasting their bandwidth. *shudder* I wonder how JPython retains Python's flexibility - using these techniques? May be this is ok in JPython's generated code, but for the user - forget it. > only-a-few-more-weeks-to-go-before-I-never-touch-Java-again-ly y'rs, let-me-sing-with-you-in-the-same-chorus-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From mwh21 at cam.ac.uk Sat May 20 12:50:42 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 20 May 2000 17:50:42 +0100 Subject: Python3k extended grammar References: <8g6bni$sfa$17$1@news.t-online.com> Message-ID: "Thomas Malik" <340083143317-0001 at t-online.de> writes: > > hmmm. am I the only one that read -> as yields? > > > seems so. Every other programming language says 'return'. For what? I thought this was about writing method/function signatures and I don't know of any programming language that uses "return" in that context. And in fact both ML and Haskell use "->" for this purpose. So it's not a wholly plucked out of the air notation. Cheers, M. -- Of the four project development variables - scope, cost, time and quality - quality isn't really a free variable. The only possible values are "excellent" and "insanely excellent", depending on whether lives are at stake. -- Kent Beck, XP Explained From dalke at acm.org Wed May 31 12:32:38 2000 From: dalke at acm.org (Andrew Dalke) Date: Wed, 31 May 2000 10:32:38 -0600 Subject: urlencoding dictionaries References: Message-ID: <8h3elu$hdb$1@slb7.atl.mindspring.net> Marc Tardif wrote: >>>> params = {'one': 'First param', >... 'two': None >... } >>>> print urllib.urlencode(params) >one=First+param&two=None > >Problem is, isn't "None" suppose to be a null object making it absurd to >output "two=None"? Shouldn't urlencode output "two=" or nothing at all >even? Is this a potential improvement upon the urllib module or is there a >way to circumvent this problem I seem to be having? If it had "two=" then how do you distinguish None from the empty string "", which will also make a "two="? The urllib doesn't store type information, it only stores their text representation. Simiarly, there's no way to distinguish between the number 1 and the string 1. You'll need to develop your own encoding scheme on top of what urllib provides. Andrew dalke at acm.org From moshez at math.huji.ac.il Sun May 7 00:46:57 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 7 May 2000 07:46:57 +0300 (IDT) Subject: maximal integer value In-Reply-To: <8f24th$2h0$1@sam.via.ecp.fr> Message-ID: On Sun, 7 May 2000 bbp at zen.via.ecp.fr wrote: > > Hi. Is there a way to know what is the maximal value an > integer is allowed to take ? import sys print sys.maxint -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From dana at oz.net Tue May 16 21:29:35 2000 From: dana at oz.net (dana_booth) Date: 17 May 2000 01:29:35 GMT Subject: tkinter Message-ID: <8fsslv$n0n$0@216.39.141.21> I do okay with Python, and I do okay with TCL/TK. Today, I begin a project which will involve a gui interface, and something that I would naturally have begun writing TCL code for. The workstation that I use is Linux. (mandrake 6.0) I think, hey, I'll see what I can do using tkinter. I re-compile Python to include the tkinter module, and it makes fine, but when I make install, error says "libtk8.3.so: shared object file not found". Permissions on libtk8.3.so are 755, and it resides in /usr/local/lib. I don't see anything wrong... So anyway, I never used tkinter today. :) But it bugs me that the module won't install. Does anyone have an idea what the problem is? -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From jerry_spicklemire at my-deja.com Wed May 24 20:24:02 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Thu, 25 May 2000 00:24:02 GMT Subject: Graphical User Interface application References: <8F3DE03A5beable@207.211.168.81> Message-ID: <8ghrqk$6uk$1@nnrp1.deja.com> Mitchell Morris wrote: > I am aware of no tool that > does everything for Python that VB does for BASIC. > The more I think about it, however, the more I wish I was wrong, The continuing development of IDlE is one of the long term goals of the CP4E project, and though it "ain't there yet", compared to your feature list, it's already a good IDE for Python. http://www.python.org/cp4e/ One very useful feature that is in place today is the Object Browser and the dubugger steps through codejust as you describe, allowing on the fly editing of running processes. I use IDlE for lot's of editing unrelated to Python too! Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From thiele at muc.das-werk.de Thu May 25 05:55:29 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Thu, 25 May 2000 11:55:29 +0200 Subject: What's in a name? References: <392c17d3$0$17863@wodc7nh7.news.uu.net> <392C3738.58C41202@muc.das-werk.de> <392CB840.1E5E5B06@teleatlas.com> <392CBAB5.37BFCE21@san.rr.com> <392CEC02.BA7DF8FA@teleatlas.com> Message-ID: <392CF891.7F1F6594@muc.das-werk.de> > Case - sensitivity is very useful. You can name a class "A" and an instance of it "a". > > Can you name some situations in reading and writing english (heh) where case > is essential to being understood? In English not. But we "Krauts" use uppercase for all Nouns. In my Opinion it's very useful and good readable. For Instance "ein paar" means "some", and " ein Paar" means "a pair". In English, France, Russian the whole Text looks equal. And last but not least case insensitivity is inconsequent! What's about incorrect spelling? "elllse" - ok. it's a "else" strig : the interpreter will know you mean "string" or do you mean your own module named "stig"? From m.faassen at vet.uu.nl Thu May 18 07:50:19 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 11:50:19 GMT Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> Message-ID: <8g0ldr$gd2$3@newshost.accu.uu.nl> JRHoldem wrote: > Unix is better....hogwash. For some of the exact reasons that > you claim Python is better than Java, NT is better than UNIX. [snip lots of argumentation] Obviously this is pretty subjective, so let's not get into an OS flamewar here. Let's instead discuss hm..speeding up the Python interpreter. How to handle the exponential growth of Python users elegantly. Why not all infinities are the same size. Or let's compare Sather to Python, perhaps. Or some other language. Okay?-thanks-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Tue May 23 05:59:54 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 09:59:54 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> <3929C933.3ED830E@tcac.net> Message-ID: <8gdkqq$nju$2@newshost.accu.uu.nl> William Tanksley wrote: > Wait a 'mo, though. Information is only carried when there is a choice. > In a case insensitive language I, the programmer, can use capitalization > to convey information to my reader in a way that the compiler won't > notice. > So case insensitivity provides _more_ information-carrying capacity. I've > always wanted to have covert channels in my Python code. I mean, aside > from the comments :-). Hm, but this covert channel would be exposed to Python! We can start using it to build automated tests and parsers, like docstrings! After all, Py3k's introspection facilities would allow us to examine the case of a particular method. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkraska1 at san.rr.com Sun May 21 00:43:35 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 21 May 2000 04:43:35 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <39276A37.BDB2F11D@san.rr.com> > Oh, yes, before anyone points it out, I am aware that the same bodies of > knowledge which point to reading based on word form rather than sequences of > characters point to white space as a significant contributor to the > readability of text by allowing the eye to rapidly organise the text and > prioritise comprehension. Strange how Python is so often noted as being > "easy to read"... > > Could it be a pattern? While your question was rhetorical, I suspect you are quite right. C/ From jkraska1 at san.rr.com Wed May 10 23:48:46 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 03:48:46 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> Message-ID: <391A2E7C.818CB3C5@san.rr.com> > What I miss from perl: I'd say using perl as a shell scripting > language is faster. Python has all the same features but they're > often implemented as functions or classes in the standard library, > rather than as special punctuation, so there's more typing to do. > And if you learn both languages from the O'Reilly "Learning P*" > books,... Speaking of O'Reilly... _Programming Python_ sucks, if you ask me. The organization of the book is bizarrely different than most all other programming books, where such books usually open up with the basics, then talk about control structures, then do some advanced programming topics, and so on. The ability to get the information you want just isn't there, partly because the author framed the book around the construction of some software project, instead of around the concept of covering the material by category, as it's usually done. I finally gave up and simply went to the HTML docs (which also aren't organized all that well; you'd think you'd be able to find the shell builtins easily, but someone had to actually point my nose to them before I finally found them, I wonder why that is?). I've ordered the _Essential Python Reference_, and I'm hoping that's lots better. Any professional programmer understands the kinds of things they are looking for (control structures, bitwise operators, et c.), and only books like _Python for Dummies_ should assume that a programmer needs to be lead by their nose through fundamental understanding of a programming language. I do really like Python, but the HTML documentation is begging for a good technical writer, IMO. C/ From JoeSmith at bogusaddress.com Sun May 7 15:13:23 2000 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Sun, 07 May 2000 19:13:23 GMT Subject: win32all-129-update.exe - Is it needed? References: Message-ID: I just was not sure what it was. I always like to make sure of what I am doing. I was thinking that win32all-129.exe was 'all' of what one needed. Is win32all-129-update.exe to patch the core python core for 1.5.2 (to get 129 to work better) or is it a patch to for 129? (I get the distinct impression that it is not a patch to go from 128 to 129 as I was thinking it might have been previously.) Thanks for the great work that you do for python. Mark Hammond wrote in message news:Wo5R4.13177$v85.87523 at news-server.bigpond.net.au... > "Joe Smith" wrote in message > news:X73R4.44404$k5.1290605 at news1.frmt1.sfba.home.com... > > On the starship site is says: > > Also download and install the patch set for build 129 - > > win32all-129-update.exe (663,799 bytes) > > > > Is this needed if one installs win32all-129.exe? > > I thought the instructions were pretty clear? I can assure you I have > better things to do than release unnecessary patch sets :-) > > Mark. > > > From boncelet at udel.edu Mon May 8 00:41:05 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 08 May 2000 14:41:05 +1000 Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> <39163F4E.EE88F9CF@san.rr.com> Message-ID: <39164561.24A711BC@udel.edu> Courageous wrote: > The issue probably is *not* your vim syntax file, but rather > the defaults that your vim resolves to. I've included my > python.vim at the end of this, but what you probably really > want is my vimrc. (stuff deleted) You are exactly right. My real question, that I didn't ask, was how to set the various colors. I had examined the vim help files, but hadn't figured it out. Your message, though, gave me the right clues. > highlight String guifg=Black guibg=Yellow > highlight Constant guifg=Blue font=Courier_New:b:h10 Charlie Boncelet ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From jkraska1 at san.rr.com Tue May 23 22:53:05 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 24 May 2000 02:53:05 GMT Subject: Case sensitivity (Was: Re: NumPy and FFT) References: <392A2F23.FD2E3127@san.rr.com> <392B3919.E984ACEF@cosc.canterbury.ac.nz> Message-ID: <392B44AF.A14A124E@san.rr.com> > If we're robbed of the ability to use case for semantic > distinctions, we're going to have to adopt some other > conventions to make those distinctions. Then there's > room for different people and different modules to use > different conventions, and at least as much scope for > confusion -- probably more. Um, if Guido "robs" us of case sensitivity, there exists a far higher than zero probability that someone will grab his source, take out all the silly *caugh* tolower()s, and release it as the *real* python 3k. Okay, now that everyone knows that I'm a tad drunk and not afraid to say what I really think, uh.... heheheh. Do ya forgive me? :)- pinot-noir-is-really-yummy-but-makes-you-make-an-ass-out-of-yerself ly y'rs From psl at mitre.org Tue May 2 11:08:09 2000 From: psl at mitre.org (Peter Leveille) Date: Tue, 02 May 2000 11:08:09 -0400 Subject: calling class constructors through calldll Message-ID: <390EEF59.521610B9@mitre.org> I am calling a class constructor in a dll using calldll. The problem is that this then causes python to try and write to an illegal memory address (i.e. 0x00000018 or 0x00000000c). Should I be able to call a class constructor through calldll? From arcege at shore.net Sat May 6 09:01:47 2000 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 06 May 2000 13:01:47 GMT Subject: Py_BuildValue - return large array References: <39133A5A.AD145915@sec.noaa.gov> Message-ID: <%IUQ4.20$w%.2158@news.shore.net> j vickroy wrote: : Hello all, : How should one return a (handle to?) "large" C-array to Python? : It seems that Py_BuildValue ("[...]", ..., ...) is only usable for : "small" arrays where one can explicitly enumerate each element in the : array. : Thanks for your time. You probably don't want to use Py_BuildValue(). For one, if you have a large array, then you might have problems enumerating the values in the function call (as seperate arguments). I would suggest creating a Python list object explicitly and populating it that way. For example, PyObject *Convert_Big_Array(long array[], int length) { PyObject *pylist, *item; int i; pylist = PyList_New(length); for (i=0; i Message-ID: <8f7ivn$d7o$1@nnrp1.deja.com> In article <8f7d9n$ii7 at autodesk.autodesk.com>, "Akira Kiyomiya" wrote: > Okay, these two regular expression codes are from Python Essential Reference > book and I am pretty confused about these. > > Could someone dare to explan step by step? I will give it a try ( don't have the manuals in front of me so beware of mistakes): > e_mail = re.compile(r'([a-zA-Z][\w-]*@[\w-]+(?:\.[w-]+)*)') 1. [\w-]* confuses me a little: \w by itself stands for [a-zA-Z0-9_] so with the * it matches 0 or more repetitions of those characters. The '-' sign is a little confusing becuase in square brackets it usually denotes a range, but here it's clearly meant to simply match itself. You'll need to check to see if it does. 2. After matching (1) we require an @ sign followed by 1 or more repetions of [\w-] 3.a The (?: ) construct allows you to define a group without it being captured for later use in the .group(n) function. 3.b. The (?:\.[\w-]+)* then matches 0 or more instances of a litteral '.' character or any of the characters in the class defined by [\w-] (1) (I'm assuming that you left out the backslash for \w above by accident So yes, this looks like it would match an email address to me. > URL = re.compile(r'((ftp | http)://[\w-]+(?:\.[\w-]+)*(?:/[\w-]*)*)') > > # I know ftp or http part plus "://" you need it for URL. Then,..... I am > lost.... > > Akira > If you understand my explaination for the first regexp, the second one should make sense now. (Assuming I haven't made a mistake.) Andrew Kuchling has written a great intro to using re's as the regular expression HOWTO at http://python.org. You should check it out. Good luck, -chris Sent via Deja.com http://www.deja.com/ Before you buy. From greg at cosc.canterbury.ac.nz Thu May 4 22:35:34 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 05 May 2000 14:35:34 +1200 Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil><20000430170952.A502@datapro.co.za> <8enie0$9n8$1@slb7.atl.mindspring.net> <3911D84D.427382D3@earthlink.net> Message-ID: <39123376.D60F8D46@cosc.canterbury.ac.nz> Charles Hixson wrote: > > I don't really recall, h_bar may indeed be a dimensionless quantity. Doesn't it have dimensions of angular momentum? -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From guido at python.org Thu May 18 23:36:08 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:36:08 GMT Subject: Q? Calling nearest inherited method References: <392295a8.3800058174@news.u-psud.fr> <3923112C.4758A8C0@python.org> <3923af51.3872163586@news.u-psud.fr> <39243201.63666219@python.org> Message-ID: <3924E10A.5E2DD804@python.org> > Laurent POINTAL wrote: > > > > On Wed, 17 May 2000 18:37:00 GMT, Guido van Rossum > > wrote: > > > > >: There's a better way. (I believe Jeremy Hylton first suggested this; he saw > > >: it as an idiom in another language:) > > >: > > >: class C(B): > > >: super_doit = B.doit > > >: def doit(self, arg): > > >: self.super_doit(arg) > > >: > > >: This avoids the need to explicitly pass self. > > > > Not sure its really better... > > 2) The biggest problem, it can go into infinite recursion... > [details omitted] I replied: > Argh! Good catch. My suggestion: use a naming convention > where it's called B_doit instead of super_doit. But this *does* > make it less elegant, and you now need to know the base class name... Jeremy just pointed out to me that he has a very elegant solution: he uses __super_doit = B.doit. This nicely makes it class-specific without working the class name into the identifier explicitly. I think this is more elegant than calling B.doit(self, arg). -- --Guido van Rossum (home page: http://www.python.org/~guido/) From mwh21 at cam.ac.uk Sat May 13 07:29:06 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 May 2000 12:29:06 +0100 Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> <8feh9q$3gn$1@nnrp1.deja.com> <8feku2$5ap$0@216.39.141.36> <391b087a.203308261@news.iol.ie> <8fhl1e$nk0$2@newshost.accu.uu.nl> <391DC577.55A@seebelow.org> Message-ID: Grant Griffin writes: > When I bought "Learning Python", I ended up finding it and the other > Python books by accident in the "Unix" section of Barnes & Noble, after > having first scoured the "Languages" section for them. Since Python > isn't especially Unix-inspired, perhaps this suggests the need to > increase Python awareness. This is a general bookshop problem; the big Waterstone's near me has about half a million books on C/C++, Java and VB each, a "general programming" section, where you look for books on interesting languages like Lisp and Haskell, and the Python books are next to the perl books in "Unix", except for "Programming Python on Win32", which is in the Windows section. Mind you, I haven't tried moaning at them. Perhaps I should. > Then again, maybe it was in the Unix section simply because there was no > room in the Languages section--which was packed tight with Perl and Java > books. M. -- A student, in hopes of understanding the Lambda-nature, came to Greenblatt. As they spoke a Multics system hacker walked by. "Is it true", asked the student, "that PL-1 has many of the same data types as Lisp?" Almost before the student had finished his question, Greenblatt shouted, "FOO!", and hit the student with a stick. -- AI koan From chibaA at TinterlogD.Tcom Thu May 11 19:26:43 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Thu, 11 May 2000 23:26:43 GMT Subject: number base conversion? (ASCII to Hex) References: <391B3E42.E7867322@fenx.com> Message-ID: <391b41e7.72263359@news1.on.sympatico.ca> That's exactly it. Very much appreciated! kc On Thu, 11 May 2000 16:12:02 -0700, emile at fenx.com wrote: >Something like this? > >>>> for i in "Testing 1,2,3 ": > print "%2x" % ord(i), > >54 65 73 74 69 6e 67 20 31 2c 32 2c 33 20 > >Emile van Sebille >emile at fenx.com > > > wrote in message >news:<391b2bd5.66612734 at news1.on.sympatico.ca>... >> How would I go about getting the base-16(hex) value of a character, >> into a string? >> >> take character word[1] (for example) >> and retrieve the hex value of 31 >> and assign it to value hexValue in an ascii format (ie. as the number >> 31). >> >> >> >> -- >> http://www.python.org/mailman/listinfo/python-list >> > From andrew at andrewcooke.free-online.co.uk Tue May 30 08:19:31 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Tue, 30 May 2000 12:19:31 GMT Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: <8h0bk6$4b7$1@nnrp1.deja.com> this isn't really on-topic because it doesn't concentrate on teaching oop (i suspect it will also use first class functions more than normal for a typical python program), but i think peter norvig is writing/has written python (or jpython) code support for his ai textbook. i've *not* read that book, but have read norvig's other book which is a recognised lisp classic - if the textbook is as good then you or your friend would learn a lot about programming while thinking you were "just" learning a lot about ai... more info at http://www.norvig.com/python-lisp.html andrew ps and learning more about a functional approach to programming might be no bad thing for someone interested in oop... Sent via Deja.com http://www.deja.com/ Before you buy. From effbot at telia.com Mon May 22 16:28:43 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 22 May 2000 20:28:43 GMT Subject: append to a file References: Message-ID: <%LgW4.9067$Za1.140265@newsc.telia.net> Scott Hathaway wrote: > How do I append to a file instead of overwriting it? I searched on the > python website and got a hit, but the link was bad. use the "a+" flag when opening the file (or "w+" and seek to the end of the file). for some more info, see the description of "open" on this page: http://www.python.org/doc/current/lib/built-in-funcs.html hope this helps! From bjorn at roguewave.com Sat May 20 19:05:09 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 20 May 2000 17:05:09 -0600 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> Message-ID: <39271A25.A348E4B9@roguewave.com> Will Rose wrote: > [snip] > > For a single data point, I'm English (tho' German was my first language, > which spoils the 'statistics' a bit). I don't think case-sensitive/ > insensitive varies with nationality; I've run across similar arguments > in file-naming contexts (eg. Unix case-sensitive/case-preserving, and > Microsoft long filenames case-insensitive/case-preserving). Some > people just do see the tokens 'token' and 'Token' as being identical, > and are very irate if their behaviour differs; others, like me, see > them as different and hate the additional complexity of trying to > memorise possible matches. (A bit like the 6-character limit on old > linkers...). I don't know why people have these two different approaches, > but it seems to be something fundamental in their use of language. This brings up another interesting point... I'm assuming the subjects from the Alice project/research would also prefer: 'token' == 'Token' to return true. Perhaps we could add something like: a = b # they're pretty similar a == b # they're the same modulo case a === b # they're the same including case a ==== b # same meaning as current 'is' for consistency add-s-until-you're-confident-I'm-joking'ly y'rs -- bjorn From mwh21 at cam.ac.uk Thu May 18 04:16:42 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 May 2000 09:16:42 +0100 Subject: Bit length of int or long? References: <392317CF.D6F878F5@python.org> Message-ID: Dennis Lee Bieber writes: > How about... > > import math > > > def bitlen(x): > assert x > 0 > return math.floor (math.log10(x) / math.log10(2) ) + 1 > Because: >>> def bitlen(x): ... assert x > 0 ... return math.floor (math.log10(x) / math.log10(2) ) + 1 ... >>> bitlen(2**10000L) inf (which surprised me; I'm sure that used to raise an exception - has this changed recently?) Cheers, M. -- how am I expected to quit smoking if I have to deal with NT every day -- Ben Raia From cut_me_out at hotmail.com Sun May 7 09:43:50 2000 From: cut_me_out at hotmail.com (Alex) Date: 07 May 2000 09:43:50 -0400 Subject: SSL on Windows? References: <39152AC9.AFBCF2FA@studcs.uni-sb.de> Message-ID: Thanks, "Dude." :) Alex. From Ralph.Schnackenberg at web.de Tue May 30 17:01:34 2000 From: Ralph.Schnackenberg at web.de (Ralph Schnackenberg) Date: Tue, 30 May 2000 23:01:34 +0200 Subject: stdin redirection problem Message-ID: Hi Pythoneers, I'm struggling with the following: ( You might probably identify me as a newbie :-) ) I want to write a server application using the "cmd" module for parsing the incoming data stream from a socket. But I'm wondering how to redirect the socket stream to the stdin of the Cmd's subclass. I tried already some helpless things inside the constructor method of the subclass of "Cmd", but as you might guess without any success. :-( Any help ? Cheers, Ralph From echuck at mindspring.com Thu May 11 12:06:07 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Thu, 11 May 2000 12:06:07 -0400 Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> <391A58E5.C9487C30@san.rr.com> <391A7AB4.B132D9DA@one.net.au> <391A92A4.F64FF43A@san.rr.com> <8fecfp$pli@newton.cc.rl.ac.uk> Message-ID: <391ADA6F.183589B6@mindspring.com> Richard Brodie wrote: > > "Courageous" wrote in message news:391A92A4.F64FF43A at san.rr.com... > > > I see. Well, then all things considered, I have no idea why one > > would want to use python/OS threads at all. The uthread implementation > > on stackless really rips. > > It depends on your reason for using threads. Sometimes, it just means > that you can write cleaner code. Having a multiprocessor, and using > multiple threads, and caring about the execution time of the Python > interpreter are putting you in something of a minority. > > For one thing, it means that you are using an interpreted language > for something performance critical. In a lot of problems, the inner > loop is likely to end up in external modules which will multiprocess > fine anyway. If yours isn't one of them them sure, go ahead. The application server in Webware for Python is a good example where: * You want a great language like Python to develop your website (even if Python is slow). * There doesn't seem to be a magic inner loop that provides huge optimization pay offs * Multiple threads are a natural, because it's a server for multiple requests * Performance is important and multiple CPUs can/should help So I guess Courageous and I are in the same basic category. I imagine any type of Python-based server would be as well. -Chuck From kkinder at my-deja.com Sun May 21 04:47:12 2000 From: kkinder at my-deja.com (Ken Kinder) Date: Sun, 21 May 2000 08:47:12 GMT Subject: Regular expressions in files References: <39254357.C7988097@uwe.ac.uk> Message-ID: <8g87qg$ht$1@nnrp1.deja.com> Use the normal regular expression API (I don't know it) against individual lines as you read them in: fd = open('filename') text = '' line = fd.readline() while line: ... here, include your code to test line ... matching the re. If the re matches, you ... may care to use the break statement to end ... the loop early line = fd.readline() ... if it got down here and the re never tested true, ... it wasn't in the file fd.close() In article <39254357.C7988097 at uwe.ac.uk>, Simon Langley wrote: > Can regular expression matching be done on files? I'd like to read just > as much of a file as is necessary to either be a (greedy) match of the > re or until a match definitely can't be found. > > If a string is read from a file, tried for a match and fails can I tell > whether it failed because a) without reaching the end of the string it > didn't match or b) it didn't match by the end of the string but might > have if the next line had been appended? That would solve the problem. > > Thanks, > > Simon > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Simon Langley > Email: Simon.Langley at uwe.ac.uk > University of the West of England > Bristol BS16 1QY > England > > -- Ken Kinder Sent via Deja.com http://www.deja.com/ Before you buy. From genesis7 at my-deja.com Tue May 9 19:29:28 2000 From: genesis7 at my-deja.com (genesis7 at my-deja.com) Date: Tue, 09 May 2000 23:29:28 GMT Subject: zlib in python 1.5.2 missing? References: Message-ID: <8fa705$b48$1@nnrp1.deja.com> In article , Moshe Zadka wrote: > > I have a quick question regarding zlib module in python 1.5.2. > > Is any one using it? If you are where can I find it. I tried building > > it from both 1.5.2 source and from their CVS tree. No luck! > > It seems to be missing zlib.h file. This file doesn't seem to > > exist anywhere in their source tree. If you have a solution, > > that would be great. > > Download the zlib sources, and install zlib. Originally downloaded the zlib source. It compiled fine. However, I didn't install it to /usr/local/include or had I tried to compiled python zlib module with the -I was. Thanks for the info. --sc Sent via Deja.com http://www.deja.com/ Before you buy. From tismer at tismer.com Sat May 6 17:45:04 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 06 May 2000 23:45:04 +0200 Subject: My Server supports Python? References: <391305A4.98430BB0@swt.edu> <39145347.59330549@san.rr.com> <39148C19.59B715BD@san.rr.com> Message-ID: <39149260.CE01110@tismer.com> Courageous wrote: > > Will Ware wrote: > > > > Courageous (jkraska1 at san.rr.com) wrote: > > > % find / -name "python*" -print > > > > He could also just do: > > > > which python > > > > though "find" and "which" both assume a Unix system. Assuming his > > path is set up correctly,... > > Yeah. I was assuming since the word "server" was used and a > command line was mentioned, it just about had to be unix. > The advantage to the find, of course, is that it will find > python even if he hasn't had it put into his path (which is > a possibility). Well, if an ISP is really supporting Python, and if typing some shell at some site > python doesn't give the desired result, you may for sure assume that they don't support it, at least not in the way it should be, right? would-never-happen-at-my-site-as-you-know-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From thiele at muc.das-werk.de Wed May 24 15:24:39 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 24 May 2000 21:24:39 +0200 Subject: Error Message-ID: <392C2C77.ABEE82E9@muc.das-werk.de> I have some code with a try and except try: function_that_rises_many_types_of_exceptions() except: print "error, but I don't know what was happend!" I use except without any argument to catch all kind of exceptions. But how can I get the type of exception without having to write down all exceptions? Is there function like GetLastException() ? From noreply at nospam.org Sat May 27 11:33:56 2000 From: noreply at nospam.org (Brian) Date: Sat, 27 May 2000 15:33:56 GMT Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> Message-ID: Not really a realistic comparison. Check out this language performance study: http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf "Alexander" wrote in message news:392F8286.13371C4E at mit.edu... > Hi > > I have implemented loop in Python > > for k in xrange(1,100000000): > pass > > and the same one in C > for ( i = 0 ; i < 1e8; i++ ) ; > > and the second one seems to be working hundreds of times faster than the > first one > > Can I do anything with that. > > Thank you > > From nospam at sorry.com Sun May 14 14:42:51 2000 From: nospam at sorry.com (Keygrass) Date: Sun, 14 May 2000 18:42:51 GMT Subject: (gulp) newbie question - portablity of python Message-ID: I first discovered Python from Leo Laporte on ZDTV. Just like what he said, the www.python.org web site says this: The Python implementation is portable: it runs on many brands of UNIX, on Windows, DOS, OS/2, Mac, Amiga... If your favorite system isn't listed here, it may still be supported, if there's a C compiler for it. Ask around on comp.lang.python -- or just try compiling Python yourself. So ... my question is this: Is this really too good to be true? What I want to do it write the program on my Win98se (at home) and then use that .exe or .bat file (or whatever extension it is) at work which uses unix. Basically, I want a build a program that will replace words and number on another file. For example, if I had a file called "Outdoor_sports" that contained the word "baseball bat", I would want my program to change it so it would say "football". -cb From jkraska1 at san.rr.com Fri May 12 20:49:03 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 00:49:03 GMT Subject: HEAP/priority queue Message-ID: <391CA714.3EB0E8B5@san.rr.com> Is there a heap anywhere in the python modules? I did an exaustive grep on all the html files, and could find nothing. I'd prefer a native module, of course. C/ From petersc at stud.ntnu.no Wed May 3 05:37:18 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 03 May 2000 11:37:18 +0200 Subject: getting used/available memory Message-ID: <390FF34E.F011F80B@stud.ntnu.no> Hei! I seem to have some nice memory leaks in my modular arithmetic module. To find out where the memory goes I'd like to find out how much memory is occupied/free at a given time. I did not find anything in sys or os on first sight. Where do I have to go? I am using python 1.5.2 on linux. The routine in question is: def tolong(u,m): R = len(u) v = copy.copy(u) n = map(long,m) c = [] for j in range(R): if (j % 100)==0: print "o" c.append([]) for k in range(R): c[j].append(mulinv(m[j],m[k])) for j in range(R-1): for k in range(j+1,R): v[k] = (v[k]-v[j])*c[j][k] % m[k] w = v[0] for j in range(R-1): w = w + v[j+1] * n[0] n[0] = n.pop(0) * n[0] return w where m is a list of 10000 relative prime integers below 2**31 and u is a list of 10000 integers which are as well below 2**31. the system has 224 MB of ram (96 + 128 swap) and after about 1000 iterations the system runs out of memory and I have to emergency sync and reboot. Would using JPython fix this problem? thanks for any advice Peter P.S.: The function mulinv calculates the multiplicative inverse of a relative to b using the forward version of the extended euclidean algorithm. as it is used in the inner loop the memory leak might as well be there: def mulinv(a,b): s = [1,0] m = b while b > 0: q, r = divmod(a,b) s.append(s.pop(0)-q*s[0]); a = b b = r return s[0] % m -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From grisha at ispol.com Sun May 28 10:49:25 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Sun, 28 May 2000 10:49:25 -0400 Subject: ANNOUNCE: mod_python 2.0 - A Python module for Apache. In-Reply-To: <200005281316.JAA15479@saltmine.radix.net> References: <200005281316.JAA15479@saltmine.radix.net> Message-ID: On Sun, 28 May 2000, Cary O'Brien wrote: > 2) I'm not sure I understand interpreter lifetime. I need to > create a system that accesses a database (PostgreSQL to start, > then mabye oracle). So I'd like to have one interpreter per > apache process, plus an initiliaizer/terminator function. That way there > could be one persistant database connection per apache process. The way to do this is to import a module that establishes the database connection. Since the module will only get imported once the first time and remain for as long as the process lives, there is your persistent database connection. At this point I do not have cleanups yet, they are coming in the future versions, so there is no terminator function - you just let the process die. > 3) You mentioned using ZPublisher. Does this mean with mod_python you > could have one interpreter per apache subprocess accessing a common > Zope database? My concern would be locking on the zope database. I > asked about doing this on the zope mailing list and couldn't get an > answer. You can use ZPublisher, but not Zope databases. Unfortunately, the Zope database locking is not suitable for simultaneous access by multiple processes. May be existance of mod_python will not give the Zope developers enough incentive to implement that. > 4) Isn't there another mod_python floating around out there? Or is > this the same one as http://modules.apache.org/search?id=49 ? pyapache != mod_python > 5) I've got the bits to pull out embedded code from HTML documents and > execute them (from a tcl based module). Interested? Yes and no. The idea sounds good, but this sort of thing doesn't belong in mod_python. Some time soon I will create a section on the website for "third party" mod_python handlers - this could be one of them. Grisha From guido at python.org Thu May 18 23:49:21 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:49:21 GMT Subject: nntp programs request References: <39245350.D0B09F20@softhome.net> Message-ID: <3924E423.C9F80C49@python.org> etoffi wrote: > > i need a program/script that downloads from an nntp server and puts the results > into a standard format (i think its called mbox) Look into the nntplib module, it does most of what you want. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From noone at do.not.use Fri May 26 14:37:23 2000 From: noone at do.not.use (Russell Turpin) Date: Fri, 26 May 2000 13:37:23 -0500 Subject: XML namespaces and xmllib References: <392DE07B.71E3F0D1@netscape.com> Message-ID: <392EC463.57547A0D@do.not.use> Ian Oeschger wrote: > I don't seem to be able to turn off the namespacing support > in xmllib so I can just get the unnamespaced elements and > attributes. It looks to me that the author may not have anticipated the desire to handle XML without namespace information. What I did was a bit of a kluge, but it works .. Instead using the elements array, override the methods unknown_starttag() and unknown_endtag(). These will get called on every tag. Your methods will need to interpret the tags. Inside these methods, split the tag argument on whitespace, and the last piece is the tag proper. The first piece, if present, is the namespace. BTW, the entitydefs that comes with xmllib is terribly meager, and will cause the parser to choke on a wide range of standard characters, such as the British pound sign. I override the constructor and use htmlentitydefs to create better entitydefs data. Good luck! xml-ing-ly yrs, Russell From felixt at dicksonstreet.com Mon May 15 22:50:59 2000 From: felixt at dicksonstreet.com (Felix Thibault) Date: Mon, 15 May 2000 21:50:59 -0500 Subject: location of home made modules In-Reply-To: Message-ID: <3.0.5.32.20000515215059.0079a100@mail.dicksonstreet.com> At 22:01 5/15/00 GMT, Huaiyu Zhu wrote: >What is the standard place to put one's home-made modules? >How to get Python to know that place? I tried to put modules in >~/lib/python/ with the following in ~/.pythonrc > >import sys, os >sys.path.append("%s/lib/python" % os.environ["HOME"]) > >This works in the interactive interpreter but does not get the module from >program files. Previously all my modules stay in the same directory as the >programs that load them so this problem did not manifest itself. > > >I can't find where in the docs this is mentioned. >Thanks for any pointer. > >-- >Huaiyu Zhu hzhu at knowledgetrack.com >-- >http://www.python.org/mailman/listinfo/python-list > I think this is to do with whatever shell you're using...with the bash shell what I had to do so my scripts could find my modules was open up the ~/.bash_profile file and add the line: PYTHONPATH=$HOME/lib/python to the section where the PATH variable was defined and then add PYTHONPATH onto the list of variables after the 'export' statement at the end of the file. But I think it all depends on which shell you're using... Hopefully helpfully- Felix From ivanlan at home.com Tue May 9 09:29:35 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Tue, 09 May 2000 07:29:35 -0600 Subject: Future of the Python Linux Distribution References: <3916F04F.7647B829@zipzap.ch> <391790A2.26CB9618@home.com> Message-ID: <391812BF.4C226C55@home.com> Hi All-- Will Ware wrote: > > Alex (cut_me_out at hotmail.com) wrote: > > > *Sigh*. I knew someone would make me do this. > > > [ lotsa Postscript ] > > How do you run this? I put it in a file tst.ps, and tried to look at it > > with gv, but all I got was a blank page. > > Add a line at the end that says "showpage". Then you should be able > to see it. > Not quite. Part of the test is figuring out how to call the Rbbx() function. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From rwallace at esatclear.ie Mon May 22 06:03:13 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Mon, 22 May 2000 11:03:13 +0100 Subject: Random numbers Message-ID: <392905E1.371F@esatclear.ie> Hi all, a couple of questions: Is there any difference between the random number generator in the 'random' module and that in the 'whrandom' one? What's the quality -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From emile at fenx.com Sat May 20 13:01:25 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 20 May 2000 10:01:25 -0700 Subject: Python3k extended grammar References: <392456A9.993FB15C@concentric.net> <8g1q8u$drc$2@newshost.accu.uu.nl><8g6bae$977$16$1@news.t-online.com> Message-ID: <0bb801bfc27d$0e5957e0$1906a8c0@fc.fenx.com> Cool! Does that mean I'll be able to use: if not( x % y ): ... do stuff or even: while not ( x % y ): ... Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Fran?ois Pinard To: Thomas Malik <340083143317-0001 at t-online.de> Cc: Sent: Saturday, May 20, 2000 9:59 AM Subject: Re: Python3k extended grammar > "Thomas Malik" <340083143317-0001 at t-online.de> writes: > > > 2. promoting integer divisions to float sounds quite stupid to me: > > (x/y) * y + x % y == x should always hold true in any sane language > > No problem. For consistency, x % y will invariably yield 0 :-). > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > > > > -- > http://www.python.org/mailman/listinfo/python-list > From sliang at florida-lnx.cc.gatech.edu Fri May 26 14:42:04 2000 From: sliang at florida-lnx.cc.gatech.edu (Shengquan Liang) Date: 26 May 2000 18:42:04 GMT Subject: How Do I Set Environment Variables ? Message-ID: <8gmghs$vm$1@solaria.cc.gatech.edu> How do i set enviroment variables in a Python script that is to be run on an Apache server? say, i want to set ORACLE_HOME = /opt/app/ora/ I wrote the following code: import os os.system("ORACLE_HOME=/opt/app/ora/") os.system("export ORACLE_HOME") .... I executed the script under my user account but when i checked my enviroment variables with "env" there is no ORACLE_ENV added. how do i straighten it out? thanks a lot. Another question is that, when the script is up on a web server, it's executed on behalf of 'nobody', will the enviroment variables be changed after running the script?  -- Shengquan Liang ________________________________________ gt2558b at prism.gatech.edu 332558 GA TECH STATION Atlanta,GA 30332-1450 From mhammond at skippinet.com.au Tue May 30 02:24:03 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 May 2000 06:24:03 GMT Subject: destructors -- when are they called? References: <393351D2.3533AEFF@san.rr.com> Message-ID: <78JY4.1025$Hz.6998@news-server.bigpond.net.au> This should be quite obvious from the Py_DECREF macro - it explicitely calls the delete function when the ref count hits zero. In the current implementation, it is indeed guaranteed (even though the language spec specifically refuses to guarantee it) Mark. "Courageous" wrote in message news:393351D2.3533AEFF at san.rr.com... > > > When writing a C language extension, is it guaranteed that the > moment your object's reference count is reduced to zero it's > destructor will be called? (I have a situation in which this > may matter). > > > C/ From jkraska1 at san.rr.com Wed May 3 02:15:22 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 06:15:22 GMT Subject: Backward chaining for __init__? References: <390F8C7E.9986DAE0@san.rr.com> <390FA242.C6DC9BBC@san.rr.com> Message-ID: <390FC4A0.BEBE37AE@san.rr.com> > 1) If the base class's constructor takes arguments, how will you > know which arguments to provide? The function that has the right profile? > 2) If we're using multiple inheritance, which ctor do we call first? Decisions, decisions. > 3) What if we want to initialize some of the object's state before we > call the ctor? (This is unusual, but not IMO completely pathological.) Kind of like an :after make-instance method in Lisp, where the semantic is that all the :initargs go first, then the :after ctor is called. Very nice functionality, that. And entirely optional all the way around. > Personally, I like Python's approach because it makes the chaining > explicit. Well, now this isn't so bad, actually. But how about: class Foo def chaining __init__(self) dosomething() This would provide the semantic that all classes inheriting from this class would chaining __init__ methods all the way down the inheritance tree. A general utility, which could be used in other contexts. Mostly I'm worried about certain __init__ methods which are required to be called on a class for the class to even make sense. I'd like to be able to say "if you're usin' my class, bud, you're doin' it my way". C/ From pecora at anvil.nrl.navy.mil Fri May 5 09:26:22 2000 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Fri, 05 May 2000 13:26:22 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> <20000430170952.A502@datapro.co.za> <8enie0$9n8$1@slb7.atl.mindspring.net> <3911D84D.427382D3@earthlink.net> <39123376.D60F8D46@cosc.canterbury.ac.nz> Message-ID: <050520000926214240%pecora@anvil.nrl.navy.mil> In article <39123376.D60F8D46 at cosc.canterbury.ac.nz>, Greg Ewing wrote: > Charles Hixson wrote: > > > > I don't really recall, h_bar may indeed be a dimensionless quantity. > > Doesn't it have dimensions of angular momentum? Uh, guys...thanks. All I really wanted to know was, do I have to use "self?" :-) From crystalc at interlog.com Tue May 23 14:05:01 2000 From: crystalc at interlog.com (Brian Alexander) Date: Tue, 23 May 2000 14:05:01 -0400 Subject: i/o redirection on NetWare volume Message-ID: Hello; I have a python program that takes input from stdin and send the result to stdout. It works perfectly when the source is a data file (or keyboard input) from a local drive (c:). When the file is on a NetWare volume, the program just seems to copy the unprocessed source to the screen. Here is how I invoke it: local source: python jlines.py < c:\myinput.txt NetWare volume: python jlines.py < j:\myinput.txt Does anyone know what might be going on? Many thanks, Brian. PS: I hope I haven't already posted this message. Please forgive me if I have. From vogler123 at my-deja.com Wed May 24 15:42:49 2000 From: vogler123 at my-deja.com (vogler123 at my-deja.com) Date: Wed, 24 May 2000 19:42:49 GMT Subject: newbie python 1.5.2/Tk/WinNT install question References: <8gf327$76j$1@nnrp1.deja.com> Message-ID: <8ghbbl$qti$1@nnrp1.deja.com> In article <8gf327$76j$1 at nnrp1.deja.com>, vogler123 at my-deja.com wrote: > Sorry to bother you all but I ran into a problem and after searching > the archives on comp.lang.python I came up empty handed. > > I finally upgraded to python1.5.2/tk8.3/tcl8.3 on WinNT from python1.4. > I went ahead and built python the following projects in Visual C++ 6.0 > as per instructions: > > python15 > python > _tkinter > > Everything went as planned and I tried the following: Found the problem. I recompiled python with tk8.0/tcl8.0 instead of 8.3 and it works as expected. I guess the latest release of tcl/tk does not work with python1.5.2?????????? Bill > > C>python.exe > >>> from Tkinter import * > >>> root = Tk() > > I then got an "Application Error" dialog message stating that "The > memory could not be "read". Debugging the application resulted in the > following error message: > > "Unhandled exeption in python.exe (TK83.DLL) 0xC0000005: Access > Violation" > > Does anyone out there in Python-land know what I am doing wrong? > Everything else appears to be working fine (tried out testpy.py). It > appears to be a problem with Tcl/Tk. > > TIA > > Bill Vogler > > PS - please also respond via email also > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com Tue May 9 13:36:01 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 09 May 2000 11:36:01 -0600 Subject: Python on 64 bit/IA-64 ... References: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> Message-ID: <39184C81.48F9689B@roguewave.com> I'm assuming Python will run more or less out of the box on ia64 *nix systems, Win64 might be more of a challenge though... (anyone have a native compiler yet :-) As long as you remember that long long is spelled __int64 you should be well on your way. The MS compiler is relatively good and much faster than the Intel elc compiler (and we've seen occational problems with complicated c++ code with the Intel compiler -- not something that should affect Python though...) Since we've had to work in a cross compilation environment, I've personally only used Python on the 32 bit client -- occationally having Python write bat scripts that are run on the win64 machine... (it also seems to help stability -- kind of interesting though when win is more stable than *nix on a platform ) -- bjorn Shiv Shankar Ramakrishnan wrote: > Hi, > Has there been any work done to make Python take advantage of a full 64 > bit environment? More specifically is anyone working on an Intel IA-64 > port of Python? > > In particular if one were to change the sources for this then which data > model would one follow - LP64 or LLP64 (P64)? Which model have people > used for existing 64 bit platforms if they did a port? > > AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited > precision (emulation). Floating points are m/c dependent but mostly > doubles. > > So this is what I think might be good for IA-64 - > > Pointers - All 64 bit. > Int - 64 bit. > Long - As it is now. > Floating Point - double (As now) or should it be long double? > > Making floating points long double will get better precision but then > the results might differ from the double based ones. > > Any comments? Also any general advice on doing a 64 bit port of Python. > Things to watch out for? Pitfalls etc ... > > Please note that I am not making any promises about an IA-64 port as > of now :-) > > Thanks, > Shiv > > P.S. If you something significant to say please cc a copy to me by > E-mail also. > > -- > http://www.python.org/mailman/listinfo/python-list From kuncej at mail.conservation.state.mo.us Tue May 23 10:16:43 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Tue, 23 May 2000 09:16:43 -0500 Subject: PIL>>> Image.open('f.GIF').save('f.jpg', 'JPEG') # ? References: <392A4E46.D7B93D86@darwin.in-berlin.de> Message-ID: > >>> im = Image.open('sample.gif') > >>> im.save('sample.jpg', 'jpeg') > Traceback (innermost last): im = Image.open('sample.gif') im = im.convert('RGB') im.save('sample.jpg','jpeg') --or-- Image.open('sample.gif').convert('RGB').save('sample.jpg','jpeg') From pointal at lure.u-psud.fr Thu May 25 07:07:20 2000 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Thu, 25 May 2000 11:07:20 GMT Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> Message-ID: <392d08fe.185503740@news.u-psud.fr> On Wed, 24 May 2000 08:18:03 +1000, "Arnold deVos" wrote: >: The real problem is that a module exports all the symbols it has imported. >: This sometimes creates a chain of unintentional dependencies between >: modules - a bit like the sort of thing that happens with .h files in C. >: >: e.g. if I forgot to import string, my code might still work because I import >: x that imports y that imports string. No amount of testing can reveal this >: error. Later someone changes the implementation of y, removing string. >: Later still, I run my previously tested code and the error is unexpectedly >: (confusingly) revealed. In our modules, we use the following syntax to avoid publication of imported symbols (copied from... I dont remember which Python source): import string _string = string del string And we always prefix string operation functions by _string. A+ Laurent. --- Laurent POINTAL - CNRS/LURE - Service Informatique Experiences Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 email : pointal at lure.u-psud.fr ou lpointal at planete.net From tismer at tismer.com Mon May 29 05:26:37 2000 From: tismer at tismer.com (Christian Tismer) Date: Mon, 29 May 2000 11:26:37 +0200 Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> <39311C09.75F70C54@tismer.com> <8gsakr$827$1@nntp.Stanford.EDU> <8gsan2$82n$1@nntp.Stanford.EDU> Message-ID: <393237CD.EDEBEF35@tismer.com> Amit Patel wrote: > > Amit Patel wrote: > | > | Actually what I'm envisioning is that the __parent__ is not the > | caller, but the namespace of the function that defined the current > | function: > | > > Oops, sorry, I missed where you wanted dynamic scope. I'd much rather > have lexical / static scope, so that's what I had in mind when I wrote > up the __parent__ thing. Oh, I see. Well, with lexical scope, you will of course have a problem with cycles. I thought of dynamic scope since it appeared quite natural to me, and I could implement it right now. What would be better for the language, dynamic or lexical? I really don't know, please tell me your thoughts. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From dale at out-think.NOSPAMco.uk Thu May 18 20:47:02 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 19 May 2000 01:47:02 +0100 Subject: How to get volume name under Win32? References: <8g1tn6$cf2$1@supernews.com> Message-ID: <8g22uh$ds3$1@supernews.com> That's excellent. Thanks In article <8g1tn6$cf2$1 at supernews.com>, "Dale Strickland-Clark" wrote: I can't find a function that'll tell me the volume name for a given drive letter - on NT / Win2000 Can anyone help? #=================================== # not sure why it's in win32api and not win32file import win32api vi = win32api.GetVolumeInformation("c:") print vi[0] # see microsoft docs for GetVolumeInformation details #==================================== can't post to c.l.p; news.pacbell.net is way sick and deja.com is offline, so here's an email instead good luck! d Dirck Blaskey Danbala Software http://www.danbala.com -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Dale Strickland-Clark wrote in message news:8g1tn6$cf2$1 at supernews.com... > I can't find a function that'll tell me the volume name for a given drive > letter - on NT / Win2000 > > Can anyone help? > > Thanks > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > > > From python at channel21.com Wed May 10 15:37:56 2000 From: python at channel21.com (Channel21 Python Team) Date: Wed, 10 May 2000 15:37:56 -0400 Subject: Custom adduser function... Message-ID: <81DD38F43381D111BA3E00A076A0998A45A05C@XENON> if I pass it the crypted passwd, how do I know what to salt it with? > ---------- > From: Jeff Bauer[SMTP:jbauer at rubic.com] > Sent: Wednesday, May 10, 2000 2:49 PM > To: Channel21 Python Team > Cc: 'python-list at python.org' > Subject: Re: Custom adduser function... > > Channel21 Python Team wrote: > > for some reason, the -p option does not actually > > set the password to what we think it is. I.E., if > > you run "/usr/sbin/useradd -p passwordval usernameval" > > it doesn't actually set the password to passwordval... > > Ah, the useradd command wants the encrypted [crypt(3)] > password passed in as an argument. You can modify > the earlier code to pass in the encrypted password > or create the account without a password and use > os.popen to set it via the passwd command. > > -Jeff > From guido at python.org Thu May 18 23:40:18 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:40:18 GMT Subject: Converting strings to hex References: <8g20r4$ru6$1@supernews.com> Message-ID: <3924E204.CE01CA0A@python.org> Dale Strickland-Clark wrote: > > The output from MD5.digest() is a 16 byte binary string. > > I want to convert it to hex for printing. It's hard to beat this, which uses only built-in operations: def hexify(s): return "%02x"*len(s) % tuple(map(ord, s)) -- --Guido van Rossum (home page: http://www.python.org/~guido/) From paulb at infercor.no Fri May 12 10:54:40 2000 From: paulb at infercor.no (Paul Boddie) Date: Fri, 12 May 2000 16:54:40 +0200 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <8f9bok$b7n$1@nnrp1.deja.com> Message-ID: <391C1B30.C5FFEE5E@infercor.no> andrich at my-deja.com wrote: > > Hi, > > well I don't know what the problem of some people is. But go and get a > dictionary. Search for rhetoric and then reread my message. At least my > Oxford and my Webster provide the valid explanation of this word. > > If we could leave this stuff out and discuss the topic, I would be more > then happy. Indeed. I don't read comp.lang.python to read about Perl. As for the suitability of your Linux distributions, I can honestly say that I haven't used them, but I can see the continued need for binary versions of Python for several platforms for the following reasons: * Python doesn't even come with every Linux distribution out there - the Corel Linux download version didn't seem to have it when I checked. * Many operating systems don't come with a (working) C compiler. Installing a C compiler isn't always something that people want to get involved with. * Some people want to use Python on operating systems where they can't access a C compiler. CGIPython is one attempt to meet this need. * New users in particular shouldn't need to get deeply involved with installing software they just want to use. I am familiar with the './configure' then 'make' then 'make install' process and the complications, but I imagine that most people are not. I needed a binary version of Python about 18 months ago for the Solaris machine that I use, but then I got round to installing GCC. I can imagine that such binaries would be useful for others, though. Paul From jraddockNOjrSPAM at hotmail.com.invalid Thu May 18 14:25:54 2000 From: jraddockNOjrSPAM at hotmail.com.invalid (JRHoldem) Date: Thu, 18 May 2000 11:25:54 -0700 Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> Message-ID: <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> My point was not that "world's funniest home videos" is *better* than "Masterpiece theatre" or anything on the Discovery channel. My point was that people should consider their choice of words and that *better* is very ambiguous as (your superlative here) can apply to numerous scenarios within the same comparison differently... Does WFHV reach a broader audience base - yea - are they uppity and "englightened" prolly not, but what does that have to do with better. .. Back to the topic of the thread...I think in some ways Java is *better* simply because the industry supports and accepts it more (although thanks to members of this community Python is becoming more widespread [that's why I'm here now{tx Glyph}]). I don't claim to be a python expert by any stretch, however I know alot about developing marketable software that needs to be accepted by a broad audience. Certainly mainstream support from a market "leader" (and I use the term loosely in this case) like Sun should be a factor in choosing your platform... Programming is not a pure art in today's world, if it was then maybe we could realistically compare Java and Python based on pure performance standards. However, marketability, support and breadth of knowledge base are all things any IT manager needs to consider when picking the *best* software platform. tired-of-code-freeze-need-a-good-goddamn-project-before-i-play- more-poker-the-bad-bad-man, JR P.S. Remarq is screwing up my Email address. For those who want to continue any part of this conversation in email, I'd be glad to learn and teach...jraddock at hotmail.com * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From thomas at xs4all.net Sun May 21 17:59:37 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 21 May 2000 23:59:37 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <000101bfc351$56439460$e92d153f@tim>; from tim_one@email.msn.com on Sun, May 21, 2000 at 02:21:09PM -0400 References: <000101bfc351$56439460$e92d153f@tim> Message-ID: <20000521235937.P13281@xs4all.nl> On Sun, May 21, 2000 at 02:21:09PM -0400, Tim Peters wrote: > I haven't used Alice. The counter-argument I've heard from some who have is > that this was much more a problem with Alice than with Python, in that Alice > exposed various predefined modules and classes with LongAttributeNames but > in a variety of distinct styles: case-sensitivity hurt because the graphics > methods used case inconsistently in their names, and nobody could keep all > its idiosyncracies straight. With benefit of full ignorance, I have to say > that sounds more plausible to me than that humans are baffled by > *consistent* use of mixed case. Amen to this. Wether it's true or not, I have a *very* hard time believing people have trouble with the fact that a != A. The rule is very simple, and very pythonic: if it looks different, it *is* different(*). Let-the-tool-fix-the-user--not-the-language-ly yr's, (*) Excuse my ignorance if I offended any UTF/UCS or whatever character interpretation dingus, with that remark :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From senn at maya.com Wed May 17 09:43:01 2000 From: senn at maya.com (Jeff Senn) Date: 17 May 2000 09:43:01 -0400 Subject: Stackless/microthreads merge news In-Reply-To: Glyph Lefkowitz's message of "16 May 2000 17:09:57 -0500" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <3921A17C.F995CEFB@tismer.com> <043ee7d0.5c606b3d@usw-ex0101-008.remarq.com> Message-ID: Glyph Lefkowitz writes: > ObOnTopic -> One thing that's been bugging me lately though; Java is > definitely faster than python, but Python and Java both use virtual > machines. The difference, as far as I can tell, is that Python > objects (namespaces, classes, class instances, etc) are actually all > *hashtables*. Java's are similiar to C structs, at least in how bytes > are arranged, linked, and accessed. Java's speed advantage is > significant, but from what I've seen so far, it doesn't seem to be the > massive leap beyond python that I'd expect. > > Is there a good technical reason for this, or is it just a poor > implementation? I haven't had a chance to read enough of Python's > sources yet, I guess, but is it doing any tricks with attribute access > to make them faster than regular hashtables? (or is my estimation of > the speed difference really just erroneous?) > > The obvious next question is "if not, why not?" but I think I > understand that, if it's the case ^_^. Hm...I haven't actually tested -- so this is speculation based on experience and tests of similar scriptable/VM systems in the past. I suspect that many of the extra cycles in Python are in heap management -- in Python objects tend to be small and contain more pointers to other things. A Python object that has 3 integer members is (at least) 4 allocations. There is overhead in both size and (more significantly) number of heap alloc/deallocations -- however the power you buy back is being able to say: any_random_object.never_before_mentioned_name = any_kind_of_thing Additionally there is the JIT issue ... which I'm not sure I have a good intuitive grasp on -- and the fact that, since Python has function pointers (and uses them!) a lot more (run) time is spent hunting for the correct bit of code to execute. But, as you say, the differences are not vast. I suspect that if Python had the resources of a Sun or MS behind it, it would get pretty fast -- but probably never as fast as a language w/o some of the "features" that Python has. -- -Jas MAYA Design From effbot at telia.com Wed May 10 14:57:34 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 10 May 2000 18:57:34 GMT Subject: Passing by value instead of reference References: Message-ID: Jeff Massung wrote: > >Then what would you expect your "test" function to do? > > Just print a different address. If test was: > > def text(x): > x=1 > > test(z) > print z > > I would want this to print the original value of z (5), not 1. >>> z = 5 >>> def test(x): >>> x=1 >>> test(z) >>> print z 5 hmm. what kind of strange python interpreter are you using? From alberanid at bigfoot.togli.questo.com Mon May 8 16:41:30 2000 From: alberanid at bigfoot.togli.questo.com (Davide Alberani) Date: Mon, 08 May 2000 20:41:30 GMT Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> Message-ID: Charles Boncelet wrote: > > I have no idea why the colors vary. probably it's the 'background' option. Put: set background=dark in your vimrc, and check if its value is modified in others places. :set background? to see how it's set. > Or, does anyone have a python syntax file of which they are > proud and willing to distribute? Hmmm... I add only these two lines on top of my python.vim: set expandtab set ts=4 -- Cinereview: Mission to Mars: Disgusto! Pessima regia ed _/Davide\_ interpretazione, noiso, stupido e scontato. Ma Brian che \Alberani/ cavolo si e` fumato? Voto: 3 From DOUGS at oceanic.com Tue May 23 21:39:06 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Tue, 23 May 2000 15:39:06 -1000 Subject: Socket bug (maybe) Message-ID: <8457258D741DD411BD3D0050DA62365907A1A0@huina.oceanic.com> localhost == 127.0.0.1 not the address of any interface. Did you try that address? -Doug- > -----Original Message----- > From: Ryan Dhuse [mailto:dhuserya at msu.edu] > Sent: Tuesday, May 23, 2000 3:08 PM > To: python-list at python.org > Subject: Socket bug (maybe) > > > It really depends on your point of view rather or not you > consider this a > bug. When a socket is bound to '', it will accept > connections from any ip > address. When a socket is bound to 'localhost' , it will not accept > connections from any machine other than the local host. it > will only accept > connections to 'localhost' on the local machine. If you are > on the local > machine and try to connect by the ip address, it will fail. > > I realize the socket documentation says that '' represents > localhost, but I > would prefer if '' was equivalent to 'localhost' in all respects. > > Should this be reported as a bug?? > > - Ryan Dhuse > > > > -- > http://www.python.org/mailman/listinfo/python-list > From effbot at telia.com Tue May 9 11:01:47 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 15:01:47 GMT Subject: Python on 64 bit/IA-64 ... References: <006001bfb9a8$0338c680$8d02a8c0@intranet.pspl.co.in> Message-ID: Shiv Shankar Ramakrishnan wrote: > |Python should run out of a box on any IA-64 Unix; activestate is > |working on a Win64 port. > | > |(afaik, the current CVS version builds and runs under Win64) > > Is this available publicly? I mean is there at least a read only CVS > access? I couldn't seem to find anything on their site. I wasn't clear; it's in the official Python CVS repository: http://www.python.org/download/cvs.html > |it's platform/tool dependent. all sane platforms use LP64. > |microsoft doesn't. > > Yes I know. I was more worried about P64 platforms. Any idea which are > the other insane :) 64 platforms if any? I think maybe Solaris also uses > a 32 bit long. Or is that due to the fact that I saw that under maybe a > 32 bit only compiler? probably. the Single Unix Specification requires ILP32 or LP64, so if it's using some other 64-bit variant, it sure aint Unix(r). > |in CPython, a python int is a C long, which means that it's 64 bits > |on any sane 64-bit platform. a python float is always a C double. > > If only everyone in the world was sane :) Unfortunately the way MS has > gone, 64bit crossplatform development with Windows also in mind is going > to be a little bit of work. exactly -- I'm usually not microsoft basher, but this one really annoys me... From bragib at my-deja.com Wed May 10 10:44:29 2000 From: bragib at my-deja.com (bragib at my-deja.com) Date: Wed, 10 May 2000 14:44:29 GMT Subject: member by member copy??? Message-ID: <8fbska$4ti$1@nnrp1.deja.com> How do I copy on object into another without having them refer to each other. Example: >>> class A: ... def __init__(self,name): ... self.name = name ... >>> a = A('bragi') >>> b = a >>> b.name 'bragi' >>> b.name= 'stina' >>> a.name 'stina' I would have liked to see >>> a.name 'bragi' How do I do this? Sent via Deja.com http://www.deja.com/ Before you buy. From embed at geocities.com Wed May 3 11:52:53 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 3 May 2000 11:52:53 -0400 Subject: How do I ignitalize a list please? References: Message-ID: > > i = 1 > mags[0] = 0 > mags[1] = 1 > print mags[i] > The shortest way to initialize an array of constants: mags = [0,1] A nifty shortcut to initialize a larger array of any single value, zeroes, etc, would be: mags = [0]*99 Warren From eludlam at mathworks.com Thu May 25 09:19:03 2000 From: eludlam at mathworks.com (Eric Ludlam) Date: 25 May 2000 09:19:03 -0400 Subject: object browser in emacs References: Message-ID: >>> hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) seems to think that: >I just realized the folowing interesting thing: If you enable jde mode for >java, you can use the speedbar which lists objects in a convenient tree in a >separate window. Now if you edit python code it automatically lists python >objects (including all python modules in the directory). Really cool. > >Is the speedbar a part of jde-mode that happens to also work in python-mode, >or is it a language-neutral app? Can I ask python-mode to use it >automatically? Speedbar is a generic tool that is part of Emacs and XEmacs. The JDE tends to include or require newer versions of speedbar. Eric -- [====]___||. Eric Ludlam "The X Guy" The MathWorks x 7556 |[]| |= eludlam at mathworks.com (work) http://www.mathworks.com _|__|=====+ zappo at ultranet.com (home) http://www.ultranet.com/~zappo O-O-O[ ]\\ Trevor Shea Ludlam (son) Oct 16th 1999; 5lbs, 11oz, 18in From dan at cgsoftware.com Thu May 25 17:16:35 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Thu, 25 May 2000 14:16:35 -0700 (PDT) Subject: Python performance notes... In-Reply-To: <1BgX4.91233$R4.523653@news1.rdc1.nj.home.com> References: <392A2ED5.6A35B754@san.rr.com> <8gjcc1$nam$1@nntp9.atl.mindspring.net> <1BgX4.91233$R4.523653@news1.rdc1.nj.home.com> Message-ID: On Thu, 25 May 2000, Brett g Porter wrote: > > "Aahz Maruch" wrote in message > news:8gjcc1$nam$1 at nntp9.atl.mindspring.net... > > So? What's your point? Try writing the following code in C: > > > > import re,sys > > f=open(sys.argv[1]) > > s=f.read() > > f.close() > > words=re.split(s,r'\s') > > uniqWords = {} > > for word in words: > > uniqWords[word] = 1 > > for word in uniqWords.keys(): > > print word > > > > How long did it take you? Did it run as fast as the Python code? Was > > the overhead of the two loops here really a significant factor? > > here it is in C++. Took me about the same amount of time it woulda taken me > to write it in Python, actually... > Your point is well taken, nonetheless... Except your version will run *much* slower given a large dataset. map's are implemented using balanced tree algorithms, while the python example is using a hash table. > > // splitter.cpp : Defines the entry point for the console application. > // > > #include > #include > #include > #include > > > using namespace std; > > int main(int argc, char* argv[]) > { > ifstream f(argv[1]); > > string newWord; > map unique; > > while (f) > { > f >> newWord; > unique[newWord]+= 1; > } > > for (map::iterator i = unique.begin(); > i != unique.end(); ++i) > { > cout << i->first << endl; > } > > return 0; > } > > > From PClaerhout at CREO.BE Tue May 23 06:30:47 2000 From: PClaerhout at CREO.BE (Pieter Claerhout) Date: Tue, 23 May 2000 12:30:47 +0200 Subject: Saving remote event log Message-ID: <2B1262E83448D211AE4B00A0C9D61B0301301154@msgeuro1.creo.be> Hello all, I wrote a script that saves the Windows event log from a remote machine, and it looks like this: #!/usr/bin/env python import os import sys import win32api import win32evtlog if len(sys.argv) == 1: computerName = win32api.GetComputerName() else: computerName = sys.argv[1] evtLogSys = win32evtlog.OpenEventLog(computerName, 'system') win32evtlog.BackupEventLog(evtLogSys, 'system.evt') win32evtlog.CloseEventLog(evtLogSys) evtLogSec = win32evtlog.OpenEventLog(computerName, 'security') win32evtlog.BackupEventLog(evtLogSec, 'security.evt') win32evtlog.CloseEventLog(evtLogSec) evtLogApp = win32evtlog.OpenEventLog(computerName, 'application') win32evtlog.BackupEventLog(evtLogApp, 'application.evt') win32evtlog.CloseEventLog(evtLogApp) Local, it works fine, but when I try this on a remote machine, I get the following error message: Traceback (innermost last): File "evtlog.py", line 14, in ? win32evtlog.BackupEventLog(evtLogSys, 'system.evt') pywintypes.api_error: (0, 'BackupEventLogW', 'No error message is available') I think it has something to do with security, but I have however a drive mapped using administrative rights to that machine. Someone has any suggestions? Kind regards, Pieter From phd at phd.russ.ru Sat May 13 06:38:01 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 13 May 2000 10:38:01 +0000 (GMT) Subject: Best HTML module? In-Reply-To: Message-ID: On Fri, 12 May 2000, Jason Long wrote: > my best bet here? Python.org mentions ZTemplate from the makers of Zope > for tasks like this, but I couldn't find it on their site. ZTemplate was once a separate package, but since that it was incorporated deep into Zope. Now some zope users aretrying to split Zope distribution back into smaller packages. Until that, you need to download etire Zope sources and pull DocumentTemplate directory out of it. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From dima at xenon.spb.ru Fri May 19 18:23:58 2000 From: dima at xenon.spb.ru (Dmitry Rozmanov) Date: Sat, 20 May 2000 02:23:58 +0400 Subject: SQL SELECT question... References: Message-ID: <3925BEFE.A04536B3@xenon.spb.ru> I think your problem is that in SQL string literals are like 'string' not "string", and 'str%' instead "str*" for LIKE. At least I had such a problem at first. So try: "SELECT sf FROM st WHERE sf='ss'" or "SELECT sf FROM st WHERE sf='%s'" % "ss" Hope this helps. ---Dmitry. Rob Elder wrote: > > Hello, guys > > I'm struggling with using SQL with Python. One question please. How > should I structure the following operation using odbc: > > cursor.execute('SELECT someField FROM someTable WHERE someField="someString"') > > This does not work for me. How is this supposed to be structured? > > TIA. > > -r From torppa at polykoira.megabaud.fi Tue May 23 09:10:29 2000 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 23 May 2000 13:10:29 GMT Subject: bug report - time.strptime() References: <8gcva8+a9aq@eGroups.com> Message-ID: <8ge005$lt8$1@news.kolumbus.fi> In article <8gcva8+a9aq at eGroups.com>, Kevin Ng wrote: ... >Note the pattern is whenever the format string has no separation, >then strptime always return a date tuple of Jan 0 !? Here is the stripped down "guts" of strptime function: if (!PyArg_ParseTuple(args, "s|s:strptime", &buf, &fmt)) return NULL; strptime(buf, fmt, &tm); return tmtotuple(&tm); So it is propably your C-librarys strptime() that is broken/weird >My python version and platform : >Python 1.5.2 (#3, Jan 20 2000, 15:59:17) [GCC egcs-2.90.29 980515 >(egcs-1.0.3 re on linux2 Python 1.5.2 (#1, Jul 2 1999, 11:12:30) [GCC egcs-2.91.60 19981201 (egcs-1.1.1 release)] on netbsd1 >>> time.strptime('000201','%y%m%d') (2000, 2, 1, 0, 0, 0, 6, 1, 0) >>> time.strptime('20000201','%Y%m%d') (2000, 2, 1, 0, 0, 0, 6, 1, 0) -- Jarkko Torppa torppa at staff.megabaud.fi Megabaud Internet-palvelut From forum21 at euskaltel.net Mon May 1 12:56:42 2000 From: forum21 at euskaltel.net (Anton) Date: Mon, 1 May 2000 18:56:42 +0200 Subject: Are you looking for hardware or software? Message-ID: <8ekdgd$mnc$5@talia.mad.ttd.net> If you wish to buy a new hardware or software, would you like to be offered, for a whole month, different prices from professional sellers, in order to get the best deal possible?. (It's Free). Forum21. Free tool for buyers. http://www.forum21.net/english From chibaA at TinterlogD.Tcom Sat May 13 22:36:15 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Sun, 14 May 2000 02:36:15 GMT Subject: Arrgh! Please help. References: <391e07b9.88187366@news1.on.sympatico.ca> <54oT4.4117$wYl.206688256@newsb.telia.net> Message-ID: <391e0f88.90186331@news1.on.sympatico.ca> Yeah... it says the value is int - which obviously won't work. Is there any way to FORCE fields to be of string? Here's the way that I'm defining that dictionary: rv = {} rv['id'] = '3' etc., etc.. and it assigns it an INT.?? Thanks again, kc On Sun, 14 May 2000 02:20:49 GMT, "Fredrik Lundh" wrote: > wrote: >> I'm pulling my hair out as to why I get this error: > >it just means that value isn't a string. > >to figure out what value happens to be, try adding >the following debug statement: > >> For this code: >> if 1: >> print "Content-Type: text/html\n\n" >> print "whatever", >> oL = "" >> for key,value in rv.items(): > print type(value) >> oL = oL + value + "&" + "blah" >> print "blah", >> print "=", >> print oL > >... > >> And while I'm at it, is there any way to use consecutive print >> statements, and NOT have spaces in the output? ( I know comma gets rid >> of the \n, but not the spaces). > >how about: > >import sys >write = sys.stdout.write > >write("sp") >write("am") > > > > > From tim_one at email.msn.com Mon May 29 16:10:40 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 29 May 2000 16:10:40 -0400 Subject: Python vs. Ruby: threads - advice appreciated In-Reply-To: <393121B7.6A922591@smets.com> Message-ID: <000001bfc9a9$f724bfe0$b12d153f@tim> [posted & mailed] [Jean-Paul Smets] > I am currently comparing Python and Ruby for a personal project > which requires many many threads. > > I came across the "philosophers" example in Ruby and was surprised by its > compacity (see below). > I am wondering if it would be easy to write such an example in > Python with as few lines of code ? Fewer (Python doesn't require the noise "end" lines), but I won't show that -- approaching a large-thread project with masses of global vrbls and repeated inline fiddly arithmetic (to map integer ids to conceptual objects to conceptual properties of those objects via global arrays) is a dead end for maintainability. Instead I'll attach a Python example that uses its higher-level objected-oriented thread interface: treat a Philospher as an object, and then, e.g., it's natural and easy to give each Philospher named left_fork and right_fork objects, greatly increasing the readability of the code after initial setup. > Also, I tried to push Ruby to its limits (N=10000) and everything > went OK (50 Mo RAM was occupied though but this is only 5Ko per > thread which I find quite good). This almost certainly has much more to do with the operating system you're running on than with the language you use. A Python thread requires trivial overhead beyond what the underlying platform thread requires; don't know about Ruby, but suspect it's much the same there (if a language supplies a native thread, it can't require *less* burden than a platform thread demands!). Note that if your 5Kb/thread is accurate, and it includes space for the thread stack, your platform's threads are going to blow up if a thread does deep function calls (indeed, on most platforms it's a thread's stack that accounts for the bulk of a thread's memory burden). > I wonder if it is possible to go that far with Python, either with > native threads You didn't name your OS, so nobody can try a comparable experiment. The Python below invites 1,000 Philosophers to dinner, and ran fine without thrashing on an old 32Mb Win95 box. I know from experience I can't push this particular box much farther than that. > or with microthreads in stackless Python ? A Stackless microthread has much less overhead than a native thread (largely because it doesn't have to pre-reserve space for "a stack"), but note that Stackless is not part of the std Python distribution. > Finaly, I found that Ruby has a very nice and completely > transparent interface to Python libraries and extensions. So, > I am wondering now what would be the inconvenience for me of > switching to Ruby for my project. Beats me. Even if I understood the Ruby code, I would find the Python below much more readable, and for a large project that's of overwhelming importance to me. I don't know whether Ruby can be made comparably easy to live with, but suspect it probably can be. [the Ruby example] > # > # The Dining Philosophers - thread example > # > require "thread" > > srand > #srand > N=10 # number of philosophers > $forks = [] > for i in 0..N-1 > $forks[i] = Mutex.new > end > $state = "-o"*N > > def wait > sleep rand(20)/10.0 > end I personally hate this Perl-like "function calls don't require parens" gimmick. In Perl it can kill you. In Ruby, I don't know whether to parse that line as sleep(rand(20)/10.0) or sleep(rand(20))/10.0 although from *context* only the first makes any sense. > def think(n) > wait > end > > def eat(n) > wait > end > > def philosopher(n) > while TRUE > think n > $forks[n].lock > if not $forks[(n+1)%N].try_lock > $forks[n].unlock # avoid deadlock > next > end > $state[n*2] = ?|; > $state[(n+1)%N*2] = ?|; > $state[n*2+1] = ?*; > print $state, "\n" Surely this is buggy: unless Ruby has some implicit global function lock that serializes calls to philosopher, multiple threads can be mucking with the global $state string simultaneously, and so the output can be inconsistent. > eat(n) > $state[n*2] = ?-; > $state[(n+1)%N*2] = ?-; > $state[n*2+1] = ?o; > print $state, "\n" Ditto. > $forks[n].unlock > $forks[(n+1)%N].unlock > end > end > > for i in 0..N-1 > Thread.start{philosopher(i)} > sleep 0.1 > end What purpose does that sleep serve? > sleep Ditto. overkill-attached-ly y'rs - tim import threading, random, time # Number of philosophers. N = 1000 # Number of times a philosopher needs to eat. # Letting the program run forever is cute, but there isn't # that much food in the universe . EATME = 10 def wait(atmost=2): """Wait a random time, by default at most 2 seconds.""" time.sleep(random.random() * atmost) # Exception raised to let a philosopher know that she can't # get both forks. class ForksBusy(Exception): pass class Philosopher(threading.Thread): def __init__(self, id): threading.Thread.__init__(self) self.id = id self.left_fork = forks[id] self.right_fork = forks[(id + 1) % N] self.feedings = 0 def run(self): # Compare this main loop: using OO organization, the # logic is much less cluttered, and so correspondingly # easier to understand and extend. while self.feedings < EATME: try: self.think() self.acquire_forks() # may raise ForksBusy self.eat() self.release_forks() except ForksBusy: pass print "philosopher %d stuffed" % self.id def think(self): print "philosopher %d thinking" % self.id wait() def eat(self): self.feedings = self.feedings + 1 print "philosopher %d on feeding #%d" % (self.id, self.feedings) wait() def acquire_forks(self): self.left_fork.acquire() if not self.right_fork.acquire(0): self.left_fork.release() raise ForksBusy def release_forks(self): self.left_fork.release() self.right_fork.release() # Create the forks. forks = [] for i in range(N): forks.append(threading.Lock()) # Create the philosophers, and start their contemplative lives. philosophers = [] for i in range(N): p = Philosopher(i) philosophers.append(p) p.start() # Wait for everyone to finish. for p in philosophers: p.join() print "Dinner is complete." From bawolk at ucdavis.edu Sat May 27 18:04:18 2000 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Sat, 27 May 2000 15:04:18 -0700 Subject: am I stupid References: <392aaf19.3364062@news.ecs.soton.ac.uk> Message-ID: <39304662.EBD378AE@ucdavis.edu> Raw strings cannot end in a single backslash. John Carter wrote: > Or, > > How do I put a backslash as the last character in a raw string. > > See the text below, cut from idle, > > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > IDLE 0.5 -- press F1 for help > >>> a='hello\\' > >>> print a > hello\ > >>> a=r'helo\' > SyntaxError: invalid token > >>> a=r'hello\\' > >>> print a > hello\\ > >>> > > Note the line before SynaxError > > John Carter > jnc at ecs.soton.ac.uk From embed at geocities.com Tue May 23 11:38:16 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 23 May 2000 11:38:16 -0400 Subject: sample Finger client and server in Python? Message-ID: hi. i'm looking for a simple Finger sample code in Python. I'd like a simple client and a server. Any stuff out there? Warren Postma From mwh21 at cam.ac.uk Sun May 7 05:43:08 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 07 May 2000 10:43:08 +0100 Subject: GC... References: <39150B0E.F17C1621@san.rr.com> Message-ID: Courageous writes: > If two python objects mutally refer to eachother, but aren't > referred to globally in any current namespace, will they be > garbage collected? No. However, this might change; Neil Schemenauer has a patch that corrects this, but it probably won't be going into 1.6, as it's a bit of a fundamental change. Prospects are good for 1.7, though, and Chris was talking about merging it into stackless a while back... Anyway, you want to see: http://www.enme.ucalgary.ca/~nascheme/python/gc.html Cheers, M. -- 39. Re graphics: A picture is worth 10K words - but only those to describe the picture. Hardly any sets of 10K words can be adequately described with pictures. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From neilh at scintilla.org Tue May 23 21:05:36 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 24 May 2000 01:05:36 GMT Subject: Optional Underscores (py3k)? References: <392AD6CD.46838306@visionart.com> Message-ID: > with all the talk case insensitive python. i was thinking > about it and realized this is very similar to allowing > optional underscores on object names as well. Optional underscores in numbers would be much more useful to me. I think it was Ada that had this but grouping numbers is generally done in writen communication. timBotMemory = 100_000_000 or for Indic specific code timBotMemory = 1_0000_0000 Neil From beazley at rustler.cs.uchicago.edu Thu May 18 12:36:02 2000 From: beazley at rustler.cs.uchicago.edu (David M. Beazley) Date: Thu, 18 May 2000 11:36:02 -0500 (CDT) Subject: [Swig] Python/SWIG: Namespace collisions in multiple modules. In-Reply-To: <20000518154430.20898.qmail@web3001.mail.yahoo.com> References: <20000518154430.20898.qmail@web3001.mail.yahoo.com> Message-ID: <200005181636.LAA05897@rustler.cs.uchicago.edu> Jakob Schiotz writes: > Dear Python and SWIG gurus, > > > I am converting many of my C programs to Python modules using SWIG, > and am having two related problems. > > 1) How do I prevent namespace collisions if several modules contain > functions with the same name? > Hmmm. As far as I know, there are no namespace collisions between C modules provided they are compiled as separate shared libraries and loaded dynamically. Of course, this might be platform dependent. > 2) If the Python executable and several extension modules are using > the same library, how do I make sure they do not get separate copies > of it? The library is apparently using global data. > You will need to look into magic linker options and chapter 12 of the SWIG docs to make this work. However, the gist of the solution is that you need to make sure you link all of the extension modules against a shared library, that you use the SWIG runtime libraries, and that you use the -R or -rpath option (depends on the linker, platform, etc...). There are some examples of this in the docs and in some of the tutorials I've given on SWIG. > > Ad 2: > > I am having problems with the MPI library (Message Passing Interface, > a library for parallel programming). > > There is a complication with the this library: the initialization > function MPI_Init(&argc, &argv) MUST be called before the program > looks at its arguments. This means that it cannot be done in a module > imported by a Python script, as the python executable has to look at > its arguments to figure out what script to load. I have built a > modified Python executable which calls MPI_Init() just before calling > Py_Main(argc, argv). > This is what I've had to do with MPI in my own applications as well. > This works on the Compaq Alpha machines, and it worked under a > previous version of AIX, but with the new version of AIX (and a new > version of the MPI library) the extension module and the python > executable apparently get completely distinct versions of the MPI > library, so the extension module believes that MPI has not been > initialized, and crashes. Any suggestions? Can I somehow load the > entire MPI library into the Python executable and somehow be sure that > it is not linked into the extension modules as well? It might be possible to add libmpi.a to the link line that builds the Python executable (although you will probably just want to list it as libmpi.a not as -lmpi). Then make sure you link Python so that it exports all of its symbols (including MPIs). I know in our own application, the way that we solved this was to write our own abstract message passing interface that could be built on top of MPI or other similar libraries. We then compiled various versions of Python that included our special message passing API functions. Then, we built extension modules using only our custom API. This worked particularly well because we could just swap versions of Python to change message-passing libraries without recompiling any of the extension modules. The only tricky part was building different versions of Python (which required among other things, the MPI_Init() problem mentioned above). Hope this helps. Cheers, Dave . From pinard at IRO.UMontreal.CA Thu May 4 23:11:53 2000 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 04 May 2000 23:11:53 -0400 Subject: webpages in python In-Reply-To: root's message of "Thu, 04 May 2000 21:42:17 -0500" References: <3912348F.87F1CAA8@swt.edu> Message-ID: root writes: > I have already created webpages in HTML. Now since python is hot > nowadays I would like to make my site dynamic using python. > Where can I get the starting tutorials for creating webpages in python > or some similar help. I just made a few such HTML pages (quite a few, to be fair to myself! :-). Visit my Web page from the signature, select any project, then from the left margin, pick either `Browse' or `Folders'. All the pages from these two buttons are produced through Python scripts. Let me use `recode' for an example. When you click `Folders', it executes: http://www.iro.umontreal.ca/contrib/recode/web/babyl.cgi.in (with the @topdir@ substituted by some Makefile), which is merely a short trampoline, written in Python. The real work is done through: http://www.iro.umontreal.ca/contrib/recode/lib/config.py http://www.iro.umontreal.ca/contrib/recode/lib/babylweb.py http://www.iro.umontreal.ca/contrib/recode/lib/htmlpage.py and also relies on an HTML template file (for the margins and such) in: http://www.iro.umontreal.ca/contrib/recode/web/layout.html `babylweb.py' transform Babyl files or messages into HTML, it requires `htmlpage.py' to merge that produced HTML into a common layout. The short `config.py' holds the few definitions specific to each project, which are also referred to from the layout. I did these to get started fast, and it gives me a lot of results for a rather small investment, which is quite satisfying so far. However, it does not look unlikely to me that I'll throw these things out once if I ever learn Zope -- something to do when I'll be grown up enough :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From rhicks at nospam.rma.edu Fri May 26 11:25:31 2000 From: rhicks at nospam.rma.edu (Robert) Date: Fri, 26 May 2000 15:25:31 GMT Subject: Komodo IDE for Python References: <34575A892FF6D1118F5800600846864D35F538@intrepid> Message-ID: Not a lot of info on the site BUT it is cool that they are now talking about Python AND have given us a glimpse of their vision. Bob Simon Brunning wrote in message news:34575A892FF6D1118F5800600846864D35F538 at intrepid... > I just came across this - > 36.html> - at /. > > -- > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > The opinions expressed are mine, and are not necessarily those of my > employer. All comments provided "as is" with no warranties of any > kind whatsoever. > > > > From mlauer at trollinger-fe.rz.uni-frankfurt.de Tue May 2 07:25:19 2000 From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de) Date: 2 May 2000 13:25:19 +0200 Subject: Python Compiler References: <8F26DEAB4joshtinamecom@209.208.0.7> <8el3sd$h77$2@ites.inria.fr> Message-ID: <390ebb1f@nntp.server.uni-frankfurt.de> Cedric Adjih (adjih at crepuscule.com) wrote: > Josh Tompkins wrote: > > This is maybe a dumb question, but here goes: (donning asbestos underwear) > > What would be the difficulty of writing a real python compiler? Or maybe a > > compiler/interpreter similar to the one in VB? Leaving platform indepenacy > > and other similar concerns aside, what are the technical hurdles? Is it > > hard to write a compiler? Given proper pointers to tutorials and > > references I'd give it a shot, if it wasn't above my (low) level of > > programming skill... > The main problem I think is that Python data-structures are not > very well suited to compilation. Where one would have used > a C fixed array, Python programs would use a list, appending each time. > The poor compiler would have to guess whether all the elements are > of the same type, and whether the number of elements is fixed and > computable, and whether there are funky operations like a[1:5]=[None]. Wouldn"t this be much less of a problem when using C++/STL as the target language ? -- -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From dana at oz.net Thu May 11 01:56:06 2000 From: dana at oz.net (Dana Booth) Date: 11 May 2000 05:56:06 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> <391A2E7C.818CB3C5@san.rr.com> Message-ID: <8fdi1m$e09$0@216.39.141.21> Courageous wrote: C: I've ordered the _Essential Python Reference_, and I'm hoping that's C: lots better. The David Beasly book, _Python Essential Reference_, is really good if you're already fairly fluent in other languages. The library is covered in detail without a bunch of BS. It's very complete, but as the title says, it's a reference book, and so it is laid out more like a dictionary. Can't say enough about how helpful this book has been to me, anyway. -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From loewis at informatik.hu-berlin.de Mon May 29 11:33:36 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 May 2000 17:33:36 +0200 Subject: Bytecode References: <393259CC.EFA3DD1E@obop.com.pl> Message-ID: > Can I take pyc file to different computer and will it run ? Sure. The Python byte code format is the same on all machines. Regards, Martin From scarblac-spamtrap at pino.selwerd.nl Tue May 9 11:12:37 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 9 May 2000 15:12:37 GMT Subject: How to execute lists of code? Or alternatives. References: <8f94as$25n$1@nnrp1.deja.com> Message-ID: rzantow at my-deja.com wrote in comp.lang.python: > Is there a way to execute a list of Python code strings? 'exec' will probably do what you want. What I would love to have is to __import__ a module from a string. I don't think that's possible though. -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From tismer at tismer.com Wed May 3 19:16:29 2000 From: tismer at tismer.com (Christian Tismer) Date: Thu, 04 May 2000 01:16:29 +0200 Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F31A5.6452D256@tismer.com> <390F7CB5.8BD62851@san.rr.com> <200005032257.PAA11560@ESCHER.SD.BBN.COM> Message-ID: <3910B34D.EE9DDF29@tismer.com> Joe Kraska wrote: > > Christian Tismer wrote: > >Courageous wrote: > >> Quite. I corresponded with the Kiev implementors a while > >> back, asking them why they hadn't added continuations to > >> Java. They responded back with "impossible on the JVM". > > > >Ah, this is the elixier. Gimme more impossibles, and I'll fly. > > Well, of course what they meant was "impossible with > the current JVM". Their project set out to be JVM- > compatible. They implemented first class functions in > Java, closures, variadic argument support, and a variety > of other things and were still JVM-compatible. Given > the Lispishness of Kiev, I began to wonder if they'd > considered doing continuations. Continuations can be > very helpful in a modeling & simulation environment, > as it sometimes becomes necessary to do your own > scheduling in such environments. But they claimed that > the current JVM couldn't do it. That sounds much better. > Sure would be nice if it could! The problem appears to be similar to make Viper stackless. I discussed this with John Skaller quite some time ago. It is harder than for Python. Python already gives you frames, and the step to use them alone is quite in reach. Compiled stack machines are different, but I have a concept. Doing it generally, for "all C programs", would be nearly impossible without changing compilers, or with doing non-portable assembly hacks. Not so for a VM, there you have much more freedom, since you just have to keep the interfaces, but nobody dictates how you build your stack layout, if you are carrying a little additional info on each call, etc. With some thought, it is possible to add continuations, even if you still have a stack layout, with a few more info. Continuations that appear in the stack can create heap-like structures on demand, only if needed. Just see the stack as a special case of a heap, that happens to be allocated in invocation order in a large structure. This is fine for most cases and efficient. But we might want to break it if we need to do so. Well, that's all too early, there are a couple of hundred thousands of source code left for me to read... ciao - chris [no Michael, I'm going to write that book anyway, be assured:] -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From slinkp23 at yahoo.com Wed May 10 21:52:19 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 10 May 2000 21:52:19 -0400 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> Message-ID: <391A1253.BF50F9D0@yahoo.com> > Aaron Turner wrote: > > What I'd like to hear from people is what technical > > resons I should switch to Python. Are there any > > features that Python has (perhaps in it's OO > > offering) that Perl lacks? From what I can tell > > people tend to prefer Python over Perl mostly > > for its syntax, which I find very likable. Two big ones come to mind: using complex data structures, and modularizing your code. Both are much easier in python. Suppose you want to make a dictionary ("hash" in perl-land) using strings as keys and lists as values. In python it's simple enough that I can fire up the interpreter and get it right on the first try, like this: >>> friends={'Bob': [], 'Jane': ['Lisa', 'Mabel', 'Freddy'], 'Lisa':['Mabel']} >>> for name in friends.keys(): ... print name, "has these friends:" ... for f in friends[name]: ... print " ", f, ... print ... Bob has these friends: Lisa has these friends: Mabel Jane has these friends: Lisa Mabel Freddy In perl, doing this is so painful to me that I'm not even going to try it now, and it only gets worse as your data structures get more complicated. After that, I'd say the biggest advantage to python is that modularizing things takes no special effort at all (you just put the code in a separate file!), whereas you have to do quite a bit of fiddling in Perl. I also really like python's error tracebacks. I've never had to use the python debugger (admittedly, my projects are small). Many of my smaller scripts work right the first time I run them, and for the rest I just read the tracebacks. Took me a while to get used to understanding them, but now it's no trouble. What I miss from perl: I'd say using perl as a shell scripting language is faster. Python has all the same features but they're often implemented as functions or classes in the standard library, rather than as special punctuation, so there's more typing to do. And if you learn both languages from the O'Reilly "Learning P*" books, you have to get farther into "Learning Python" before you find out how to do those things, as compared to "Learning Perl". OTOH, you've learned a lot more about python than you have perl if you finish both books. ................ paul winkler .................. slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From m.faassen at vet.uu.nl Tue May 30 11:22:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 15:22:06 GMT Subject: What's in a name? References: <8h0d7u$5id$1@nnrp1.deja.com> Message-ID: <8h0mau$70i$1@newshost.accu.uu.nl> rzantow at my-deja.com wrote: [snip] > Wouldn't case insensitity make Just van Rossum just van Rossum? Ooh..you almost hit on *the* argument against case insensitivity that'll reach Guido! Case insensitivity will make Guido van Rossum equivalent with Guido Van Rossum And Guido definitely prefers the former spelling. :) though-it-doesn't-make-it-VanRossum-which-is-even-worse-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From debl.nospam at world.std.com Fri May 12 02:08:37 2000 From: debl.nospam at world.std.com (David Lees) Date: Fri, 12 May 2000 06:08:37 GMT Subject: Setting up PIL? Message-ID: <391B9FE1.DFE013B0@world.std.com> I just downloaded both the ZIP file and an exe for the Python Imaging Library, but have not been able to get either to work. Any pointers or advice? the EXE seems to install version 1.5.1 of Python along with PIL. I am already using 1.5.2. There seemed to be no option to only install PIL. The ZIP file appears to contain a more recent verson of PIL, but I have not been able to get it to work either. Instructions for installation and use seem to be lacking. I get an error on the import Image line of any scripts I try. David Lees From andymac at bullseye.apana.org.au Fri May 12 07:17:53 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Fri, 12 May 2000 21:17:53 +1000 (EST) Subject: Why should I switch to Python? In-Reply-To: <391A2E7C.818CB3C5@san.rr.com> Message-ID: On Thu, 11 May 2000, Courageous wrote: > I do really like Python, but the HTML documentation is begging for > a good technical writer, IMO. Fred Drake gladly accepts patches! -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From kc5tja at garnet.armored.net Tue May 2 16:02:56 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 2 May 2000 20:02:56 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil><20000430170952.A502@datapro.co.za> Message-ID: In article , Remco Gerlich wrote: >If you think Hungarian is useful in Python, could you give a list of useful >prefixes to use? Well, the original thread was on just Hungarian notation if memory serves me correctly. Nonetheless, I use Hungarian in an application specific manner, so no I can't give *specific* examples. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From aahz at netcom.com Mon May 15 13:40:42 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 May 2000 17:40:42 GMT Subject: Python Plans from ActiveState References: <51rthscplh93iuktpbn87lihguqo1rq5s8@4ax.com> Message-ID: <8fpcqq$7fk$1@slb7.atl.mindspring.net> In article , Mark Hammond wrote: > wrote in message >news:51rthscplh93iuktpbn87lihguqo1rq5s8 at 4ax.com... >> >> PYTHONPATH should be an environment variable, not a registry string. > >I disagree completely. This would be as bad as attempting to put Python >on the global path. It is hard to do across platforms. It prevents >multiple Python versions installed side-by-side (which is possible now - >just not via the default installer). I agree the registry sucks, but IMO >a global environment sucks even more! Correct me if I'm wrong, but environment variables are *not* global in my experience. To be precise, env vars are precisely as global under NT/Win98 as they are under Unix: they *can* be set up as global, but setting an env var in any process (including a shell) overrides the global for that process *and* all sub-processes (including processes spawned from a shell). Because scripts (both shell and other kinds) make it trivial to set env vars and launch programs, and because env vars are available on all OSes (AFAIK), it seems to me they're much better for cross-platform usage than a registry entry. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Internet $tartup$: Arbeit ueber alles --Aahz From rjroy at takingcontrol.com Thu May 25 17:28:27 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 25 May 2000 21:28:27 GMT Subject: XML to SQL or XML into Tables SomeHow References: <392e080f.1310806219@news.online.no> Message-ID: <392d99fa.68868109@news1.on.sympatico.ca> On Thu, 25 May 2000 11:11:32 GMT, thomas at cintra.no (Thomas Weholt) wrote: >Hi, > >I want to submit a special formattet xml, nothing more than xml based >on a specified DTD, to a module/script that "transforms" the xml data >to a valid SQL insert-statement. > >Ex. > > > > > > > > > > > > > > > > >
    >
    >
    > >I want an output like : > ># SQL-statements > >use test; >insert into person >(name, sex) >values >("thomas", "male"); > >insert into person >(name, sex) >values >("bill", "male"); > >insert into person >(name, sex) >values >("jane", "female"); > >################## > >Perhaps the entries must have a specified type like > etc. > >For simple insertion statements this shouldn`t that hard to do, but >I`m having a hard time locating the stuff to do it. > >I`ve looked at RAX, SAX, Pyxie etc. If somebody could give me a hint >on how to "transform" the example above I`d be happy to try and make a >more generic module out of it. I just need some help to get started. > >Thomas This is a quick and dirty implementation based on xmllib. I had to change one attribute name from xml-data to xml_data to comply with naming conventions though there are ways of getting around that. Hope this helps Bob ################### import xmllib, string class myparser(xmllib.XMLParser): def __init__(self): xmllib.XMLParser.__init__(self) self.currentdatabase = '' self.currenttable = '' self.currentitems = [] self.currentstatements = [] # self.currentdata = [] def handle_data(self, data): # self.currentdata.append(data) pass def start_xml_data(self, attrs): pass def end_xml_data(self): pass def start_database(self, attrs): self.currentdatabase = attrs['name'] def end_database(self): print 'use %s;' % self.currentdatabase print string.join(p.currentstatements, '\n') self.currentdatabase = '' self.currentstatements = [] def start_table(self, attrs): self.currenttable = attrs['name'] def end_table(self): self.currenttable = '' def start_row(self, attrs): # self.currentdata = [] pass def end_row(self): fields = [] values = [] for f, v, t in self.currentitems: if f: fields.append(f) values.append(v, t) fieldz = string.join(fields,',') valz = string.join(map(typemark, values), ',') stmt = 'insert into %s (%s) values (%s);' % (self.currenttable, fieldz ,valz) self.currentitems = [] self.currentstatements.append(stmt) def start_field(self, attrs): # if no field_name will ignore later self.currentitems.append((attrs.get('field_name', None), attrs.get('value', ''), attrs.get('field_type','string'))) def end_field(self): pass def typemark(value_type): v, t = value_type if t == 'string': return '"%s"' % v else: return v ### some test code data= """\
    """ if __name__ == "__main__": p=myparser() p.feed(data) p.close() From loredo at spacenet.tn.cornell.edu Thu May 11 13:53:20 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Thu, 11 May 2000 13:53:20 -0400 Subject: How to identify memory leaks in extensions? Message-ID: <391AF390.C419189A@spacenet.tn.cornell.edu> Hi folks- One of my extensions using NumPy arrays appears to have a memory leak. Do any of you more experience extension programs have any tips and techniques you'd care to share on identifying the source of memory leaks in a dynamically loaded module? I'm on a Mac and Solaris, by the way. I suspect the problem is that I haven't DECREF'd an ArrayObject correctly, but I don't find the NumPy documentation very helpful with advice on when to DECREF and INCREF (e.g., the "trace" and "matrix_vector" examples in Ch. 12 appear to my nonexpert eye to offer inconsistent advice on whether to DECREF an array created by PyArray_PyContiguousFromObject and only used within the extension). For the curious, the code is posted below if you'd like to offer specific rather than general advice. Either is appreciated! Thanks in advance for any help you can offer, Tom Loredo /*------------------------------------------------------------------------------ * Calculate the model metric & related quantities needed for the marginal * distribution for the nonlinear parameters. Return them in a tuple: * * (metric, L, rdet, P, A, S) * * metric = model metric (MxM matrix) * L = Cholesky factorization of metric (lower triangular MxM) * rdet = Sqrt of determinant of the metric * P = Projections of data on models (M vector) * A = Amplitude estimates (M vector) * S = Sufficient statistic * * The Cholesky algorithms are adapted from *Numerical Recipes*. ------------------------------------------------------------------------------*/ static char vba_metricAnalysis_doc[] = "metricAnalysis(dmat,data): Calculate the metric from the design matrix; get various derived quantities from it & the data via Cholesky."; static PyObject * vba_metricAnalysis (PyObject *self, PyObject *args) { int mdims[2], pdims[1]; int nmod, nsamp, a, b, i, m; PyObject *input1, *input2; PyArrayObject *dmat, *smpls; PyArrayObject *metric, *cfmetric, *proj, *amps; double *dmdata, *mdata, *cfdata, *diag, *pdata, *sdata, *adata; double sum, rdet; /** Parse the design matrix & data; make them contiguous. */ Py_TRY(PyArg_ParseTuple(args, "OO", &input1, &input2)); dmat = (PyArrayObject *) PyArray_ContiguousFromObject(input1, PyArray_DOUBLE, 2, 2); if (dmat == NULL) return NULL; smpls = (PyArrayObject *) PyArray_ContiguousFromObject(input2, PyArray_DOUBLE, 1, 1); if (smpls == NULL) return NULL; /** Check that their dimensions are consistent. */ if (dmat->dimensions[1] != smpls->dimensions[0]) { PyErr_SetString(PyExc_ValueError, "inconsistent data dimensions!"); return NULL; } /** Store the # of models & samples; make vector references to dmat & data. */ nmod = dmat->dimensions[0]; nsamp = dmat->dimensions[1]; dmdata = DDATA(dmat); sdata = DDATA(smpls); /** Calculate the metric. */ mdims[0] = nmod; mdims[1] = nmod; metric = (PyArrayObject *)PyArray_FromDims(2, mdims, PyArray_DOUBLE); if (metric == NULL) return NULL; mdata = DDATA(metric); for (a=0; a=0; m--) { sum -= *(cfdata+a*nmod+m) * *(cfdata+b*nmod+m); } if (a == b) { if (sum <= 0.) { PyErr_SetString(PyExc_ValueError, "metric is not positive definite!"); return NULL; } *(diag+a) = sqrt(sum); rdet = rdet * *(diag+a); } else *(cfdata+b*nmod+a) = sum/ *(diag+a); } } /** We have the factorization in the lower triangle and diag; *** replace the diagonal and zero the upper triangle. */ for (a=0; a=0; b--) { sum -= *(cfdata+a*nmod+b) * *(adata+b); } *(adata+a) = sum / *(cfdata+a*nmod+a); } for (a=nmod-1; a>=0; a--) { sum = *(adata+a); for (b=a+1; bdimensions[0]; cvdata = DDATA(covar); /** Find the inverse of the metric to use as covariances. First find *** the inverse of L; then multiply in place for the full upper inverse; *** then fill in the lower triangle. */ for (a=0; a Message-ID: <8gla4o$msn$1@nnrp1.deja.com> Pete Shinners wrote: > with all the talk case insensitive python. i was thinking > about it and realized this is very similar to allowing > optional underscores on object names as well. > if a user prefers the "Words Separated By Caps" style > (GetValue, ClearScreen) they are welcomed to it. but if > another user prefers "Words Separated With Underscores" > (get_value, clear_screen) Of course, what people mean when they write "GetValue" or "get_value" is really "get value". So when will we bite the bullet and dissolve this ambiguity forever by allowing whitespace in identifiers. Wouldn't you all want to be able to write: my bank account = my bank account + my salary Or why not: if ok to continue and has attr(the current node, "next"): only-half-kidding-ly y'rs // Niklas Sent via Deja.com http://www.deja.com/ Before you buy. From kc5tja at garnet.armored.net Tue May 2 07:25:50 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 2 May 2000 11:25:50 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil><20000430170952.A502@datapro.co.za> Message-ID: In article , Dave Abrahams wrote: >type({}) is types.DictType >type(UserDict()) is types.InstanceType See my other post on the ambiguities of the word "type." >It ain't obvious to me. >>>> PrintName( Foo() ) >The name is *** Allow me to re-iterate this, YET AGAIN: def PrintName( name ): print "The name is %s" % name Now, IN THE CONTEXT OF PrintName, 'name' is *obviously* a string. So it doesn't make sense to use Hungarian notation here. This is *precisely* what I'd written in the previous article. I *cannot* put it more bluntly than this. >Still if your listOfListOfNames represents a way to map latitude and >longitude to the names of cities, then "cityNames" or >"mapCoordinateCityName" might be a better name for it. Again, it all depends on the "type" of objects you're dealing with. If you're dealing with sets of coordinates, then calling it a list of list of X would be a little antithetical to the whole purpose of the notation, yes? >> pArgument = argv[2]; >And where's the unit cancellation here? char *argv[] defines argv as a vector of character pointers. >I don't think you're being fair to mathematicians and physicists by trying >to saddle them with responsibility for this nastiness. Since YOU are the one with the notion that this is somehow "nasty," it is YOU who are saddling them with the responsibility. *I* don't think Hungarian is nasty -- I see it as a tool a programmer can use to keep things straight in his head, and on paper, precisely as a Physicist would use units to keep things straight in his/her head. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From roy at popmail.med.nyu.edu Sun May 21 18:39:02 2000 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Sun, 21 May 2000 18:39:02 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: Ian Parker wrote: > I'd assumed the path to be case-sensitive only because it is running on > a case-sensitive OS, such as UNIX. On Windows NT and VMS the case > doesn't appear to matter. The fact that the case sensitivity of URLs depends on the underlying file system is actually a bit of a pain. I often see people develop web sites on Macs or PC's and then upload them to our Unix web server. All the case-mis-matched links that worked just fine on the Mac/PC are now broken. I prefer case sensitive, can live with case insensitive, but "maybe, depending on context" is terrible. From pinard at iro.umontreal.ca Sat May 13 21:02:29 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 May 2000 21:02:29 -0400 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) In-Reply-To: "Magnus Lie Hetland"'s message of "Sat, 13 May 2000 19:48:51 +0200" References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> Message-ID: "Magnus Lie Hetland" writes: > This is indeed a bit strange IMO... If I were to join the elements of a > list I would rather ask the list to do it than some string... I.e. > ['foo', 'bar', 'baz'].join(', ') Someone more knowledgeable than me could check, than confirm or inform. I think that usually, what was: string.FUNCTION(TEXT, ARG1, ARG2...) in 1.5 can be written: TEXT.FUNCTION(ARG1, ARG2...) in 1.6. That is, the _first_ argument in the functional writing becomes the object of the object-form writing. The fact that we have: string.join(SEQUENCE [, TEXT]) with TEXT not being the first argument, and even optional, is the source of the bizarreness. It shows to me that the `join' method is not really meant to be a string method, the string is just not the important object, here. The 1.6 writing does not look neat, and I would rather see `join' as a method of sequences, would it mean adding that method to all sequence types. I would also much like that `TEXT' remains optional: SEQUENCE.join() should return the string of sequence elements joined with spaces. The fact that that method returns a string is not a serious reason to make it a string method. A TYPE method does not have to return a TYPE object. Many methods return integers, tuples, or other things, this is not shocking at all. TEXT.join(SEQUENCE) always looked pretty awkward to my eyes. I hope Guido will revise this before committing 1.6. Else, it might soon become another lambda story! :-) Maybe that part of the problem is that the meaning of the word `join' is ambiguous, and disambiguated by prefixing it by `string'. The original problem might come from there: the prefixation is used in this case to "explain" the word `join', much more than to say which kind of object is mainly operated by the function. This is at least my opinion. We may disagree in various ways about what should be best done, but one thing we are probably agreeing upon is that having `join' as a method of string is not really proper. P.S. - Does someone knows if Guido read this group? If not, I would send a copy of this letter directly to him. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From emile at fenx.com Mon May 22 21:58:20 2000 From: emile at fenx.com (Emile van Sebille) Date: Mon, 22 May 2000 18:58:20 -0700 Subject: First different char in two strings? References: <3929CD50.3172F245@fenx.com> <005901bfc46f$843716c0$6401a8c0@home> Message-ID: <022e01bfc45a$6580bde0$1906a8c0@fc.fenx.com> Ah, but with only a minor mod, time it again: ;-) a = "abc"* b = a[:-1]+'l' for i in range(len(a)-1,0,-1): if b[i] != a[i]: break print i Life's-easier-when-you-get-to-select-the-test-case-ly y'rs, Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Darrell Gallion To: Cc: Sent: Monday, May 22, 2000 9:29 PM Subject: Re: First different char in two strings? > Emile wrote: > > But, being as I generally find that the obvious way is often the > > fastest, > > or close enough, here's the obvious: > > > > a = "this is a test" > > b = "this is not a test" > > for i in range(len(a)): > > if b[i] != a[i]: > > break > > print i > > > That was fun. The binary search won. > > Output: > 1499999 > 3.86000001431 Sec > 1499999 > 0.468000054359 Sec > 1499999 > 0.0939999818802 Sec > ########################################### > > import string, re > > s1="abc"*500000 > s2 = s1[:] > s2 = s1[:-1]+'l' > > def algo1(a, b): > for i in range(len(a)): > if b[i] != a[i]: > return i > return -1 > > > def algo2(a, b, pat= re.compile("("+"."*1000+")")): > aS = pat.split(a) > bS = pat.split(b) > offset=0 > for x in xrange(len(aS)): > if aS[x] != bS[x]: > i=offset+algo1(aS[x], bS[x]) > return i > else: > offset=offset+len(aS[x]) > return -1 > > def algo3(a, b): > aLen=len(a) > if aLen < 2: > if a[0] != b[0]: > return 0 > if a[1] != b[1]: > return 1 > return -1 > > aLen=aLen/2 > aL= a[:aLen] > bL= b[:aLen] > if aL==bL: > aH=a[aLen:] > bH=b[aLen:] > if aH==bH: > return -1 > else: > return aLen+algo3(aH, bH) > else: > return aLen+algo3(aL, bL) > > > import time > t1=time.time() > print algo1(s1, s2) > print time.time()-t1 > > t1=time.time() > print algo2(s1, s2) > print time.time()-t1 > > t1=time.time() > print algo3(s1, s2) > print time.time()-t1 > > > > From warlock at eskimo.com Tue May 23 01:59:36 2000 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 22 May 2000 22:59:36 -0700 Subject: Random numbers References: <000401bfc45d$882e46c0$9ea2143f@tim> Message-ID: On Mon, 22 May 2000 22:20:57 -0400, Tim Peters, in the persona of , brought forth the following words...: >[Russell Wallace] >> Is there any difference between the random number generator in the >> 'random' module and that in the 'whrandom' one? > >No, but you shouldn't use whrandom: whrandom is an interal implementation >detail of random.py. whrandom.py should probably be renamed to _whrandom.py >(or something) to stop people from tripping over it. > >> What's the quality > >If you know enough about random numbers to understand an answer to that >question, then telling you it's the standard Wichman-Hill (that's where "wh" >comes from) generator is all the answer you need . Seriously, test it >and determine whether it's adequate for your application; if you can't test >it objectively, then you have no way of knowing whether any other package is >adequate either (and neither does anyone else, so don't ask). > >Ivan Frohne wrote a very nice package of stronger generators, which should >be available from his Starship page. But unless you're doing extreme work, >WH should be adequate for a start. Any serious program relying on random >numbers should be tested with at least two distinct generators, though, and >Ivan's pkg is great for that. > >nothing-random-about-generating-random-numbers-ly y'rs - tim > > > As an aside, for those using linux, then /dev/random and /dev/urandom are good reseources for (very nearly) random numbers. -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From effbot at telia.com Tue May 9 14:08:26 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 18:08:26 GMT Subject: SOAP on Python? References: <8f9igd$j2r$1@nnrp1.deja.com> Message-ID: Stuart Zakon wrote: > A quick search of comp.lang.python, www.python.org, www.zope.org, and > www.pythonware.com turned up precious little on SOAP efforts in the > Python community. > > Given the fanfare at userland (http://soap.weblogs.com/) there should be > some mature efforts underway. > > Anybody have any links to ongoing projects? guess the search engine hasn't picked up the latest changes to our site... we plan to release a first public version of soaplib.py any day soon (it's currently being alpha tested). watch this space for more info: http://www.pythonware.com/products/soap for some more SOAP news, see the daily Python URL: http://hem.passagen.se/eff/url.htm From fedtke at my-deja.com Tue May 30 06:49:44 2000 From: fedtke at my-deja.com (fedtke at my-deja.com) Date: Tue, 30 May 2000 10:49:44 GMT Subject: ASP/COM-Problem Message-ID: <8h06c9$q29$1@nnrp2.deja.com> Hello, I try to run a ASP site with Pythoncode in it. The Pythoncode queries a database, does some formatting, etc. Sometimes the ASP-Application crashes and stops all Sites on the server. After that the Sites can not be started again, i have to reboot the machine. The System is: NT4 IIS4 Python 1.52 Pythonwin Build 127 I try to find out where the error occurs but i dont understand the error message in the event log. -------------------------------------------------- ------------- An object call caused an exception. (IID: {51372AEF-CAE7-11CF-BE81-00AA00A2FA25}) (Method: 3) (Microsoft Transaction Server Internals Information: File: i:\viper\src\runtime\mtxex\activity.cpp, Line: 889) (Exception: C0000005) (Address: 0x1e2a2ea9) pythoncom15!PyCom_HandlePythonFailureToCOM(struct tagEXCEPINFO *) + 0x69 ole32!DllGetClassObject + 0x77 ole32!CoCreateInstance + 0x6A asp + 0x23991 asp + 0x24DB3 asp!TerminateExtension + 0x3BFF asp!TerminateExtension + 0x32BC asp!TerminateExtension + 0x313B asp!TerminateExtension + 0x7AC9 asp + 0x326F8 mtxex!MTSCreateActivity + 0x1F3C mtxex!MTSCreateActivity + 0xF3E -------------------------------------------------- ------------- Thanks for every hint CF Sent via Deja.com http://www.deja.com/ Before you buy. From chibaA at TinterlogD.Tcom Wed May 10 15:49:17 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 10 May 2000 19:49:17 GMT Subject: HELP! Simple question re: dictionaries References: <3919b810.430052072@news1.on.sympatico.ca> Message-ID: <3919bd76.431433758@news1.on.sympatico.ca> I'll give it a shot - thanks! kc On 10 May 2000 20:34:09 +0100, Michael Hudson wrote: >chibaA at TinterlogD.Tcom writes: > >> Hi, >> >> I just want to write a for statement to go through each element of a >> dictonary. I would have assumed it would look something like this >> (argumentList being the dictonary): >> >> for ___ in argumentList: >> # whatever... >> >> ... but I'm not sure of the exact syntax. If anyone knows, could you >> let me know? Thanks! > >for key,value in argumentList.items(): > # whatever ... > >is pretty idiomatic... > >Cheers, >M. > >-- >34. The string is a stark data structure and everywhere it is > passed there is much duplication of process. It is a perfect > vehicle for hiding information. > -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From anthony at dstc.edu.au Wed May 3 20:37:35 2000 From: anthony at dstc.edu.au (Anthony J Wilkinson) Date: Thu, 4 May 2000 10:37:35 +1000 (EST) Subject: Using Fnorb with JPython & Orbix In-Reply-To: <39104A3B.3E2148F9@gte.com> Message-ID: On Wed, 3 May 2000, Gary D. Duzan wrote: > I don't believe this combination will work for you. Last I checked, > Fnorb's IDL parser and GIOP engine were implemented as C extension > modules, which JPython isn't going to like. If you can use CPython, > that should be fine. Or you could try making calls out to Java stubs > generated by Orbix (or some other Java ORB) from JPython. The cdr extension module is required to use Fnorb. Even if you get the stubs generated in CPython by fnidl or java with some other ORB you won't be able to use Fnorb from JPython. We will look into using JNI to enable this if there is demand for it. Regards, Anthony _____________________________________________________________________ Anthony J Wilkinson anthony at dstc.edu.au Software Engineer http://www.fnorb.com DSTC Pty Ltd Ph: +61 7 3365 4310 From sreekant at uklinux.net Mon May 15 21:48:17 2000 From: sreekant at uklinux.net (Sreekant Kodela) Date: Tue, 16 May 2000 01:48:17 GMT Subject: Python / CGI / E-mail problem Message-ID: <3920E594.F3F2E4CD@uklinux.net> Hi there I am trying to send automated emails to the people who joined the mailing list. I am using the smtplib and sending the mail but my users came back to me that they can see the code. I tried to mail it to my self and hotmail was ok but pop/kmail was showing the code. I am using the following method. Is there anything stupid I'm doing!! hdr='From: xxxxx'+smtplib.CRLF+'SUBJECT: xxxxxx'+smtplib.CRLF hdr2='StokZilla

    FreeMailingList

    ' hdr2=hdr2+'

    '+time.asctime(time.gmtime(time.time()))+'




    If there is any problem with the email / report etc \ please inform the webmaster from homepage or alternately mail the author.' hdr3='
    ' def makemsg(rep,ta): try: msg='' for n in rep: if len(n)>2: msg=msg+(''+`stripper(n[0])`+''+`stripper(n[1])`+''+`stripper(n[2])`+'') msg=hdr+hdr2+msg+hdr3 s=smtplib.SMTP('localhost') s.sendmail('stokzilla at localhost',"skodela at uklinux.net",msg) s.close() print '

    sending mail to '+ta except: pass Please help. Thanks Sreekant PS: Stripper() is just a return string.replace(string.strip(x),'"','') From mwh21 at cam.ac.uk Thu May 4 19:17:20 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 May 2000 00:17:20 +0100 Subject: Problems again on starship? References: Message-ID: bhoel at starship.python.net (Berthold H?llmann) writes: > There is a Problem !? fwiw, I can log in again. -- 39. Re graphics: A picture is worth 10K words - but only those to describe the picture. Hardly any sets of 10K words can be adequately described with pictures. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From Gareth.McCaughan at pobox.com Mon May 15 15:55:22 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 15 May 2000 20:55:22 +0100 Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> <86g0rkn4xc.fsf@g.local> Message-ID: <8666sf611x.fsf@g.local> Michael Hudson wrote: >> Michael Hudson wrote: >> >>> (let ((result ())) >>> (dotimes (i n) >>> (rplacd (last result) (cons i nil)))) >>> >>> is O(n^2), yet people still manage to program in Common Lisp... >> >> .. because they know that instead they can say >> >> (loop for i from 0 below n collect i) > > Quite. This *is* usenet, but does that really need to be said? > > Cheers, > M. > (who vows never to leave anything implicit in a usenet posting ever > again) I assume you're saying that my reply was superfluous and I shouldn't have bothered posting it. I'm evidently being stupid, because I don't understand why. - Because it's about Lisp, not about Python? Clearly you can't mean that, since it was you who brought the subject up in the first place :-). - Because everyone already knows what I said? On comp.lang.lisp, obviously that would be true, but hardly here. If I've committed some solecism, I'd like to know, so that I don't do it again... -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From m.faassen at vet.uu.nl Tue May 23 06:15:19 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 10:15:19 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gc0b6$eh4$1@newshost.accu.uu.nl> Message-ID: <8gdlnn$nju$5@newshost.accu.uu.nl> Neel Krishnaswami wrote: > Martijn Faassen wrote: [snip] >> I'd like to see something like that. For other inputs on this and >> other things, I think the algorithms part of C++'s STL may be worth >> investigating (keep the few neat bits, throw away the rest), and for >> a really out there thing I've recently been playing a bit with the >> language K (that is, I've read some of the manual), at www.kx.com >> K's a bit in the style of APL (though I don't know APL). All I've >> been doing is translating some of the operators to Python classes, >> but since I can't think in K yet I haven't accomplished a lot. :) > I've been meaning to learn J or K for a while. My interest was > intiated the language Charity. It was the claim of the Charity authors > that a large subset of interesting programs could be written as > compositions of a fixed set of combinator fns, and that programs > written in this way are much easier to optimize because you can have a > lot of information about the structure of the combinators. Charity is > really a toy language though (numbers are built from Peano's axioms!). Right, the same claims are made by the K people, it seems. You can highly optimize vector operations. > J and K are apparently languages that really stress this, *and* are > real languages, so I'm interested in learning one of them. However, > they look enough like line noise that I've put it off. I shall have to > rectify this RSN... One of the applications of K appears to be a database system that is way more compact and way faster than traditional databases. In fact, it sounds quite a bit like metakit, in that it's column based. They give this as an example of the power of K. K does looks like line noise, though. Very much so. :) And I've found that Python code is only 3 times as long or so, while being more readable. (and a lot slower) This from a very limited experiment! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mstenber at cc.Helsinki.FI Wed May 10 10:25:42 2000 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 10 May 2000 17:25:42 +0300 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> Message-ID: "Fredrik Lundh" writes: > note that future Python versions may also support > something like: > > for item1 in list1; item2 in list2: > ... > Ugh.. that looks bit obscure - why sudden use of ; for example? I'd like something like for item1, item2 in list1, list2: (Oo.) That'd be consistent with current tuple action as well, and just some appearance-related glue compared to the normal map(None, list1, list2) case. > but that's another story. -Markus > -- If you sat a monkey down in front of a keyboard, the first thing typed would be a UNIX command. -- Bill Lye From effbot at telia.com Mon May 22 11:00:25 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 22 May 2000 15:00:25 GMT Subject: Case confusion, or exception befuddlement? (was Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <392846F1.C89F7CED@Lugoj.Com> Message-ID: Nick Mathewson wrote: > Obviously, this is confusing. But is the problem in the case-sensitivity, > or in the error message? Suppose that instead, a newbie saw: > > Traceback (innermost last): > File "", line 1, in ? > NameError: No such variable as 'X'. > > Or even better: > > NameError: No such variable as 'X'. Did you mean 'x' instead? or the ABC way: >>> PUT 3 IN x >>> PRINT X There's something I can't resolve in your command PRINT X *** The problem is: you haven't told me HOW TO PRINT X okay, okay, I get the point... case-sensitive-ly yrs /F From thomas at cintra.no Thu May 11 06:46:59 2000 From: thomas at cintra.no (‘5ŰHH575-UAZWKVVP-7H2H48V3) Date: Thu, 11 May 2000 10:46:59 GMT Subject: Extract links from html-page Message-ID: <391a8ea7.100679489@news.online.no> Hi, I`d like to extract just the links in a web-page or html-document. It would be nice if relative links like 'Logo in a page at http://www.test.site.org became "http://www.test.site.org/source/test_pyt.tgz" in the end too, but ... The result should be a list of links. Thanks. Thomas From effbot at telia.com Sun May 21 05:32:49 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 21 May 2000 09:32:49 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> Message-ID: <53OV4.5071$wYl.214479360@newsb.telia.net> jpb wrote: > >Some quick answers: for case insensitivity, we'll have tools that > >enforce consistent casing (and maybe the case insensitivity will be in > >the tools alone). > > Please, let the insensitivity be in the tools, not the language. amen. From effbot at telia.com Tue May 16 14:18:22 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 16 May 2000 18:18:22 GMT Subject: python source -> ast References: <39218269.99B3B830@roguewave.com> Message-ID: Bjorn Pettersen wrote: > A while back I remember someone creating a module similar to the > 'parser' module, but created more 'intuitive' ASTs (i.e. not quite as > deep). > > I've searched at the vaults and python.org but couldn't find it... > Anyone have any pointers? iirc, it's part of python2c: http://lima.mudlib.org/~rassilon/p2c/ From mjhand at concentric.net Sat May 27 01:40:28 2000 From: mjhand at concentric.net (Manus Hand) Date: 27 May 2000 01:40:28 EDT Subject: python cgi browser detection??? References: <8gjabb$7f2$1@nnrp1.deja.com> Message-ID: <392F5EE0.E10D348E@concentric.net> Information on the browser that invoked your CGI script is available in os.environ['HTTP_USER_AGENT'] Hope that helps, Manus tiddlerdeja at my-deja.com wrote: > > I'd like to use Python for a CGI script which would detect the type of > browser a request has been made from and then return an apporpriate > response. > > E.g. If I get a request from IE5 I'd like to return HTML > If I get a request from a WAP browser, I'd like to return WML. > > Any information greatly appreciated. > > Sent via Deja.com http://www.deja.com/ > Before you buy. From jkraska1 at san.rr.com Sat May 6 02:27:01 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 06 May 2000 06:27:01 GMT Subject: Arg. Silly question! Message-ID: <3913BBF0.5F255D1E@san.rr.com> Okay, in all the documentation, I can't find the way that one goes about determining an object's type/ancestry. I have two different types of things that I want to do: 1. Figure out if an object is inherited from a particular class. 3. Figure out if an object is an instance of a particular class. Arg. I'm getting a headache. :) (And I ordered my copy of Guido's Essential Python 2 days ago, but don't have it yet). C/ From parker at gol.com Wed May 24 10:15:00 2000 From: parker at gol.com (Ian Parker) Date: Wed, 24 May 2000 14:15:00 GMT Subject: [PATCH] Identifiers with '?' References: <392a054a.556160620@news.nikoma.de> <8gep52$ik$1@nnrp1.deja.com> Message-ID: In article <8gep52$ik$1 at nnrp1.deja.com>, Uwe Zessin writes >In article , > Michael Hudson wrote: >> nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) writes: >> >> > On 21 May 2000 20:33:07 +0100, Michael Hudson >wrote: >> > >> > >Tee hee. I have on my machine built (in the last few days) a Python >> > >that allows one to use identifiers containing +, *, !, ?, & and @. >> > >This means you have to space your operators properly, but is IMHO >> > >quite a cool mod. I can clean it up and post the patch for that if >> > >anyone's interested... >> > >> > Why not add '$' to that to cater to people from the VMS (or even >> > BASIC) world? SYS$LOGICAL and all that (or whatever they look like). >> >> Easy as pie: >> >> [mwh21 at atrus build-aug]$ ./python >> Python 1.6a2 (#16, May 23 2000, 09:54:00) [GCC 2.95.2 19991024 >(release)] on linux2 >> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >> Copyright 1995-2000 Corporation for National Research Initiatives >(CNRI) >> >>> sys$logical = 1 >> >>> sys$logical >> 1 > >That would be a nice feature, because the $ is usually used in system- >defined names on OpenVMS. Can we ask (cry at) Guido to allow $s in >names? I don't want to put that into the OpenVMS port now and risk >an incompatibility if he decides to give the $ a different meaning >later. > >-- >Uwe Zessin > > >Sent via Deja.com http://www.deja.com/ >Before you buy. I second that (without implying, in any way, a vote). I'd certainly like to be able to use the $ on vms python. For me $ and _ seem natural characters to have in names, whereas I'd probably be horrified if, say, ! or ~ were allowed. Odd really. -- Ian Parker From fwang2 at yahoo.com Tue May 2 16:59:57 2000 From: fwang2 at yahoo.com (oliver) Date: Tue, 2 May 2000 16:59:57 -0400 Subject: ConfigParser question In-Reply-To: References: Message-ID: sorry, I found the silly error, should have used "from ConfigParser import *". thanks oliver On Tue, 2 May 2000, oliver wrote: > hi, > > here is a beginner question, I am testing out ConfigPaser module, and run > into error when I create the object instance, can anyone kindly point out > why? > > > >>> import ConfigParser > >>> x = ConfigParser() > Traceback (innermost last): > File "", line 1, in ? > TypeError: call of non-function (type module) > > oliver > > > > From sigvetj at stud.ntnu.no Mon May 22 09:38:56 2000 From: sigvetj at stud.ntnu.no (Sigve Tjora) Date: Mon, 22 May 2000 15:38:56 +0200 Subject: Dictionary COM object populated with custom COM-objects Message-ID: <3929386F.84404FDB@stud.ntnu.no> I have been trying to pass a dictionary from python to Delpi via COM. It seems like the supplied "Python.Dictionary" COM object only can be populated with strings. Is this true? Is there any way to pass a generic dictionary populated with python COM objects from python to a COM-aware application? I hoped that return etc.com32ext.wrap(myDictionary) #or what-ever that module is named :-) would work, but it didn't. Thanks in advance! Sigve, sigvetj at stud.ntnu.no From jraddockNOjrSPAM at hotmail.com.invalid Thu May 18 16:53:49 2000 From: jraddockNOjrSPAM at hotmail.com.invalid (JRHoldem) Date: Thu, 18 May 2000 13:53:49 -0700 Subject: Using ADO in Python References: <4D0A23B3F74DD111ACCD00805F31D8101D8BD0A8@RED-MSG-50> Message-ID: <016c03e0.4e5234e4@usw-ex0101-008.remarq.com> I'm not sure if this works the same, but I believe so (all of the ADODB I've done has been in ASP) Like Bill Hunter said, try using the .Open() method of the recordset object (instead of using an .execute() command to populate your recordset). I believe the basic argument structure is rstObject.Open(SQL,Connection) more complex is like rstObject.Open(SQL,Connection,CursorType,LockType) methinks... Hope I helped... the-very-hungry-just-ate-some-baskin-robbins-smoothie-want-some- more-bad-bad-man - JR * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From johngrayson at home.com Wed May 31 13:12:41 2000 From: johngrayson at home.com (John Grayson) Date: Wed, 31 May 2000 17:12:41 GMT Subject: Tk events References: <3933F9C6.F67412D8@mitre.org> Message-ID: <8h3h5u$g5j$1@nnrp1.deja.com> In article <3933F9C6.F67412D8 at mitre.org>, Peter Leveille wrote: > Does anyone know what the event name is for catching mouse movement > without a button pressed? Grayson's book "Python and Tkinter > Programming" mentions a PointerMotionMask for the Motion event, but I > can't find any more info on that mask. > Peter, I think Example_6_2.py demostrates this, and the event is also noted on page 618. However, this snippet tracks the motion of the mouse without a button down... from Tkinter import * root = Tk() def motion(event): print 'Mouse: x=%d, y=%d' % (event.x, event.y) frame = Frame(root, width=250, height=250) frame.bind('', motion) frame.pack() root.mainloop() John Sent via Deja.com http://www.deja.com/ Before you buy. From rtowster at emerging.com Thu May 11 16:54:26 2000 From: rtowster at emerging.com (Robert Towster) Date: Thu, 11 May 2000 15:54:26 -0500 Subject: SSL on Windows? References: <39152AC9.AFBCF2FA@studcs.uni-sb.de> <8fc03c$1eg$1@coco.singnet.com.sg> Message-ID: I need to do this too.. I DL M2Crypto windows binary release (0.4 because 0.5 release RSN) now I only need to do a SSL client (to hit an existing server). I started playing with the demos.. (specifically echo.py) I keep getting PRNG not seeded. (see traceback below) The line that apparently seeds PRNG is this: Rand.load_file('../randpool.dat', -1) I can change it so that it points to a different file and then the script will make the SSL connection and get the web page but it causes an invalid page fault in python.dll My ultimate destination is to make a script that will do a https post to a URL and get a response.. I can get a perl library to do this.. but.. I wanna use python =) ------------------------------------------ C:\Program Files\Python\Lib\demo\ssl>"c:\program files\python\python.exe" echo.py LOOP: SSL connect: before/connect initialization LOOP: SSL connect: SSLv3 write client hello A LOOP: SSL connect: SSLv3 read server hello A LOOP: SSL connect: SSLv3 read server certificate A LOOP: SSL connect: SSLv3 read server key exchange A LOOP: SSL connect: SSLv3 read server done A INFO: SSL connect: SSLv3 write client key exchange A Traceback (innermost last): File "echo.py", line 37, in ? s.connect((host, port)) File "C:\Program Files\Python\Lib\M2Crypto\SSL\Connection.py", line 81, in con nect return self._check_ssl_return(m2.ssl_connect(self.ssl)) File "C:\Program Files\Python\Lib\M2Crypto\SSL\Connection.py", line 48, in _ch eck_ssl_return raise Err.SSLError(Err.get_error_code(), self.socket.getpeername()) M2Crypto.Err.SSLError: SSLEAY_RAND_BYTES: ('10.11.75.10', 443): PRNG not seeded C:\Program Files\Python\Lib\demo\ssl> ------------------------------------------ Ng Pheng Siong wrote: > > According to The Dude : > > There is an SSL interface for Python. First you will need an SSL > > library, > > for example from www.openssl.org, then the SSL wrapper from > > http://home.att.net/~nvsoft1/ssl_wrapper.html > > You will need Perl for Win32 (http://www.activestate.com/ActivePerl) > > to install OpenSSL on Windows. > > > > M2Crypto at http://www.post1.com/home/ngps/m2 > > Gives you OpenSSL's crypto, SSL and S/MIME. > > > > Cheers. > -- > Ng Pheng Siong * http://www.post1.com/home/ngps From ben at co.and.co Sat May 27 08:03:36 2000 From: ben at co.and.co (ben at co.and.co) Date: Sat, 27 May 2000 12:03:36 GMT Subject: HowCanI: inlined exceptions References: <392EE821.714573DD@visionart.com> Message-ID: def foo(str): return str def baz(str): raise str def bar(str1,str2): return str1 + str2 def catch(function, list_of_argcs, error=None): try: return apply(function, list_of_argcs) except: return error a = catch(foo, ("blabla",), "Failed") print a b = catch(baz, ("blabla",)) print b c = catch(bar, ("blabla", "flafla")) print c Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From michael at stroeder.com Tue May 23 03:10:38 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 23 May 2000 09:10:38 +0200 Subject: urllib/ftpwrapper References: <959023972.859403@fezzik.endicor.com> Message-ID: <392A2EEE.ADB075A@stroeder.com> Kent Polk wrote: > > What would be a suggested method to allow outgoing port 20 connections > from a Python setuid'd server such as Medusa? Isn't it possible to bind to the privileged port 20 and do a setuid afterwards? Ciao, Michael. From benpark at my-deja.com Wed May 10 11:59:52 2000 From: benpark at my-deja.com (Ben Park) Date: Wed, 10 May 2000 15:59:52 GMT Subject: PalmPilot and python Message-ID: <8fc11i$9q8$1@nnrp1.deja.com> What prevent python from porting to Palm? Can someone explain it in a way that a non-expert understands? Palm has at least 2MB of memory. I bought a Mac SE about 10 years ago with 1MB which functioned beautifully. I still have it in my garage; a component of the video board burned. Sent via Deja.com http://www.deja.com/ Before you buy. From samschul at pacbell.net Thu May 11 19:40:46 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Thu, 11 May 2000 23:40:46 GMT Subject: Pythonwin com? Message-ID: <8ffgdr$840$1@nnrp1.deja.com> I have been trying to unravel the secrets of COM from Python! A few weeks ago I asked the following question and was able to solve the problem: Given the following VB script how do I get it to work under Python: DIM Frame as Variant ' Setup an array DIM dx as DocFile ' Get a DocFile Object DIM ex as NEW ExpSetup ' Get a ExpSetup Object DIM bRes as Integer ex.Start(dx) ' Do Experment dx.GetFrame 1,Frame ' Get The Data array ---- Modify Frame ---- dx.PutFrame 1,Frame ' Put the data back The following Python code Python code works: ex = win32com.client.Dispatch(Winx32App.CLSID) dx = win32com.client.Dispatch(DocFile.CLSID) Frame = {} # Here I have to set Frame up as a tuple ex.Start(dx) # Do experment, This works # This now works returning a tuple Array in Buff Buff = dx.GetFrame(1,Frame) # This does not work, I can not return the data dx.PutFrame(1,Buff) It appears that the data type returned is not compatable with the data type required for the PutFrame() function. The following definitions are returned in the Makepy file: def GetFrame(self, frame=defaultNamedNotOptArg, FrameVariant=defaultNamedNotOptArg): """Get Frame Data""" return self._ApplyTypes_(0xa, 1, (24, 0), ((2, 1), (16396, 3)), 'GetFrame', None, frame, FrameVariant) def PutFrame(self, frame=defaultNamedNotOptArg, FrameArray=defaultNamedNotOptArg): """Put Frame Data""" return self._ApplyTypes_(0xb, 1, (24, 0), ((2, 1), (16396, 3)), 'PutFrame', None, frame, FrameArray) Any ideas would be appreciated Sam Schulenburg Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Fri May 26 10:40:33 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 May 2000 14:40:33 GMT Subject: Buffer overflows? References: <392A348E.7E31DD58@stroeder.com> Message-ID: <8gm2d1$tck$1@slb7.atl.mindspring.net> In article <392A348E.7E31DD58 at stroeder.com>, Michael Str?der wrote: > >Some server software written in Python (e.g. Medusa) claims in its >documentation to be more secure than software written in C regarding >buffer overflows. > >Well, it's obvious that there are no problems with string buffers >(like strcpy() in C) within pure Python code. But many modules (e.g. >socket) are wrapping C code. How about these modules? Are there any >security reviews of the C code of the Python library? I haven't seen any response to this, so I'm reposting it in case it just got lost in the noise. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From rumjuggler at cryptarchy.org Wed May 24 23:48:18 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Thu, 25 May 2000 03:48:18 GMT Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> <392C4B4F.60C4@esatclear.ie> <392C7F0F.64BA39D0@cosc.canterbury.ac.nz> <392C8D19.28D7@esatclear.ie> Message-ID: On Thu, 25 May 2000 03:16:57 +0100, Russell Wallace wrote: >Greg Ewing wrote: >> I'd much rather have an honest, well-defined "wrap around" >> operator that I can rely on, even if I have to look up the >> language definition now and then, than have to wade through >> code that's been obfuscated to work around its absence. > >So define one. > >def wrapmod(x, y): > while x < 0: > x = x + y # simple implementation, could do it more efficiently > return x % y >From what I've seen of what negative modulo operators do, it seems as if def wrapmod(x, y): return (( x%y ) + y ) % y ) would work -- Barnabas T. Rumjuggler The world is turning into a cesspool of imbeciles. -- Harlan Ellison From hzhu at rocket.knowledgetrack.com Mon May 15 15:30:52 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Mon, 15 May 2000 19:30:52 GMT Subject: NaN again - and IEEE arithmatics References: Message-ID: On Sat, 13 May 2000 00:56:32 -0400, Tim Peters wrote: >Different machine sounds more plausible. Python itself knows nothing about >NaNs, and all visible behavior wrt them is a platform-dependent accident. > >THere's nothing you can do that's guaranteed to work. Here's a way to make >a NaN that's quite *likely* to work on any IEEE-754 platform, though: > >>>> Inf = 1e300**2 >>>> NaN = Inf - Inf >>>> NaN >-1.#IND >>>> Inf >1.#INF >>>> > >Since that was a Windows session, that's how Microsoft happens to spell NaN >and infinity these days. > Thanks a lot. It works on both: RedHat 6.1 egcs-2.91.66 Python 1.5.2 -> nan Solaris 2.7 gcc 2.95.2 Python 1.6a2 -> NaN >> So why isn't there a predefined class or object for NaN? > >Basically because IEEE-754 is primarily a hardware standard. The things it >defines may as well not exist if your *software* doesn't know about them. >In Python's case, Python is implemented in C, and it's C that provides no >portable way to get at this stuff. So Python can't either, at least not >without a huge pile of #ifdef's, one for each platform, and enough different >people volunteering with the right combination of platform + 754 expertise >to write all that crap. > >The next iteration of the C standard is supposed to address this. Then it >will be much easier to address it in Python too. In the meantime, you're >really on your own with this stuff, be it from Python, Perl, C, C++, >Fortran, ... > In the interim it might be worthwhile to implement temporary standard Inf and NaN objects for a few "popular" platforms like Solaris, NT and Linux: 1. It helps to standardize the name, useful for dumping or loading numbers. It would be easy to change when the "true standard" arrives in the future then would a hundred differently named hacks. 2. For users of other OSes it provides working examples of how such things are supposed to be done so they can implemente them in a more or less standard way. In any case I can live happily with the names nan and NaN, as I'm not affected by how MS changes names of things. -- Huaiyu Zhu hzhu at knowledgetrack.com From parker at gol.com Sun May 21 02:03:26 2000 From: parker at gol.com (Ian Parker) Date: Sun, 21 May 2000 06:03:26 GMT Subject: Python3k extended grammar References: Message-ID: <23QE0DA$u3J5EwhL@gol.com> In article , Robert writes >uggh...keep "return"...out with "->"...nuff said! > >As a newbie..."return" makes it much easier read and understand > >Bob > >Roy Katz wrote in message >news:Pine.GSO.4.21.0005181437530.2583-100000 at z.glue.umd.edu... >> Hi! >> >> (apologies in advance as to the applicability of this message to such a >> general group) >> >> >> I checked out the TYPE-SIG material.. It's really interesting. >> I agree that grammars which take into account the type of an object are >> in quite demand in Python; however, as a (practical) programmer I take >> offense at the creation of (yet) more keywords and operators. For >> example, take the function declaration grammar: >> >> def func( x: Integer, y: Integer ) -> Integer: >> >> what's the rational behind using the -> operator, rather than sticking to >> 'return'? >> >> def func( x, y ) return Integer: >> >> IMHO it's just another operator or keyword to bloat my language. >> Same thing with the proposed 'decl' operator. Why another keyword? >> What's wrong with the following: >> >> >> >> int = Integer >> def add( (int) x, (int) y ) # specifies type of the parameter >> return int; # specifies the return type >> raise exGenException: # specifies the exceptions thrown >> >> z = x + y # body >> return z # exit. >> >> >> No added keywords there. I understand that the above is more verbose, >> however, I believe this approach is vastly more consistent with the >> traditional grammar. Then again, this is only my personal preference. >> >> Another question: to whoever proposed the following notation: >> >> x: [ Integer ] >> >> what happens when we have a list of list of strings? >> >> x: [[ StringType ]] >> >> am I correct here? >> >> >> As I see it, we have a grammar spectrum with Pascal and Java on one side, >> (which places the burden on the programmer to declare, detail and >> categorize every little nuance), and perl on the other -- a language >> which IMHO is reconfigurable ad nauseum. (what kind of situation >> necessates changing the starting array index from 0, anyway?). >> >> >> >> Roey Katz >> Jewish Programmer. >> Oy. >> > > I'd prefer an alternate e construction: def integer func( x: Integer, y: Integer ): -- Ian Parker From abouf066 at aix2.uottawa.ca Tue May 2 11:06:49 2000 From: abouf066 at aix2.uottawa.ca (abouf066 at aix2.uottawa.ca) Date: Tue, 2 May 2000 11:06:49 -0400 Subject: How to get the list of imported variables/functions Message-ID: Greetings, Is there a way to know what variables/functions were imported from a given module after : from blah_blah import * Thanks for your time and help _____________________________________________________________ LaBoufarikoise From sreekant at uklinux.net Wed May 17 13:25:18 2000 From: sreekant at uklinux.net (Sreekant Kodela) Date: Wed, 17 May 2000 17:25:18 GMT Subject: Python / CGI / E-mail problem References: Message-ID: <39231A01.631B5446@uklinux.net> Oleg Broytmann wrote: > On Tue, 16 May 2000, Sreekant Kodela wrote: > > I tried using the MimeWriter but failed. Do you have any simple exampe by > > any chance. > > #! /usr/local/bin/python -O > > import sys, os, string > from mimetools import choose_boundary > from MimeWriter import MimeWriter > import base64 > > try: > from cStringIO import StringIO > except ImportError: > from StringIO import StringIO > > > def gen_mime(zip_file): > email_from = "Oleg Broytmann " > email_to = "phd at sun.med.ru" > > #sendmail = open("sendmail", 'w') > sendmail = os.popen("/usr/sbin/sendmail '%s'" % email_to, 'w') > sendmail.write("""From: %s > To: %s > Subject: %s > Precedence: bulk > MIME-Version: 1.0 > """ % (email_from, email_to, zip_file)) > > mime = MimeWriter(sendmail) > > firstpart = mime.startmultipartbody("related") > firstpart.write("""\ > Your mailer does not support MIME encoding. Please upgarde to MIME-enabled > mailer (almost every modern mailer is MIME-capable). > """) > > subwriter = mime.nextpart() > subwriter.addheader("Content-Transfer-Encoding", "base64") > subwriter.addheader("Content-Disposition", "inline; filename=\"%s\"" % zip_file) > subwriter.startbody("application/zip") > > zip_file = open(zip_file, 'r') > base64.encode(StringIO(zip_file.read()), sendmail) > zip_file.close() > > mime.lastpart() > sendmail.close() > > def run(): > zip_file = sys.argv[1] > gen_mime(zip_file) > > if __name__ == '__main__': > run() > > Oleg. (All opinions are mine and not of my employer) > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. Hi there Hope I'm not being a nuisance on this ng. I tried your way. At the end smtplib.SMTP('localhost').sendmail(to_address,from_address,???) What should I use in place of ???. I actually used a StringIO object to create the mime message. Should I use the os.popen() eventhough the ensuing code will end up on someone elses server! Thanks for the answers and patience Sreekant From adjih at crepuscule.com Mon May 29 08:16:09 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 29 May 2000 12:16:09 GMT Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <393004FA.846A54BF@mit.edu> Message-ID: <8gtn29$s8u$1@ites.inria.fr> Alexander wrote: > Michael Hudson wrote: >> Alexander writes: >> >> > Hi >> > >> > I have implemented loop in Python >> > >> > for k in xrange(1,100000000): >> > pass >> > >> > and the same one in C >> > for ( i = 0 ; i < 1e8; i++ ) ; >> > >> > and the second one seems to be working hundreds of times faster than the >> > first one >> > >> > Can I do anything with that. >> >> Well, it's an empty loop so it's pretty useless to all mankind. >> >> Is this /just/ a troll, or has Python's (relative) lack of speed >> bothered you? Yes, C can spin empty loops faster (especially if the >> optimiser removes the loop entirely...), but for doing most >> significant things, the difference is much less noticeable. > > Actually I've created array and did something like this : > > for k in xrange(1,10000): > for m in range(1,10000): > x[m] = .... #some calculation of the value of an array's element x[m] > > and this work's realy slow compared to C. I don't mind it working 3 times > slower, but .. > > Perhaps it is possible, to do something like implementing loops in C inside > Python ?? > (though it seems to me it will not help) You're right, Python is slow. That is fast to program with, but slow to run. For many cases, it is fast enough. For other cases, its speed is an issue, but programmer time is deemed more important. For other cases, one can profile, and write a C module (with the extension API, SWIG, CXX or SCXX), for the bottlenecks, when possible. If you need more speed than Python has (but not top speed), and something more clean than C++, you can try something in between, such as Java or Eiffel. -- Cedric From rol9999 at attglobal.net Tue May 9 07:09:35 2000 From: rol9999 at attglobal.net (Roland Schlenker) Date: Tue, 09 May 2000 11:09:35 +0000 Subject: Block comments? References: <391653B7.2F38A7F2@san.rr.com> <8f754o$flg$1@sunnews.cern.ch> <391772C6.69096697@san.rr.com> Message-ID: <3917F1EF.756CFFB7@attglobal.net> Courageous wrote: > Well, the """ """ works most of the time (a use for strings that I hadn't > thought of), but of course what I want is to disable arbitrary elements of > code without reformatting and the like. It seems that there isn't really > a full block comment notation, given when you CAN'T use strings. You can also use ''' ''' to comment out a section which contains """ """. if 1: ''' """ 'eggs' spam "ham" """ ''' pass Roland Schlenker From mwh21 at cam.ac.uk Sat May 27 05:59:36 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 May 2000 10:59:36 +0100 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> Message-ID: Alexander writes: > Hi > > I have implemented loop in Python > > for k in xrange(1,100000000): > pass > > and the same one in C > for ( i = 0 ; i < 1e8; i++ ) ; > > and the second one seems to be working hundreds of times faster than the > first one > > Can I do anything with that. Well, it's an empty loop so it's pretty useless to all mankind. Is this /just/ a troll, or has Python's (relative) lack of speed bothered you? Yes, C can spin empty loops faster (especially if the optimiser removes the loop entirely...), but for doing most significant things, the difference is much less noticeable. Cheers, Michael -- The "of course, while I have no problem with this at all, it's surely too much for a lesser being" flavor of argument always rings hollow to me. Are you personally confused by the meanings for "+" that exist today? -- Tim Peters, 29 Apr 1998 From Jan.Kybic at epfl.ch Fri May 26 12:07:39 2000 From: Jan.Kybic at epfl.ch (Jan Kybic) Date: 26 May 2000 18:07:39 +0200 Subject: Thanks for configure.in, was: Cross-compiling Python References: <392C156C.51EE84B6@quasar.ipa.nw.ru> <392DC5B5.BFCF48BD@quasar.ipa.nw.ru> <392E27F2.3BB0AA09@onera.fr> Message-ID: > Here's a configure.in I used to cross compile on SGI for NEC supercomputers. > You have to find out the AC_TRY_RUN and remove them. They are trying > to run a test on local platform. Great. It worked as it is. There were just two more things to comment out: AC_CHECK_SIZEOF(long long) and AC_C_CHAR_UNSIGNED which apparently call AC_TRY_RUN. So I can now cross-compile Python for ARM Linux on Psion S5. It crashes when run but that's another story. I hope to get this sorted out fast. Thanks again. Jan -- ------------------------------------------------------------------------- Jan Kybic BIG IOA DMT EPFL Lausanne, Switzerland or tel. work +41 (21) 693 5142 For PGP key see my WWW page. http://bigwww.epfl.ch/kybic From petersc at stud.ntnu.no Mon May 22 12:22:46 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 22 May 2000 18:22:46 +0200 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> <39271A25.A348E4B9@roguewave.com> <39295C88.EFEDE889@roguewave.com> Message-ID: <39295ED6.2EADA60C@stud.ntnu.no> Bjorn Pettersen wrote: > > But all those English keywords must be very confusing to people who do > not speak the language... I suggest we implement a global dictionary > that maps the language specific keyword names (or phrases, not all words > have a one-to-one mapping) to their canonical form... Just think, I > could spell the common pydiom (I'm assuming this was perfectly clear to That would be Really Nice(TM) but I am not sure in how far that is practical. I would be okay with internationalized grammars so I can compile a German version of the interpreter (maybe called wuerge_schlange). > as (with the Norwegian mapping...): > > s? lenge som 1: > linje = f.lesLinje() > hvis ikke linje: > brekk > ... > > hey, it's much easier for every Norwegian speaking person (and I'm sure > the f-bot can read it too ;-) As a matter of fact I can, too. ;-] But I would also really like to be able to write: solange 1: linie = f.leselinie() falls nicht linie: abbrechen This would help me a lot when teaching German children (8-14) how to program. hilsen-fra-trondheim-og-ha-det-bra-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From lars.lundstedt at telia.com Sun May 7 03:03:15 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Sun, 07 May 2000 07:03:15 GMT Subject: SV: win32all-129-update.exe - Is it needed? References: Message-ID: One slight problem though...I can't download the file because it doesn't seem to be there... Mark Hammond skrev i diskussionsgruppsmeddelandet:Wo5R4.13177$v85.87523 at news-server.bigpond.net.a u... > "Joe Smith" wrote in message > news:X73R4.44404$k5.1290605 at news1.frmt1.sfba.home.com... > > On the starship site is says: > > Also download and install the patch set for build 129 - > > win32all-129-update.exe (663,799 bytes) > > > > Is this needed if one installs win32all-129.exe? > > I thought the instructions were pretty clear? I can assure you I have > better things to do than release unnecessary patch sets :-) > > Mark. > > > From kc5tja at garnet.armored.net Thu May 4 05:35:16 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 4 May 2000 09:35:16 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> Message-ID: In article <8erd4a$ac1$1 at nnrp1.deja.com>, jschmitt at vmlabs.com wrote: >If your problems are solved by this kind of mindless busy work, you >have much bigger problems that any amount of hungarian notation will >ever fix. I good primer on writing maintainable code is recommended. >Try _Programming_with_Dick_and_Jane_. This beautiful piece of artwork deserves no other comment from me. I'll let the rest of the readership decide what type of person you really are. >Just so there's no question about attributions, I'm enclosing the whole >message that I'm replying to. I might add that that is an incredibly wasteful use of network bandwidth, and is not looked highly upon in common Usenet practice. Are you aware that a large population of Internet users still pay by the minute over relatively poor connections? If you wanted to unambiguously identify a message to which you are replying to, either quote specific chunks of text (the relavent parts), or specify a message ID. The cognizant reader will know how to use a usenet news archival site, such as Deja.com, to locate the article and read the original for himself. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From pinard at iro.umontreal.ca Wed May 24 11:52:32 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 24 May 2000 11:52:32 -0400 Subject: Good ideas :-), no time :-( In-Reply-To: "Neil Hodgson"'s message of "Wed, 24 May 2000 12:56:01 GMT" References: Message-ID: "Neil Hodgson" writes: > > So, I came with this "simple" idea, that we should have tools for > > converting Makefiles and shell scripts into specialised Python scripts. > > (And why not `sed' and `awk' as well, once on that road, the same as > > Perl once did.) > There are some interesting proposals for make replacements written in > Python [...] I know! :-) The goal behind the idea is automatically converting a Makefile, _hoping_ to get a more readable result. Automatic conversion always has its own idiosyncrasies, it is not easy to get clean results. Rethinking and rewriting Makefiles into `make' replacements might be a much more difficult task, and might not always be automated, I presume. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From sctheagn at kraken.itc.gu.edu.au Mon May 8 03:23:32 2000 From: sctheagn at kraken.itc.gu.edu.au (Joal Heagney) Date: Mon, 08 May 2000 17:23:32 +1000 Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <391645E3.3B850279@san.rr.com> <39165663.666406EB@san.rr.com> Message-ID: <39166B74.76828949@kraken.itc.gu.edu.au> Courageous wrote: > > "==" works just as well. Python smart enough to try a pointer > > compare first. The code path is almost the same so I doubt there > > would be much speed gained by using "is". > > Well that's cool. The next question is... > > Do all string constants which are lexically equivalent obey > the identity rule? IOW, does the python byte compiler know > how, upon compilation, to make two seperate instance of > "joe" point to the same single instance? I think this is true. Looking up my "Programming Python" book, I tested this with the 'is' operator. x = 'joe' y = x x is y gave 1. x = 'may' y = 'may' x is y gave 1. Trying this on lists x = ['joe', 'may', 'bob'] y = ['joe', 'may', 'bob'] x is y gave 0 y = x y gave ['joe', 'may', 'bob'] x is y gave 1. Joal Heagney/AncientHart From m.faassen at vet.uu.nl Mon May 15 04:39:26 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 May 2000 08:39:26 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> <8fhm9a$nk0$6@newshost.accu.uu.nl> Message-ID: <8fod3u$l2c$1@newshost.accu.uu.nl> tony summerfelt wrote: > On 12 May 2000 19:32:58 GMT, Martijn Faassen wrote: >> I'm not sure what you mean here. The effbot can occasionally be a bit >> snappy though! But gives far more directly useful answers than the >> timbot. >> I didn't think you were under attack? > whatever. Um, you must be in a bad mood, giving the answer 'whatever' to a polite note from me. You might want to work on your posting style a bit? > i suppose i could just score it out in my newsreader, but my better solution > is to just leave. less work, everyone's happy I suppose so. I must say you do seem a bit touchy, so it may be better for you. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aahz at netcom.com Wed May 10 09:51:31 2000 From: aahz at netcom.com (Aahz Maruch) Date: 10 May 2000 13:51:31 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> Message-ID: <8fbph3$g59$1@slb1.atl.mindspring.net> In article <3919D30A.74DE at seebelow.org>, Grant Griffin wrote: > >tom-christiansen-is-an-expression-of-_perl's_-personality- > -ly y'rs, By George! I do belive he Gets It. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Internet $tartup$: Arbeit ueber alles --Aahz From fiona at sitegnome.com Sat May 13 06:39:56 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sat, 13 May 2000 20:39:56 +1000 Subject: [FAQTS] Python Knowledge Base Update -- May 11th, 2000 References: <20000511143830.22000.qmail@synop.com> <391d1cbc.451350422@news.nikoma.de> Message-ID: <391D30FC.109D2616@sitegnome.com> > >Below are the entries from the newsgroup that I've entered into > > >http://python.faqts.com today. > > Is there any particular reason why nearly all of your article is > double-spaced? I find it a bit hard to read. I apologise for the double spacing -- this should be fixed soon... regards, Fiona Czuczman -- The Site Gnome http://www.sitegnome.com From case at ironwater.com Fri May 19 10:14:07 2000 From: case at ironwater.com (Case Van Horsen) Date: Fri, 19 May 2000 07:14:07 -0700 Subject: PostgreSQL from Python 1.5.2 References: <3924599A.9CEB3FB1@xenon.spb.ru> Message-ID: <39254C2F.E0C02F1E@ironwater.com> Use the Windows ODBC drivers for Postgresql (ftp://ftp.postgresql.org/pub/odbc/latest/) and mxODBC for Python ( http://starship.python.net/crew/lemburg/mxODBC-1.1.1.zip ). Case Dmitry Rozmanov wrote: > Hi. > > I'd like to connect to Postgresql on Debian Linux box from Python from > Windows95 box. All I have found it is PyGres module, but it contanes .c > file that must be compiled. I don't have any C compiler on windows. > > Please, suggest me something. > > Thanks in advance. > > ---Dmitry From parkw at better.net Mon May 15 18:13:51 2000 From: parkw at better.net (William Park) Date: Mon, 15 May 2000 18:13:51 -0400 Subject: location of home made modules In-Reply-To: ; from hzhu@rocket.knowledgetrack.com on Mon, May 15, 2000 at 10:01:28PM +0000 References: Message-ID: <20000515181351.A3758@better.net> On Mon, May 15, 2000 at 10:01:28PM +0000, Huaiyu Zhu wrote: > What is the standard place to put one's home-made modules? > How to get Python to know that place? I tried to put modules in > ~/lib/python/ with the following in ~/.pythonrc > > import sys, os > sys.path.append("%s/lib/python" % os.environ["HOME"]) > > This works in the interactive interpreter but does not get the module from > program files. Previously all my modules stay in the same directory as the > programs that load them so this problem did not manifest itself. > > > I can't find where in the docs this is mentioned. > Thanks for any pointer. > > -- > Huaiyu Zhu hzhu at knowledgetrack.com Use environment variable PYTHONPATH=~/lib/python or put the module in /usr/local/lib/site-python/... Python online doc explain this. Search for 'PYTHONPATH' or 'site-packages' or 'site-python'. --William From emile at fenx.com Tue May 23 13:16:35 2000 From: emile at fenx.com (Emile van Sebille) Date: Tue, 23 May 2000 10:16:35 -0700 Subject: First different char in two strings? References: <20000523170053.8398.qmail@web2006.mail.yahoo.com> Message-ID: <04fd01bfc4da$b5bf7000$1906a8c0@fc.fenx.com> Darrell, I knew before ever responding that the binary search would of course be the fastest. Originally, I was simply trying to make the point that without knowing what kind of strings you'll be comparing, or the range of possible strings anyway, that you can't design the right algorithm. In that case, the binary search is probably the right thing. But, for example, if you know that they're going to be long, and if they're different, it's likely to be in the first few bytes, then a different method may out-perform the binary search. It all depends on the data. Anyway, I resisted posting this yesterday: ;-) def algo5(a, b): return len(("".join(map(lambda a,b: str(a==b),a,b)).split("0"))[0]) But-it-gets-beat-by-the-binary-search-as-well-ly y'rs Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Darrell Gallion To: ; Sent: Tuesday, May 23, 2000 10:00 AM Subject: Re: First different char in two strings? > Emile wrote: > >Ah, but with only a minor mod, time it again: ;-) > >a = "abc"* > >b = a[:-1]+'l' > > > >for i in range(len(a)-1,0,-1): > > if b[i] != a[i]: > > break > >print i > > > >Life's-easier-when-you-get-to-select-the-test-case-ly > y'rs, > > I missed the meaning of the ";-)" > Then didn't read close enough the > "range(len(a)-1,0,-1)" > But your absolutely correct > "Life's-easier-when-you-get-to-select-the-test-case-ly > y'rs" > > Unexpectedly the binary search still wins. > Change "range" to "xrange" and it becomes faster. > ******** > 1499999 > 0.00999999046326 sec Reverse linear > 1499999 > 0.0900000333786 sec Binary search > ******** > > But the strings have to be the same length. > > > --Darrell Gallion > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Send instant messages & get email alerts with Yahoo! Messenger. > http://im.yahoo.com/ > > -- > http://www.python.org/mailman/listinfo/python-list > From slinkp23 at yahoo.com Thu May 11 13:27:58 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 11 May 2000 13:27:58 -0400 Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> Message-ID: <391AED9E.30C70EF@yahoo.com> James Felix Black wrote: > > > Two big ones come to mind: using complex data structures, and > > modularizing your code. Both are much easier in python. > > I won't dispute your second point, but I don't understand your first. The only explanation for this that I can think of is that you're a lot smarter than I am! Python: nesting data structures preserves the structure. Perl: nesting data structures flattens the structure, unless you use references. OK, that's not such a big deal; I could live with that, it's just a little more punctuation needed to make the structure, and it's not hard to read. It's getting stuff *out* of the data structures that I find to be radically different. (code snipped) > Sure looks similar, doesn't it? Not to me. The key line is this, in my version: for f in friends[name]: Your version: for $f (@{ $friends{ $name } }) { > Of course, the de-referencing of the > array reference looks bizarre, ^^^^^^^^^^^^^ Yes, it does. :) More to the point, I got too frustrated with staring at man perldsc and man perllol trying to understand it. Can you explain the meaning of each bit of punctuation on that line? Faced with something I thought should be simple, but took up 1200 lines in the perl man pages, I gave up. I got to like perl because it was easy; I gave up on it because I needed complex data structures and they were driving me crazy. I'm really honestly impressed that you can do it with no trouble, but I think a lot of people who need scripting languages will have a similar reaction to mine: "This is too hard!" -- ................ paul winkler .................. slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From shecter at darmstadt.gmd.de Fri May 26 05:23:17 2000 From: shecter at darmstadt.gmd.de (Robb Shecter) Date: Fri, 26 May 2000 11:23:17 +0200 Subject: Java vs Python References: <391F88EB.D25BB0F8@san.rr.com> Message-ID: <392E4285.D0F72C75@darmstadt.gmd.de> Courageous wrote: > > 1. Which is more maintainable ? > > Python. No comparison. I wonder about this. Python is much more maintainable in a practical way, because of the interpreter and reflective language features. A good Java IDE like IBM Visual Age can make up for most of that, though. The other issue is that Java is statically typed, and has the "interface" feature for clearly specifying an API. Since it's statically typed, excellent hyperlinked API can be automatically generated that tells client programmers all they need to know about how to use a library. Python's docs are also very good, but they're put together by hand, and occasionally lack details like the return value of a method, or a list of what exceptions it throws. This affects maintainability. So, this doesn't have so much to do with Python vs. Java per se, but the maintainability of a statically vs. dynamically typed language. - Robb From embed at NOSPAM.geocities.com Tue May 30 15:42:14 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Tue, 30 May 2000 15:42:14 -0400 Subject: Python sighting in the wild: Red Hat's Anaconda GUI installer Message-ID: I noticed while installing Red Hat Linux version 6.2 that their entire installation system is written in Python. Way to go Red Hat. I guess the Snakes thing should have tipped me off. Technically, installer programs are "embedded systems". It's a demanding place to put any technology, and it speaks volumes for Python that Anaconda doesn't just work, it works well. I'm convinced that Linux + Python is going to be a real killer in the embedded systems world. Now if only I could get Linux+Python+TinyX all on one 1.44 mb floppy. (Anyone seen the QNX technology demo 1.44 mb floppy?) Warren Postma From mwh21 at cam.ac.uk Sun May 7 18:32:01 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 07 May 2000 23:32:01 +0100 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: Glyph Lefkowitz writes: > Vetle Roeim writes: > > > - age. the other "P" language[0] has been around a little longer.. right? > > I hear this tossed around a lot. How *much* longer? I think perl was born in 1987 and Python in 1991. Not sure about either of those though. [biggo snippo] > Unfortunately, one of the best features of the python community is > that it seems to have a sane group of people in it who know multiple > languages and will choose appropriate ones for the appropriate task. > We need more rabid, unabashed evangelists. :-) Why? [little-o snippo] > > [1]: I like Lisp, but it *does* have a PR-problem. > > Lisp *IS* a PR-problem. Lisp needs to change its name and shed some > syntax before it's ever going to get 'mainstream' acceptance; the > ideas in lisp are good, but too many cs students have been tortured > with it ... Lisp needs to *shed* some syntax? What are you smoking? Lisp has no discernable syntax (and that's arguably one of it's better features). Have you read "Lisp: Good News, Bad News, How to Win Big" by Richard P. Gabriel? It's well worth a read: http://www.naggum.no/worse-is-better.html IMHO, Lisp has not entered the mainstream because people are too close-minded to realise that something can be both different from what they are used to and yet a good thing. Not that modern lisp is perfect, but it's flaws aren't insurmountable given, say, one tenth of the money that's gone into Java. Cheers, M. -- it's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done -- Erik Naggum, comp.lang.lisp From tanzer at swing.co.at Tue May 23 01:06:08 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 23 May 2000 07:06:08 +0200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Your message of "Mon, 22 May 2000 19:42:30 CDT." <3929D3F6.DE9CCCBC@prescod.net> Message-ID: Paul Prescod wrote: > I prefer case sensitivity. But I think that most of the arguments people > make in favor of it are bunk. Amen. It's just a matter of taste (or mayby acculturation?). Having used both case-sensitive and case-insensitive languages, I think its a non-issue. After a day or two, one just doesn't notice anymore. Personally, I prefer case-sensitivity. Judicious use of case increases the readability of programs. OTOH, misuse of case leads to horrible results. > 1. If you spend time with newbies -- especially Windows-trained newbiews > -- you will note the case sensitivity is a problem. > > 2. Code written in a case insensitive language is roughly as robust and > readable as that in a case sensitive language. > > The most honest arguments are "case sensitivity feels cleaner" and that > it "is more popular with existing programmers." IMHO, the problem starts with changing the case policy midstream. I'd happily accepted a case-insensitive Python when I started to use it. I'm not amused to have the language changed after two years of intense programming in it. It'd be a nightmare to check several hundred Python modules for errors introduced by such a change. The dynamic nature of Python doesn't help here, either :-( -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From paul1brian at my-deja.com Tue May 16 15:04:52 2000 From: paul1brian at my-deja.com (paul1brian at my-deja.com) Date: Tue, 16 May 2000 19:04:52 GMT Subject: which is best opensource application server / middleware for python Message-ID: <8fs647$q8h$1@nnrp1.deja.com> I am looking to create an "enterprise class" architecture for my own web site/edification. I would like it to be nicely n-tier, using a web server /dbase as a front and back end. However I do want a decent piece of middleware - and I would like to know if the group has any advice on this subject. (a quick search of deja has not provided any meat) I know zope is sort of in this area, but it seems much more orientated towards document management than business middleware. Messaging-products like XIPC seem (besides expensive) interesting but I have no idea how well it works with python. Everything else is just EJB - how easy is it to create EJBs through JPython ? Is there a tutorial? I would appreciate the groups views .... thank you in advance pbrian at theorrery.com Sent via Deja.com http://www.deja.com/ Before you buy. From herzog at online.de Fri May 19 08:13:23 2000 From: herzog at online.de (Bernhard Herzog) Date: 19 May 2000 14:13:23 +0200 Subject: Fractran machine! References: <39250239.D384FF0D@geneva-link.ch> Message-ID: Boris Borcic writes: > Fran?ois Pinard wrote: > > > > Hi, people. Here is a Fractran machine, with a demo program. > > How long does the demo take to halt ? I don't claim to have understood how the demo program for the fractran machine works, but it seems pretty obvious that it will never halt. >From the doc string: Each computation cycle works as follow. Find the first fraction for which the denominator exactly divides the accumulator. If there is no such fraction, the machine halts. ... And the fractran program: fractran.load_program((17, 91), (78, 85), (19, 51), (23, 38), (29, 33), (77, 29), (95, 23), (77, 19), (1, 17), (11, 13), (13, 11), (15, 14), (15, 2), (55, 1)) Note that the last item has a denominator of 1, so there will always be a fraction whose denominator exactly divides the accumulator. Another observation: If a program has a fraction whose denomintor is 1, it must be the last one in the program. Fractions after that will never be used. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From jschmitt at vmlabs.com Thu May 4 04:41:49 2000 From: jschmitt at vmlabs.com (jschmitt at vmlabs.com) Date: Thu, 04 May 2000 08:41:49 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) Message-ID: <8erd4a$ac1$1@nnrp1.deja.com> Be forwarned, I have a particularly strong hate-on for hungarian notation. I think it is no coincidence that the worst software in the world and the worst programming conventions come out of the same establishment. I have a bunch of philosophical reasons for disliking hungarian notation, but I think the most basic is that it is the antithesis of structured programming practices. Two of these practices would be data hiding and data abstraction. Hungarian notation is directly at odds with these ideals. How can you have any level of abstraction if the user of the abstraction has to be concerned with the minutia of the implementation? And, the very idea of hungarian notation is the exact opposite of data hiding. > > release. Is it painful? You bet. Just ask Billy -- the translation from > > old symbol names to new names broke the compile for weeks. But once it was > > all over, I had fixed no less than 14 bugs that would *never* become > > apparent until after I'd released the code to the public. Most of the bugs > > were bound to be of the "intermittent" type too, so I was particularly > > pleased at the end result. If your problems are solved by this kind of mindless busy work, you have much bigger problems that any amount of hungarian notation will ever fix. I good primer on writing maintainable code is recommended. Try _Programming_with_Dick_and_Jane_. > > Again, it takes skill to use a tool well. What does it take to recognize such a mind-numbing productivity inhibitor? Hungarian notation is a stupid way to mask stupid programming habits. There's no need for it in any language, and in a dynamically typed language like Python, it's even more sinful than in a statically typed language such as C. Just so there's no question about attributions, I'm enclosing the whole message that I'm replying to. In article <8el305$h77$1 at ites.inria.fr>, Cedric Adjih wrote: > Samuel A. Falvo II wrote: > > In article <8ehrb9$mm5$1 at ites.inria.fr>, Cedric Adjih wrote: > >> If you can read, you should be able to read the definition of > >>any variable, and there are serious drawbacks. A flame of this > >>notation is for instance in "Developing Windows NT Device Drivers": > >>"The so-called `Hungarian Notation' (developped by a Hungarian > >>programmer at Microsoft) is one of the worst ideas to have hit > >>software development in many years" > > > "All good ideas are judged from the enemies they make." -- I forgot who. > > >> The main problem, is that when you change the type of a structure > >>you _cannot_ change the name (because other people are using it), > >>so the type specification becomes plain wrong. The 'wParam' > >>is reported to be such an example (now unsigned 32 bits), there > >>are other examples in Microsoft API (should be worse with Win64). > > > Hungarian notation is fine for the definition of an API, as long as its used > > to describe abstract concepts, like arrays, pointers to things, a count of > > whatever, etc. Hardcoding the bit-widths of types is obviously going to get > > you into trouble in the future. Just because Microsoft fscked up the > > execution doesn't mean the idea is somehow "bad." > > > Like I said earlier, I use it only when it makes *sense* to. Like anything > > else you have in your toolshed, Hungarian notation is a tool. Those who are > > skilled in its use will not have the problems you cite above. :) Those who > > aren't only use it because it's a fad. > > It's ok. It's just that most of the time I've read some code using it, > it was following Microsoft broken conventions. I personally don't > like marking pointers/arrays (he! that would be like Perl), but I > using it in a clever way, is of course quite good. > > >> Also each time you change the type of one variable/parameter, > >>you have change all the variable names of all the code under > >>your control. > > > In my work with Dolphin, I've found, on several occasions, where I needed to > > change symbol names pervasively throughout the source. I have found #MORE > > BUGS# just waiting to crop up and bite me in the butt this way than through > > any other technique. The very thing you cite as a "problem" is the very > > thing that will help reduce the number of bugs in Dolphin upon its final > > release. Is it painful? You bet. Just ask Billy -- the translation from > > old symbol names to new names broke the compile for weeks. But once it was > > all over, I had fixed no less than 14 bugs that would *never* become > > apparent until after I'd released the code to the public. Most of the bugs > > were bound to be of the "intermittent" type too, so I was particularly > > pleased at the end result. > > > > I view it as sheer laziness on the programmers part. You get what you pay > > for. > > That's right. This is why, when I change code and break some > invariant/expectation (even if the types aren't changed), I often > change the variable/struct/function names, to review all the code > possibly using it. > > >> And finally, for multi-platform code, it makes less sense: > >>what happens if you don't have 2-bytes integers and you > >>have code with wXXXX variables (unsigned int 16 bits) ? > > > On PowerPCs, a word is 32-bits. On Intels, 16-bits. So what's the lesson > > to be learned here? Don't hardcode widths in the meanings of your symbols. > > > Hungarian notation as used by Microsoft is by far NOT the only way to use > > it. > > No but the very name "Hungarian notation" comes from its (incorrect) use > at Microsoft. > > > For example, I *never* identify word-widths in my Hungarian notated > > variable names. Why? Because of the very problem you cite above. However, > > I do indicate higher-level meanings with prefixes: p for pointer, c for a > > count (e.g., cb for a count of bytes, cuint32 for a count of 32-bit unsigned > > integers, etc), a for array, etc. > > > Again, it takes skill to use a tool well. > > Agreed. > > -- Cedric > Sent via Deja.com http://www.deja.com/ Before you buy. From nascheme at enme.ucalgary.ca Mon May 8 01:19:33 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 May 2000 05:19:33 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <391645E3.3B850279@san.rr.com> Message-ID: Courageous wrote: >Oh, I see what you're saying. So if I compare mymodule.ALPHA >to an attribute thay may or may not be set to mymodle.ALPHA, >I can do an identity-compare. Nifty. "==" works just as well. Python smart enough to try a pointer compare first. The code path is almost the same so I doubt there would be much speed gained by using "is". Neil -- "More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason, including blind stupidity." -- W.A. Wulf From m.faassen at vet.uu.nl Mon May 22 05:56:12 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 09:56:12 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: <8gb07s$bhu$5@newshost.accu.uu.nl> Neel Krishnaswami wrote: [snip] > Suspicions are most easily dispelled/confirmed via evidence, and > taking the trouble to do this has the pleasant side-effect that you > can either cease expending effort worrying, or move directly to taking > positive action to correct the problem. I've seen quite a few variant ways to spell Pascal keywords. Uppercase, lowercase, and so on. That wasn't very pretty in my opinion. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From moshez at math.huji.ac.il Sun May 28 01:08:50 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 28 May 2000 08:08:50 +0300 (IDT) Subject: global name space and importing In-Reply-To: <39306CB7.B5419219@bioeng.ucsd.edu> Message-ID: On Sat, 27 May 2000, Curtis Jensen wrote: > How come the global declaration works when I define it from withing the > interpreter, but not from within a file that I import? See following > example. > > file: foo_bar.py: > def foo(i): > x = i > > def bar(i): > global y > y = i > > Python interpreter: > >>> from foo_bar import * Yet another example on why "from foo import *" is evil. It imports all the names *currently* in the module. "y" is not in the module until you *call* bar. >>> from foo import * >>> bar() >>> from foo import * >>> y 1 Where # foo.py def bar(): global y y = 2 Solution: don't do 'from ... import *' -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From moshez at math.huji.ac.il Sat May 27 11:08:16 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 27 May 2000 18:08:16 +0300 (IDT) Subject: vars between classes In-Reply-To: Message-ID: On Sat, 27 May 2000, Marc Tardif wrote: > OK, here's working code now. My previous code was only meant to help > demonstrate my problem. In this new code, I have tried to change var in > the first class by calling "first" explicitly. Unfortunately, "3" is still > not printed: > > #!/usr/local/bin/python > > class first: > def __init__(self, var): > self.var = var > self.myMethod() > > def myMethod(self): > print "first:", self.var > second(self.var) ^^^^^^^^^ Here you construct a new object of class "second", which inherits its __init__ from "first", which calls its "myMethod", which prints "second." It's still not very clear what you expect to happen. > print "last:", self.var > > class second(first): > def myMethod(self): > print "second:", self.var > first.var = 3 > > def test(var): > first(var) > > if (__name__=='__main__'): > test(2) > > > -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From jkraska1 at san.rr.com Thu May 25 19:54:29 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 23:54:29 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> Message-ID: <392DBDDF.CB4470EF@san.rr.com> > Yes, it *is* an absurd notion. And a rather pejorative one, to boot. > Perhaps you should consider an apology? I think you're right, frankly. Speculative character assassination from the point of view of ignorance and from the security of relative anonymity is disgusting. Our insulting friend might also for his own edification investigate the following Latin terminology: "CUM HOC ERGO PROPTER HOC" It should be educational. C/ From frank.sergeant at redneck.net Thu May 25 13:40:43 2000 From: frank.sergeant at redneck.net (Frank Sergeant) Date: 25 May 2000 12:40:43 -0500 Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: <87wvkir0is.fsf@den.home.net> Nick Bower writes: > I colleague the other day, who was familiar with various procedural > languages said: > > "I want to learn OOP. Can you recommend a book (and language)?" I recommend _Object-oriented Software Construction_ (either 1st or 2nd edition) by Meyer, as it delves deeply into OO and what it means and what it requires and what it implies. It was the first _principled_ book on OO that I read, as opposed to the "oooh, objects -- cool!" drivel, such as the _Tao of Objects_ book. OOSC should give you some things to think about and Python will free you from some of its straight-jacket. I am not in the Eiffel camp, but I think Meyer does a good job of presenting OO and many important principles. Even more than OOSC, I recommend almost any book on Smalltalk. It is easy to find a bad Java book but it is hard to find a bad Smalltalk book. In particular, I recommend _Smalltalk, Objects, and Design_ (you may need to find it used, but there may be a 2nd edition soon?) by Chamond Liu and _Smalltalk -- An Introduction to Application Development Using VisualWorks_ by Hopkins and Horan. I am in the Smalltalk camp and think Python and Smalltalk are very similar and that studying OO in Smalltalk will improve your use of OO in Python. I hope that helps. -- Frank frank at canyon-medical.com From ulf.engstrom at b2b-link.com Fri May 19 06:53:44 2000 From: ulf.engstrom at b2b-link.com (=?iso-8859-1?Q?Ulf_Engstr=F8m?=) Date: Fri, 19 May 2000 12:53:44 +0200 Subject: Fw: How to get volume name under Win32? Message-ID: <01b201bfc180$80c25fa0$858647c1@DEVELOPMENT> Not everything from os.popen() works on w2k, but at least you can get it 'working at all' on that platform as opposed to win95/98. (Some of the functions won't work as specified, but can be used in different ways, at least after some fiddling around). >>> p = os.popen('dir') >>> p.read() ' Volume in drive D is Ulf\012 Volume Serial Number is 9C2C-3B1F\012\012 Directo ry of D:\\downloads\\os\012\01227.04.2000 11:25

    .\01227.04 .2000 11:25 ..\01220.11.1999 11:33 freebsd\01208.02.2000 10:16 partition\01206.04.2000 08:47 qnx\01220.11.1999 11:33 wsh\012 0 File(s) 0 bytes\012 6 Dir(s) 5\377668\37 7397\377056 bytes free\012' No pprint for sure ;) Regards Ulf Dale Strickland-Clark: > The rumours appear to be wrong. > > I get the same error on a Win2000 system. Guido: > > As has been said many times before, os.popen() is 99% broken on Windows > > 95/98. > > The error you posted is typical for the situation. Rumor has it that it > > works > > on W2000... Dale Strickland-Clark: > > > In fact ,I can't get os.popen to work at all! From Gareth.McCaughan at pobox.com Sun May 14 18:49:12 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 14 May 2000 23:49:12 +0100 Subject: Speed References: <391e9056_3@goliath.newsfeeds.com> Message-ID: <86d7mon3x3.fsf@g.local> Janos Blazi wrote: > global r > r=[] > > def neue_zeile(z): > global r > z.reverse(); > r=[] > last=-1 > for x in z: > if x==last: cnt=cnt+1 > else: > if last != -1: > r = [cnt,last] + r > last=x > cnt=1 > r = [cnt,last] + r > > l=[1] > for i in range(0,41): > print i,len(l) > neue_zeile(l) > l=r > print i,len(l) > > print "*done*" .. > Now it is clear that C is faster than Python, so the C program will have a > shorter execution time. > But I cannot believe that C can be hundreds of times faster (The C code need > less than 2 seconds on my NT machine and the Python code more than 17 > minutes.) > > Is my Python code stupid? Can I improve it? Here's a more idiomatic Python version. def successor(s): result = [] last,n = s[0],0 for x in s: if x==last: n=n+1 else: result.extend([n,last]) last,n = x,1 result.extend([n,last]) return result l=[1] for i in range(41): print i, len(l) l = successor(l) print i, len(l) print "done" On my machine, this takes about 3.3s. (Have you encountered Conway's work on the problem this little program is investigating?) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From warlock at eskimo.com Wed May 3 01:38:56 2000 From: warlock at eskimo.com (Jim Richardson) Date: Wed, 03 May 2000 05:38:56 GMT Subject: plain text python source -> HTML syntax highlighted source References: <65118AEEFF5AD3118E8300508B1248774CB2C0@ALTNET> Message-ID: On Tue, 02 May 2000 14:03:04 GMT, ben at co.and.co, in the persona of , brought forth the following words...: >Jim Richardson wrote: >> Just when I think Vim has no more surprises for me:) >> >> (Jim, who just wishes Vim used python as a macro language.) > >Just compile vim with the |+python| feature, and you have a builtin >Python-interpreter. >(:h python) > Woohoo! (ok, so I prefer playing with computers to TV or drinking beer in a bar, sue me...) -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From alvaro at ocse.infonegocio.com Tue May 23 06:13:22 2000 From: alvaro at ocse.infonegocio.com (AMR) Date: Tue, 23 May 2000 12:13:22 +0200 Subject: Photo and Image (Tkinter) References: <8gdhv7$4s59@esiami.tsai.es> Message-ID: <8gdl5f$4s510@esiami.tsai.es> Hello Pedro, I think is an dificcult question. I've asked for several times and I don't have answer. I think someone must have an example to do this. Thanks in advance, alvaro at ocse.infonegocio.com "Pedro Redondo" escribi? en el mensaje news:8gdhv7$4s59 at esiami.tsai.es... > Hello: > > I need samples for create and modify Images with Tkinter. > > -- > Pedro Redondo Vergara > > p.redondo at optichrome.es > > Optimus, El Sistema de Gesti?n para la Industria Gr?fica > > Optichrome Computer Systems Espa?a, S.A. > C/ Andr?s Tamayo, 3 - 28028 Madrid > ES: Tel: +34 917 242 670 Fax: +34 917 130 360 > > > From thiele at muc.das-werk.de Tue May 23 15:07:24 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 23 May 2000 21:07:24 +0200 Subject: How do I create extensions to Python in C? References: Message-ID: <392AD6EC.431F99AC@muc.das-werk.de> > Do you want to call standart C-functions (like system calls)? Forget it, you don't need it! All these functionality are available in python. The pythonfunctions are straight forward calls to the c-functions. To call other c-function is a little bit more difficult. You have to build your own pythonmodul (written in c, shared library). But this is to complicated to write it in a few lines. If you're interested, please mail me. I have a prototype. Thomas From effbot at telia.com Tue May 9 12:07:43 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 16:07:43 GMT Subject: Name mangling References: <8f6vti$n0v$1@nnrp1.deja.com> <8f9bbe$akc$1@nnrp1.deja.com> Message-ID: ullrich at math.okstate.edu wrote: > > section 9.6 in the tutorial discusses this: > > > > http://www.python.org/doc/current/tut/node11.html > > > > "Any identifier of the form __spam (at least two > > leading underscores, at most one trailing under- > > score) is now textually replaced with > > _classname__spam, where classname is the > > current class name with leading underscore(s) > > stripped. This mangling is done without regard > > of the syntactic position of the identifier, so it > > can be used to define class-private instance > > and class variables, methods, as well as globals, > > and even to store instance variables private to > > this class on instances of other classes" > > Thanks. But actually I'd found that part in the docs, > but I don't see how it implies that the silly snippet I > posted should not work. Probably I'm just being dense, > but usually when I find the right page in the docs I get > an "aha" out of it - here I don't get it at all... oh, I forgot to include the important part: the paragraph I quoted ends with this sentence: "Outside classes, or when the class name consists of only underscores, no mangling occurs." in other words, this works: _C__foo = 42 class C: def __init__(self): self.value = __foo c = C() From alan.gauld at gssec.bt.co.uk Wed May 3 10:42:08 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Wed, 03 May 2000 15:42:08 +0100 Subject: Doesn't anybody write to paper anymore? References: <38F5FDF3.EE2FBA01@tcac.net> <38F94701.CA52FDBB@tcac.net> <8dd0gq$crn$1@nnrp1.deja.com> Message-ID: <39103AC0.35E2071D@gssec.bt.co.uk> "Hernan M. Foffani" wrote: > > docs say that os.popen() is "unreliable on Windows." Is this still > Well, there is a reliable "os.popen()" for windows around there. Really where? I couldn't get popen to work at a;ll on NT4 or win95 > you want to print in windows from python, that will be useless. Tis true, alas... > The quick way: output to a text file, then run "notepad /p filename". Or just output direct to LPT: prt = open('LPT:','w') prt.writelines(mytext) prt.close() > The advanced way: use the win32 module from pyhton. Better, but printing under Windows using GDI is a pain... Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From phd at phd.russ.ru Wed May 17 09:35:01 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 13:35:01 +0000 (GMT) Subject: DCOracle and handling of package OUT parameters broken ?! In-Reply-To: <8fu6b3$qj3$1@news.hants.gov.uk> Message-ID: On Wed, 17 May 2000, Graham Bleach wrote: > > oci.error: (6502, 'ORA-06502: PL/SQL: numeric or value error: character > string buffer too small\012ORA-06512: at "AJUNG.SELECT_LOB", line > 22\012ORA-06512: at line 2\012') > > Hmm, this looks like the buffer mentioned above is the OCI buffer > used/created by DCOracle. I'm not familiar with DCOracle (not enough time). > Is there anything that's specifically designed to handle CLOBs being > returned from Oracle? DCOracle (or may be OCI) cannot return LOB - you need to SELECT it separately. For example, instead of returning the LOB, return ROW ID, and then SELECT the row by ID. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From jkraska1 at san.rr.com Thu May 11 02:49:42 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 06:49:42 GMT Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> Message-ID: <391A58E5.C9487C30@san.rr.com> > > To wit: if I create multiple Python threads on a > > machine with multiple CPUs, I should be expecting > > take advantage of the additional CPU's, correct? > > no. > > for more info, see: > http://www.python.org/doc/current/api/threads.html I just read that. It suggests that the threads may be mutually locking eachother out some of the time, but it does not say that they will not see a performance gain once you discount the contention issues. In particular, the brief discussion might suggest to this otherwise naive reader that if the threads were operating in relative mutual exclusion to eachother and objects which, once divided between them, were non- co-referencial, here might not be as much contention for python locking structures as the document mentions. ??? C/ From james.wynne at xiam.com Thu May 4 06:21:15 2000 From: james.wynne at xiam.com (james.wynne) Date: Thu, 04 May 2000 10:21:15 GMT Subject: Imaplib and jpython Message-ID: Hi I'm new to python, (so bear with me). I wrote the following code in Python (cpython) import imaplib, string #def Move(server,name,pwd): M=imaplib.IMAP4("walrus.xiam.com") M.login("mojo","mojo") dummy,N=M.select() and it gives me the following response ['OK','10'] if i run it on jpython I this response ['OK',[none]] I have other examples as well of this sort of behaviour. Is there a reason why my python code wont run consistently on jpython? J From parker at gol.com Sun May 21 18:30:42 2000 From: parker at gol.com (Ian Parker) Date: Sun, 21 May 2000 22:30:42 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: In article , Neil Hodgson writes >> You'll notice that a url is case sensitive and urls are bandied about as >> currency so in my opinion I think the population can generally handle >case. > > URLs are case sensitive but domain names are insensitive in practice and >most URLs bandied about with the intent of seeing them manually entered are >bare domain names. I don't know if domain names are insensitive by design or >there is something that fixes my typing by doing a search but asking for >weirdly cased domains works. > > Looking at the statistics for my web site last week, of 16000 hits, there >were 73 misses of which 4 were miscapitalisations, 3 look strange with >little relation to the site, and none look like misspellings (the others >were for robots.txt and a file I removed). So someone has failed to see what >they want because of case sensitive URLs. I would expect that most hits come >from clicking on references so there should be little need for manually >typed URLs but when used they will lead to errors because of capitalisation. > > Neil > > > DNS is case-insensitive hence the insensitivity of domain names. I'd assumed the path to be case-sensitive only because it is running on a case-sensitive OS, such as UNIX. On Windows NT and VMS the case doesn't appear to matter. However, UNIX derived software may not always make the right assumptions for the underlying OS, thus Apache is case- sensitive on aliases, but not on files I'm familiar with case-insensitive languages and file-systems and I prefer them, however it seems relatively easy to switch to either style. Regards Ian -- Ian Parker From zino3 at aol.com Fri May 19 23:11:45 2000 From: zino3 at aol.com (The Lost Dog) Date: Fri, 19 May 2000 23:11:45 -0400 Subject: Guitar tuning program References: Message-ID: <39260223_4@127.0.0.1> I've got a tuner that I found by accident at The Sharper Image(!). It's the only one I've ever seen, but it is made by OnBoard Research Corporation. It clips to the head of my guitar and works on vibration. You can also set it to tune to any note you put in it. It was only $20, and I love it. I've never seen it in their catalogue, but maybe Sharper Image could tell you more about it. It's definitely worth every penny. The Lost Dog Laurent Duperval wrote in message news:YLaV4.46370$wz3.175637 at newscontent-01.sprint.ca... > Hi, > > I'm looking for a guitar tuning program program that will work like one of > those electroning tuner things: you hit a string and it tells you if your > string is flat, sharp or on the money. I have one already but it won't let > me do proper pitch tuning: I want to be able to to tune my guitar half a > tone (or more) higher or lower (i.e. move E to Eb or F). Can anyone > recommend a utility of some sort that will let me do this? Here are my > requirements: > > - Has to work on Intel-Linux. If it's a Windows program, I'm not > interested unless the source code comes with it > > - No tuning by ear, please! I can figure out how to do that on my own but > I'm not any good at it. I want to stick my PC's mic in front of the > strings and then use the tool like I would my electroninc tuner > > - Preferably not a Xforms- or Qt-based program. I prefer Tk or tkInter or Java > C w/ X11. Binaries are acceptable also, provided I can get them from a reputabe > site > > Thanks, > > Laurent -----= 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 mycroft at actrix.gen.nz Fri May 26 07:37:54 2000 From: mycroft at actrix.gen.nz (Paul Foley) Date: 26 May 2000 23:37:54 +1200 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: On 21 May 2000 18:39:07 GMT, Neel Krishnaswami wrote: > Perhaps you should look at languages that are case-insensitive, and > see if people have the problems you suspect they might? Large bodies > of source code for Common Lisp, Scheme and Dylan are available under Common Lisp is *not* case-insensitive. The reader just upcases most symbols by default, but you can easily change that if you want (e.g., make it downcase everything, leave the case as typed, or invert the case of non-mixed-case symbols), and you can quote characters (with backslash, or by surrounding them with vertical bars) to tell the reader to leave them alone. |Foo|, |foo| and |FOO| are three totally independent things. -- If that makes any sense to you, you have a big problem. -- C. Durance, Computer Science 234 (setq reply-to (concatenate 'string "Paul Foley " "")) From fiona at sitegnome.com Sun May 28 00:32:58 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 28 May 2000 04:32:58 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 28th, 2000 Message-ID: <20000528043258.11667.qmail@synop.com> Greetings, Below are the entries that I've entered into http://python.faqts.com today. The knowledge base is growing well, so far there are over 160 questions and answers! Thanks to everyone that has contributed and gotten back to me with suggestions and feedback. Now, I have a call for help. As I'm relatively new to Python I'm not confident on defining the folder structure for content in the Python knowledge base. At the moment, unless the question is very obviously related to a particular topic, it gets whacked into the "common problems" folder. This is less than ideal - therefore if anyone can suggest an appropriate structure or jump into FAQTS and help create it I'd be very grateful. Thanks, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How do I set environment variables in a Python script that is to be run on an Apache server? After setting environment variables in a script will they be changed after running the script? http://www.faqts.com/knowledge-base/view.phtml/aid/3298 ------------------------------------------------------------- Fiona Czuczman Cliff Crawford Problem: Say, I want to set ORACLE_HOME = /opt/app/ora/ I wrote the following code: import os os.system("ORACLE_HOME=/opt/app/ora/") os.system("export ORACLE_HOME") .... I executed the script under my user account but when I checked my enviroment variables with "env" there is no ORACLE_ENV added. Solution: That's because os.system spawns a new process (with a copy of the original environment of the parent process) each time it's called. You want to use os.environ instead: os.environ["ORACLE_HOME"]="/opt/app/ora/" This changes the environment for all future os.system calls. Once the process dies, the changed environment dies with it. ------------------------------------------------------------- How can I embed/port Python to Vxworks? http://www.faqts.com/knowledge-base/view.phtml/aid/3301 ------------------------------------------------------------- Fiona Czuczman Richard Wolff What follows are some of the details. This same information and the rest of the story can be found at http://daikon.tuc.noao.edu/python As usual, no warranty for fitness nor merchantability nor freedom from un-wanted side-effects of creeping featurism. --------------------------------------------------------------------- Here's how I set up Python as an embedded task in VxWorks. Note that building the system for VxWorks is not going to be as nicely set up as doing so for most systems. We can't run configure for one thing. So there are a number of changes that you have to consider/make by hand. Before getting to the details, a thank you to Paul Fernhout for some helpful advice in a recent comp.lang.python posting. Perhaps the best way to get started is to build Python on your workstation and use that as the start of the port. This way, many of the files you need will be present. For instance, the parser generator program will be built and run, so it isn't needed for the cross-compile. You'll also have config.h file that might well serve as a useful starting point. The files from the distribution that you need to modify are in Include, Modules, Objects, Parser, and Python. At the top level, you'll need to change Makefile and config.h. The diff file (pydiff) will make a lot of changes for you, but you should probably take a look at what's going on first. There may well be better ways of doing things. By the way, the diff is against Python 1.5.2 and is for VxWorks 5.2 (pre-Tornado). You'll need (or want) to do the following: 1) Edit the top level Makefile to reflect the correct definitions for CC, RANLIB, LD, and AR. Make the same edits in the Makefiles in Objects, Parser, and Python directories. Make the same edits in Makefile.pre in Modules. 2) Edit config.h 3) Get a version of getopt.c and put it in the top level directory, along with a suitable getopt.h, which can go in the Include directory. Or put getopt.c somewhere else and modify Makefiles suitably. 4) Edit Setup (and Setup.local, Setup.thread). 5) If you include modules that I didn't, you'll probably want to edit that module's ".c" file. If you have a different version of VxWorks, look for the VXWORKS define and modify as needed. 6) Modify Modules/python.c as you will. You probably will want to modify the arg0 value. 7) Remove the buildno file if you want. 8) In Modules, run makesetup to build the Makefile and config.c. If you have used both Setup and Setup.local, run makesetup Setup Setup.local 9) At the top level, run make. The output will be "python.o" in this directory. 10) Load that into your VxWorks system. On my system, Python took too much stack space to run under the shell, so I spawn the task, which is what "sppy" ("spawn python") does. If Python comes alive, but you get lots of xxx:yyy: No such file or directory and xxx:yyy: File exists, don't worry. Those messages are from 'stat' as it probes the file system on xxx looking for library files. I don't know how to stop this; it's both annoying and harmless. 10a) You should 'cd "python-top-level-directory"' before you load the python.o file, or you should be sure that you have the Lib directory in a standard place (or you have modified the Makefiles to reflect suitable prefix and exec-prefix directories). Or you might set the PYTHONHOME environment variable in Modules/python.c before Python goes through its initialization steps. 11) When the >>> prompt appears, it's likely that a carriage return will bring back the shell prompt. That's because the shell runs at much higher priority than Python and it grabs all the characters. It needs to be demoted, which is what the "demoteShell" code in Modules/python.c does (with a vengeance...there's probably no need to suspend the shell). So run that routine from the shell, and then run Python as you will. 12) To exit, the usual command sequence (or sys.exit) will get you back to the shell prompt, at which time, you should raise the shell priority back to 1 (use "restoreShell"). 13) You can make things more interesting by having Python code that will allow you to run VxWorks routines. You need a slight extension of Python, to be found in my "Modules/vxmodule.c". Modify Setup (or Setup.local, rerun makesetup, and then the top level make). 14) A simple VxWorks class makes use of the vxmodule code. See VxWorks.py Thus, i = VxWorks.Vxw("i","") builds an 'i' such that 'i()' gives the same task information table from the Python prompt as it does from the VxWorks shell. Or, routeAdd = VxWorks.Vxw("routeAdd", "ss") builds a routeAdd function that can be used to add a route to the VxWorks routing table (routeAdd("90.0.0.0, "gateway")), and so forth. 15) If you have the VxWorks module in place, you can then define rs = VxWorks.Vxw("restoreShell","") and when you run rs(), you have, for interactive use, effectively suspended Python, as the shell will get all the input characters. "demoteShell" and 'rs' thus allows you to switch back and forth between Python and the VxWorks shell. Richard Wolff May, 2000 P.S. I did this work because I want to run various routines in the VxWorks environment under the control of a "scripting" language. There are three approaches here...embed Python in VxWorks, which is what this note is about, connect Python running on a workstation to the VxWorks shell via telnet, or connect Python on the workstation to a process on the VxWorks box via a socket connection. Which way to go is nice question. The other question one ought to answer is, "why aren't you using rt-linux?". P.P.S. All this code is released under the same terms and conditions as the Python license. ------------------------------------------------------------- How can I create a Tkinter MessageBox with the MessageBox - option "YESNOCANCEL"? http://www.faqts.com/knowledge-base/view.phtml/aid/3297 ------------------------------------------------------------- Fiona Czuczman Robert Roy Problem: When I use - import tkMessageBox tkMessageBox.askquestion("equal","even better", icon=QESTION, type=YESNOCANCEL) The error message here is: NameError: QUESTION Solution: QUESTION is not in your namespace try tkMessageBox.askquestion("equal", "even better", icon=tkmessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) however this will bring up another a type error: keyword parameter redefined. so then instead of using askquestion use _show tkMessageBox._show("equal", "even better", icon=tkmessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) If you look at the sources you will see that askquestion is just a shortcut for _show(title, message, icon, type) where icon=QUESTION and type=YESNO ref: def askquestion(title=None, message=None, **options): "Ask a question" return apply(_show, (title, message, QUESTION, YESNO), options) ------------------------------------------------------------- Is it possible to set the minimum size of the window? http://www.faqts.com/knowledge-base/view.phtml/aid/3299 ------------------------------------------------------------- Fiona Czuczman Robert Roy Try this: import Tkinter root = Tkinter.Tk() root.minsize(400,200) Tkinter.Button(root, text='Hello").pack() root.mainloop() also see maxsize and geometry ------------------------------------------------------------- I'm trying to use the smtplib for sending mail, and I keep getting error: (10061, 'winsock error') when I try just to connect to the localhost. http://www.faqts.com/knowledge-base/view.phtml/aid/3296 ------------------------------------------------------------- Fiona Czuczman Andrew Henshaw I'm guessing that your code looks something like: import smtplib server=smtplib.SMTP('localhost') server.connect() If so, then your problem is that the server.connect() function was already called when you instantiated "server". The connection is automatically made when you provide the hostname as a parameter to SMTP. I believe that the SMTP example in the library documentation is in error, in this regard. From cpr at emsoftware.com Thu May 25 14:40:42 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Thu, 25 May 2000 18:40:42 GMT Subject: Python in an embedded environment References: Message-ID: Also note that Python is now essentially the Itanium BIOS. That's fairly deeply embedded in fairly smart devices (future Itanium PCs). ;-) http://developer.intel.com/technology/efi/toolkit_overview.htm -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Robert Cragie" wrote in message news:newscache$nff4vf$b7o$1 at jenpc07.jennic.com... > This is probably a bit off-topic, but I'd be interested to hear peoples > views on the suitability of Python and its VM in an embedded 'smart devices' > environment. There is a lot of talk of embedded Java, Jini etc., but it > strikes me that Python is probably very suitable as a language for > programming smart devices, as it satisifies a lot of the reasons for > choosing Java etc. (e.g. 'WORA') Plus it's cleaner syntax etc. implies > easier, safer code development which is a big consideration for these sorts > of devices. Plus it would be an open-source solution. I realise there may be > some issues around thread handling (e.g. global interpreter lock) which > would need to be addressed. From shogan at iel.ie Wed May 24 10:56:30 2000 From: shogan at iel.ie (Shaun) Date: Wed, 24 May 2000 15:56:30 +0100 Subject: parse-ing? how does it work? Message-ID: <009a01bfc590$3eef5ce0$2801000a@iel.ie> i put this......... > import string > > class MessageFormatError: > def __init__(self, value): > self.value = value > def __str__(self): > return self.value > > class Message: > def __init__(self, messageStr): > (idStr, subIdStr, nvSeqStr) = string.split(messageStr, None, 2) > > try: > self.id = int(idStr) > self.subId = int(subIdStr) > except ValueError: > raise MessageFormatError("Can't parse: %s" % messageStr) > > self.nvSeq = parseNvSeq(nvSeqStr) > > def parseNvSeq(nvSeqStr): > if len(nvSeqStr) == 0: > return None > else: > return nvSeqStr # decode here... > ......code in a module called findx.py, and heres what happened >>> from findx import * >>> m = Message("123 234 This is an nvSeqStr.") Traceback (innermost last): File "", line 1, in ? m = Message("123 234 This is an nvSeqStr.") File "C:\Program Files\Python\Tools\idle\findx.py", line 19, in __init__ self.nvSeq = parseNvSeq(nvSeqStr) NameError: parseNvSeq >>> ive tried moving and changing loads of ways but i cant get it to work, parseNvSeq seems to be the main problem, would ye be able to tell me whats wrong? please.. thanks Shaun _____________________________________________________ my original problem: ok, i have variables ,id ,subId, nvSeqStr a message will be passed in like...(some code & pseudo code below) forgive me im still a newbie and i cant grasp this stuff at all.... class message: import string def __init__(self, id, subId, nvSequence): self.id=id self.subId=subId self.nvSequence=nvSequence() #overloaded constructor 1 #sets up member vars id and subId subId of type int def __init__(self, id, subId, nvSequence=None): self.id = id self.subId = subId self.nvSequence = nvSequence def Message(StringMsg): # what i want to do is, 1) find the index of the first integer in the string StringMsg 2) #on an error throw a format exception 3) save int in var id 4) find the index of the second integer in the string StringMsg #on an error throw a format exception save int in var subId 5) keep the rest of the string in var nvSeqStr 6) if nvSeqStr is not empty 7) try decode it #on an error throw a format exception 8) else set nvSeqStr to null #on an error throw a format exception ===================== Shaun Hogan Interactive Enterprise Ltd. alt. E-mail : shaun_hogan at yahoo.com Phone: +353 86 8342529 The University of Limerick Rollerhockey Club URL: http://rollerhockey.csn.ul.ie From jlj at cfdrc.com Fri May 19 09:32:23 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Fri, 19 May 2000 08:32:23 -0500 Subject: Newbie problem with extending & embedding References: <39238544.778B6FEC@san.rr.com> Message-ID: <39254267.F15BBB94@cfdrc.com> C, With my installation of Visual C++ 6.0, I got a handy utility called DEPENDS.EXE which will report the dependencies of a given executable or DLL (much like the "ldd" command on some Unices). On my box this got installed under: C:\Program Files\Microsoft Visual Studio\Common\TOOLS\DEPENDS.EXE If your version of VC6 didn't come with this for some reason, there may very well be a free version available for download "out there". Hope this helps, Lyle Courageous wrote: > > On Windows: > > "ImportError: DLL load failed: One of the library files needed > to run this application cannot be found." > > Okay, playing around with this, this error is considerably > different than when the .dll doesn't exist: "ImportError: > No module named fred". > > This is a very simple module right now with one function > and a simple init section. This could be some cluelessness > I have with VC6 and the construction of .dll's. I'm a > Unix guy just barely limping through all this broken Windows > stuff. > > It almost seems as if I've created a .dll with a dependency > to another .dll which is not in the path. However, looking > over my Project->Settings->Link section, I can find no .dll's > mentioned there. > > Any hints? > > C/ From effbot at telia.com Wed May 10 12:55:28 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 10 May 2000 16:55:28 GMT Subject: Load Arbitrary Script as Module? References: <8f9bs3$b9u$1@nnrp1.deja.com> <3X8S4.3482$wYl.200101376@newsb.telia.net> Message-ID: <4wgS4.3559$wYl.206475264@newsb.telia.net> Fredrik Lundh wrote: > > Is there a way to load a module given a full filepath? Something like: > > > > driver = LoadModule("C:\\Stuff\\sample.py") > > driver.someFunction() > > start here: > http://www.deja.com/=dnc/getdoc.xp?AN=621152936 > > and add something like: > > def import_file(filename): > name = os.path.splitext(os.path.basename(filename))[0] > return do_import(name, filename) umm. sure looks like a bot error (guess the wrong code was in the clipboard). here's the correct code: def import_file(filename): name = os.path.splitext(os.path.basename(filename))[0] return do_import(name, open(filename).read()) From sharris at nospam.primus.com Sun May 21 22:22:59 2000 From: sharris at nospam.primus.com (Steven E. Harris) Date: Mon, 22 May 2000 02:22:59 GMT Subject: C++ extension module crashes on Solaris References: Message-ID: Guido van Rossum writes: > It seems your shared library module doesn't see the symbols defined by > the Python main app. Normally, these are being exported by default. > I wonder if the trick of using g++ for the linker breaks this? Yes, that turned out the to be the problem. I will take some time on Monday to prepare a more complete summary of what I learned (based upon _lots_ of helpful contributions), but to summarize: * Python must be linked with the option '-Wl,-E' passed to the linker. (That is, on Solaris, using g++, with the GNU binutils package.) Other advice involving compiling the extension with '-fPIC' also seemed relevant, but turned out to not make any difference. Now I'm not sure why '-fPIC' _isn't_ required! -- Steven E. Harris Primus Knowledge Solutions, Inc. http://www.primus.com From dgrisby at uk.research.att.com Fri May 12 05:09:28 2000 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 12 May 2000 09:09:28 GMT Subject: Bolting a Bison/Flex parser into Python References: Message-ID: <8fgho8$mr3$1@pegasus.csx.cam.ac.uk> In article , Anthony J Wilkinson wrote: >The idl compiler, fnidl, that comes with Fnorb does >this. Full source is included with the distribution. Note that to build >changed grammar or lexer files you will need to do the following which is not >yet documented or in the makefile: omniORB's IDL compiler, omniidl, also builds Python objects, but in a slightly different way to fnidl. fnidl builds Python objects directly from bison; omniidl first builds a tree of C++ objects, then converts them into Python objects later. This means it is possible to create back-ends in C++ as well as Python. (Having said that, all our back-ends are in Python since it's so much easier.) You can get omniidl as part of omniORB 3 or omniORBpy, from: http://www.uk.research.att.com/omniORB/ Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From noone at do.not.use Mon May 15 15:02:20 2000 From: noone at do.not.use (Russell Turpin) Date: Mon, 15 May 2000 14:02:20 -0500 Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> <8fmrm2$ubh$1@nnrp1.deja.com> <8foueq$4q7$1@nnrp1.deja.com> <39203ddd$0$14803@wodc7nh1.news.uu.net> Message-ID: <392049BC.44372D51@do.not.use> Gordon McMillan wrote: > You lose! > Please send me a blank check... The 10 lira are on their way .. Russell From sai at iris.chem.cuhk.edu.hk Tue May 16 21:59:40 2000 From: sai at iris.chem.cuhk.edu.hk (SC Zhong) Date: Wed, 17 May 2000 09:59:40 +0800 Subject: win32 problems Message-ID: would someone please help me for the two problems: 1. I installed the py152.exe in win98 (japanese version). I started IDLE, load a python script for editing, then exit with 'Ctrl-D', there always will come an error message from windowns. The message is somehow 'pythonw page violation, module: kernel32.dll, address: ...'. 2. I have problem setting up my hp workstation for a printer, so I wrote a 'print daemon' script, using the pc as my workstation's print server. I put a line 'c:/progra~1/python/pythonw.exe d:/scripts/wpd.py' (wpd.py is my script name) in the registry 'run' so that it can be started in the background when windows starts. The script works fine except that everytime I print something, a DOS windows will popup and then disappear. I read that the 'pythonw.exe' is for the silent mode with no 'console' popup, is it right? what can I do to get rid of the annoying DOS windows? thanks alot Sai c chung From "dbroadwell" at spam.mindspring.com Mon May 29 06:45:29 2000 From: "dbroadwell" at spam.mindspring.com (David Broadwell (remove spam.)) Date: Mon, 29 May 2000 06:45:29 -0400 Subject: more about the blasted pen and paper... References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newshost.accu.uu.nl> Message-ID: <8gthku$b7q$1@slb7.atl.mindspring.net> > > I draw on a paper with a blue color > > paper.draw(color='blue') > pen.paper=paper > pen.draw(color='blue') > "Pen, you're going to be drawing on that piece of paper. Draw in > blue." Very similar to the first one, but with a pen. paper.draw(pen.blue) two objects, one atribute and one function. (new to the list, had to say something, this thread was too good.) From mak at imakhno.freeserve.co.uk Mon May 29 08:15:59 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Mon, 29 May 2000 13:15:59 +0100 Subject: Raising exceptions during call back Message-ID: <8gtn85$g9s$1@newsg2.svr.pol.co.uk> My C extension module calls back to Python subroutines that the user has written. The trouble is, if the user makes an error, the sub isn't called (I just get NULL). Printing a stack track (with print_stack) just shows the Python stack up to the moment that it entered call back, and shows nothing about the error in the subroutine. What can I do to get the stack information during the subroutine itself? eg def mysub(): t=(1,2) print t[3] #error! EnterCallBack() If I call print_stack() from the extension module, I only get trace information up to the EnterCallBack() call, it says nothing about where an error occured inside mysub(), which I'm sure you can imagine would make it very difficult to write code for. From effbot at telia.com Thu May 4 16:34:15 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 04 May 2000 20:34:15 GMT Subject: BLOBS and python References: <8esivv$l5k$1@nnrp1.deja.com> Message-ID: sp00fD wrote: > I'm trying to insert an image as a blob, but unless I escape any quotes > ("') within it, it seems to puke. The problem is, it's an image and if > I escape the quotes, I change the image. How can I do this? > > import cgi > import MySQLdb > query = cgi.FieldStorag() > image = query["filename"].value > > c = MySQLdb.connect(...) > con = c.cursor() > con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % image) use parameters, not string formatting operators: > con.execute("INSERT INTO foo (myblob) VALUES (?)", [image]) (the exact syntax is implementation dependent; see the docs for your binding for details). From paulk at mathworks.com Thu May 25 11:08:06 2000 From: paulk at mathworks.com (Paul Kinnucan) Date: Thu, 25 May 2000 11:08:06 -0400 Subject: object browser in emacs References: Message-ID: <8gjfkn$9v6$1@news.mathworks.com> Huaiyu Zhu wrote in message ... >I just realized the folowing interesting thing: If you enable jde mode for >java, you can use the speedbar which lists objects in a convenient tree in a >separate window. Now if you edit python code it automatically lists python >objects (including all python modules in the directory). Really cool. > >Is the speedbar a part of jde-mode that happens to also work in python-mode, >or is it a language-neutral app? Can I ask python-mode to use it >automatically? > >I could have examined the elisp code ... but I'm no expert and somebody may >already know the answer. One of my goals for the JDE is to make Java developers aware of useful Emacs features, such as speedbar and imenu, that do not appear on the Emacs menu and hence may escape that notice of even longtime Emacs users. To that end, I put these features on the JDE menu. - Paul From effbot at telia.com Tue May 23 15:37:55 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 23 May 2000 19:37:55 GMT Subject: Photo and Image (Tkinter) References: <8gdhv7$4s59@esiami.tsai.es> <8gdl5f$4s510@esiami.tsai.es> Message-ID: AMR wrote: > I think is an dificcult question. I've asked for several times and I don't > have answer. Tkinter's PhotoImage class: http://www.pythonware.com/library/tkinter/introduction/photoimage.htm the Python Imaging Library comes with Tkinter support (and samples): http://www.pythonware.com/products/pil/index.htm (info) http://www.pythonware.com/library/pil/handbook/index.htm (docs) http://www.pythonware.com/library/pil/handbook/imagetk.htm also see the scientific computing howto: http://www.python.org/topics/scicomp/ and the graphics section at the vaults of parnassus: http://www.vex.net/parnassus/ From petersc at stud.ntnu.no Fri May 19 01:29:49 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 19 May 2000 07:29:49 +0200 Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> Message-ID: <3924D14D.85BF9A35@stud.ntnu.no> Alex wrote: > > > Is there a difference between the binascii.crc_hqx and the zlib.crc32 > > call? > > I don't know. The place to check would be the source code of the two > modules, I guess. And the results (as far as I can see) are: 1) zlib.crc32: is just a wrapper for the zlib's crc32 algorithm. probably good for speed but you don't know what you get (and depending in availability on zlib is not perfect either). 2) binascii.crc_hqx: seems to be a crc16 implementation used for the hqx-encoding. 3) binascii.crc32: obviously a crc32 algorithm with a nice documentation and some ISO blur. I think that'd be the way to go. spam-and-egg-ly y'rs -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From wtanksle at dolphin.openprojects.net Sun May 7 20:42:52 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 08 May 2000 00:42:52 GMT Subject: Strange error message when calling random in Py1.5 Message-ID: I'm running Python 1.5, doing some scripting for an urgent project (aren't they all), when I get an odd error. I can't imagine that this is normal; I can reproduce it from the Python prompt: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import random >>> random.random(100) Traceback (innermost last): File "", line 1, in ? random.random(100) TypeError: too many arguments; expected 1, got 2 >>> Whew. This one's not believable. Any ideas? -- -William "Billy" Tanksley From javanet at dynacap.com Tue May 2 18:54:50 2000 From: javanet at dynacap.com (Arnaldo Riquelme) Date: Tue, 2 May 2000 14:54:50 -0800 Subject: Database Programming Message-ID: I'm very new to Python, and I've been playing with it quite a bit. Most of the stuff I've done includes lots of SQL and C shell staff. I have a tab delimitted file that looks like this ( foo.prn) ========================================================= 19990222 86.8750 88.1250 86.6250 87.9375 24994 19990223 87.6875 87.8750 86.6250 87.3750 16288 19990224 87.0000 87.6875 85.7500 85.7500 18013 19990225 84.7500 85.0000 83.3750 84.4375 25336 ========================================================= I want to insert this file to database table called format_prices with fields (time,open,high,low,close,volume) I'm using mxODBC module in win32. I created a function that reads the file and puts the contents into a list ====================================================== def read_his_file(s): #make sure we are in the d:\__newstocks__ directory import os, string, sys os.chdir("d:\__newstocks__") lines = open(s).readlines() #get rid of new line character and white spaces lines = map(string.split, lines) table = [] #get rid of the header lines = lines[1:] for i in lines: prn = i[:-1] table.append(prn) return table ======================================================= Now I get this list [['19990222', '86.8750', '88.1250', '86.6250', '87.9375', '24994'].......] How do I loop thru the list and insert the date into format_prices? Is there some docs or tutorial that talks about issues like manipulating database with python.? In advance ,thanks a lot for all your help. Arnaldo From DOUGS at oceanic.com Wed May 3 04:42:17 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Tue, 2 May 2000 22:42:17 -1000 Subject: How to get terminal width? Message-ID: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> Assuming you're on a *nix platform, there is an environmental variable, COLUMNS, that should be accessible. If you use curses there is a stdscr.getmaxyx() function. -Doug- > -----Original Message----- > From: cpmcda01 at shark.kitenet.net [mailto:cpmcda01 at shark.kitenet.net] > Sent: Tuesday, May 02, 2000 1:45 PM > To: python-list at python.org > Subject: How to get terminal width? > > > > I need to write a command line script in Python that needs to > know the width > of the terminal in characters. I've looked through several modules and > haven't yet found what I'm looking for. Does anyone know > where I need to > look? > > > -- > Later, > _) Craig McDaniel > _)_) craig at tool.net > _)_)_) cpmcda01 at slug.louisville.edu > -- > http://www.python.org/mailman/listinfo/python-list > From jblazi at netsurf.de Sun May 14 07:39:39 2000 From: jblazi at netsurf.de (Janos Blazi) Date: Sun, 14 May 2000 13:39:39 +0200 Subject: Speed Message-ID: <391e9056_3@goliath.newsfeeds.com> Please look at the question at the end of this long posting. Here is a Python program: -------------------------------------------------------- global r r=[] def neue_zeile(z): global r z.reverse(); r=[] last=-1 for x in z: if x==last: cnt=cnt+1 else: if last != -1: r = [cnt,last] + r last=x cnt=1 r = [cnt,last] + r l=[1] for i in range(0,41): print i,len(l) neue_zeile(l) l=r print i,len(l) print "*done*" ---------------------------------------------------- And here the same program (as far I can tell) in C: ---------------------------------------------------- #include #include list R,L; void neue_zeile(list& z) { int last,cnt,x; z.reverse_items(); R.clear(); last=-1; forall(x,L) { if (x==last) ++cnt; else { if (last != -1) {R.push(last); R.push(cnt);} last=x; cnt=1; } } R.push(last); R.push(cnt); } int main() { int i; L.push(1); for(i=0;i<41;i++) { cout << i << " : " << L.length() << "\n"; neue_zeile(L); L=R; } cout << i << " : " << L.length() << "\n"; return 0; } ------------------------------------------------------- Now it is clear that C is faster than Python, so the C program will have a shorter execution time. But I cannot believe that C can be hundreds of times faster (The C code need less than 2 seconds on my NT machine and the Python code more than 17 minutes.) Is my Python code stupid? Can I improve it? Janos Blazi -----= 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 rayleyva at my-deja.com Tue May 9 23:16:09 2000 From: rayleyva at my-deja.com (rayleyva at my-deja.com) Date: Wed, 10 May 2000 03:16:09 GMT Subject: My mistake ... I didn't know Deja would do that to the code References: <8f9jr7$kk1$1@nnrp1.deja.com> <8fa1be$4k6$1@nnrp1.deja.com> Message-ID: <8fak9e$plg$1@nnrp1.deja.com> Thanks for the tip ... I'll be using it so I don't publicly humiliate myself next time Thanks for the help guys. Now all I've got to do is read up on what the hell an HTML form is, and make the page a dynamic report by letting people click on a column header to sort the information! Then of course comes data entry, then comes ... oh yeah sleep! 'preciate the help. Ray In article , Alex wrote: > > > I didn't know Deja would do that to the code > > There's not much you can do. On the deja page you use to view the post, > there's a link that says something like 'View original USENET format' > that will show the post with your intended formatting. > > Alex. > Sent via Deja.com http://www.deja.com/ Before you buy. From mwh21 at cam.ac.uk Sat May 13 11:59:13 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 May 2000 16:59:13 +0100 Subject: Python/Zope References: <02a401bfbc51$c99f5ae0$100a0a0a@dotfunk.com> Message-ID: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: > "Carl Page" writes: > > > The modern replacement (IMHO) for newsgroups is web-archive backed > > email groups. > > Let me vehemently disagree! :-) Me too! > I rather hate Web archive email. One has just no means to handle > high volume efficiently, and has to be on-line all the time > (something I cannot afford). Still in agreement. > More traditional newsreaders like Gnus are undoubtedly less flashy, > but they do the job _much_ better. Yes, gnus is far better. One of my favourite things is viewing mailing lists more or less as if they were newsgroups. > P.S. - If I ought to handle Web archives, and I it occurred a few times by > now, I swallow everything I can, and turn what I got into newsgroups (using > ad hoc Python scripts :-), before starting to read for real. It's a lot > of work for me, but I've the feeling that I win time on the overall process. Did you know you can get mbox format archives for all of the python.org mailing lists? Look in http://www.python.org/pipermail/.mbox/ Then just dump the file in nnmail-procmail-directory and you're away! Cheers, M. -- well, take it from an old hand: the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -- Erik Naggum, comp.lang.lisp From loewis at informatik.hu-berlin.de Mon May 29 11:58:29 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 May 2000 17:58:29 +0200 Subject: some thing aboute the PyTypeObject struct. References: <8gtp2i$243$1@gw.localdomain> Message-ID: "Sameh chafik pro" writes: > I want to question you about the PyTypeObject struct. > At prensent i try to export an agents lib write in C++ to Python and i want > to know is that is possible to set the hierarchy of a given class for mor > efficient translation code. I want to know if for a given class B derived > from a class A i can say that in the PyTypeObject struct or with an other > struct ? You can't have inheritance relationship between builtin types automatically. However, please have a look at the extension classes framework; I believe they support such a mechanism. Regards, Martin From robin.illusionsescalation at ACM.org Sun May 28 21:14:54 2000 From: robin.illusionsescalation at ACM.org (robin.illusionsescalation at ACM.org) Date: Sun, 28 May 2000 21:14:54 -0400 Subject: request: web site copy utility Message-ID: I realize this must be a common request, but I can't find the answer anywhere (Deja, Parnassus, Grimoire...). So before I cook my own... I'm looking for a Python script to download an entire web site. That is, given an URL, it will mirror the tree of files that exists at (and below) the URL on a local drive. Links to "outside" sites should be skipped. All images, backgrounds, CSS & JS files should be grabbed. ----- robin robin.illusionsescalation at ACM.org media artist / information architect www.execulink.com/~robin/ The form of e-coli bacteria that causes geomagnetic storms on earth. (remove illusions to reply) From mrw at nwu.edu Tue May 16 01:38:14 2000 From: mrw at nwu.edu (Mitchell R Whorlow) Date: 16 May 2000 00:38:14 -0500 Subject: Python and PVM Message-ID: <86u2fzyrzt.fsf@kemp064063.res-hall.nwu.edu> I am attempting to add a few more PVM function calls to the Python module for PVM available at www.flyn.org. I am currently interested in adding support for four calls, mainly pvm_joingroup(), pvm_lvgroup(), pvm_barrier(), and pvm_gettid(). I have added these function definitions to the downloadable C code, but after recompiling the module, I get undefined symbol errors when I try to import pypvm. I am hoping that someone can spare some time to help me out. My setup is: -FreeBSD 4.0 -gcc 2.95.2 -Python 1.5.2 -PVM 3.4 I used the same commands to compile the new module as I used to compile the original module. > ./configure > gcc -fPIC -O -I/usr/local/include -I/usr/lib/python1.5/config \ -DHAVE_CONFIG_H -c ./pypvm_coremodule.c > gcc -shared pypvm_coremodule.o -L/usr/local/pvm3/lib/FREEBSD -lpvm3\ -o pypvm_coremodule.so > make install That all works great for compiling and installing the original module, but after my additions, I now get the following error when starting up python: > python Python 1.5.2 (#2, Mar 16 2000, 23:37:01) [GCC 2.95.2 19991024 (release)] on freebsd4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import pypvm Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/site-packages/pypvm.py", line 25, in ? from pypvm_core import * ImportError: /usr/local/lib/python1.5/site-packages/pypvm_coremodule.so: Undefined symbol "pvm_gettid" >>> My function definition for pvm_gettid is quite simple, so I don't think that is the problem: There must be a linking error somewhere, but I can't figure it out, because as far as I can tell, I link against the necessary libraries. Thanks for any help, Mitch From cut_me_out at hotmail.com Thu May 4 15:48:45 2000 From: cut_me_out at hotmail.com (Alex) Date: 04 May 2000 15:48:45 -0400 Subject: BLOBS and python References: <8esivv$l5k$1@nnrp1.deja.com> Message-ID: > I'm trying to insert an image as a blob, but unless I escape any > quotes ("') within it, it seems to puke. The problem is, it's an > image and if I escape the quotes, I change the image. How can I do > this? > > import cgi > import MySQLdb > query = cgi.FieldStorag() > image = query["filename"].value > > c = MySQLdb.connect(...) > con = c.cursor() > con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % image) Don't know whether it'll be fast enough for you, but From hinsen at cnrs-orleans.fr Thu May 25 13:50:58 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 25 May 2000 19:50:58 +0200 Subject: Makefiles [offtopic] References: <392C76CF.27A5D18B@san.rr.com> <392C8D1D.C5DEB536@san.rr.com> <8gj1td$tci$1@dokkum.cs.uu.nl> <392D3795.8B6D59CA@san.rr.com> Message-ID: Fran?ois Pinard writes: > Courageous writes: > > > What *is* the best tool for managing builds? > > I do not know, but it will likely be written in Python! :-) And it might not be so far away: http://software-carpentry.codesourcery.com/ -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From aahz at netcom.com Tue May 30 15:46:35 2000 From: aahz at netcom.com (Aahz Maruch) Date: 30 May 2000 19:46:35 GMT Subject: Python for project planning tool References: <3933C0D0.63B8731A@NOSPAM.philips.com> Message-ID: <8h15qr$d9$1@slb0.atl.mindspring.net> In article <3933C0D0.63B8731A at NOSPAM.philips.com>, Jeroen Lamain wrote: > >We are trying to develop a project managment tool like MS Project 98. > >Previously we were developing using c++ and gtk. Yesterday I >tried Python and the GNOME binding. I was very impressed by >the ease of development. (this was my first experience with Python) > >Is python ok for developing such a tool ? I mean... is it usable >for a such a kind of project. Will I have enough performance >when writing everything in Python (UI, task scheduler) ? The "standard" argument is that Python makes it much easier to test out different algorithms. What's better, O(N^2*0.1) for a C++ solution or O(NlogN) for a Python solution? Once you get to the best algorithm, you can recode in C++ if you find bottlenecks. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Have you coined a word today? --Aahz From thomas at xs4all.net Fri May 26 19:14:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 27 May 2000 01:14:48 +0200 Subject: Help! SMTPlib In-Reply-To: <8gmti4$sf5$1@nnrp1.deja.com>; from sjoshi@ingr.com on Fri, May 26, 2000 at 10:24:19PM +0000 References: <8gmti4$sf5$1@nnrp1.deja.com> Message-ID: <20000527011448.D13281@xs4all.nl> On Fri, May 26, 2000 at 10:24:19PM +0000, sjoshi at ingr.com wrote: > I'm trying to use the smtplib for sending mail, and I keep getting > error: (10061, 'winsock error') when I try just to connect to the > localhost. I can't help you much with that winsock error, not really being a windows man and all, but have you tried connecting yourself, through windows telnet? Just do start -> run -> 'telnet 25', using the same localhost you are using in smtplib ? Are you sure you are running a SMTP server, on port 25 ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jkraska1 at san.rr.com Mon May 29 15:23:18 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 19:23:18 GMT Subject: VCC PRIORITY QUEUE NATIVE IMPL Message-ID: <3932C43C.8E617E0@san.rr.com> This is a visual c++ implementation of a heap-priority queue. It is 5-6 times faster than the equivalent python, as tested doing heapsort. This priority queue implements "lowest is best" priority, so all pops always retrieve the lowest item in the queue. This is my second implementation of a python C extension, and I believe it is correct, however there exists some small chance I've messed up something with references, as I'm fairly new at this. Hope someone finds this useful, C/ ////////////////////////////////////////////////////////////////////// // Pqueue.c -- pque and pque cursor object types for python ////////////////////////////////////////////////////////////////////// #include #include #include #include ////////////////////////////////////////////////////////////////////// // FORWARD DECLARES AND THE LIKE: ////////////////////////////////////////////////////////////////////// static char msg[256]; staticforward PyTypeObject PqueueObjectType; ////////////////////////////////////////////////////////////////////// // INTERNAL DATA TYPES: ////////////////////////////////////////////////////////////////////// typedef struct __PqueueNode PqueueNode; typedef struct __PqueueNode { double priority; PyObject* object; } PqueueNode; ////////////////////////////////////////////////////////////////////// // EXTERNAL DATA TYPES / PYTHON OBJECTS: ////////////////////////////////////////////////////////////////////// typedef struct __Pqueue { PyObject_HEAD PqueueNode** heap; // the heap array long len; // current length long alloclen; // allocated length } Pqueue; ////////////////////////////////////////////////////////////////////// static void PqueueObjectDestroy (Pqueue* self); static PyObject* PqueueObjectGetattr (Pqueue* self, char* name); static int PqueueSeqLen (Pqueue* self); //#################################################################### // PQUEUE METHODS //#################################################################### static PyObject* PqueuePush ( Pqueue* pque, PyObject* args ) { PqueueNode* newnode; PqueueNode* temp; PyObject* object; double pri; PqueueNode** heap; long pos; if (!PyArg_ParseTuple(args,"dO", &pri, &object)) { PyErr_SetString(PyExc_ValueError, "attempt to push onto pque without an object to push"); return NULL; } Py_INCREF ( object ); newnode = (PqueueNode*) malloc ( sizeof(PqueueNode) ); newnode->object = object; newnode->priority = pri; pos = pque->len+1; heap = pque->heap; heap[pos] = newnode; pque->len++; //sprintf(msg,"print \"pushing node pos= %d pri= %f\"", pos, pri); //PyRun_SimpleString(msg); while (heap[pos/2]->priority > heap[pos]->priority) { temp = heap[pos/2]; heap[pos/2] = heap[pos]; heap[pos] = temp; pos /= 2; } Py_INCREF(Py_None); return Py_None; } static PyObject* PqueuePop ( Pqueue* pque, PyObject* args ) { PqueueNode** heap; PqueueNode* popnode; PqueueNode* temp; PyObject* retval; long pos; long len; double pri; long j; if (pque->len == 0) { Py_INCREF(Py_None); return Py_None; } heap = pque->heap; popnode = heap[1]; retval = popnode->object; len = pque->len; pri = popnode->priority; pos = 1; j = 2; if (len>1) { heap[1]=heap[len]; len--; while ( pos <= len/2 ) { if ( jpriority > heap[j+1]->priority) j++; if ( heap[pos]->priority <= heap[j]->priority) break; temp = heap[pos]; heap[pos] = heap[j]; heap[j] = temp; pos = j; j = pos*2; } } pque->len--; free((char*)popnode); //Py_INCREF(retval); return retval; } //// PqueuePeek() -- return the value of the tail item, but don't pop static PyObject* PqueuePeek ( Pqueue* pque, PyObject* args ) { if (pque->len == 0) { Py_INCREF(Py_None); return Py_None; } Py_INCREF(pque->heap[1]->object); return pque->heap[1]->object; } static PyObject* PqueueDump ( Pqueue* pque, PyObject* args ) { int i; for (i=0;ilen+1;i++) { sprintf(msg,"print \"node %f\"", pque->heap[i]->priority); PyRun_SimpleString(msg); } Py_INCREF(Py_None); return Py_None; } //#################################################################### // MODULE HOOKUPS //#################################################################### //// Primary instance object CONSTRUCTOR static PyObject* PqueueCreate ( PyObject* module, PyObject* args ) { Pqueue* pque = PyObject_NEW (Pqueue,&PqueueObjectType); PqueueNode* sentinel = (PqueueNode*) malloc ( sizeof(PqueueNode)); long initialsize = 1000; PyArg_ParseTuple(args,"i", &initialsize); // failure okay sprintf(msg,"print \"new pque size is %d\"", initialsize); PyRun_SimpleString(msg); // we always make room for a sentinel pque->heap = (PqueueNode**) malloc ( (initialsize+2) * sizeof(PqueueNode*) ); sentinel->priority = -1; pque->heap[0] = sentinel; pque->len = 0; pque->alloclen = initialsize; return pque; } //// Pqueue object method hookup static char PqueuePushDoc[]= "p.push(priority,object) -- pushes an object onto the queue with the designated priority; always returns None"; static char PqueuePopDoc[]= "p.pop() -- pops the highest priority object off the priority queue; returns None if no object is present."; static char PqueuePeekDoc[]= "p.peek() -- returns the object at the head of the pque, leaving it in the pque; returns None if no object is present."; static struct PyMethodDef PqueueObjectMethods[]= { { "push", (PyCFunction)PqueuePush, 1, PqueuePushDoc }, { "pop", (PyCFunction)PqueuePop, 0, PqueuePopDoc }, { "peek", (PyCFunction)PqueuePeek, 0, PqueuePeekDoc }, { "dump", (PyCFunction)PqueueDump, 0, PqueuePeekDoc }, { NULL, NULL } }; static PySequenceMethods PqueueSequenceMethods= { (inquiry) PqueueSeqLen, // len(p) (binaryfunc) 0, // concat (intargfunc) 0, // ? (intargfunc) 0, // p[i] (intintargfunc) 0, // p[i:j] (intobjargproc) 0, // p[i]=v (intintobjargproc) 0, // p[i:j]=v }; //// Pqueue object python type static PyTypeObject PqueueObjectType = { PyObject_HEAD_INIT(0) // mandatory init 0, // ? "pqueue", // object name sizeof(Pqueue), // record size 0, // ? (destructor) PqueueObjectDestroy, 0, // print (getattrfunc) PqueueObjectGetattr, 0, //PqueueObjectSetattr, 0, // compare 0, //PqueueObjectRepr, 0, // number &PqueueSequenceMethods, 0, // mapping 0, // hash 0, // call 0 // str }; //// Our module-level methods; there's just one: static char PqueueCreateDoc[] = "create() -- creates a priority queue object"; static PyMethodDef PqueueModuleMethods[]= { {"create", PqueueCreate, 1, PqueueCreateDoc}, {NULL, NULL } }; //#################################################################### // PQUEUE PRIMARY METHODS //#################################################################### static void PqueueObjectDestroy (Pqueue* self) { int i; free((char*)self->heap[0]); // free the sentinel for (i=1;ilen+1;i++) // from sentinel to end { Py_DECREF ( self->heap[i]->object ); free((char*)self->heap[i]); } PyMem_DEL (self); } static PyObject* PqueueObjectGetattr ( Pqueue* self, char* name) { return Py_FindMethod(PqueueObjectMethods,(PyObject*)self, name); } static int PqueueSeqLen (Pqueue* self) { return self->len; } //#################################################################### // GLUE //#################################################################### void _declspec(dllexport) initpqueue() { Py_InitModule("pqueue", PqueueModuleMethods); } ////////////////////////////////////////////////////////////////////// // END ////////////////////////////////////////////////////////////////////// From walter at bnbt.de Tue May 16 04:16:31 2000 From: walter at bnbt.de (walter at bnbt.de) Date: Tue, 16 May 2000 08:16:31 GMT Subject: ANNOUNCE: XIST 0.1 - an XML based extensible HTML generator Message-ID: <8fr04l$fbp$1@nnrp1.deja.com> Hi all! XIST is a HTML preprocessor/generator and an XML transformation engine. Some of the significant features of XIST include: * Easily extensible with new XML elements * Can be used for offline or online page generation * Allows embedding Python code in XML files * Works together with httpdapy/mod_python * Simplifies handling of deeply nested directory trees * Automatically generates HEIGHT and WIDTH attributes for images It was written as a replacement for the HTML preprocessor HSC (http://www.giga.or.at/~agi/hsc/), and borrows some features and ideas from it. It also borrows the basic ideas (XML/HTML elements as Python objects) from HTMLgen or HyperText. XIST is available from ftp://titan.bnbt.de/pub/livinglogic/xist/. Direct questions regarding XIST to walter at bnbt.de.

    XIST 0.1 - an XML based extensible HTML generator. (16-May-2000) Bye... Walter D?rwald Sent via Deja.com http://www.deja.com/ Before you buy. From copal at cifnet.com Sat May 13 00:55:19 2000 From: copal at cifnet.com (Ian Mondragon) Date: Fri, 12 May 2000 23:55:19 -0500 Subject: Objective-C + Python...? Message-ID: <391CE037.14B030E9@cifnet.com> hello, all- i was searching the archives today for information about compiling python on NeXTSTEP (success!), and stumbled accross a tasty little treat: i found 2 messages, one from guido himself, about objective-c interoperability. unfortunately, these dated back to april of 1995, with no more mention of the project. so...did this ever culminate into something as glorious as it sounds like it could be? or did the project bite the dust? my company is still _very_ NeXT based, and i am one of the three people in my group loudly banging the python drum, and something like this would probably be of more use than i can imagine in terms of rapid development and python advocacy. please do let me know of *anything* pertaining to this topic... thanks. -ian -- Ian Mondragon == copal at cifnet.com From bjorn at roguewave.com Thu May 4 13:58:33 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 04 May 2000 11:58:33 -0600 Subject: Map lots of words to lots of integers References: <39176ae0.613278087@news.online.no> Message-ID: <3911BA49.C7FCA7C2@roguewave.com> The shelve module should be most useful to you: import shelve db = shelve.open('foobar.db') db['key'] = [1,2,3] for k in db.keys(): print k, db[k] db.close() if your lists get _really_ long, just add a layer of indirection (something along the lines of): db['word'] = ['@word at 1', '@word at 2'] # list of keys to sublists db['@word at 1'] = [1,2,3] # first sublist db['@word at 2'] = [4,5,6] # second sublist -- bjorn ?5?HH575-UAZWKVVP-7H2H48V3 wrote: > > Hi, > > I need a fast way of mapping words to integers. A single word must be > able to point to many, *many*, integers. Tried stuff like a dict, > words as keys, pointing to a list of integers. This is all fine and > nice if the thing is located in memory. I want to (or need ) to store > all of this on disk. And the method must be fast. Thought I could use > a Berkley DB file using words as keys, but what should they point to? > > The number of words can of course be thousands and the integers they > point to even more. Does Zopes internals like ZODB etc. offer anything > I could use? > > What I`ve tried so far is to make a general indexing-module, where you > do something like > > x = Indexer('data_file.db') > > # extract words from documents etc. > > x.add(word2index, id) > etc. etc. > x.index() > print x.locate('python') > [432,6363,326,65464,6544,456465465,65433,76] # of course this would be > # HUGE and may not fit into a list > > What I`d really need is to store several integers as one key/id, ex. > as a tuple, but I`ll settle for less if somebody just could give me > some pointers. > > NOTE! The number of words are as many as there are eh ... words, and > integers, well, how far can a human count? > > Thanks. > > Thomas > -- > http://www.python.org/mailman/listinfo/python-list From jkraska1 at san.rr.com Sun May 28 16:35:15 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 28 May 2000 20:35:15 GMT Subject: Multfile C Extensions References: Message-ID: <393183A1.CA671D4B@san.rr.com> > since all functions/variables must be static (aside from init) > how can i get the different files to work with each other? I don't believe that this is strictly true; the primary motivation for making all the methods/variables static is to prevent namespace collision. static declarations in a single file are therefore WISE, but not required. > i can work around most of the problems, but the biggest > one seems to be the initializing stuff. > > is there an example of a C extension out there that is split > into a couple source files? the biggest problem is i want it > all in one module... > > urgh, this shouldn't be so tough? Well, the obvious trick, albeit totally ugly, would be to do something like... #include "file1.c" #include "file2.c" #include "file3.c" ... segmenting all your files together into only one file which you compile. The other idea which comes to mind is simply taking extreme care to manage your symbol space and forgo the use of static variables. I should point out that some of the harder problems I've had during my professional career have involved finding namespace conflicts which the compiler did not detect; a situation in which the compiler quietly allows a duplicate symbol to override a previous instance of the symbol in the symbol space is nightmarish indeed. C/ From mwh21 at cam.ac.uk Thu May 4 16:37:51 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 May 2000 21:37:51 +0100 Subject: Problems again on starship? References: Message-ID: bhoel at starship.python.net (Berthold H?llmann) writes: > Hello, > > I just tried to login to the starship using ssh. It used to work after > the big crash, but does not work anymore. ssh, instead of asking me > for the passphrase, asks me for a password, which used to be a sign, > that I mad some typo using the command, but I triple checked the > command, and it is correct. Any changed configureation? Hmm; that's odd; ssh -v mwh at starship.python.net gets me amongst other stuff: atrus.jesus.cam.ac.uk: Remote: Could not open /home/crew/mwh/.ssh/authorized_keys for reading. which is bizarre, 'cause it was there last week... M. -- 41. Some programming languages manage to absorb change, but withstand progress. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From sabren at manifestation.com Tue May 30 16:42:17 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Tue, 30 May 2000 16:42:17 -0400 (EDT) Subject: Using strings with ' in them in SQL-queries In-Reply-To: <39342055.1301760@news.c2i.net> Message-ID: On Tue, 30 May 2000 thomas at cintra.no wrote: > db = _pg.connection(....) > db.query('insert into test (id, name) value (1, 'fdsfds''fdsf') ') > > That works ok. But the string I need to insert I get from a variable. > I cannot seem to use a variable in the query-string. Is there any way > around this? How can I handle characters in strings that may > comprimise the requirements of a valid sql-statement?? Hey Thomas, well, for one thing, you can use double quotes.. :) db.query("insert into test (id, name) value (1, 'fdsfds''fdsf') ") but then, try this: import string somestring = "a ' value ' with ' apostrophes" somestring = string.replace(somestring, "'", "''") Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From m.faassen at vet.uu.nl Fri May 12 15:29:01 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 19:29:01 GMT Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: <8fhm1t$nk0$5@newshost.accu.uu.nl> Konrad Hinsen wrote: > Oliver Andrich writes: >> So, what things are open and need to be solved: >> >> 1. Is the whole effort really needed and worth the work you have to do? > All I can say is that I have profited a lot from it. Sure, I got a > Python installation with RedHat 6.1, but not with all the nice add-on > packages which I use. I think the distutils should be able to help a lot here. Once they are mature enough, you should be able to easily install most add-ons through those. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From yawyi at gmx.de Tue May 30 16:51:44 2000 From: yawyi at gmx.de (Johannes Stezenbach) Date: Tue, 30 May 2000 22:51:44 +0200 Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <8h15qr$rje$1@news.udel.edu> Message-ID: <39342a83$0$18384@personalnews.de.uu.net> Terry Reedy wrote: >0. Tuples currently do not have methods, so a full (rather than half) >implementation of the other choice is currently not possible! There is no reason for tuples not to have methods. >1. Any string can be used as a joiner, but not all tuple/lists can be >joined (as join is currently implemented). One input and the output are >strings, and the other input is a sequence of strings. Join is about >strings, and not about general sequences (or even general tuples and >lists). It's a valid argument against join() generalization, but irrelevant regarding sep.join(seq) vs. seq.join(sep). >2. It is common to use one joinstring (such as ' ', ',' or ', ') to join >mupliple stringseqs and rare to join one stringseq with multiple >joinstrings. (The same is true for realworl nails, staples, glue joining >batches of wood, cardboard, fabric, paper, etc.) It is at least as >sensible to consider joining to be a method of the relatively stable (in >any particular context) joiner as to think of it as a method of the more >variable collection being joined. This makes sense only if you think of separators as abstract objects. But as they are usually short strings, I predict people will use a common coding style like this: str1 = ", ".join(list1) str2 = ", ".join(list2) str3 = ", ".join(list3) See? It's unreadable not only because it's the wrong way round, but also because the "unframed" separator string looks funny (unusual/unfamiliar). >3. Generalization seems more sensible this way. For instance, suppose I >want to be able to join any sequence and have non-string items converted to >strings: > >import string; join = string.join > >class joiner: > def __init__(s, sep): > # assert (type(sep) == type('')) > s.sep = sep > def join(s, seq): > # return s.sep.join(map(str, seq)) > return join(map(str, seq), s.sep) # don't have 1.6 yet > >comma = joiner(', ') >comma.join((1,2,3)) ># '1, 2, 3' >comma.join('string') ># 's, t, r, i, n, g' Despite all I said before, I like this one because it's both elegant and confusing. Except that you commited a Python coding crime by not naming self self. Johannes From effbot at telia.com Wed May 17 10:58:10 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 17 May 2000 14:58:10 GMT Subject: How to reprint sys.last_traceback References: Message-ID: <6syU4.7910$Za1.122019@newsc.telia.net> Warren Postma wrote: > I see that the last traceback object is in the sys module as > sys.last_traceback. > How do I force a dump of that to a file object, or stringio or something > like that? (as a python function) http://www.python.org/doc/current/lib/module-traceback.html From m.faassen at vet.uu.nl Mon May 15 05:50:10 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 May 2000 09:50:10 GMT Subject: Java vs Python References: <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F@lp.airnews.net> Message-ID: <8foh8i$31m$1@newshost.accu.uu.nl> Erno Kuusela wrote: [snip] > HD> 3 Which is faster eg. Java servlets or Python CGI with > HD> mod_python ? > cgi is usually a bit slow, whether you use it to run java or python > or perl or cobol programs. Not if you run it with something like mod_python. CGI is slow because it keeps firing up interpreters. Things like mod_python (or Zope for that matter) make this unnecessary; a python interpreter stays in memory. Unless there's something else about CGI making it slower? I can't imagine what, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From peter.milliken at gtech.com Wed May 17 22:38:58 2000 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 18 May 2000 12:38:58 +1000 Subject: Auto-insert of colons in Emacs References: Message-ID: <8fvl63$seb9@news1.gtech.com> Hi John, To quote a famous recent email "Why hobble your mind with a detail the computer can figure out for itself?" :-) Have a look at true language sensitive editing using Emacs at http://members.xoom.com/pmilliken I have just updated the minor mode (you will see it if you haunt gnu.emacs.sources) and added a new template language for Python :-) So, now you can get the computer to generate all of the syntax and you just supply the variable names :-) This mode works with any major mode, not just Python, there are language templates for C, Ada, Emacs-Lisp etc I have only just started learning Python, so I don't claim the templates are perfect but I have been using them for a couple of days now without problems. If there is something you don't like let me know and I will fix it (full instructions on how the templates work and how to modify them are included in the 45+ page user manual :-)). Any questions, please don't hesitate to call :-) Peter John Wiegley wrote in message ... > >Why hobble your mind with a detail the computer can figure out for >itself? > >It's very strictly defined where a colon should go in Python, so it >makes little sense that humans should be bothered with this detail. >If it makes the code more readable for those who didn't write it, I >can understand; but the author has better things to think about. > >Accordingly, the following snippet of Emacs code will ensure there is >always a colon where it should be. You should never have to type them >again, except when you want the whole statement to fit on one line. > >To use it, just put everything after the "----" in your .emacs file. > >Enjoy. This was written for users of python-mode.el >(http://www.python.org/emacs/python-mode/) > >---------------------------------------------------------------------- > >(eval-after-load "python-mode" > '(progn > (defvar python-keywords-wanting-colon > '("def" "class" "if" "while" "else" > "try" "except" "finally" "for" "lambda")) > > (defvar python-kwc-regexp nil) > > (require 'advice) > (defadvice py-newline-and-indent (before always-insert-colons activate) > "Always make sure that colons appear in the appropriate place." > (unless (eq (char-before) ?:) > (let ((here (point)) > insert-colon already-has-it) > (save-excursion > (beginning-of-line) > (save-excursion > (if (search-forward ":" here t) > (setq already-has-it t))) > (unless already-has-it > (unless python-kwc-regexp > (require 'regexp-opt) > (setq python-kwc-regexp > (concat "\\s-*\\<" > (regexp-opt python-keywords-wanting-colon t) > "\\>"))) > (if (looking-at python-kwc-regexp) > (setq insert-colon t)))) > (if insert-colon > (let ((last-command-char ?:)) > (py-electric-colon nil)))))))) From gavin at coaps.fsu.edu Tue May 30 13:06:15 2000 From: gavin at coaps.fsu.edu (Peter Gavin) Date: Tue, 30 May 2000 13:06:15 -0400 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <392d08fe.185503740@news.u-psud.fr> Message-ID: <3933F507.5A78EF7C@coaps.fsu.edu> Laurent POINTAL wrote: > > In our modules, we use the following syntax to avoid publication of > imported symbols (copied from... I dont remember which Python source): > > import string > _string = string > del string > > And we always prefix string operation functions by _string. > This looks like a good idea. Wouldn't it be useful to be able to do it in one step? It shouldn't be too hard to add a syntax similar to: import string as _string That would eliminate the need for _string = string; del string. Peter Gavin From Gareth.McCaughan at pobox.com Wed May 10 16:24:16 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 10 May 2000 21:24:16 +0100 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> Message-ID: <8666smcfwv.fsf@g.local> Fredrik Lundh wrote: > Jacek Generowicz wrote: >> How would you rewrite the following code, in good >> python style ? >> >> list1 = [ 1,2,3,4,5,6 ] >> list2 = [ 6,5,4,3,2,1 ] >> >> count = 0 >> for item in list1: >> print item - list2[count] >> count = count + 1 > > slightly less obscure: > > for i in range(len(list1)): > item1 = list1[i] > item2 = list2[i] > ... > > the slightly more obscure way: > > for item1, item2 in map(None, list1, list2): > ... For this particular case, I suggest for x in map(lambda a,b: a-b, list1,list2): print x or, for those who aren't scared of such things, for x in map(operator.sub, list1,list2): print x Of course this only works because the operation being done on the items factors into (1) a simple combination of the two, and (2) something being done to the result. I can't persuade myself not to remark on how much I hate the way that Python's syntax for lambdas and map/reduce interacts to produce horrors like map(lambda a, b, c: a+b+c, p, q, r) But my preference, which is for some notation along the lines of map({a,b,c -> a+b+c}, p,q,r) isn't very Pythonic. Especially as we already have a {...} syntax for dictionaries. (I admit to slightly disingenuous use of whitespace in the last two snippets.) Best of all for this, of course, would be list comprehensions. But that's been done to death in c.l.py already. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From mjackson at wc.eso.mc.xerox.com Mon May 8 14:14:36 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 8 May 2000 18:14:36 GMT Subject: OT [Way OT]: Unicode Unification Objections References: Message-ID: <8f706c$imk$1@news.wrc.xerox.com> Franc[approximately]ois_Pinard writes: > Agreed that Japanese people are themselves on this. Some are ready to > accept Han unification together with Microsoft Windows, if they really > have to be bundled together, they just don't care. Others do. Has their Justice Department determined whether said bundling is, in fact, an anticompetitive attempt to stamp out other Han vendors? > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard You see that my newsreader handles the cedilla in your name just fine, but somewhere along the way the one in the header gets munged into an imbedded break into the ISO-8859-1 character set. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson In judging others, folks will work overtime for no pay. - Charles Carruthers From phd at phd.russ.ru Fri May 5 04:39:20 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 5 May 2000 08:39:20 +0000 (GMT) Subject: No strptime? In-Reply-To: <3911C96B.3B2CCD5E@concentric.net> Message-ID: On Thu, 4 May 2000, Manus Hand wrote: > I had the same problem, so I rolled my own (limited) strptime. I'd recommend looking at http://www.fukt.hk-r.se/~flognat/hacks/strptime.py Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From rwcitek at uci.edu Thu May 18 13:55:21 2000 From: rwcitek at uci.edu (Robert Citek) Date: Thu, 18 May 2000 12:55:21 -0500 Subject: Python AND (not vs.) Perl In-Reply-To: <5mVU4.4656$wYl.204818944@newsb.telia.net> References: <3.0.6.32.20000517234308.008189a0@earthlink.net> Message-ID: <3.0.1.32.20000518125521.0070a5bc@earthlink.net> At 05:01 PM 5/18/00 GMT, Fredrik Lundh wrote: >Robert Citek wrote: >> I have seen a lot of discussion about Python vs Perl >> as well as discussion >> on Python and C, C++, Java, VBA, etc. So I was wondering >> if Python can use >> any of the existing Perl modules or classes? And can Perl use Python >> modules or classes? Any pointers in the right direction appreciated. > >http://mini.net/pub/ts2/minotaur.html Beautiful! I am going to give this a whirl. Now I can have my Python and Perl. After all, isn't that what a glue language is supposed to do? Thanks a bunch. - Robert From ryan at velara.com Tue May 23 14:37:27 2000 From: ryan at velara.com (Ryan Donahue) Date: Tue, 23 May 2000 14:37:27 -0400 Subject: How do I create extensions to Python in C? Message-ID: I new to python and would like to use it to call some C functions. How do I do this. Ryan Donahue ryan at velara.com From ullrich at math.okstate.edu Tue May 23 15:28:33 2000 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 23 May 2000 19:28:33 GMT Subject: Decimals -> Fraction strings, my solution References: <3922bbbb.59529999@client.ce.news.psi.net> <3922E238.29CEDE3B@stud.ntnu.no> <39242f0a.1044508290@news> Message-ID: <392adae5.350207138@news> On 22 May 2000 13:36:27 -0400, =?ISO-8859-1?Q?Fran=E7ois_Pinard?= wrote: >ullrich at math.okstate.edu (David C. Ullrich) writes: > >> def gcd(a, b): >> while a: >> a, b = b % a, a >> return b > >By the way, I think the above could be better written: > >def gcd(a, b): > while b: > a, b = b, a % b > return a > >It does not change much, and I'm not even sure exactly why, but I find it >more legible. I had no idea what you were getting at at all until you explained elsewhere that preserving a > b seemed more natural. (I think that allowing a call gcd(a,b) whether a > b or not is good - if a < b the first time through the loop will swap them - probably that initial "if a < b swap" might be faster. But I'm not gonna worry about that, cuz I use this in situations where there's no "<" in any case...) >-- >Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > > > From paul.robinson at quantisci.co.uk Wed May 10 10:28:35 2000 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Wed, 10 May 2000 15:28:35 +0100 Subject: Configure --with-thread Message-ID: <39197213.61145095@quantisci.co.uk> Two quick questions: 1) In the README included with py152.tgz the description of configuring thread support says the following: (Threads aren't enabled automatically because there are run-time penalties when support for them is compiled in even if you don't use them.) so, firstly is this correct and up-to-date? (I ask because the description of how to enable the module is slightly out of date) and if so: what kind of run-time penalties are we talking about? 2) Does anyone know which (if any) current (and recent) Linux distributions have thread support configured for Python by default? Thanks, Paul. ----------------------------------- Business Collaborator Team Enviros Software Solutions http://www.businesscollaborator.com ----------------------------------- From frankc at colconsulting.com Fri May 5 07:23:31 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Fri, 05 May 2000 07:23:31 -0400 Subject: Copyright and License References: <000601bfb662$d0d47ce0$d02d153f@tim> Message-ID: <3912AF33.FFB5E949@colconsulting.com> Neil Hodgson wrote: > > > > I'm looking for something more along the lines of the Python GPL. There > > > is a Python accepted (Open Source) license, but it points back to the > > > Python specific one. > > > > I don't understand what you're saying. Assuming nobody else does either, > > that may explain why you're not getting the answer you want . > > I think I understand what Frank wants because I've already done it. If > you want a license that is just like the Python license but with the serial > numbers filed off then just do it. Replace all references to "Stichting > Mathematisch Centrum" and "CNRI" with "Frank V. Castellucci" or whatever you > wish to call your coding collective. > > For my version, see: > http://www.scintilla.org/License.txt > > A possible reason for this topic turning up is that SourceForge only > wants to host your project if it uses an open source license. You can pick > from a pre-approved set which includes the Python license or submit your own > for consideration so its easier to just use your favourite one from their > set. > > Neil Thanks Neil. Done! I will also assume that any contributions would in effect have the same copyright with the authors name in the "filed" off spots. -- Frank V. Castellucci From noone at do.not.use Fri May 26 14:40:48 2000 From: noone at do.not.use (Russell Turpin) Date: Fri, 26 May 2000 13:40:48 -0500 Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> <392C4B4F.60C4@esatclear.ie> <392C7F0F.64BA39D0@cosc.canterbury.ac.nz> <87itw2qtj0.fsf@deneb.cygnus.argh.org> Message-ID: <392EC530.BDDA4E9D@do.not.use> Greg Ewing writes: > If you know that the operands will never be negative, declare them > as unsigned so that the compiler has the chance to optimise. .. You never know when you will want a sentinel. Russell From jeremy at beopen.com Wed May 31 14:42:19 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 31 May 2000 14:42:19 -0400 Subject: Error message References: Message-ID: Michael Hudson writes: > > I particularly hate: > > TypeError: illegal argument type for built-in operation > > It just tells you nothing. I've been meaning to whip round the Python > sources and replace all the calls to PyErr_BadArgument (for 'tis that > that gives the above message) with something a little more helpful, > but I haven't got round to it yet... > That would be a great project for someone to pick up. There aren't that many places that need to be fixed. If you just focus on the Objects directory, you'll be able to fix most of the ones that people run into. Jeremy From effbot at telia.com Thu May 11 09:37:15 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 13:37:15 GMT Subject: Newbie questions - FAQ and tuples. References: <34575A892FF6D1118F5800600846864D215DF8@intrepid> Message-ID: Simon Brunning wrote: > Firstly, is there a FAQ/charter for this newsgroup? http://www.python.org/doc/FAQ.html also see: http://www.faqs.org/ftp/faqs/python-faq/python-newsgroup-faq > Secondly, I'm working through the tutorial, and I'm a bit confused > about this tuples business. I *think* that I understand how they > work, but what are they *for*? simple, often heterogeneous collections of data values. usually used where you would use a C struct or a Pascal record, and where a class would be to heavyweight. most often used for things like multiple return values, dictionary keys, coordinate pairs, etc. and everywhere else it makes sense to use a tuple instead of some other container type... "tuple : set of (so many) elements -- usually used of sets with ordered elements " -- merriam webster From r2d2 at mao.acc.umu.se Tue May 30 03:33:00 2000 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: 30 May 2000 07:33:00 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <39333CC3.32805F5@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: >Personally, I don't think that such a generalised join belongs >as a method of *either* argument. >I think that a suitably generalised join should be a builtin, >like map and reduce. I can't see a generalised join being used often enough to warrant making it a built-in. Whenever you need a generalised join, you can simply write: reduce(lambda x,y: x+" "+y, list) (Use desired operation in place of x + " " + y.) Since you will be using __add__ operations anyway (in the generalised case) I don't think there would be any great speed improvements by having the generalised join as a built-in. // Niklas From greg at cosc.canterbury.ac.nz Wed May 24 21:17:03 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 25 May 2000 13:17:03 +1200 Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> <392C4B4F.60C4@esatclear.ie> Message-ID: <392C7F0F.64BA39D0@cosc.canterbury.ac.nz> Russell Wallace wrote: > > a simple > arithmetic operation on ints will compile into a section of code with > multiple branch instructions *even in the overwhelmingly most common > case where negative operands will never occur*. If you know that the operands will never be negative, declare them as unsigned so that the compiler has the chance to optimise. Or give the language another operator that complains about negative numbers. > different humans > *disagree* on what the logical thing for negative integer division to > return is. Sigh. This is because language designers have big holes in their heads when they try to map two different operations onto the same operator. It's not a case of one being more "logical" than the other -- both are useful, depending on the circumstances. The *logical* thing to do is to provide two operators (four, actually, counting the corresponding flavours of division). > I'd much rather explicitly add 60 and know where I stand. That only works if you know that you're never going to go more than once around the clock in the negative direction. If you don't know that, the correction you have to apply is hairier still. I'd much rather have an honest, well-defined "wrap around" operator that I can rely on, even if I have to look up the language definition now and then, than have to wade through code that's been obfuscated to work around its absence. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From dale at out-think.NOSPAMco.uk Thu May 18 16:25:16 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 18 May 2000 21:25:16 +0100 Subject: Checksum routine - new to Python Message-ID: <8g1no6$8uc$1@supernews.com> I need a little checksum routine as part of a larger project. I've written the one below, which basically works, but it only produces a 32 bit checksum. I'd prefer a 64 bit checksum but don't know how to code it in Python. I can't get 'logical and' with >31 bits to work. This code might look unusual but some of the files I'm checksumming have long strings of binary zeros at the end which were having the effect of clearing out the checksum. Also this code will handle files that are all zeros and still yield a useful result. If there is a Python library with something suitable, I'll happily use that instead. Thanks for any advice/help. def CheckSum(filepath): file = open(filepath, "rb") chksum = 0L toggle = 0 allfile = file.read() i = 0 while i < len(allfile): ch = allfile[i] if ord(ch) > 0: if toggle: chksum = chksum << 1 chksum = chksum + ord(ch) chksum = chksum & 0X7fffffff toggle = not toggle else: chksum = chksum + 1 i = i + 1 return chksum -- Dale Strickland-Clark Out-Think Ltd, UK From akuchlin at mems-exchange.org Tue May 23 13:14:13 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 23 May 2000 13:14:13 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8g7t5c$1i7i$1@thoth.cts.com> Message-ID: <3ditw5xk7u.fsf@amarok.cnri.reston.va.us> bwinton at tor.dhs.org (Blake Winton) writes: > Speaking as someone who had to use Modula-3, Ugh! > (Modula 3's largest mis-feature, for me at least, was that all keywords > had to be typed in ALL-UPPERCASE. My little finger got really sore > after four months of programming. :P) I always liked that feature. Since I usually programmed on a plain console (still do), there weren't many options for syntax highlighting. Writing all the keywords in uppercase made program structure, as opposed to lowercase variable names, leap out at you. Syntax colouring without colour, in a way. --amk From m.faassen at vet.uu.nl Tue May 23 10:30:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 14:30:06 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <8ge4le$bjk$1@newshost.accu.uu.nl> Moshe Zadka wrote: > [Martijn] >> Also, I don't think >> this would help a lot in the newbie example. Your example might confuse >> newbies even more. ("I'm trying to assign to A and now I can't because A >> already exists?") > Let me re--run the examples with --reable-error-messages: [snip] > Is that understandable enough? Yeah, I temporarily forgot about the 'with-readable-error-messages' flag you mentioned when I posted. Thanks. :) Still-want-my-"foo=Foo()"-though-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From hinsen at cnrs-orleans.fr Wed May 3 04:41:27 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 03 May 2000 10:41:27 +0200 Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <390F1FA2.8E57AC51@tismer.com> Message-ID: Christian Tismer writes: > If it should be necessary to make Java stackless > in order to convince Guido, I'd even go that way. (ROTFL:-)) I see it's time to create an association that fights against the threatening extinction of stacks. Stacks of all computers, unite! -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From jbauer at rubic.com Thu May 11 17:43:40 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 11 May 2000 16:43:40 -0500 Subject: Object type problem References: <391B17EA.97E72E9F@ldis.com> Message-ID: <391B298C.B630403B@rubic.com> Jonathan Donald wrote: > I get an odd (to me) error message when trying to do this: > > logstr = now + ": " + strng + "\n" > the error message: > TypeError: __add__ nor __radd__ defined for these operands Try this format: logstr = "%s: %s\n" % (now, strng) Or if you don't want 'None' to appear in logstr: if strng: logstr = "%s: %s\n" % (now, string) else: logstr = "%s: \n" % now Regards, Jeff Bauer Rubicon Research From speed at ?.com Tue May 23 08:31:52 2000 From: speed at ?.com (Jake Speed) Date: Tue, 23 May 2000 12:31:52 GMT Subject: Is it just Syntactic Sugar ? References: <20000523090202.V13281@xs4all.nl> Message-ID: thomas at xs4all.net (Thomas Wouters) wrote in <20000523090202.V13281 at xs4all.nl>: [...] >However, the main reason for this patch is *not* speed... Speed is a >minor issue, in Python design. The main rason for augmented assignment >is to provide a convienent and obvious way for mutable objects to be >modified: > >MyLargeOBject = MyLargeObject + 1 > >Creates a new instance of MyLargeObject, copying all data, and then adds >one to it. Unless you override __add__ in MyLargeObject to avoid that, >but then you can never do: > >MyOtherObject = MyLargeObject + 1 > >without modifying MyLargeObject as well. The += syntax is very good for >this, as you can be totally sure the programmer wants you to modify the >object, not create a new, modified copy. So we have: a = 3 a += 2 # assignment / symbol binding a = Object() a += 2 # expression / method call def foo(a): a += 2 # ?????? -Speed! From jbauer at rubic.com Tue May 9 17:54:55 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 09 May 2000 16:54:55 -0500 Subject: MySQLdb + Python + quotes References: <3918809E.1D5F3CFE@rhk.dk> Message-ID: <3918892F.EA075D0F@rubic.com> Lars Hoeyrup Jensen wrote: > I use the MySQLdb module to make Python interact with > MySQL. I have a problem, when I try to insert strings > that contain special characters (here I primarily think > of quotes: ' and "). There _must_ be a smart > way to escape these characters. >>> import MySQLdb >>> MySQLdb.escape_string("""some '"' quotes""") 'some \\\'\\"\\\' quotes' Jeff Bauer Rubicon Research From jkraska1 at san.rr.com Mon May 29 16:26:36 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 20:26:36 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> Message-ID: <3932D314.AFF2289C@san.rr.com> > >CP4E, to be honest, i have my vague doubts about that. In some way you are > >postulating the same level of intellectual potential for everyone, but > >that's another question you might have investigated for a longer time > >already. One alternative comes to mind: the language is case-sensitive, but doesn't allow symbols that would be duplicates if it were not. I personally prefer case-sensitivity, but that doesn't keep me from thinking :)- C/ From kc5tja at garnet.armored.net Mon May 1 06:31:03 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 1 May 2000 10:31:03 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> <8ek3as$f0e$2@newshost.accu.uu.nl> Message-ID: In article <8ek3as$f0e$2 at newshost.accu.uu.nl>, Martijn Faassen wrote: >In what way is 'cmd' hungarian notation? There's no prefix anywhere, unless >it's all prefix. :) cmd is the type of string being sent to it, so it'd be all prefix (examples in Windows would be a variable named hwnd instead of hwndDialogBox). -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From jlj at cfdrc.com Wed May 24 10:09:09 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Wed, 24 May 2000 09:09:09 -0500 Subject: flock on windowsnt References: <392B9607.7250A905@yahoo.co.jp> Message-ID: <392BE285.BF287B56@cfdrc.com> There is a function _locking() which I haven't used, but which sounds like it does the same thing as flock() under Unix. The prototype is: _locking(int handle, int mode, long nbytes) Look it up in the MSDN documentation for more details. It does not appear to have been wrapped into any of the standard Python modules (at least not for Python 1.5.2). tkssato at yahoo.co.jp wrote: > > I want to use a function such as "flock()" on WindowsNT. > > On unix, it seems "fcntl" module is available. > > Is there any way on NT ? > > Thanks for reading this article. From echuck at mindspring.com Fri May 19 16:40:53 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 19 May 2000 16:40:53 -0400 Subject: Objective-C + Python...? References: <391CE037.14B030E9@cifnet.com> <3dpuqpp3xb.fsf@newcnri.cnri.reston.va.us> <3921DA7B.961C5B89@cifnet.com> Message-ID: <3925A6D5.898552B4@mindspring.com> Ian Mondragon wrote: > > Andrew Kuchling wrote: > > > There was an Objective C SIG; see > > http://www.python.org/sigs/objc-sig/. Unfortunately, the links to > > actual code seem to have rotted. Anyone on the newsgroup still have > > copies of the objc module? > > > > --amk > > thanks for responding. i actually found the sig later on that night & > successfully downloaded the last version from the archives (ver. 0.55). > if you want to get your hands on it, you can get ahold of it here: > > ftp://ftp.codefab.com/pub/incoming/PyObjC-0.55.tar.gz > > i know i'm going to be hacking (read: kludging) away at it. }-) > > -- > __END__ > > Ian Mondragon == copal at cifnet.com > > $bigBoys->use(BSD); Ian, I too was a big NeXTer before moving to Python. There was a product for NeXTstep that allowed various scripting languages including Python and others to interoperate with Obj-C seamlessly. You could even pull up a scripting terminal inside your app and start poking away. I couldn't remember the name, but a search for 'Python' on http://www.stepwise.com gave it up: Objective-Everything. I never used it, but a highly regarded colleague of mine did and he liked it a lot. Here's a PR: http://www.stepwise.com/PR/Nov/TipTop_971124.html And here's the company: http://www.tiptop.com/ Hope that helps. -Chuck ____________________________________________________________ http://webware.sourceforge.net From brandonirons at topmail.de Wed May 24 12:46:08 2000 From: brandonirons at topmail.de (Brandon Irons) Date: Wed, 24 May 2000 16:46:08 GMT Subject: print, softspace, and stdout -- Newbie Message-ID: I can't get softspace to take effect for sys.stdout. I have tried: sys.stdout.softspace = 0 print 'a' print 'b' with the result: a b I can get the result I want using write(): sys.stdout.write( 'a' ) sys.stdout.write( 'b' ) with the desired result: ab I've even tried: sys.stdout.close() sys.stdout.softspace = 0 # then I couldn't figure out how to reopen sys.stdout Since the softspace attribute was made writeable, it seems to me there must be a way to get this output using print and softspace. What is it? My second question is: In that last code snippet, how would I go about re-opening stdout? TIA. oBrando From mfletch at tpresence.com Sun May 21 12:23:17 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 21 May 2000 12:23:17 -0400 Subject: Case sensitivity/insensitivity Message-ID: I use voice recognition (Dragon) exclusively for my Python coding (have for over a year now). It has never caused a problem with case sensitivity. Text-to-speech is something I've not tried on code. It could be there will need to be a mode created for it where you get "\Cap token \No-Space \Cap header" output (i.e. the inverse of speech-to-text). More intelligent would be to allow both types of systems to easily, interactively, create per-document vocabularies such that I could say "Say that as 'Cap token header'" to have the text-to-speech system create a shorthand when reading (and something similar for the dictating, as well, of course). Enjoy, Mike -----Original Message----- From: Francis Glassborow [mailto:francis at robinton.demon.co.uk] Sent: Saturday, May 20, 2000 6:57 PM To: python-list at python.org Subject: Re: Case sensitivity/insensitivity In article <8g742q$2jv3$1 at thoth.cts.com>, Will Rose writes >Some >people just do see the tokens 'token' and 'Token' as being identical, >and are very irate if their behaviour differs; others, like me, see >them as different and hate the additional complexity of trying to >memorise possible matches. There is a largish minority for whom using case sensitive tokens is a menace -- those that rely on text-speech because their eyesight is severely impaired. Another problem that will become more visible over the next half dozen years are the problems of those using voice recognition systems. Of course these are only issues in the context of identifiers only being disambiguated by the use of uppercase/lowercase. Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation -- http://www.python.org/mailman/listinfo/python-list From thomas at xs4all.net Thu May 4 16:44:50 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 4 May 2000 22:44:50 +0200 Subject: circular reference: canonical CPython approach please! In-Reply-To: <0SfQ4.15265$HG1.409453@nnrp1.uunet.ca>; from embed@geocities.com on Thu, May 04, 2000 at 10:28:44AM -0400 References: <0SfQ4.15265$HG1.409453@nnrp1.uunet.ca> Message-ID: <20000504224450.C3309@xs4all.nl> On Thu, May 04, 2000 at 10:28:44AM -0400, Warren Postma wrote: > Has anyone written something like this: > x = MyRedClassInstance(); > y = MyBlueClassInstance(); > x.y = shadow(y) # weak reference > y.x = shadow(x) # weak reference > When you del x, then y.x automatically becomes None, but otherwise, any > other problems are avoided. Is that possible? Not in Python, no. If you write shadow as a C extention, then yes, it's possible to maek x.y and y.x refer to the other without incrementing its refcount. However, it will not automatically 'undefine' the references when the other goes away; doing that would require rewriting the rc-collector. I dont know enough about the advantages of weak references to say wether that's worth it -- I've never had any problem with avoiding circular references in my code. Python-programmers-shouldn't-read-up-on-perl-5.6.0-ly y'rs, -- anyone notice how Perl adopted Python's number scheme ? -- -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From erno at iki.fi Mon May 15 09:31:33 2000 From: erno at iki.fi (Erno Kuusela) Date: 15 May 2000 16:31:33 +0300 Subject: The REALLY bad thing about Python lists .. References: <000c01bfbe43$27c56f40$b82d153f@tim> Message-ID: >>>>> "Tim" == Tim Peters writes: Tim> On some flavors of Unix, this is more than just luck: realloc Tim> will eventually move the vector to "the end" of the address Tim> space, after which further growth is just a mix of boosting Tim> the VM high-water mark and the occasional sbrk. in the memory allocator used on gnu/linux, chunks of memory larger than some threshold are allocated using mmap() on /dev/zero. these blocks can then be moved around with mremap(), to archieve a similar effect as described above. -- erno From ecastro at cicei.ulpgc.es Fri May 5 15:16:45 2000 From: ecastro at cicei.ulpgc.es (Enrique Castro) Date: 5 May 2000 19:16:45 +0000 Subject: Python Newbie Problem References: <3912E1D5.332F2084@cyberus.ca> Message-ID: <39131041.6B2CBE1B@cicei.ulpgc.es> Hi, I have installed Python and Tcl/Tk very recently on Win95. I do not understand the "init.tcl in the path" message. What you need is to provide the path to the Tcl binaries, which are located (in a normal installation in Win95) at "some_user_path"\Tcl\bin Thus, simply edit autoexec.bat to set path path=%path%;"root"\tcl\bin blues-l at cyberus.ca wrote: > Hi, > I'm a newbie when it comes to Python. > I have been trying to get it going on Win95 but I am dead in the water > as far as > getting Tkinter to work. > It loads okay but I get a message saying that it cannot find a "usable" > init.tcl in the path when I try using it. > init.tcl IS there and in the path. It is version 8.05 > Everything else works .... > What defines "usability"? From kc5tja at garnet.armored.net Wed May 3 16:12:03 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 3 May 2000 20:12:03 GMT Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> <390FC76A.59FB5779@san.rr.com> Message-ID: In article <390FC76A.59FB5779 at san.rr.com>, Courageous wrote: >The error in your reasoning occured when you likened computer >programmers to lemming-like consumers who do what everyone >else is doing. Since Perl has always had a vastly larger >presence than Python, but Python is growing in spite of this, >your analogy seems even further mistaken. Two strikes....... > >But the real question is will Python ever really become a >mainstream language. Good question! Time will tell... Add to that his claim that "technology doubles ever year" is also incorrect. To be more specific, Moore's law states that the performance of microprocessor systems double every 18 months (not every year), and refers *strictly* to hardware. It does *NOT* apply to software. Want proof? Windows. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From phd at phd.russ.ru Fri May 19 06:18:18 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 19 May 2000 10:18:18 +0000 (GMT) Subject: ValueError: unpack tuple of wrong size??? In-Reply-To: Message-ID: On Fri, 19 May 2000, Dag Sunde wrote: > Question: > When a method has a boolean return, and two output-params, how do I > call it? I think you must pass two Buffer objects, that will get filled upon return; the return value should be one boolean... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From thomas at xs4all.net Tue May 30 15:39:57 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 30 May 2000 21:39:57 +0200 Subject: Is it just Syntactic Sugar ? In-Reply-To: <3933F800.9CCE3B6D@cs.byu.edu>; from tjpalmer@cs.byu.edu on Tue, May 30, 2000 at 05:18:56PM +0000 References: <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> Message-ID: <20000530213957.E469@xs4all.nl> On Tue, May 30, 2000 at 05:18:56PM +0000, Thomas Palmer wrote: > Bjorn Pettersen wrote: > > [Guido] has considered a += method. It would require adding more > > 'magic' methods however, so there is still some resistance... > Not really. As syntactic sugar, it is just a rewrite. > i += 1 (or i++ for that matter) would be rewriten to > i = i + 1. Whether memory addresses were cached for > optimization is another issue, but the point is that > only '__add__' needs overwritten still. The compiler > would just rewrite the code. Well, if it is only a rewrite, it is *completely* useless. Since when does Python care about syntactic sugar ? I personally am beginning to detest the `object` sugar to represent repr(object), because it seems so very unpythonic (I'd be much obliged if anyone could give me a reason for ``, other than the usual hysterical raisin ;-) Adding ++/+= et al as rewrites would be horrifying. No, I have more faith in the idea that += is an *in place* add, for mutable types. It does require more __magic__(), but in my (maybe not too humble at this moment) opinion, it's bloody well worth it. I dont know what the __magic__ names would be, as __addeq__ seems out of place (we're talking about assignment, or mutation, not equality) but i'm sure someone can think of a couple of good names ;-P __addass__'ly yr's, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rkiendl at gmx.net Fri May 5 05:07:56 2000 From: rkiendl at gmx.net (Robert Kiendl) Date: Fri, 05 May 2000 11:07:56 +0200 Subject: pythonwin - python1.5/1.4 problem Message-ID: <39128F6C.9372FEF1@gmx.net> hi i am trying to compile current pythonwin sources with python1.5.2-headers on VC++6.0. i quickly get the following errors. if i try to fix single inconsistences i don't come an end. is there a newer pythonwin-source which doesn't rely on python1.4-headers ? i also have the problem of access error crashes when loading release-win32ui.pyd with release-python15.dll in a debug-myapp (while release-win32gui.pyd and other win32-pyd's load properly) maybe there are common reasons of those problems? robert --------------------Configuration: win32ui - Win32 Debug-------------------- Compiling... stdafx.cpp h:\src\pythonwin\win32ui.h(31) : error C2371: 'PyObject' : redefinition; different basic types h:\program files\python\include\object.h(116) : see declaration of 'PyObject' h:\src\pythonwin\win32assoc.h(38) : error C2504: 'ui_base_class' : base class undefined h:\src\pythonwin\win32assoc.h(41) : error C2061: syntax error : identifier 'ui_type' h:\src\pythonwin\win32assoc.h(50) : error C2061: syntax error : identifier 'ui_type' h:\src\pythonwin\win32assoc.h(51) : error C2061: syntax error : identifier 'ui_type' h:\src\pythonwin\win32assoc.h(64) : error C2146: syntax error : missing ';' before identifier 'type' h:\src\pythonwin\win32assoc.h(64) : error C2501: 'type' : missing storage-class or type specifiers h:\src\pythonwin\win32assoc.h(86) : error C2061: syntax error : identifier 'ui_type' h:\src\pythonwin\win32assoc.h(88) : error C2146: syntax error : missing ';' before identifier 'type' h:\src\pythonwin\win32assoc.h(88) : error C2501: 'type' : missing storage-class or type specifiers h:\src\pythonwin\win32cmd.h(22) : error C2146: syntax error : missing ';' before identifier 'type' h:\src\pythonwin\win32cmd.h(22) : error C2501: 'type' : missing storage-class or type specifiers h:\src\pythonwin\win32app.h(12) : error C2146: syntax error : missing ';' before identifier 'type' h:\src\pythonwin\win32app.h(12) : error C2501: 'type' : missing storage-class or type specifiers h:\src\pythonwin\win32app.h(14) : warning C4518: 'static void ' : storage-class or type specifier(s) unexpected here; ignored h:\src\pythonwin\win32app.h(14) : error C2146: syntax error : missing ';' before identifier 'cleanup' h:\src\pythonwin\win32app.h(54) : error C2065: 'RETURN_ERR' : undeclared identifier Error executing cl.exe. win32ui.pyd - 16 error(s), 1 warning(s) From aahz at netcom.com Mon May 22 11:41:55 2000 From: aahz at netcom.com (Aahz Maruch) Date: 22 May 2000 15:41:55 GMT Subject: Best HTML module? References: <3.0.5.32.20000514125226.007d97c0@earthlink.net> Message-ID: <8gbkg3$4r0$1@slb0.atl.mindspring.net> In article <3.0.5.32.20000514125226.007d97c0 at earthlink.net>, Robert Citek wrote: > >My question is similar to Jason's. Insead of replacing certain tags, I >would like to extract data from an HTML page. The "Learning Python" book >has an example on p.265 that uses the string module to find and get the >information. Using the string module and the re module for regular >expressions, I can get the information I want but the code is becoming >large, unsightly, and unwieldy. Could the HTMLlib be used to do the same >thing? Or is some other module better suited for extracting data from HTML >pages (if so, which module)? htmllib certainly *can* do this, but without information on what kind of data you're trying to extract, I can't push you in the right direction. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Not everything in life has a clue in front of it...." --JMS From dpartrid at lawson.appcomp.utas.edu.au Wed May 10 03:04:08 2000 From: dpartrid at lawson.appcomp.utas.edu.au (Douglas Partridge) Date: Wed, 10 May 2000 07:04:08 GMT Subject: glob Message-ID: <391909E6.94A0E5AA@lawson.appcomp.utas.edu.au> Is there a recursive glob? Doug Partridge ~ ~ ~ From robin at jessikat.demon.co.uk Fri May 19 06:14:51 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 19 May 2000 11:14:51 +0100 Subject: modifying inherited methods References: <3925097F.7BA39636@muc.das-werk.de> <39250B93.4710EB86@muc.das-werk.de> Message-ID: In article <39250B93.4710EB86 at muc.das-werk.de>, Thomas Thiele writes >Oh, sorry I misunderstand you. > >But the other thing is easy as well. > >class A: > def __init__(self, a,b,c,d): > ..... > >class B(A): > def __init__(self, a,b): > c = > d= > A.__init__(self, a,b,c,d) > > > yes the only problem is when A.__init__ has a lot of arguments and you don't want to cut and paste these to a bunch of inheriting class methods. -- Robin Becker From pinard at IRO.UMontreal.CA Fri May 19 10:38:22 2000 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 19 May 2000 10:38:22 -0400 Subject: Fractran machine! In-Reply-To: Boris Borcic's message of "Fri, 19 May 2000 10:58:33 +0200" References: <39250239.D384FF0D@geneva-link.ch> Message-ID: Boris Borcic ?crit: > How long does the demo take to halt ? Once it finishes printing the whole series of prime numbers! Yet, it is likely that you will run out of memory before it does. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Sun May 21 23:40:09 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 21 May 2000 23:40:09 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: "John W. Baxter"'s message of "Sun, 21 May 2000 19:51:55 -0700" References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: "John W. Baxter" ?crit: > Those are the ones...and they were followed with "glass teletypes" which > were also uppercase only (and of course some expensive ones which weren't). I saw a few of those, indeed. Even when raising the speed from 110 to 300 bauds (cardiac people, abstain! :-), these terminals were kind of boring, as you had to wait a lot for things to happen. At least, with mechanical ones, all the big constant noise to give you a feel that _something_ was happening! :-) > For that matter, it looked for a while as if the "raceway" terminals > would win out over the bitmapped (via a character-generator ROM). > [In raceway, the beam traced out a pattern over each character position, > with the beam turned on and painting non-background in those portions > of the raceway pattern which would make the desired character.] If you mean those oscilloscopes which simultaneously drove the X and Y coordinates, with separate analogic hardware for each character, the only one I knew were the CDC 6x00 consoles, and these were pretty expensive pieces of technology. I do not count the CDC 1700 _huge_ oscilloscope as a terminal, since it was all graphics, characters drawn were nothing else than special graphic programs, software this time. Very expensive, that one... These devices were, by far, too costly to be ever used as user terminals. No surprise that raster displays won over them, given that ROMs were at least less expensive that all that specialised hardware, and especially the tubes themselves. Raster technology was far more widespread, because of television. ROMs later became cheap. Nowaday, using oscilloscopes for glass terminals would just not make any sense, the price could not be right. At the time of oscilloscopes, by exaggerating only a bit, I could say that the quantity of hardware was roughly proportional to the number of characters supported, so nobody could afford the luxury of lower case letters. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From relder at omegabit.com Fri May 19 13:38:26 2000 From: relder at omegabit.com (Rob Elder) Date: Fri, 19 May 2000 10:38:26 -0700 Subject: Varibles in SQL statements Message-ID: Hello, I don't understand how to use (or format really) varibles in SQL.With the sequence var = '1' mycursor.execute('SELECT userID FROM userTable WHERE userID=var') I get a too few paramerters error This does work: mycursor.execute("SELECT userID FROM userTable WHERE userID='1'") ??? TIA. -r From mhammond at skippinet.com.au Thu May 4 00:53:50 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 04 May 2000 04:53:50 GMT Subject: Python Programming on Win32 - Hammond/Robinson References: <8enf56$sof$1@supernews.com> Message-ID: Indeed, you are correct - and also the first to report this. Ill add it to the Errata on starship... Mark. "Dale Strickland-Clark" wrote in message news:8enf56$sof$1 at supernews.com... > I've seen Mr. Hammond hereabouts and I have a question about your book which > I'm working through at the moment. > > Have I missed something or is there a mistake on page 309. Should Table 17-1 > say os.path.isdir, os.path.isfile, etc? > > I hope its not me because otherwise I think I understand it! > > Thanks for the book, by the way. Very handy. I'm new to Python and I'm sure > I'm going to find it handy. I hope you and Mr Robinson have been well > rewarded for your efforts :-) > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Experts > > > From guido at python.org Fri May 19 22:42:49 2000 From: guido at python.org (Guido van Rossum) Date: Sat, 20 May 2000 02:42:49 GMT Subject: C++ extension module crashes on Solaris References: Message-ID: sharris at nospam.primus.com (Steven E. Harris) writes: > Again, I copy the (re)built module into place and try to import it: > > $ cp seh_test.so ~/usr/local/lib/python1.5/ > $ python > Python 1.5.2 (#1, May 19 2000, 09:34:45) [GCC 2.95.2 19991024 (release)] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import seh_test > Traceback (innermost last): > File "", line 1, in ? > ImportError: ld.so.1: python: fatal: relocation error: file ./seh_test.so: symbol PyExc_IndexError: referenced symbol not found > >>> > > > Note that I can compile and use the CXX Demo application, which uses > both extension and embedding together. I can't get extending to work > alone, though. It seems your shared library module doesn't see the symbols defined by the Python main app. Normally, these are being exported by default. I wonder if the trick of using g++ for the linker breaks this? One thing you could try is to link your module statically... -- --Guido van Rossum (home page: http://www.python.org/~guido/) From rob at hooft.net Mon May 15 03:01:37 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: 15 May 2000 09:01:37 +0200 Subject: optimization References: Message-ID: >>>>> "EH" == Eric Hagemann writes: EH> Is it faster to split a string into a tuple with individual EH> elements >>> a= "as the end" >>> (x,y,z) = string.split(a," ") EH> or as a list >>> q = string.split(a," " ) EH> where following accesses would entail q[0]='as' etc. Why does it need to be the fastest? EH> Is is faster to index through a list >>>> a=[1,2,3,4.....] >>>> for i in range(4): a[i]..... EH> or >>>> for x in a: ....... Why does it need to be the fastest? EH> I am looking in general to produce EH> quick code and am looking for coding techniques that are best EH> utilize the language. The best python techniques are those that make the code the most readable. So: if you are writing a simple command interpreter: (command,source,destination)=string.split(commandline) (Note: no x,y,z) And if you need to iterate over all elements of a list: for commandline in script: do() The general idea of optimizing python is: Write your program. Do not focus on speed, but on readability and maintainability. If it is too slow: optimize the inner loop while documenting it very well. If it is still too slow, write a C routine to replace the inner loop. See also: http://www.python.org/doc/essays/ppt/hp-training/sld039.htm http://www.python.org/doc/essays/list2str.html -- ===== rob at hooft.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From moshez at math.huji.ac.il Sun May 28 00:57:41 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 28 May 2000 07:57:41 +0300 (IDT) Subject: [PATCH] A compromise on case - another suggestion In-Reply-To: <3930990D.FE8D5F80@stud.ntnu.no> Message-ID: On Sun, 28 May 2000, Peter Schneider-Kamp wrote: > Is that really so? From a quick look at the relevant sources I saw > at least some places where IndexError is checked. So you may be right. > > But does it have to be like that? Can't we use the length of the list > to check? No. Have a look at the fileinput module for a place where you can't use the length to check, and the IndexError hack works quite well. I'm starting to think that my jocular reference to the "--with-readable-error-messages" switch might become true: trade a little efficiency for debuggability. From buzzard at contactbox.co.uk Thu May 4 15:24:47 2000 From: buzzard at contactbox.co.uk (Duncan Smith) Date: Thu, 04 May 2000 19:24:47 GMT Subject: Installing numpy References: <3910b8e1.0@news2.cluster1.telinco.net> <3911776F.25845625@oreilly.com> Message-ID: <3911dd31.0@news2.cluster1.telinco.net> Thanks for responding to my posting. I still can't get it set up properly. I've tried the zip and the tar.gz. I unzip them to my python directory and get a subdirectory (Numerical-15.2) with 5 subdirectories (Demo, Include, Lib, Src and Test). No .pth file anywhere. I run the script 'setup.py install' and get nowhere. A computer scientist friend of mine has tried as well and has not figured it out yet. I think he's going to have a go at editing the script to get it to work, but other people seem to install it O.K. so there must be another way. I need numpy desparately for handling some Bayesian Belief Network stuff. I'm not a computer scientist and haven't got enough time to figure out how to implement it in C. Thanks again. From akuchlin at mems-exchange.org Tue May 23 13:00:20 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 23 May 2000 13:00:20 -0400 Subject: Is unpickling data a security risk? References: <3927C31D.4022850@maxnm.com> Message-ID: <3dr9atxkuz.fsf@amarok.cnri.reston.va.us> "Fredrik Lundh" writes: > you can plug this hole by using a custom unpickler, where the > find_class method is overridden (see the pickle source code for > details). but there might be other holes in there... Note that the Unpickler type in the cPickle (*not* pickle) module has a .noload() method. From the docstring: ==== noload() -- not load a pickle, but go through most of the motions This function can be used to read past a pickle without instantiating any objects or importing any modules. It can also be used to find all persistent references without instantiating any objects or importing any modules. ==== This feature should probably be back-ported to pickle.py -- A.M. Kuchling http://starship.python.net/crew/amk/ Constraints often boost creativity. -- Jim Hugunin, 11 Feb 1999 From embed at geocities.com Tue May 2 08:59:17 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 2 May 2000 08:59:17 -0400 Subject: BOM should be ignored by Python References: Message-ID: <_lAP4.14253$HG1.387165@nnrp1.uunet.ca> > I believe this was discussed on python-dev, and decided that Python itself > should not handle BOM markers at all - simply leave them to the app. Python IS an app though. If the app named Python is going to live with UTF source editors, then Python must become aware of unicode when reading it's own .py source code files. Is python ever going to handle source code in Unicode? A cautious first step would be UTF-8 "acceptance". Handling a python source file (.py) differently, not changing open(). Actually, new open() type function (uopen() ?) would be nice, that has all the semantics of Unicode handled by the file objects created by the uopen() call. Warren From neilh at scintilla.org Sun May 21 05:27:55 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 21 May 2000 09:27:55 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: > When we teach our children to write we teach them case sensitivity, I do not > remember any governing body suggesting we should drop case sensitivity from > written language in order that 'everyone' will therefore be able to write. > > I also cannot believe that this is a difficult lesson to learn. > > How many times would you have to be told before you understood it? Once or > twice? While I /know/ that Unix file names are case sensitive, that doesn't stop me from mistyping them. This is something Windows and Macintosh do right - removing a cause of error for no real limitation in functionality. I would extend the same scheme to variable naming in Py3K. Names have one and only one capitalisation. Other capitalisations are an error. The IDEs can provide different styles of help here, from no action through highlighting miscapitalisation to automatic case changing. Some people have been using a=A(). Even me. But is this something that you really feel should be encouraged? Or is it a source of ambiguity and potential misunderstanding. Neil From debl.nospamm at world.std.com Tue May 16 11:56:18 2000 From: debl.nospamm at world.std.com (David Lees) Date: Tue, 16 May 2000 15:56:18 GMT Subject: How to display images? - Repost Message-ID: <39216FA0.B8E8F735@world.std.com> I posted this question on Saturday (4 days ago) and did not see an answer. I have seen similar questions posted by others, but not answers. How does one display images in Python. I am using Python 1.5.2 and PIL running under Win95 and am able to read, write and rotate images to the disk without any problem. tkinter is installed. However, when I use the .show method it does not seem to work. I do not get any errors,something flashes (does not look like an image though) and then I am back at the command prompt. The command is im.show() or im.rotate(45).show() I even wrote the results of a rotate out from Python and looked at it with an external viewer. I would like to view directly in Python. Thanks in advance. David Lees From ajs at ix.netcom.com Mon May 22 22:29:30 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 22 May 2000 22:29:30 -0400 Subject: PyOpengl... gone forever? References: <5hcW4.5291$wYl.211543552@newsb.telia.net> <3dpuqecxrb.fsf@amarok.cnri.reston.va.us> Message-ID: <8gcqlv$6uq$1@slb7.atl.mindspring.net> > Squeal loudly at me if it dies gain. http://starship.python.net:9673/crew/da Time to squeal. I think. From greg at cosc.canterbury.ac.nz Tue May 30 21:49:32 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 31 May 2000 13:49:32 +1200 Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <8h15qr$rje$1@news.udel.edu> Message-ID: <39346FAC.F2797EA5@cosc.canterbury.ac.nz> Johann Hibschman wrote: > > Actually, it sounds more and more to me like 'join' should just be > left as a function, and not made a method at all. Indeed - there seem to be just as many subjective arguments in favour of any of the alternatives, so the safest thing to do is leave the darn thing alone! I know we're promised that string.join will still be there, but if ''.join exists, people will start using it, and it won't be long before it's unremovable. Too Many Ways To Do It... -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From dalke at acm.org Mon May 8 18:35:52 2000 From: dalke at acm.org (Andrew Dalke) Date: Mon, 8 May 2000 16:35:52 -0600 Subject: Irix 6.5, gcc 2.95.2, readline and control-C problem References: <8f2031$m9o$1@slb3.atl.mindspring.net> Message-ID: <8f7fa6$abt$1@slb3.atl.mindspring.net> Quinn Dunkan wrote: >I have python compiled with gcc 2.8.1 on irix 6.5 system. If I hit ^C when >readline is doing its thing, python locks up. Meanwhile, I have python >and readline compiled with sgi cc on another irix 6.5 system, and everything >works properly. > >So it appears to be a gcc thing. I didn't catch that this was gcc/egcs in the original post. I was having problems with SGI's cc. I can start Python Python 1.5.2 (#3, Oct 18 1999, 17:40:54) [C] on irix646-n32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> then press ^C to hang the process. Attaching dbx I get the following traceback. You can see the loop: > 0 _ioctl(0x0, 0x54d7, 0x10108c20, 0x0, 0x540f, 0x0, 0x3ff605c0, 0xfb5f450) ["/xlv22/ficusjan23/work/irix/lib/libc/libc_n32_M4/sys/ioctl.s":15, 0xfac47c8] 1 ___new_tcsetattr(0x0, 0x54d7, 0x10108c20, 0x0, 0x540f, 0x0, 0x3ff605c0, 0xfb5f450) ["/xlv22/ficusjan23/work/irix/lib/libc/libc_n32_M4/term/new_tcsetattr.c ":48, 0xfacbae4] 2 tcsetattr(__fd = 0, __act = 21519, __t = 0x10108c20) ["/usr/include/sys/termios.h":136, 0x100bd0c4] 3 set_tty_settings(tty = 0, tiop = 0x10108c20) ["/net/alamo/export/home/dalke/ftps/readline-4.0/rltty.c":428, 0x100bd318] 4 rl_deprep_terminal() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/rltty.c":581, 0x100bd7a4] 5 rl_cleanup_after_signal() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":361, 0x100c9118] 6 rl_signal_handler(sig = 2) [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":157, 0x100c8b24] 7 sig_fixup_mask(0x0, 0x54d7, 0x10108c20, 0x0, 0x540f, 0x0, 0x3ff605c0, 0xfb5f450) ["/xlv23/patches/2420/work/irix/lib/libpthread/libpthread_n32_M3/sig.c":43 7, 0x3ff436ac] 8 _sigtramp(0x0, 0x54d7, 0x0, 0x0, 0x540f, 0x0, 0x3ff605c0, 0xfb5f450) ["/xlv22/ficus-jan23/work/irix/lib/libc/libc_n32_M4/signal/sigtramp.s":61, 0xfaa1e60] 9 _ksigaction(0x2, 0x7f0efd00, 0x10108e90, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv22/ficusjan23/work/irix/lib/libc/libc_n32_M4/signal/ksigaction.s":23 More (n if no)?, 0xfaa1db8] 10 sigaction(0x0, 0x7f0efd00, 0x10108e90, 0x3ff43658, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv23/patches/2420/work/irix/lib/libpthread/libpthread_n32_M3/sig.c":414, 0x3ff435e0] 11 rl_set_sighandler(sig = 2, handler = 0x100c8ac0, ohandler = 0x10108e90) ["/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":242, 0x100c8c90] 12 rl_maybe_set_sighandler(sig = 2, handler = 0x100c8ac0, ohandler = 0x10108e90) ["/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":259, 0x100c8cec] 13 rl_set_signals() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":272, 0x100c8d80] 14 rl_reset_after_signal() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":371, 0x100c917c] 15 rl_signal_handler(sig = 2) [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":179, 0x100c8b98] 16 sig_fixup_mask(0x2, 0x7f0efd00, 0x10108e90, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv23/patches/2420/work/irix/lib/libpthread/libpthread_n32_M3/sig.c":437, 0x3ff436ac] 17 _sigtramp(0x0, 0x7f0efd00, 0x0, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv22/ficus-jan23/work/irix/lib/libc/libc_n32_M4/signal/sigtramp.s":61, 0xfaa1e60] 18 _ksigaction(0x2, 0x7f0f0220, 0x10108e90, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv22/ficus-jan23/work/irix/lib/libc/libc_n32_M4/signal/ksigaction.s":23 19 sigaction(0x0, 0x7f0f0220, 0x10108e90, 0x3ff43658, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv23/patches/2420/work/irix/lib/libpthread/libpthread_n32_M3/sig.c":414, 0x3ff435e0] 20 rl_set_sighandler(sig = 2, handler = 0x100c8ac0, ohandler = 0x10108e90) ["/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":242, 0x100c8c90] 21 rl_maybe_set_sighandler(sig = 2, handler = 0x100c8ac0, ohandler 0x10108e90) ["/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":259, 0x100c8cec] 22 rl_set_signals() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":272, 0x100c8d80] 23 rl_reset_after_signal() [ "/net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":371, 0x100c917c] 24 rl_signal_handler(sig = 2) [" /net/alamo/export/home/dalke/ftps/readline-4.0/signals.c":179, 0x100c8b98] 25 sig_fixup_mask(0x2, 0x7f0f0220, 0x10108e90, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv23/patches/2420/work/irix/lib/libpthread/libpthread_n32_M3/sig.c":437, 0x3ff436ac] 26 _sigtramp(0x0, 0x7f0f0220, 0x0, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv22/ficus-jan23/work/irix/lib/libc/libc_n32_M4/signal/sigtramp.s":61, 0xfaa1e60] 27 _ksigaction(0x2, 0x7f0f0740, 0x10108e90, 0x0, 0x3ff585a0, 0x3ff58c60, 0xfffffffd, 0x0) [ "/xlv22/ficus-jan23/work/irix/lib/libc/libc_n32_M4/signal/ksigaction.s" :23, 0xfaa1db8] [...keeps on going for a while more...] It *may* be that readline was compiled with gcc instead of cc. I've removed the build directory. Scanning the .a file it looks like it was compiled with cc, since I see a line: cc -DEFAULT:abi=n32:isa=mips4:proc=r10k -c -DHAVE_CONFIG_H -I. -I. -I/usr/local/include "-DRL_LIBRARY_VERSION=\"4.0\"" -g -n32 funmap.c but nothing about gcc nor egcs. The machine is an 'IRIX64 origin 6.4 IP27'. Yes, it should be ungraded. The compiler is 'MIPSpro Compilers: Version 7.2.1' Andrew dalke at acm.org From mjhand at concentric.net Thu May 4 15:03:07 2000 From: mjhand at concentric.net (Manus Hand) Date: Thu, 04 May 2000 13:03:07 -0600 Subject: No strptime? References: <75F7304BB41CD411B06600A0C98414FC0A40F9@ORSMSX54> Message-ID: <3911C96B.3B2CCD5E@concentric.net> I had the same problem, so I rolled my own (limited) strptime. I import it like this: # ---------------------------------------------------------- # Add a strptime() function to the time module, if necessary # ---------------------------------------------------------- try: time.strptime except: import strptime time.strptime = strptime.strptime And here is the module that gets imported (written to Python 1.5.2): import string # ========================================================================== # This function provides enough of the functionality of time.strptime() # to make (my program) happy. It is imported and used if the host platform # does not support time.strptime(). This function is restricted as follows: # (1) The only recognized arguments are %Y %m %d %b %H and %M # (2) There must be a single character between each such argument in the # format string, and this character must match (exactly) the character # after the corresponding data from the string. For example, you may # not use "%Y%m%d" as an argument for "19991125". Instead you must # split the data up as "%Y-%m-%d" and "1999-11-25". (Note that this # restriction [or something like it] is apparently in force in # "official" versions of time.strptime() as well.) # ========================================================================== def strptime(str, format): where, esc, result = 0, 0, [0] * 9 spot, month = 'YmdHM', [None, 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] try: for ch in '%s ' % format: if esc == 0: if ch == '%': esc = 1 elif str[where] != ch: raise Oops else: where = where + 1 elif esc == 1: escChar, esc = ch, 2 elif esc == 2: data = string.split(str[where:], ch)[0] where, esc = where + len(data) + 1, 0 if escChar == 'b': result[1] = month.index(string.upper(data)) else: result[string.find(spot, escChar)] = int(data) # --------------------------------------------------------- # Validate ranges for month, day-of-month, hour, and minute # --------------------------------------------------------- if ((not (1 <= result[1] <= 12 and 1 <= result[2] and 0 <= result[3] <= 23 and 0 <= result[4] <= 59)) or (result[1] == 2 and result[2] > 28 + (result[0] % 4 == 0)) or (result[2] > 30 + ((result[1] + (result[1] > 7)) % 2))): raise Oops except: raise ValueError return tuple(result) From tourist at flashcom.net Sun May 21 13:01:32 2000 From: tourist at flashcom.net (Gogmagog) Date: Sun, 21 May 2000 10:01:32 -0700 Subject: Python and SOAP - is anyone washing up a storm? Message-ID: I understand that SOAP has been accepted as "note" status by WC3 and is being considered by the IETF as a standard for heterogenous systems to make RPC XML calls. Although originated by Microsoft, Simple Object Access Protocol (SOAP) has gained industry acceptance. IMHO, it marks also a decision by Microsoft to defend the market they have rather than embracing and extending. I am aware of DCOM and CORBA work in Python, but is anyone coding up Python middleware to handle this oncoming SOAP standard? The Burton Group sees it as being the most significant XML proposal and a means for B2B "plug and play" components to interacy in a multiplatform environment. There's going to be a lot of Linux *and* Windows about... Comments? Questions? Abuse? Ian Clark. From effbot at telia.com Tue May 2 05:56:49 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 02 May 2000 09:56:49 GMT Subject: Examples of 'Python Programming on Win32' References: <8em82k$gs7$1@nnrp1.deja.com> Message-ID: Norbert.Klamann at pobox.com wrote: > does anyone have a copy of the examples for > 'Python Programming on Win32' by M.Hammond /A.Robinson > handy ? http://www.oreilly.com/catalog/pythonwin32/index.html (click on "examples" in the left margin) From hamish_lawson at yahoo.co.uk Sat May 20 11:56:50 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Sat, 20 May 2000 08:56:50 -0700 Subject: Damnation! References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: <153bb080.5c1c7462@usw-ex0104-031.remarq.com> If case insensitivity was introduced, I propose that there should be a command-line switch to revert to case sensivity for backwards compatibility (my own preference would actually be to keep case sensitivity as the default and have a switch to make it case-insensitive if desired). Hamish Lawson * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From shapr at uab.edu Wed May 24 18:56:09 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 24 May 2000 22:56:09 GMT Subject: Error References: <392C2C77.ABEE82E9@muc.das-werk.de> Message-ID: <392C636F.C1540343@uab.edu> Thomas Thiele wrote: > > I have some code with a try and except > > try: > > function_that_rises_many_types_of_exceptions() > except: > print "error, but I don't know what was happend!" > > I use except without any argument to catch all kind of exceptions. > But how can I get the type of exception without having to write down all > exceptions? > > Is there function like GetLastException() ? is this what you're asking for?: try: f = open('/tmp/blah.txt') except IOError, e: print "SPAM!",e this will let you catch _just_ an IOError (like no, such file or dir) but you can also replace the except line with: except (IOError, AssertionError),e: if you want to catch multiple types of exceptions on this line. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From akuchlin at mems-exchange.org Thu May 11 11:53:15 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 11 May 2000 11:53:15 -0400 Subject: Const-Correctness of Python/C References: <20000511114535146.AAA71.378@pcfue9> <391AB63D.E768D78D@cfdrc.com> Message-ID: <3d8zxhjd78.fsf@amarok.cnri.reston.va.us> Lyle Johnson writes: > Some older C compilers wouldn't support the const keyword, so that could > be a problem. Note that GNU autoconf already has tests for compilers that don't support const, and the generated config.h file will #define const to the empty string if the compiler doesn't support it. So adding const shouldn't break even old compilers. I don't know if GvR would consider this a priority, but go ahead and post the list of functions that could use the additional const declarations. -- A.M. Kuchling http://starship.python.net/crew/amk/ "Mortal man?" "Yes?" "Beware of the dog." -- Charon warns Orpheus, in SANDMAN: "The Song of Orpheus" From greg at cosc.canterbury.ac.nz Mon May 29 22:26:27 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 30 May 2000 14:26:27 +1200 Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> Message-ID: <393326D3.400AA248@cosc.canterbury.ac.nz> On Sun, 28 May 2000 20:14:46 +0200, Thomas Malik wrote: > And then, i mean, once told, one shouldn't forget that 1/2 == 0. A person > forgetting that all the time should propably learn something else. You're failing to take the dynamicness of Python into account. The problem isn't with writing 1/2 and forgetting what it means; the problem is with writing a/b when you can't be sure until run time what type a and b are. Most of the time in Python it doesn't matter if you leave a number as an integer until such time as it needs to become a float, whereupon conversion is automatic. This is very convenient -- until you want to do real division, at which point it all falls apart. Either you explicitly convert to floats at every division, which clutters up the code, or you have to take care to convert all numbers which you might conceivably want to divide to floats on input. Either approach is error prone in the worst possible way, i.e. mistakes lead to bugs which are hard to trace. I assume that no-one would disagree with the following statements: 1. Integer division and real (or rational, if you prefer) division are different operations. 2. Whenever you write a division operation into your code, you always know which one you want. Currently, Python provides no way for you to directly specify which one you want -- instead, it uses a heuristic based on the run-time types of the arguments. This clearly violates the principle of not trying to guess what the programmer meant. Therefore, it is un-Pythonic. QED. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From mike.zaharkin at westgroup.com Thu May 4 14:53:56 2000 From: mike.zaharkin at westgroup.com (MikeZ) Date: Thu, 4 May 2000 14:53:56 -0400 Subject: help installing wxPython References: <39119A7F.B6FE8B0B@cicei.ulpgc.es> Message-ID: <3911c745@wwwproxy3.westgroup.com> I had this same problem when I installed a new wxPython application on Win95. Some machines worked fine, others didn't. The way I fixed this problem was to also update the msvcrt.dll in the windows/system directory. This seemed to fix it. -Mike Z. Robin Becker wrote in message ... >In article <39119A7F.B6FE8B0B at cicei.ulpgc.es>, Enrique Castro > writes >>Hi, >... >If this is 2.1.15 I had the same problem with my system. You need to get >your system upgraded to use the ws2_32.dll I believe an upgrade is >available from > > > ftp://ftp.microsoft.com/bussys/winsock/winsock2 > > >I upgraded and found a problem related to the outdated version of >msvcrt.dll installed by this upgrade. Luckily it makes a backup in >windows\ws2backup and I was able to copy the previous (actually newer >version) msvcrt.dll back to c:\windows\system\ (I think I had to do this >in safe mode though). Altogether a pain. I don't know whether it's >wxPython's compile or the original wxWindows build which causes this >nonsense. Python certainly doesn't need winsock2 so I guess this is an >avoidable blunder. >-- >Robin Becker From phd at phd.russ.ru Sat May 20 08:29:00 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 20 May 2000 12:29:00 +0000 (GMT) Subject: urllib/ftpwrapper In-Reply-To: Message-ID: Hi! Thanks! I'll test it and report sometime next week. On Sat, 20 May 2000, Guido van Rossum wrote: > Oleg Broytmann writes: > > > > fname, headers = urllib.urlretrieve("ftp://starship.python.net/") > > > > and it hangs :( Almost all FTP URLs will hang > I played with this a bit and found that ftp.python.org works but > starship.python.net hangs... Then I had a sudden idea: maybe these > ftp daemons only send the 226 message once the data socket has been > closed! > > The following change works for me: in urllib.py, class addclosehook, > method close(), move the call addbase.close(self) to the top of the > method, so the data socket gets closed before the hook (which waits > for the 226 code on the control socket) is called. > > def close(self): > addbase.close(self) > if self.closehook: > apply(self.closehook, self.hookargs) > self.closehook = None > self.hookargs = None > > Let me know if this fixes your problem (with no other changes to > urllib). Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From pinard at iro.umontreal.ca Sat May 13 11:43:57 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 May 2000 11:43:57 -0400 Subject: Python/Zope In-Reply-To: "Carl Page"'s message of "Fri, 12 May 2000 13:36:44 -0700" References: <02a401bfbc51$c99f5ae0$100a0a0a@dotfunk.com> Message-ID: "Carl Page" writes: > The modern replacement (IMHO) for newsgroups is web-archive backed > email groups. Let me vehemently disagree! :-) I rather hate Web archive email. One has just no means to handle high volume efficiently, and has to be on-line all the time (something I cannot afford). More traditional newsreaders like Gnus are undoubtedly less flashy, but they do the job _much_ better. P.S. - If I ought to handle Web archives, and I it occurred a few times by now, I swallow everything I can, and turn what I got into newsgroups (using ad hoc Python scripts :-), before starting to read for real. It's a lot of work for me, but I've the feeling that I win time on the overall process. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From rturpin at my-deja.com Sun May 14 14:35:47 2000 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Sun, 14 May 2000 18:35:47 GMT Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> Message-ID: <8fmrm2$ubh$1@nnrp1.deja.com> rturpin at my-deja.com writes: >> .. Creating vectors of length n by prepending >> elements one at a time is now an n^2 operation! > In article , Michael Hudson wrote: > So create it by appending n elements and then > reverse it.. Of course. Unless you have an application that manipulates both ends of the array! > .. this is still n^2, I guess, .. You guess wrong. Creating an array by appending at the end is linear in the length of the array. Russell Sent via Deja.com http://www.deja.com/ Before you buy. From rwcitek at uci.edu Sun May 14 13:52:26 2000 From: rwcitek at uci.edu (Robert Citek) Date: Sun, 14 May 2000 12:52:26 -0500 Subject: Best HTML module? In-Reply-To: Message-ID: <3.0.5.32.20000514125226.007d97c0@earthlink.net> My question is similar to Jason's. Insead of replacing certain tags, I would like to extract data from an HTML page. The "Learning Python" book has an example on p.265 that uses the string module to find and get the information. Using the string module and the re module for regular expressions, I can get the information I want but the code is becoming large, unsightly, and unwieldy. Could the HTMLlib be used to do the same thing? Or is some other module better suited for extracting data from HTML pages (if so, which module)? Any pointers to examples of how to use the HTMLlib module, and pointers to more appropriate modules greatly appreciated. TIA, - Robert ----- At 06:42 PM 5/12/00 GMT, Jason Long wrote: >Sorry if this is a silly question, but I'm Python newbie. > >I would like to be able to take an HTML template file and replace >certain tags or comments with data in my Python variables. Is HTMLlib >my best bet here? Python.org mentions ZTemplate from the makers of Zope >for tasks like this, but I couldn't find it on their site. From tim_one at email.msn.com Wed May 17 02:03:12 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 17 May 2000 02:03:12 -0400 Subject: The REALLY bad thing about Python lists .. In-Reply-To: Message-ID: <000601bfbfc5$95612f20$b52d153f@tim> [Tim] >> ISO/ANSI C doesn't fully define what happens when (roughly) >> integer division or % are handed negative numbers. [Glyph Lefkowitz] > The foibles of standards commitees will never cease to amuse me. > Thank you for this little tidbit. The next iteration of C has threatened to "fix" this, by mandating Fortran's original mistake (truncation, as opposed to Python's floor). BTW, have you "served" on a stds committee? It's, umm, educational. Most officially work by consensus, and after a decade of repeating the same arguments at every mtg, eventually person A will vote for person B's marginal idea, just so A can get B's vote on their own marginal idea; and vice versa. I was on an ANSI committee once tasked with designing a high-level cross-language parallelism model, partly paralyzed by one member who refused to approve of anything that required any dynamic allocation (no heap, and not even a bloody *stack*!). The committee eventually did the honorable thing: in the end, it voted to dissolve itself. That's one case where consensus triumphed <0.9 wink>. Long life to benevolent dictators. >> ... note that Windows is Python's most heavily used platform >> now -- I personally doubt Python would have survived if it only >> had its Mac and Unix base since '91. > Do you actually have a basis for that statistic? Mostly divine revelation. There was a surreal discussion about this on the Python-Help group about a year ago, with people mostly trading anecdotes even lamer than yours about Red Hat's use of Python being some sort of evidence . Not that I have better evidence! The only *hard* statistic Guido has is the download stats from python.org, where the number of Windows downloads routinely beats the number of all others combined (last stats I saw were from last August, where Windows was "winning" by an easy factor of 2). You can point to Red Hat today as not counting in the python.org stats, but that's relatively recent (note my "since '91"), so did nothing to help Guido sell Python's case when Python really needed the help. Someone else can point to PySol on Windows, which is also popular and doesn't boost the python.org Windows stats either. I leave it to c.l.py to figure it out for certain . not-admitting-that-a-little-known-part-of-python-startup-sends- email-to-python.org-whenever-python's-invoked-ly y'rs - tim From phd at phd.russ.ru Wed May 24 07:15:23 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 24 May 2000 11:15:23 +0000 (GMT) Subject: Cookies / CGI In-Reply-To: <8ggbn1$2vk$1@gxsn.com> Message-ID: On Wed, 24 May 2000, RS Solutions wrote: > Is there a simple script somewhere I can look at that sends and retrieves > cookies via CGI? > > I've looked at the cookie module but its not clear to me how that gets > posted to the end-user. # ----- create ----- #! /usr/local/bin/python -O def set_cookie(): import time t = time.gmtime(time.time()) t = (t[0] + 10,) + t[1:] # add 10 years :) import Cookie cookie = Cookie.Cookie() cookie["id"] = str(1024) cookie["id"]["expires"] = time.strftime("%a, %d-%b-%Y %T GMT", t) cookie["id"]["path"] = "/" print cookie try: print "Content-type: text/html" set_cookie() print "Location: test_c.py" except: #print exception # ----- test ----- #! /usr/local/bin/python -O def get_cookie(): import os, Cookie cookie = Cookie.Cookie(os.environ.get("HTTP_COOKIE")) c = cookie.output("Cookie: ") if c: print c else: print "Cookies not found" try: print "Content-type: text/html" print get_cookie() except: #print exception Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From m.faassen at vet.uu.nl Mon May 1 10:11:40 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 May 2000 14:11:40 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> Message-ID: <8ek3as$f0e$2@newshost.accu.uu.nl> Samuel A. Falvo II wrote: > It's cases like this that I choose to use hungarian notation: > uint32 Evaluate( char *cmd, char *param1, char *param2 ); In what way is 'cmd' hungarian notation? There's no prefix anywhere, unless it's all prefix. :) If this is a discussion about having some conventions for names, I agree. In Python, my lists (and sometimes dictionaries) tend to be plural forms of nouns, for instances: values = [] elephants = [] On occasion I also use: valueList = [] elephantList = [] mouseDict = {} Decidedly not Hungarian, but quite readable. In general I've found it doesn't pay to be overly strict about this in Python -- I prefer naming things well, and keeping functions and methods relatively short. This way I don't tend to lose track about what some variable was referring to so easily, as it all still fits in my limited 7 (plus or minus 2) short time memory. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From senn at maya.com Tue May 9 16:11:22 2000 From: senn at maya.com (Jeff Senn) Date: 09 May 2000 16:11:22 -0400 Subject: Stackless/microthreads merge news In-Reply-To: Christian Tismer's message of "Tue, 09 May 2000 19:35:21 +0200" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> <39144E9E.4928C7E2@tismer.com> <39184C59.DD33AA67@tismer.com> Message-ID: Christian Tismer writes: > BTW the Kaffe code was interesting, especially how the JIT works. > I'll look into this again, but not for Java. ::)) Ah yes... I looked at it a bit when he first was hacking. Food for thought: Several times I have considered what it would be like to have a 'simple-unified-VM' that supported continuations (if not full continuations -- then at least micro-threading) and could run Python, Java Script, Ruby, ... [Visual] Basic?, Perl??, ... Java????... It would not really be that hard -- I would give up type-strength and speed-performance in the first go-round in favor of a tiny and simple extremely portable VM that applied an extensible library of primitive functions to Python-style dynamically typed objects on the heap. -- -Jas P.S. Consider what would happen when I "compiled" my Java Script code and then ran the Python de-compiler on the byte-codes... :-) From farmerk at pacbell.net Sat May 6 04:36:40 2000 From: farmerk at pacbell.net (Keith J. Farmer) Date: Sat, 6 May 2000 01:36:40 -0700 Subject: CGI/PIL incompatibility (Win2k) Message-ID: Running Win2k's IIS server. I've got a program that accesses piddlePIL, which of course tries to load up PIL and the _imaging.dll file. The dll file works fine when run via IDLE, but refuses to load when run via a CGI interface. sys.path shows the same for both -- the dll file is in a directory listed. Does anybody know why that dll in particular would refuse to load? Other dll's load fine, just this and a tkinter (I believe -- I don't use it) that have this problem. Many thanks -- Keith From mwh21 at cam.ac.uk Sat May 27 05:55:03 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 May 2000 10:55:03 +0100 Subject: Microthreads: wait( duration ) with minimal processor overhead, u References: Message-ID: wware at world.std.com (Will Ware) writes: > > [uthread6.py] > > Using the Unix 'mail' program, I find that the text is full of nonsense > like "3D" and "=09". I think this is an artifact of MIME encoding. Is > there any way to repost it without this stuff? Or is there a filter > somewhere handy for getting rid of it? That's quoted-printable, one of the evils of the modern world. (IMHO) Try sticking it through "mmencode -q -u". HTH, Michael -- 93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From jkraska1 at san.rr.com Sun May 14 22:57:37 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 May 2000 02:57:37 GMT Subject: A TYPICAL NEWBIE MISTAKE? References: <391F513B.CEA12592@san.rr.com> Message-ID: <391F6844.E473FC2E@san.rr.com> > > def __init__() > > > > i=0 > > f=3.1 > > s="str" > > ll=[] > > Actually, it should be: > > class MyClass: > > def __init__(): > self.i = 0 > self.f = 3.1 > self.s = "str" > self.ll = [] You forgot the (self) in the def line... :) > Note that without the 'self.' in __init__() (or any other method), a > variable *local to that method* is created; the variables would disappear > upon the completion of the method. Yeah, I make that mistake all the time. The interpreter is constantly correcting me. It's my c++/java background with its implicit "this". I miss the colons all the time, too (as Mr. Pinard so readily pointed out.... ha). Which brings me to the topic. Sometimes colons seem syntactically unnecessary. For example: if : statement else: statement Really, else doesn't need a colon, as far as I can tell (I can see the need for the if, supposing you wan to have the statement on the same line). Doesn't seem like "def" does, either. C/ From aahz at netcom.com Tue May 9 08:57:15 2000 From: aahz at netcom.com (Aahz Maruch) Date: 9 May 2000 12:57:15 GMT Subject: wierd error after if or while References: <8f90uq$u4v$1@nnrp1.deja.com> Message-ID: <8f91vb$jfl$1@slb3.atl.mindspring.net> In article <8f90uq$u4v$1 at nnrp1.deja.com>, wrote: > >I am a newbie - in fact I just downloaded it today, and so far it looks >like a very useful language. The only problem is I seem to be doing >something stupid. If I run the folloing bit of code > >x = 4 > >if x==4: >print "hello" > >I get the following error message > > File "", line 2 > print "hello", > ^ First of all, next time please include the entire error message. In this case, I know you received a syntax error, but that might not be so obvious next time. The problem is that Python uses whitespace to indicate that statements belong in a block. Your "if" starts a new block, so the "print" needs to be indented, like this: if x==4: print "hello" -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "It's not because my mind is made up that I don't want you to confuse me with any more facts. It's because my mind isn't made up. I already have more facts than I can cope with. So SHUT UP, do you hear me? SHUT UP!" _The Shockwave Rider_, 1975 From cheesefactory at yahoo.com Mon May 22 19:14:43 2000 From: cheesefactory at yahoo.com (Paul Schreiber) Date: Mon, 22 May 2000 16:14:43 -0700 (PDT) Subject: python 1.6a2 and openssl (debian) solved Message-ID: <20000522231443.9780.qmail@web113.yahoomail.com> [background: i've installed debain packages openssl 0.9.4-5, libssl 0.9.4-5, and libssl-dev 0.9.4-5.] Thomas: thanks! I got it to work: My lines in Python-1.6a2/Modules/Setup.in are: SSL=/usr/lib/ssl socket socketmodule.c \ -DUSE_SSL -I/usr/include/openssl \ -L/usr/lib -lssl -lcrypto Paul __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ From billtut at microsoft.com Sat May 13 07:01:06 2000 From: billtut at microsoft.com (Bill Tutt) Date: Sat, 13 May 2000 04:01:06 -0700 Subject: Using ADO in Python Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD0A8@RED-MSG-50> > From: alien at netspace.net.au [mailto:alien at netspace.net.au] > > > I can create an ADODB.Recordset object and use it under Python. No > problem. But how do I use a recordset returned, for example, from > Connection.Execute()? > > When I try something like: > > import win32com.client > > con = win32com.client.Dispatch("ADODB.Connection") > con.Open("Provider=SQLOLEDB.1;Password=password;Persist Security > Info=True;User ID=sa;Initial Catalog=Surefire;Data Source=ARMALYTE") > rs = win32com.client.Dispatch("ADODB.Recordset") > print rs.State > rs = con.Execute("SELECT * FROM Stock WHERE Stock_Unique_Id IS NULL") > print rs.State > > I get the error: > > Traceback (innermost last): > File "F:\Code\Python\ado.py", line 8, in ? > print rs.State > AttributeError: 'tuple' object has no attribute 'State' > > The first "print rs.State" works, the second does not. > > Any help would be appreciated. > Execute is returning a tuple. Replace the 2nd "print rs.State" with "print rs" and you'll see whats going on. The reason that Execute is returning a tuple is because Execute has an out parameter besides the normal recordset return value. Something like rs = con.Execute(....)[0] might do the trick. Bill From mwh21 at cam.ac.uk Tue May 30 07:39:46 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 May 2000 12:39:46 +0100 Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <39333CC3.32805F5@cosc.canterbury.ac.nz> <8h087l$bnc$4@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Fredrik Lundh wrote: > > if you think that keeping string.join in there is the most serious > > design mistake in 1.6, you may be in for some really interesting > > surprises... > > That of course doesn't make it any less true that we should stop > " ".join() *now* before it is too late. If there are other more serious > design mistakes, I suggest you point them out to us if you want our > help fixing them. :) > > Since the debate about generalized 'join()' on lists can be fought > on forever, what about following the earlier more pragmatic > suggestion of somehow hiding 'join()' on strings and exposing it > only through string.join(), making that the One Right Way to Do It? > If 'string' suddenly is a pain to import, a builtin: sjoin() or > whatever. > > " ".join() is just not making sense to a *lot* of people. I'm sure > you can get used to it, but I had to blink a couple of hundred times > first, myself. Well, to add a counterview, I am quite happy with sep.join; when I first saw it I thought (once!) "hmm, that's odd", and then got on with using it. It's not an obvious solution, I'd admit - but that doesn't mean it's not a good one. Cheers, M. -- Strangely enough I saw just such a beast at the grocery store last night. Starbucks sells Javachip. (It's ice cream, but that shouldn't be an obstacle for the Java marketing people.) -- Jeremy Hylton, 29 Apr 1997 From glyph at twistedmatrix.com Sat May 13 16:08:23 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 13 May 2000 15:08:23 -0500 Subject: Stackless/microthreads merge news In-Reply-To: Christian Tismer's message of "Sat, 13 May 2000 20:44:49 +0200" References: <39185686.665174C0@tismer.com> <391C085A.58329C18@prescod.net> <391DA2A1.276EFFAA@tismer.com> Message-ID: Christian Tismer writes: > > interface continuation{ > > public Object apply( Object[] ) throws throwable; > > } > > Sure. Does Java support function variables? > COntinuations must be callable objects, and I need to > be able to split them off of a running context at any > time. Is that possible without changing Java? Of course not! That might have the unintended side-effect of increasing programmer productivity! :-P If you tell a java programmer that you want "function variables", they will tell you that it's easy ... a list of "function variables" would only require that you rewrite your code like this: interface FunctionObject { Object funcall (Object[] f); } class AddFunctionObject implements FunctionObject { Object funcall (Object[] args) { double a = ((Number)args[0]).doubleValue(); double b = ((Number)args[1]).doubleValue(); return new Double(a+b); } } Vector v = new Vector(); FunctionObject f = new AddFunctionObject(); v.addElement(f); ... later ... Enumeration e = v.elements(); while (e.hasMoreElements()) { FunctionObject f = (FunctionObject) e.nextElement(); Object[] args = {new Integer(5), new Integer(3)}; Object result = f.funcall(args); } this being roughly equivalent to the python code: v=[lambda x,y: x+y] ... later ... for f in v: result=f(5,3) But of course, java is "better", because it's "really object oriented" and in "real" languages, code isn't a first class object, or storable in variables. A disturbing number of Java programmers believe that Smalltalk is this way too, and that block closures were just a weird abberation that nobody uses. (This is an oversimplified version of the Java version, of course. You'd have to swaddle everything in 5 different try { } catch (){} blocks before it would actually compile.) If you want to do this reflectively (I.E. use the method foo.bar on some object rather than writing your own code) it's possible, but it would be brittle (dependant upon strings for linking at runtime, so you don't get any lovely compiler checks for your code... and with the amount of typing you need to get anything done in java, you need those checks), slow (the linking would be re-done each time, since you'd be calling the reflective string methods), and hard (you STILL wouldn't be able to say foo.bar, you'd have to say "foo.getClass(),'bar', or similiar). Not to mention the fact that if I wrote it here it would be so insanely verbose that internet customers in europe would be yelling at me for wasting their bandwidth. only-a-few-more-weeks-to-go-before-I-never-touch-Java-again-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From d98aron at dtek.chalmers.se Thu May 11 13:41:40 2000 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 11 May 2000 17:41:40 GMT Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> <8feioj$fei$1@nyheter.chalmers.se> <8feld6$8h8$1@nnrp1.deja.com> Message-ID: <8ferck$h3l$1@nyheter.chalmers.se> In article <8feld6$8h8$1 at nnrp1.deja.com>, Andrew Cooke writes: > In article <8feioj$fei$1 at nyheter.chalmers.se>, > d98aron at dtek.chalmers.se (Fredrik Aronsson) wrote: >> Well, using Haskells syntax, I would suggest >> map((\a,b,c -> a+b+c), p,q,r) > > what's that funny backslash for? > \ is like lambda: Perhaps it was chosen to look like the mathematical expression: \ \ / \a b c.a+b+c Haskell has a lot of nifty features and very nice syntax. Have anyone written a comparison? Here is the original problem solved in Haskell anyway: list1 = [ 1,2,3,4,5,6 ] list2 = [ 6,5,4,3,2,1 ] zipWith (-) list1 list2 (well, if you want print it nicely, you probably need putStr (unlines (map show (zipWith (-) list1 list2))) instead) /Fredrik From ben at co.and.co Sun May 21 06:19:55 2000 From: ben at co.and.co (ben at co.and.co) Date: Sun, 21 May 2000 10:19:55 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: [ Lots of things about case-sensitivity and readability already said ] I don't know about alice, but I think the quest for case-insensivity is masking the problem at hand: class Employee: def __init__(self, salary=0): self.Salary = salary def set_salary(self, salary): self.salary = salary The problem is: there's no way to check a python program without running it, and without variable declarations there's no way to catch errors like these. Case-insensitivity is not going to help: def set_salary(self, salary): self.Salyry = salary Right now, the topic of variable declarations is thightly coupled with Statical Typing, but it doesn't need to. The second is build on the foundations of the former: def __init__(self, salary=0): decl self.salary = salary and def __init__(self, integer salary=0): decl integer self.salary = salary If variable declarations would exist, it would be trivial to make Idle say 'Ni' whenever you make a spelling mistake (not limited to mistakes against case), because it knows all variables. It would also catch some unwanted reuse of variables. Side notes: o Types: I've seen a few proposals for a (bla: integer) syntax. This makes no sense if you want initialising too. Compare: def f(bla=0: integer): def f(bla: integer=0): def f(integer bla=0): o A 'with'-keyword would be handy from time to time: with self: decl .salary = salary decl .name = '' decl .age = 0 o My school doesn't want to consider Python for teaching without typed variables (right now the're using Oberon). So hurry up, Types-SIG! Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From corg at copernic.com Mon May 15 15:04:35 2000 From: corg at copernic.com (Gaetan Corneau) Date: Mon, 15 May 2000 15:04:35 -0400 Subject: DLL functions that return char * Message-ID: Hi, I want to use windll to call a few simple functions in a DLL. Many of those functions return char *. Ex: char* GetName(); // export stuff omitted The buffer is owned by the DLL and overwritten for each call. How can I convert the returned value to a valid Python string? Thanks, ______________________________________________________ Gaetan Corneau Software Developer Copernic.com http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Les T?l?tubbies, c'est de la musique d'ascenseur pour les yeux" -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/B/MU d- s+:++ a C++ UL+ P--- W+ N- K- W++ t-- !5 X- R+ tv-- b++ DI++ G e++ h---- r+++ y++++ ------END GEEK CODE BLOCK------ From neelk at brick.cswv.com Sun May 21 15:14:21 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 21 May 2000 19:14:21 GMT Subject: [PATCH] Identifiers with '?' Message-ID: At the risk of treading on the raging identifier-flamewar, I'd like to present a one-line patch that brings one of Lisp's little syntactic conveniences to Python -- the ability to make identifiers with a question mark in the name. This is very useful for naming boolean flags and functions. An example will probably illustrate most easily. Python 1.6a2 (#1, May 21 2000, 14:59:38) [GCC 2.7.2.1] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> import types >>> types.IntType >>> instance? = isinstance # A var with '?' in the name >>> >>> instance?(3, types.IntType) # It can be used like any other name 1 I've restricted the use of '?' to the same status as numbers; you can't start a variable name with '?', but it can be part of the follow on. So 'foo?' is legal, but '?foo' isn't. (This is easy to change, though.) Patch follows, against the 1.6 alpha in CVS. The change to 1.5.2 should be likewise obvious. Bon appetit! Index: tokenizer.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.41 diff --context -r2.41 tokenizer.c *** tokenizer.c 2000/05/03 23:44:37 2.41 --- tokenizer.c 2000/05/21 19:05:09 *************** *** 625,631 **** goto letter_quote; break; } ! while (isalnum(c) || c == '_') { c = tok_nextc(tok); } tok_backup(tok, c); --- 625,631 ---- goto letter_quote; break; } ! while (isalnum(c) || c == '_' || c == '?') { c = tok_nextc(tok); } tok_backup(tok, c); Neel From jlj at cfdrc.com Tue May 2 10:00:03 2000 From: jlj at cfdrc.com (Lyle Johnson) Date: Tue, 02 May 2000 09:00:03 -0500 Subject: CGI File Size Limit? References: <_h6P4.14007$g4.347236@newsread2.prod.itd.earthlink.net> <390DA15A.EAF8D635@cfdrc.com> Message-ID: <390EDF63.F4D1F64E@cfdrc.com> Ed, Don't know if this is the answer or not, but doing a search for "cgi" on the Python FAQ (http://www.python.org/search/search_faq.html) yielded this hit: 7.12. cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! Be sure you have the latest python.exe, that you are using python.exe rather than a GUI version of python and that you have configured the server to execute "...\python.exe -u ..." for the cgi execution. The -u (unbuffered) option on NT and win95 prevents the interpreter from altering newlines in the standard input and output. Without it post/multipart requests will seem to have the wrong length and binary (eg, GIF) responses may get garbled (resulting in, eg, a "broken image"). Hope this helps, Lyle Ed wrote: > > More information: > If I test the len(form["userfile"].value), it is only 3134 instead of > 18k (the "CONTENT_LENGTH"). That means the CGI.py module is not > getting the data. Something wrong with CGI module reading binary data > off of the standard input stream. > > Have I confirmed that it is a problem with the cgi.py module? > > Ed wrote: > > > I'm having trouble uploading an 18K file via CGI and saving it to a > > file from my Python script. The file gets saved, but the file size > > is only 1k. I'm assuming that the cgi module is only reading the > > first 1k bytes. I'd like to know if this sounds reasonable and how > > to solve the problem....and if not reasonable, where else I might > > look for the problem. Thanks.... From pinard at iro.umontreal.ca Mon May 29 11:34:55 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 29 May 2000 11:34:55 -0400 Subject: pyc files In-Reply-To: "=?iso-8859-2?q?Przemys=B3aw_G._Gawro=F1ski?="'s message of "Mon, 29 May 2000 13:53:21 +0200" References: <39325A31.1C0839A6@obop.com.pl> Message-ID: "Przemys?aw G. Gawro?ski" writes: > Can I create a rpm with only pyc files or do I need the py file also to > make package distrubution ? I do not think you need the `.py' files, except for quoting line sources in traceback matters, maybe. But I did not try. You probably should :-). -- -------------- next part -------------- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From Wolfgang.Grafen at marconicomms.com Wed May 31 09:23:57 2000 From: Wolfgang.Grafen at marconicomms.com (Wolfgang Grafen) Date: Wed, 31 May 2000 15:23:57 +0200 Subject: memory leak on solaris 2.5.1 / 2.6 ? Message-ID: <3935126D.32AFBAA1@marconicomms.com> Following problem: starting the Python interpreter in interactive mode about 2.6 MB will be allocated. Issuing following command >>> x = "1001" * 5000000 will occupy about 22 MB. >>> del x doesn't decrease the amount of allocated Memory. I discovered that problem when running a Python script allocating more than 1 GB Memory after reading from several files. With Suse-Linux the memory will be properly freed on a Intel PC and a pre-compiled Python 1.5.2 version. I tried it with a standard configured Python version 1.5.2 as well a thread-enabled version with many extension modules compiled in with gcc version 2.7.2 on Solaris 2.5.1. The same effect also occured with Python version 1.6a compiled as described above. Running Python 1.5.2 and 1.6.a compiled as described above from Solaris 2.6 also showed the same problem. Is there any solution for that? Thanks Wolfgang From aa8vb at yahoo.com Fri May 19 08:20:07 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 19 May 2000 08:20:07 -0400 Subject: GUI (Tkinter) and "cancel" In-Reply-To: <392500B2.D467C8EB@muc.das-werk.de>; from thiele@muc.das-werk.de on Fri, May 19, 2000 at 10:52:03AM +0200 References: <392500B2.D467C8EB@muc.das-werk.de> Message-ID: <20000519082007.A1734431@vislab.epa.gov> |I have a simple graphical user interface written with Tkinter. This |allows a user to call a function by pressing on a button (or something |like this). The function works for some minutes, somtimes up to an hour. |How can I implement a "cancel"-button that allows the user to cancel the |time-intensive function. | |At first I thought on creating another thread, but it must be simpler. |How? The essence of the problem is you need to have your GUI (Tkinter) process periodically checking for user events, either by returning to the main event loop or calling one of the "check for user events" APIs (Tkinter's update method for example--though see caveats in the docs). You have a number of options: 1) Modify your work function to periodically check for user events. worker() -> check_events() -> check_events() -> check_events() 2) Change your work function to be event-driven. That is, to do its work in pieces, saving appropriate state betweeen each piece. Just wake up to do a slice of work via Tkinter timers, and return to the main event loop after each slice to handle user events. tk_timer_event -> worker() tk_timer_event -> worker() tk_timer_event -> worker() 3) Fork off a subprocess to do the work. 4) Create a thread to do the work. Which one is simplest really depends on your situation (how much coupling there is between the GUI "thread" and the compute "thread", for example, using the term thread loosely here). -- Randall Hopper aa8vb at yahoo.com From ben at co.and.co Tue May 2 10:03:04 2000 From: ben at co.and.co (ben at co.and.co) Date: Tue, 02 May 2000 14:03:04 GMT Subject: plain text python source -> HTML syntax highlighted source References: <65118AEEFF5AD3118E8300508B1248774CB2C0@ALTNET> Message-ID: Jim Richardson wrote: > Just when I think Vim has no more surprises for me:) > > (Jim, who just wishes Vim used python as a macro language.) Just compile vim with the |+python| feature, and you have a builtin Python-interpreter. (:h python) Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From bruce_dodson.nospam at bigfoot.com Mon May 15 18:24:58 2000 From: bruce_dodson.nospam at bigfoot.com (Bruce Dodson) Date: Mon, 15 May 2000 19:24:58 -0300 Subject: How python development is speedy! References: <391FFDB5.FC9A85CA@cui.unige.ch> Message-ID: To me, it's "something else". I can write a simple function more or less just as quickly in C++ and Python. The Python version might be 10 lines and the C++ might be a few lines longer due to things like variable declarations and closing braces, but they would take just as long to write. However, when you get to debugging, or integrating a number of larger modules together it's Python all the way... Things like the interactive mode and the reload function give Python definite advantages in allowing you to edit and debug modules within a running program. (This is one of the hallmarks of VB as well, although in VB there are some limits, e.g. you can't change function signatures at run time, and have to quit the debugger in order to save.) Bruce Sunil Hadap wrote in message news:391FFDB5.FC9A85CA at cui.unige.ch... > Hello, > > I use Python,I don't know Java. I am just curious, people keep > reporting that Python is very fast in development as compared to Java > and C++. Is this because of language feature or because of reduced > compile-run-debug cycle, or something else! > > When I look at my Python code, I see little difference in terms of > development efficiency as compared to C++ when used with STL and other > good libraries. Does the higher types such as lists and tuples make > Python so powerful, after all C++ had all that. > > > Sunil > > -- > "Live as if you would die tomorrow, > learn as if you would live forever." > --Mahatma Gandhi > > From arnold at dstc.monash.edu.au Tue May 9 20:56:04 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Wed, 10 May 2000 10:56:04 +1000 Subject: Figuring out an object's type In-Reply-To: Your message of "Tue, 09 May 2000 19:40:11 EST." <8fab7p$4kh$1@bob.news.rcn.net> Message-ID: <200005100056.KAA04604@xevious.dstc.monash.edu.au> -->"David" == David Allen writes: David> How can a python programmer figure out the type of an object? the type() function returns the type. if the object is a class instance, then it has an attribute __class__ that can be used to determine its class. >>> class foo: ... pass ... >>> f = foo() >>> type(f) >>> f.__class__ >>> f.__class__.__name__ 'foo' >>> d From mwh21 at cam.ac.uk Mon May 8 10:53:45 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 08 May 2000 15:53:45 +0100 Subject: Tricks to do "enums"? References: <3916CED8.DE2D103E@fenx.com> Message-ID: emile at fenx.com writes: > Watch out for this one. IRK, this results from auto interning some > strings. > > >>> a = "this is a longer string value" > >>> eval("'this is a longer string value' is a") > 0 > >>> b = "JoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoe" > >>> eval ("'JoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoeJoe' is b") > 1 > > There's-an-assumption-at-the-bottom-of-this-I-assume-ly y'rs, Look at Python/compile.c, line 261 (or search for "Intern selected string constants"). Basically string constants that *could* be Python identifiers (ie. consist entirely of A-Za-z0-9_) are interned. I think this is the third (or fourth?) time I have posted this bit of information to this newsgroup... Cheers, Michael -- 81. In computing, turning the obvious into the useful is a living definition of the word "frustration". -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From ben at co.and.co Tue May 2 12:31:32 2000 From: ben at co.and.co (ben at co.and.co) Date: Tue, 02 May 2000 16:31:32 GMT Subject: CGI File Size Limit? References: <_h6P4.14007$g4.347236@newsread2.prod.itd.earthlink.net> <390DA15A.EAF8D635@cfdrc.com> <390EDF63.F4D1F64E@cfdrc.com> <390EE74D.CC69F8AD@cfdrc.com> Message-ID: Ed wrote: > I wrote a simple test program to verify that, on the command line, I do > indeed need the -u flag to read binary data from stdin. Funny, > though....now the server barfs on TEXT files, too, using > "#!/Software/Python/python.exe -u". Before, without the -u, it processed > both text and binary files...it just didn't read the binary data correctly. > Now it doesn't upload even text files....(gives the error I showed in the > previous post). Such are the joys of an OS that mocks with the content of files, depending on the way you look at it. (And now, people are asking for Python to do the same thing (Scan for BOM and Unicode in "BOM should be ignored...")) Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From ghost_man at my-deja.com Tue May 16 22:58:09 2000 From: ghost_man at my-deja.com (ghost_man at my-deja.com) Date: Wed, 17 May 2000 02:58:09 GMT Subject: reading in a string Message-ID: <8ft1rq$pgb$1@nnrp1.deja.com> I am writing a python script that through the os.system command calls VSS and imports the files over. I then run os.system('dir /s >> myfile.txt') I want to be able to read in the contents of the file one line at a time and execute some command on it. My problem is when the file is something like C:\program files\python\temporary Python reads it as c:\program files\python\011emporary I am getting tripped up by the \t switch. I cannot at this point and time run string.replace because it has already been converted over. Any ideas how I can read the string in correctly? I have explored the glob module and it would seem very cumbersome to try and cover this. Is there an easier way to read in the contents of my file and have them import correctly? Sent via Deja.com http://www.deja.com/ Before you buy. From scarblac-spamtrap at pino.selwerd.nl Sun May 14 13:37:56 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 14 May 2000 17:37:56 GMT Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> Message-ID: rturpin at my-deja.com wrote in comp.lang.python: > And why should this be? It isn't hard to write > resizable vector code that is fast at both ends. > There are lots of times when you want to manipulate > a list from both ends. And Python syntax makes it > easy: I think it's *much* more common to append than to prepend. In fact, I can't remember when I prepended to a list in Python (except as a special case of adding something at some point in the list). Imho, adding extra space at the beginning of lists is mostly a waste of space. So I would find it interesting to know why you use prepending so much :) -- Remco Gerlich, scarblac at pino.selwerd.nl 7:37pm up 69 days, 7:51, 8 users, load average: 0.26, 0.31, 0.38 From jkraska1 at san.rr.com Tue May 2 23:48:45 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 03:48:45 GMT Subject: Backward chaining for __init__? References: <390F8C7E.9986DAE0@san.rr.com> Message-ID: <390FA242.C6DC9BBC@san.rr.com> > class Derived(Parent): > def __init__(self): > Parent.__init__(self) > # do whatever else Thank you. Somehow in the various pieces of documentation I have, it wasn't at all obvious to me that you could treat the type as an object. This makes sense now in retrospect. I'm curious, however, as to the philosophical justification for leaving backward-chaining ctors out of Python? While it's just synactic sugar, some kinds of sugar really taste good. What would be really nice is some use controlled way of making backward chaining methods in general, as opposed the the limited __init__ case. C/ From mmiller3 at iupui.edu Tue May 2 12:53:38 2000 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 02 May 2000 11:53:38 -0500 Subject: Reading in strings -> numbers ?? References: <390A2D23.7029E557@fenx.com> <8ede36$9r6$1@nnrp1.deja.com> <300420001022354625%pecora@anvil.nrl.navy.mil> Message-ID: <87vh0w51wt.fsf@lumen.med.iupui.edu> >>>>> "Louis" == Louis M Pecora writes: > After three weeks of learning Python have I actually found > a real wart? A common requirment in programming > (especially for numerical stuff) is to read in data that is > often generated by other programs and other people. The > common form is a "table" structure: You might be able to make use of TableIO [1], which I wrote to satisfy my needs for reading and writing white-space delimited ascii data. Mike [1] http://php.iupui.edu/~mmiller3/python/ -- Michael A. Miller mmiller3 at iupui.edu Krannert Institute of Cardiology, IU School of Medicine Indiana Center for Vascular Biology and Medicine From sharan_chang at my-deja.com Wed May 17 16:55:43 2000 From: sharan_chang at my-deja.com (sharan_chang at my-deja.com) Date: Wed, 17 May 2000 20:55:43 GMT Subject: How to use JNI wrapped class in JPython Message-ID: <8fv106$24p$1@nnrp1.deja.com> I am new in JPython, plan to use JPython to test my Java classes. Some of my Java classes uses JNI wrapped class and whenever I run the MyJavaClassWithJni.main (argv) from JPython, I get java.lang.NoClassDefFoundError: com/lgc/sw/myJNIClass All my JNI wrapped Java Classes are in one .jar file and there are associated .dll files. How does JPython know it needs to load classes from these files? I tried import the .jar file and it did not work. - Sharan Sent via Deja.com http://www.deja.com/ Before you buy. From guido at python.org Sun May 21 18:05:58 2000 From: guido at python.org (Guido van Rossum) Date: Sun, 21 May 2000 15:05:58 -0700 Subject: ANNOUNCE: Python CVS tree moved to SourceForge Message-ID: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> I'm happy to announce that we've moved the Python CVS tree to SourceForge. SourceForge (www.sourceforge.net) is a free service to Open Source developers run by VA Linux. The change has two advantages for us: (1) we no longer have to deal with the mirrorring of our writable CVS repository to the read-only mirror ar cvs.python.org (which will soon be decommissioned); (2) we will be able to add new developers with checkin privileges. In addition, we benefit from the high visibility and availability of SourceForge. Instructions on how to access the Python SourceForge tree are here: http://sourceforge.net/cvs/?group_id=5470 If you have an existing working tree that points to the cvs.python.org repository, you may want to retarget it to the SourceForge tree. This can be done painlessly with Greg Ward's cvs_chroot script: http://starship.python.net/~gward/python/ The email notification to python-checkins at python.org still works (although during the transition a few checkin messages may have been lots). While I've got your attention, please remember that the proper procedures to submit patches is described here: http://www.python.org/patches/ We've accumulated quite the backlog of patches to be processed during the transition; we'll start working on these ASAP. --Guido van Rossum (home page: http://www.python.org/~guido/) From cwr at crash.cts.com Fri May 19 12:33:13 2000 From: cwr at crash.cts.com (Will Rose) Date: 19 May 2000 16:33:13 GMT Subject: OT: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> Message-ID: <8g3qc9$2m9f$2@thoth.cts.com> Grant Griffin wrote: : I guess I take a "shrink wrap" mentality, both from an author's and a : user's perspective. The "gizmo" should meet the user's need, as defined : by the user. (Note, however, that the "user" is partly defined by the : "gizmo", because user's don't use gizmos which don't meet their needs.) [...] : But to go back to tarring and feathering tar, the user has little need : for packaging without compression, so packaging and compression : constitute a single gizmo from the modern user's perspective. QED Well, no. I use tar quite a bit. I suppose I subsequently compress files about half the time. In fact, I seldom use zip, even on MSDOS machines. Tho' compressing the output of tar automatically would do no harm, it would be a nuisance and extra work for my (slow, old) CPUs. And you'd need a version of tar which understood all the various forms of compression. I come across three or four on a pretty regular basis. Generally I find that archiving and compression are more conviently considered as two separate processes. Will cwr at cts.com From thomas at xs4all.net Thu May 4 17:03:37 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 4 May 2000 23:03:37 +0200 Subject: Linux Processes from Python HOW-TO? In-Reply-To: <390DBBC1.12EADB7@pacific.jpl.nasa.gov>; from btang@pacific.jpl.nasa.gov on Mon, May 01, 2000 at 10:15:45AM -0700 References: <8ecpch$j73$1@nnrp1.deja.com> <20000428234608.L11481@xs4all.nl> <390DBBC1.12EADB7@pacific.jpl.nasa.gov> Message-ID: <20000504230337.E3309@xs4all.nl> On Mon, May 01, 2000 at 10:15:45AM -0700, Benyang Tang wrote: [ in reply to my blabbering about processes ] > Can this process manipulation be done for Windows 95 or 98? Yes, all except fork(). Also, the exact technicalities are slightly different under Windows, as far as i know. The way you point to your executable, for instance ;) Windows does not have something that can serve as a replacement for fork(), however. If I recall correctly, this was one of the changes Microsoft and ActiveState were going to bring -- a way to simulate perl's fork() (which is the same as Python's fork(), which is just the standard UNIX fork()) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From r2d2 at mao.acc.umu.se Mon May 29 03:01:07 2000 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: 29 May 2000 07:01:07 GMT Subject: Optional Underscores (py3k)? References: <392AD6CD.46838306@visionart.com> <8gla4o$msn$1@nnrp1.deja.com> <26052000.6@sanctum.jae.ddns.org> Message-ID: In article <26052000.6 at sanctum.jae.ddns.org>, Juergen A. Erhard wrote: > Niklas> Or why not: > > Niklas> if ok to continue and has attr(the current node, "next"): > >Looks ugly... I'd like to be able to say > > if ok to continue and the current node has attr "next": > >;-) Ouch! Painfull AppleScript flashbacks. ;) // Niklas From tom at parlant.com Mon May 15 16:34:57 2000 From: tom at parlant.com (Thomas Lane) Date: Mon, 15 May 2000 14:34:57 -0600 Subject: removing "close" button in Tkinter Message-ID: <39205F71.D8969155@parlant.com> I'm trying to write a Tkinter program that has the maximize and minimize buttons in the upper-right corner of the window, but I don't want the close button. Does anyone know how to hide/remove this button from a "TopLevel" window? Thomas Lane tom at parlant.com From jhauser at ifm.uni-kiel.de Wed May 10 13:12:14 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 10 May 2000 19:12:14 +0200 Subject: Passing by value instead of reference References: Message-ID: <87snvqib2p.fsf@ifm.uni-kiel.de> Frederic says no :-) But in case of mutable arguments one can use sometimes (if one knows the type of the arguments beforehand) copy.copy() or copy.deepcopy(), or not? import copy def byvalue(a): a=copy.deepcopy(a) a[3]=10 a=[1,2,3,4] print a byvalue(a) print a This is not general, but helps in some situations. HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From scarblac-spamtrap at pino.selwerd.nl Wed May 31 05:36:18 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 31 May 2000 09:36:18 GMT Subject: Sequence-length - Missing the obvious ? References: <3934db4e@nntp.server.uni-frankfurt.de> Message-ID: mlauer at trollinger-fe.rz.uni-frankfurt.de wrote in comp.lang.python: > class sequence: > > def __getitem__( self, i ): > return self.d[i] > > seq = sequence() > seq.d = "Hallo" > > for item in seq: > print item, > > ----------------------------------- > > This works - gives out "H a l l o". > __getitem__ get?s called five times. > > But why ? How does the for loop knows > how much elements the sequence contains ? > I did not program the __len__ function, > so... how ? for loops just call __getitem__ with increasing i until an IndexError is raised. This makes them really generic. So __getitem__ is actually called six times. -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "Suicide on the steppes": The Russian Civil War was designed to simulate chaotic conditions in Russia in 1917. Players can get points for attacking their own units. From exarkun at flashmail.com Mon May 15 00:10:52 2000 From: exarkun at flashmail.com (Jp Calderone) Date: Mon, 15 May 2000 00:10:52 -0400 Subject: popen2 + passwd Message-ID: <391F78CC.362C5D12@flashmail.com> Can anyone tell me why this doesn't work? import popen2 i, o = popen2.popen2('passwd bin') pwd = '12345ASD' o.write(pwd + '\n') o.write(pwd + '\n') i.close() o.close() Running it through the interpreter yields no output (as it should), but the password for the bin user doesn't change to what I'd expect it to (12345ASD), but to something else. Thanks in advance, Jp -- 12:08am up 12 days, 4:36, 3 users, load average: 0.04, 0.05, 0.06 From thomas at xs4all.net Fri May 19 09:31:53 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 19 May 2000 15:31:53 +0200 Subject: Newbie: opening files. In-Reply-To: <39254013.C5B3834A@spamspamhotmail.com>; from Gonk_@spamspamhotmail.com on Fri, May 19, 2000 at 03:22:28PM +0200 References: <39254013.C5B3834A@spamspamhotmail.com> Message-ID: <20000519153153.H13281@xs4all.nl> On Fri, May 19, 2000 at 03:22:28PM +0200, Bart Holthuijsen wrote: > now this is what I try to do: > ------------------------- > from sys import * > from os import * > from string import * > > def main(): > chdir('c:\stage\Xalan') > f = open('Yearend.xml','r') > print "file opened" > ------------------------- > The following error message appears: > C:\Stage\xalan>python open.py > Traceback (innermost last): > File "open.py", line 25, in ? > if __name__=='__main__': main() > File "open.py", line 13, in main > f = open('Yearend.xml','r') > TypeError: illegal argument type for built-in operation > What am I doing wrong? This: > from sys import * > from os import * > from string import * os.open() overwrites the builtin open(), and os.open() takes different arguments. A friendly tip: do *not* use 'from foo import *' until you realize what it does -- and then do not use it either :-) If you really dislike the extra few characters it takes to prepend 'os.' or 'sys.', import the symbols you need by hand: from os import system, fork from sys import argv, exit from string import letters, replace But I think you'll find in larger programs, just importing the modules and using the 'full' name makes your code a lot more obvious. Especially when debugging.. you wont have to re-trace to find out what a particular variable is bound to :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From darrell at dorb.com Mon May 29 14:38:51 2000 From: darrell at dorb.com (Darrell Gallion) Date: Mon, 29 May 2000 11:38:51 -0700 Subject: Walking recursivly through a directory-structure References: Message-ID: <064301bfc99d$23dd7e30$6401a8c0@home> Just needed this last night. While trying to use cvs_chroot from http://starship.python.net/~gward/python/ def find_cvs_dirs (start_dir): # p = os.popen("find %s -type d -name CVS" % start_dir, "r") files = [] def walker(fileList,top, files): for file in files: if file=="CVS": fullName = top+os.sep+file fileList.append(fullName) os.path.walk(".", walker, files) return files "P?l Sollie" wrote in message news:m3og5pcsvi.fsf at rancid.apocalypse.no... > I've been looking at os.path.walk for this, but I'm not sure how to > implement it. Anyone able to point me in the rigth direction? > > -- > P?l Sollie > sparkz at ikke.no > sollie at bitemyshinymetalass.com > -- > http://www.python.org/mailman/listinfo/python-list From darcy at vex.net Sat May 20 18:33:00 2000 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 20 May 2000 22:33:00 GMT Subject: CGI Authentication form passthrough question References: <3C1077AC64755A57.0FB8B24AA3155646.CE4465C98A055096@lp.airnews.net> <3925E44A.33B90279@bigfoot.com> Message-ID: <8g73qs$206q$1@news.tht.net> David Rock wrote: > How do I make this form submission and all subsequent submissions display based on a verified un/pw? Right now, all someone would have to do is remember > the URL after the login stuff and they wouldn't need to worry about it. (I thought of using if __name__ == '__main__' to verify that the cgi being > accessed by the form is not the main process, but sometimes it should be) Don't use a form for the password. Use the built in login/password facility in the Apache (You do use Apache, right?) web server. This password needs to be sent for each page but your browser does this for you automatically once you have entered password correctly once. The variable REMOTE_USER now holds the name that the user logged in as and you can always check for that before continuing. Let the system do all the hard work. Look at the various Auth directives for details. You can put them in a block in the config file or put them in .htaccess. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From frankc at colconsulting.com Sat May 20 08:31:54 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Sat, 20 May 2000 08:31:54 -0400 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> Message-ID: <392685BA.F6B3D24A@colconsulting.com> Courageous wrote: > > I thought about this for a while, and my suspicion is that > the first negative reaction that people have against case > insensitivity is probably the instinctive (and false) idea > that everyone would be writing python programs without case. > > The occasions in which you really want to have variables/ > attributes which differ by case alone are quite rare. About > the only time I have ever seen this regularly is in some > types of code where accessors (in c++/java) differed from > private attributes only in case, ala: > > class Myclass > { > private int myvar; > int Myvar(); > } > > I can't really see any other real use of actual case sensitivity > in the language. Does anyone out there actually make use of > case sensitivity? > > Truly curious. > > I guess what I'm saying is, now that I think about it, > "so what, no big loss." > > Kind of like the braces, only far less consequential. > > C/ IMHO there are three (3) aspects to case sensitivity: 1. It is a compiler identifier semantic ( Self is NOT self is not SELF ) 2. Readability, with, of course, some kind of consistency style standard 3. Descriptive, with certain methodologies the case is used to delineate type, action, and purpose I appreciate and utilize all of them. -- Frank V. Castellucci http://corelinux.sourceforge.net OOA/OOD/C++ Standards and Guidelines for Linux http://PythPat.sourceforge.net Pythons Pattern Package From ajung at sz-sb.de Wed May 17 07:59:42 2000 From: ajung at sz-sb.de (Andreas Jung) Date: Wed, 17 May 2000 13:59:42 +0200 Subject: DCOracle and handling of package OUT parameters broken ?! Message-ID: <20000517135941.A23544@sz-sb.de> Dear all, I have the following stored proc: create or replace procedure select_lob( tabname IN varchar2, primkey IN varchar2, primval IN varchar2, retstr OUT varchar2) IS mylen integer; myclob clob; sql_smt varchar(1024); bufb varchar2(32767); BEGIN sql_smt := 'select inhalt from ojs_de where docnum='''||primval||''''; execute immediate sql_smt into myclob; mylen := DBMS_LOB.GETLENGTH(myclob); DBMS_LOB.READ(myclob , mylen, 1,bufb); retstr := substr(bufb,1,2900); END; Its task is to deliver the content of a CLOB (XML files < 32000 characters). The procedure is being called from search.py: ... curs.execute('select docnum from ojs_de order by docnum') data = curs.fetchall() for d in data: docnum = d[0] print docnum res= curs.procedures.select_lob('ojs_de','docnum',docnum) print res ..... Python fails with the following traceback: Traceback (innermost last): File "./search.py", line 23, in ? res= curs.procedures.select_lob('ojs_de','docnum',docnum) File "DCOracle/DCOracle/ociProc.py", line 133, in __call__ if oci_.oexec(oc): self._error() File "DCOracle/DCOracle/ociProc.py", line 106, in _error raise error, (rc, oci_.OracleErrorMessage(c.lda, rc)) oci.error: (6502, 'ORA-06502: PL/SQL: numeric or value error: character string buffer too small\012ORA-06512: at "AJUNG.SELECT_LOB", line 22\012ORA-06512: at line 2\012') When I reduce the size of the output string (substr()) to less than about 2000 I receive the data correctly. Is this DCOracle related or a problem of Oracle ?! Our environment: Oracle 8.16 EE, Solaris 2.7, Python 1.5.2, DCOracle 1.3 Thanks for helping, Andreas Jung From dgoodger at bigfoot.com Mon May 22 12:40:56 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Mon, 22 May 2000 12:40:56 -0400 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> <39271A25.A348E4B9@roguewave.com> <39295C88.EFEDE889@roguewave.com> Message-ID: on 2000-05-22 12:12, Bjorn Pettersen (bjorn at roguewave.com) wrote: > "John W. Baxter" wrote: >> In article <39271A25.A348E4B9 at roguewave.com>, Bjorn Pettersen >> wrote: >> >>> This brings up another interesting point... I'm assuming the subjects >>> from the Alice project/research would also prefer: >>> >>> 'token' == 'Token' >> >> AppleScript (not to be taken as "the only right way") does that: >> >> "token" is "Token" >> returns true, while >> >> considering case >> "token" is "Token" >> end considering >> returns false. > > But all those English keywords must be very confusing to people who do > not speak the language... I suggest we implement a global dictionary > that maps the language specific keyword names (or phrases, not all words > have a one-to-one mapping) to their canonical form... Just think, I > could spell the common pydiom (I'm assuming this was perfectly clear to > the Alice people ;-): > > while 1: > line = f.readline() > if not line: > break > ... > > as (with the Norwegian mapping...): > > s? lenge som 1: > linje = f.lesLinje() > hvis ikke linje: > brekk > ... That's another thing that AppleScript does (or did; I'm not sure if it's still supported) -- Dialects. I could write a program using the English Dialect, then change to the Japanese Dialect and all the keywords and syntax structure would be magically translated (in 2-byte SJIS, of course; not a big leap to Unicode). Very cool. Do I detect a trend here? I can just see it now, "Apple Py"! Or perhaps the biblical serpent on the tree of knowledge would be more appropriate... -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From effbot at telia.com Tue May 9 06:27:04 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 10:27:04 GMT Subject: Python on 64 bit/IA-64 ... References: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> Message-ID: Shiv Shankar Ramakrishnan write: > Has there been any work done to make Python take advantage of a full 64 > bit environment? Python runs just fine on 64-bit platforms. > More specifically is anyone working on an Intel IA-64 port of Python? Python should run out of a box on any IA-64 Unix; activestate is working on a Win64 port. (afaik, the current CVS version builds and runs under Win64) > In particular if one were to change the sources for this then which data > model would one follow - LP64 or LLP64 (P64)? Which model have people > used for existing 64 bit platforms if they did a port? it's platform/tool dependent. all sane platforms use LP64. microsoft doesn't. > AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited > precision (emulation). Floating points are m/c dependent but mostly > doubles. in CPython, a python int is a C long, which means that it's 64 bits on any sane 64-bit platform. a python float is always a C double. From m.faassen at vet.uu.nl Fri May 12 15:27:11 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 19:27:11 GMT Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <8f9bok$b7n$1@nnrp1.deja.com> Message-ID: <8fhluf$nk0$4@newshost.accu.uu.nl> andrich at my-deja.com wrote: > well I don't know what the problem of some people is. But go and get a > dictionary. Search for rhetoric and then reread my message. At least my > Oxford and my Webster provide the valid explanation of this word. > If we could leave this stuff out and discuss the topic, I would be more > then happy. Hey, this _is_ the Python newsgroup. We do go off on tangents here, answer rethoric questions and then question the answers. I already wondered why this thread was seeing so much posts, concluded someone must've gone off on some interesting tanget somewhere, and started contributing. :) Sorry, though, if that upset you! The original questions should indeed be discussed. I myself used your Linux distribution for a while when the then-current version of Red Hat packed 1.5.1 and not 1.5.2 (or was it 1.4? I forget. I do recall using your stuff once, though). Currently it seems Python has sufficient moment that most distributors include the most up to date version, so it may become less necessary these days, as you say. Thanks for the great job though, and good luck with Perl! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From emile at fenx.com Tue May 2 11:39:14 2000 From: emile at fenx.com (Emile van Sebille) Date: Tue, 2 May 2000 08:39:14 -0700 Subject: How to get the list of imported variables/functions Message-ID: <0a5a01bfb44c$a4e13500$1906a8c0@fc.fenx.com> >>> a = dir() >>> from string import * >>> b = dir() >>> for each in b: if not (each in a): print each I couldn't get Mike's sys.module['imported_mod'].keys() to work, and dir() of import * type thing doesn't do it. HTH, Emile van Sebille emile at fenx.com ------------------- From ngps at madcap.dyndns.org Thu May 25 10:30:32 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 25 May 2000 14:30:32 GMT Subject: E-Commerce solution using Python and Zope. References: <392CD741.E7241339@maxnm.com> Message-ID: <8gjde8$dsk$1@violet.singnet.com.sg> According to Itamar Shtull-Trauring : > John Mitchell wrote: >> Zope (http://www.zope.org) has a module or something for >> Cybercash and/or >> OpenMarket's stuff. Report back your findings! > > The CyberCash product (Wampum) works nicely (well, queries - I'm > testing it > with a credit-card this afternoon.). There's a nice store solution at > http://e-tailer.adroit.net. I've written an S/MIME-generator for Zope called ZSmime. Your Zope site can accept credit card numbers, say, and have ZSmime send them out as S/MIME-signed/encrypted mail to your Netscape Messenger-using back offce. http://www.post1.com/home/ngps/zope/zsmime -- Ng Pheng Siong * http://www.post1.com/home/ngps From nascheme at enme.ucalgary.ca Wed May 10 06:20:37 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Wed, 10 May 2000 10:20:37 GMT Subject: Python, cgi and redirect References: <39191ca8.537672021@news.ramk.fi> Message-ID: Teemu Keskinarkaus wrote: >Is there simple cgi module for python that can do redirect?? Now I'm >doing redirect in cgi-script like this: > >print "Status: 302 Moved" >print "Location: http://url.to.somewhere" > >That works fine except I get 'Premature end of script headers' errors >in apache error_log everytime I use that script. You need to terminate the headers with a empty line ("\r\n"): sys.stdout.write("Status: 302 Moved\r\n" "Location: http://url.to.somewhere\r\n" "\r\n") I think most clients will accept "\n" although it is not technically correct. Neil -- Every expert was once a novice. From emile at fenx.com Mon May 22 10:10:42 2000 From: emile at fenx.com (emile at fenx.com) Date: Mon, 22 May 2000 07:10:42 -0700 Subject: how to find out the father class? Message-ID: <39293FE2.2757F77B@fenx.com> >>> class A: pass >>> class B(A): pass >>> B.__bases__ (,) Emile van Sebille emile at fenx.com ------ wrote in message news:<8gbdou$sd3$1 at nnrp1.deja.com>... > Hi! > > How can I find out the father class of a given class? > > Regards, > Mike > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > From mhammond at skippinet.com.au Sat May 13 15:48:56 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 13 May 2000 19:48:56 GMT Subject: distribute win32 code References: <391D8B91.CF465DEB@innuendo.de> Message-ID: If you search dejanews, you will find code from me that imports these modules at runtime without registry settings. If you are only calling other COM objects (ie, not running them), then it should work fine with pythoncom15.dll in the same directory as the app itself... Mark. "Ulrich Schreiner" wrote in message news:391D8B91.CF465DEB at innuendo.de... > i wrote a nice installscript for a complex product in python and used > the win32 extensions for the NT-dist to write some values in the > registry an to create some shortcuts. everythin fine. > > i bundled python into the distribution because our customer does not > have python installed (and i dont think he wants python on his > production machine). everything seems to be ok, but there are problems > with the COM support. the win32api is available if the needed DLL (i > think its pywintypesXX.dll) is in the path. but to use COM there is an > additional DLL (pythoncomXX.dll). it does not work to put this dll in > the path; it only works if it is registered as an python extension in > the registry (to be honest: i encountered some very strange problems > when this dll wasnt in the system32-directory too, some sort of missing > entry-point in the dll; when i moved it back and recreated the registry > settings everything worked.). > > well, normally all of these DLLs are in the system32-directory but you > can copy them to another location as long as this location is in the > PATH. win32api works fine, but COM does not! > > question: is it possible to create a win32 python distr with COM support > which runs "out-of-the-box"? only with some sort of path-settings and NO > registry-settings? > > if the answer is "no" ... would it be a great problem to do this? > > feel free to email me. > > thanks > From fredrik at pythonware.com Sat May 20 06:38:25 2000 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 20 May 2000 12:38:25 +0200 Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> <3924D14D.85BF9A35@stud.ntnu.no> <20000519120721.D13281@xs4all.nl> <392638BE.DD502E36@stud.ntnu.no> Message-ID: <003c01bfc247$a13a91e0$0500a8c0@secret.pythonware.com> Peter Schneider-Kamp wrote: > Excuse me, but how can you be sure it is the same algorithm? > As far as I can read the sources to zlibmodule.c it uses the > function crc32 defined in zlib.h of the underlying platform. where the "underlying platform" is of course the zlib library by Gailly and Adler: http://www.info-zip.org/pub/infozip/zlib/ (also see ISO 3309 and/or ITU-T V.42...) From ajs at ix.netcom.com Sun May 21 11:39:57 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 21 May 2000 11:39:57 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <39276A37.BDB2F11D@san.rr.com> Message-ID: <002201bfc33a$d284c7e0$a3e06dd1@oemcomputer> Scientists, engineers, etc - Common sense. Just common sense. Undertaking an effort to learn programming is approaching a new game with new rules. TYPE <> type <> Type, etc. A rule. You got say 400 hundred to deal with. This particular rule is one of the easy ones. And kids are open to games with rules. Just help them understand what the rules are. Split the Python community by going case insensitive, and what you've accomplished is narrow the problem to the 399 other rules. And I have read the Alice dissertation. From phd at phd.russ.ru Fri May 5 10:37:32 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 5 May 2000 14:37:32 +0000 (GMT) Subject: HTMLParser tag contents In-Reply-To: <3913CBAA.64BB@seebelow.org> Message-ID: On Sat, 6 May 2000, Grant Griffin wrote: > I've been trying to figure out how to use HTMLParser. My immediate need > is to extract the entire of a file. (I could do that with 're', > but I'm trying to learn HTMLParser.) Sure, HTMLParser will returns a > tag's _attributes_, but I can't figure out how to get to the tag's > _contents_. Can it do that? Do not use HTMLParser - use SGMLParser. HTMLParser is for different parsing - more for HTML-to-text conversions... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From hzhu at rocket.knowledgetrack.com Tue May 30 20:39:48 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Wed, 31 May 2000 00:39:48 GMT Subject: __builtins__ Message-ID: It looks like that I have to use __builtins__.min (1,2) in the interpreter but __builtins__['min']([1, 2]) in a module. Why is this so? This arises in the context of redefining min in a module. Huaiyu From tismer at tismer.com Tue May 30 18:11:09 2000 From: tismer at tismer.com (tismer Kaun) Date: Wed, 31 May 2000 00:11:09 +0200 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <8h1ama$nd8$1@newshost.accu.uu.nl> Message-ID: <39343C7D.3099D6AF@tismer.com> Martijn Faassen wrote: > > Paul Magwene wrote: > > < news of the impending move to PythonLabs snipped> > > > Oddly enough, I found the most exciting part of this announcement (other > > than the news that Guido et al. will be devoting their full efforts to > > Python) to be the fact that I can now put a face to the name "Tim > > Peters" (see http://www.pythonlabs.com/team.html ). > > Me too. I wanted to post this! A face for Tim Peters! Yay! > > > That photo isn't a fake, is it? > > Of course it's a fake. You didn't see any mention of the PSU in that FAQ > either, did you? This is all going exactly according to plan. We need > to be prepared for the Whitespace Invasion in 2010. Doesn't look like a fake. Strong back, weak mind, that's the picture that has been drawn by one of his early employers. Maybe we should not take the mind part too seriously :-) > And-what-about-Gordon-McMillan-hm?-ly yours, Wanna picture? Gordon looks like a wise Indidana, a very tall and very pretty guy, dark skin, white hair, soundy deep voice, absolutely lovely to talk to, and I can assure your he is one of the greatest guys and best friends I ever met - ly - chris From urner at alumni.princeton.edu Sun May 28 22:15:26 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 28 May 2000 19:15:26 -0700 Subject: Clifford Algebra References: <8gsehu$btl@gap.cco.caltech.edu> Message-ID: kern at caltech.edu (Robert Kern) wrote: >Or I might simply re-implement the same ideas in pure Python. > >> Kirby That's what I'd like to see. I'm reading http://carol.wins.uva.nl/~leo/clifford/ thinking it'd help learn the concepts to see the code. Kirby From fiona at sitegnome.com Fri May 12 00:45:32 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Fri, 12 May 2000 14:45:32 +1000 Subject: [FAQTS] Python Knowledge Base Update -- May 10th, 2000 References: <20000510142743.8629.qmail@synop.com> <391B5C62.D71F17BE@polyu.edu.hk> Message-ID: <391B8C6C.DDFF96FE@sitegnome.com> > Would you consider setting this up as _another_ mailing list? The number > of messages > on the python lists is very large for me to cope. > > Regards, > ST Hi, We have found in other communities (PHP, MySQL) that posting Knowledge Base Updates back to the list is both beneficial and important. Of course, if people on the Python list feel these posts are inappropriate we will stop. It is important to post these messages to the list so that the sources who have been quoted get a chance to see where and how they have been quoted. This gives them a chance to correct any errors we make, and hopefully encourages people to help build the knowledge base resource. Posting back to the list is beneficial as it gives a concise summary of helpful threads. This is one of the areas of newsgroup and mailing list etiquette that is often forgotten or overlooked. Lastly, hopefully encouraging people on the list to use resources like http://python.faqts.com will in time actually reduce the number of emails and the burden on the community... cheers, Fiona From skip at mojam.com Mon May 22 10:25:00 2000 From: skip at mojam.com (Skip Montanaro) Date: Mon, 22 May 2000 09:25:00 -0500 (CDT) Subject: [Python-Dev] ANNOUNCE: Python CVS tree moved to SourceForge In-Reply-To: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> Message-ID: <14633.17212.650090.540777@beluga.mojam.com> Guido> If you have an existing working tree that points to the Guido> cvs.python.org repository, you may want to retarget it to the Guido> SourceForge tree. This can be done painlessly with Greg Ward's Guido> cvs_chroot script: Guido> http://starship.python.net/~gward/python/ I tried this with (so far) no apparent success. I ran cvs_chroot as cvs_chroot :pserver:anonymous at cvs.python.sourceforge.net:/cvsroot/python It warned me about some directories that didn't match the top level directory. "No problem", I thought. I figured they were for the nondist portions of the tree. When I tried a cvs update after logging in to the SourceForge cvs server I got tons of messages that looked like: cvs update: move away dist/src/Tools/scripts/untabify.py; it is in the way C dist/src/Tools/scripts/untabify.py It doesn't look like untabify.py has been hosed, but the warnings worry me. Anyone else encounter this problem? If so, what's its meaning? -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "We have become ... the stewards of life's continuity on earth. We did not ask for this role... We may not be suited to it, but here we are." - Stephen Jay Gould From jmassung at magpiesystems.com Tue May 2 15:56:24 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Tue, 2 May 2000 13:56:24 -0600 Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> Message-ID: Warren Postma wrote in message ... >> First question: what do I need to be careful of, if anything when using >> Python on Mac? > >I think the bigger issues than using a Mac are how to teach programming to >young kids. Tkinter was hard for me (new to Python - and I use a Mac) to get going, and it won't work from inside the interpreter. And I think graphics are key for kids. Not to stray from promoting Python (which I love), but maybe starting with Hypercard would be better? Easy to code (but many things can be done), and the graphics and sound are already there. I coded and edu. math game for 8-12 year olds in Hypercard 1 summer at Fermilab, and it went over really well with the kids. Maybe you could start them with one and move to another? Jeff From john at nwjohn.jf.intel.com Fri May 12 14:23:41 2000 From: john at nwjohn.jf.intel.com (John Villalovos) Date: 12 May 2000 11:23:41 -0700 Subject: Easy way to print numbers with thousand separators? References: <391C4B81.D90F27E8@fenx.com> Message-ID: <8fhi7d$dvi$1@nwjohn.jf.intel.com> Thanks! I'll try that. John In article <391C4B81.D90F27E8 at fenx.com>, wrote: ><list>> > >John, > >This is because your copy of python was compiled without _locale >support. > >You'll need to recompile to fix this. This is how I do it on my RH6 >system. >in dist/src/Modules, modify Setup by removing the leading # in the line: > >#_locale _localemodule.c # access to ISO C locale support > >I update python to the CVS version every couple of weeks. I've got an >update >script in /usr/src/python that reads: >cvs -z6 -q up -P -d >cd dist/src >make clean >./configure --with-thread --prefix /usr >make >make test >make install > >If you've installed the sources, you should be able to recompile >starting >with 'make clean' and on from above. > >If recompiling isn't a real option, you'll need to adapt some code to >do the formatting. see http://deja.com/getdoc.xp?AN=588167809 for a >start. > >HTH, > >Emile van Sebille >emile at fenx.com From James_Pannozzi at aon.com Wed May 10 08:53:49 2000 From: James_Pannozzi at aon.com (James Pannozzi) Date: Wed, 10 May 2000 08:53:49 -0400 Subject: Python Front End to Dos Progrrams? References: <8eurti$2dt$1@ssauraab-i-1.production.compuserve.com> <3916D0CE.A85E9EDB@stud.upb.de> Message-ID: <8fbm3d$143$1@ssauraaa-i-1.production.compuserve.com> Yes thanks, this sounds like a good idea. I tried out the "expect" from my Cygwin bash but I get a message that it can't find init.tcl and that it thinks my tcl 8.0 was not set up properly. I'll investigate this furthur. Thanks Again Jim "Mirko Liss" wrote in message news:3916D0CE.A85E9EDB at stud.upb.de... > James Pannozzi wrote: > > > Has anyone ever written a Python front-end to DOS based programs in which > > the user clicks on a menu and then the Python program generates the correct > > set of goofy dos app keypresses and sends it to the dos app? Is this > > do-able? > I suppose you need two different things: > > a. The python equivalent of the expect - command which is available > under Unix. > expect parses the standard output of an application and feeds to its > standard input. There are various packages available at > ftp.python.org or > at the Vaults of Parnassus. > Some are plain wrappers around Unix's expect, some emulate expect. > > b. A Python GUI toolkit to create window frames, buttons, etc. > Tcl/Tk and Tkinter are already included into the W95 Python > Distribution. > You might only need some documentation how to use Tkinter. > wxPython suits me fancier, but that's just my own silly opinion. > > friendly regards, > > Mirko > > -- > M Li?, Tel 05251-740120 From bwinton at tor.dhs.org Mon May 1 23:42:34 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Tue, 02 May 2000 03:42:34 GMT Subject: Good style for multi-valued returns References: <889A6EB6AE399393.619B0539BFCAAE0F.5C6D110C3DA908F7@lp.airnews.net> <43E1059BD6C613C1.19161A8DC1C439F1.3E710DAA95C4F8D8@lp.airnews.net> <8dq1k1$6na$1@slb2.atl.mindspring.net> Message-ID: On 21 Apr 2000 17:02:57 GMT, Aahz Maruch wrote: >In article <43E1059BD6C613C1.19161A8DC1C439F1.3E710DAA95C4F8D8 at lp.airnews.net>, >Cameron Laird wrote: >>I think I still have special cases where I want to move dictionaries >>around, but I'm learning that their proper domain is much smaller than >>I used to believe. > >Well, yeah. For passing information around, dictionaries are >appropriate when the key/value linkage is external rather than an >artifact of your program logic -- basically using a dict as an in-memory >database. In addition, I find dictionaries extremely useful for >managing % strings. Wow, I just realized that this could totally make some Java code I've used totally obsolete. In an app I was writing, we used token-inflation to fill in values from web pages, but if we could have stuffed the data into dictionaries (which we did anyways), then having the "%" operation would have made a 20-30 line class into a one character operator. >>> dict = {"a":"aa", "b":"bb", "c":"cc"} >>> string = "%(a)s - %(b)s - %(c)s" >>> string '%(a)s - %(b)s - %(c)s' >>> string % dict 'aa - bb - cc' And that's why Python is so cool. Later, Blake. -- 9:48pm up 10 days, 1:58, 1 user, load average: 0.23, 0.05, 0.02 From conversy at lri.fr Mon May 8 12:19:30 2000 From: conversy at lri.fr (Stephane Conversy) Date: Mon, 08 May 2000 18:19:30 +0200 Subject: Text widget in Tkinter Message-ID: <3916E912.17D0A580@lri.fr> If I want to program a multi-column editor with Tkinter. With the Text widget, can I specify it to be multi-column (I doubt) otherwise,I have to use 2 text widgets, but what is the best way to know if the insertion of a character has made the text flow reach the limit of the first text widget ? Id'like to make the text flow to continue in the second text widget... -- St?phane Conversy http://www-ihm.lri.fr/~conversy/ mailto:conversy at lri.fr From paulb at infercor.no Wed May 10 07:11:04 2000 From: paulb at infercor.no (Paul Boddie) Date: Wed, 10 May 2000 13:11:04 +0200 Subject: MySQLdb + Python + quotes References: <3918809E.1D5F3CFE@rhk.dk> <39191138.EF1C30A9@rhk.dk> Message-ID: <391943C8.589F4FE9@infercor.no> Lars Hoeyrup Jensen wrote: > > I know, I _had_ found that in the news archives, but as Jeff says: it's a > different MySQL-module from what I use (I use MySQLdb, not MySQL). Therefore > it didn't work. Rather than using Python's value substitution in strings as suggested, it should be possible to use "bind variables" in MySQLdb like this: cursor.execute("SELECT * FROM MY_TABLE WHERE MY_COLUMN = %s", (my_column,)) Note the use of the Python/C style "%s", but note also that we aren't using such "placeholders" with Python's % operator - an additional tuple parameter is required. As a result, the database module should process the values in the tuple and hopefully get the database to bind the values to the query (or action) accordingly. This is all just speculation on my part, however, as I have never really done any work with MySQL, but I do remember something about this in the MySQLdb documentation. Other database modules use different syntax for the placeholders; for example, Sybase products prefer "?", and replacing the placeholders in the above example would indeed make it work on Sybase products. I would discourage the use of simple string substitution when building queries. After all, the database modules are there to make the handling of all kinds of values, and the issues surrounding them (such as quote escaping) transparent. If your database module doesn't support this kind of functionality then I would recommend either improving it so that it does, or finding another which does; I wouldn't consider modules which are deficient in this respect as being suitable for serious work. Paul From abrahams at mediaone.net Sat May 6 12:46:30 2000 From: abrahams at mediaone.net (Dave Abrahams) Date: Sat, 06 May 2000 16:46:30 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> <3912b3bc$0$73579@news.voyager.net><3913075C.66826A07@san.rr.com> Message-ID: in article 3913075C.66826A07 at san.rr.com, Courageous at jkraska1 at san.rr.com wrote on 5/5/00 1:36 PM: > But that said, C++ templates are Satan. No, they're a very useful tool... shall we say, Satan's little helper? my-wife-left-cuz-i-spent-my-nights-on-template-metaprogramming-ly y'rs, dave From tim_one at email.msn.com Sat May 13 13:53:58 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 13:53:58 -0400 Subject: NaN again - and IEEE arithmatics In-Reply-To: Message-ID: <000701bfbd04$36bc6b60$212d153f@tim> [Tim, suggests this way to make a NaN] > >>>> Inf = 1e300**2 > >>>> NaN = Inf - Inf > >>>> NaN > >-1.#IND > >>>> Inf > >1.#INF > >>>> [Mark C Favas] > Unfortunately, on a real <0.3 wink> operating system (Tru64 Unix on Compaq > Alpha) this code fragment produces a core dump: > > Python 1.6a2 (#99, May 12 2000, 08:21:33) [C] on osf1V4 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) > >>> Inf = 1e300**2 > Floating exception (core dumped) Are you using a DEC (ya, ya, Compaq) compiler to build Python? If so, try using its -ieee switch. by-default-overflow-is-supposed-to-be-silent-ly y'rs - tim From mdefreitas at sikorsky.com Wed May 3 22:49:25 2000 From: mdefreitas at sikorsky.com (mdefreitas at sikorsky.com) Date: Thu, 04 May 2000 02:49:25 GMT Subject: THE answer? References: <8ea0ao$fro$1@nnrp1.deja.com> <8ea9uu$rh0$1@nnrp1.deja.com> <8ecad6$bun$1@ites.inria.fr> <8ecref$lck$1@nnrp1.deja.com> <8ehnvs$m0h$1@ites.inria.fr> <8eieq8$ees$1@nnrp1.deja.com> <8el1mf$gu4$1@ites.inria.fr> <8epre0$ilj$1@nnrp1.deja.com> Message-ID: <8eqofg$jno$1@nnrp1.deja.com> > I think we need to send PyRun_File a COPY of the global > dictionary, no? If so, how do we create a copy of a dictionary. > I couldn't find anything like that in C/API document.. OK, forget that... I think I have the real answer here... rather than copy the global dictionary, I'll just create one with the necessary elements for each recursive call. This is the final answer which seems to work: void interp(char *file) { static int nest_level = 0; FILE *fd = fopen(file, "r"); if (nest_level == 0) Py_Initialize(); nest_level++; PyObject *dict = PyDict_New(); PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins()); PyRun_String("import ui\n"); // get my extension PyRun_File(fd, file, Py_input_file, dict, dict); if (Py_FlushLine()) PyErr_Clear(); // flush output nest_level--; if (nest_level == 0) Py_Finalize(); } This works, and each recursive call to the interpreter has a fresh set of global vars. You will note the lack of error checking and memory cleanup. Here is my more complicated version... Is my error checking OK? int interp(char *script) { static int nest_level = 0; static bool failed = false; static boo py_init = false; nest_level++; FILE *fd; if (!(fd = fopen(script, "r"))) { failed = true; cerr << "interp: Cannot open script " << script << endl; if (py_init) PyErr_BadArgument(); } else { if (nest_level == 1) { Py_Initialize(); py_init = true; } PyObject *dict = PyDict_New(); if (!dict) { failed = true; PyErr_Print(); } else { PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins()); PyObject *stat1 = PyRun_String("import spear\n", Py_file_input, dict, dict); // import my extensions if (!stat1) { failed = true; PyErr_Print(); } else { Py_DECREF(stat1); PyObject *stat2 = PyRun_File(fd, script, Py_file_input, dict, dict); if (!stat2) { failed = true; PyErr_Print(); } else { Py_DECREF(stat2); if (Py_FlushLine()) PyErr_Clear(); // flush output } } Py_DECREF(dict); } } nest_level--; int ret_val = (failed ? -1 : 0); if (nest_level == 0) { if (py_init) { py_init = false; if (failed) PyErr_Clear(); Py_Finalize(); } failed = false; } return(ret_val); } I hope my memory cleanup is OK. I'll worry about passing args as locals later. Thanks for everyone's help... especially Cedric Adjih and Warren Postma (via email). Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Tue May 30 21:00:27 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 30 May 2000 21:00:27 -0400 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com In-Reply-To: <39340B3B.5769B898@yale.edu> Message-ID: <001101bfca9b$9c4b85c0$c72d153f@tim> [Paul Magwene] > Oddly enough, I found the most exciting part of this > announcement (other than the news that Guido et al. will be > devoting their full efforts to Python) to be the fact that I > can now put a face to the name "Tim Peters" (see > http://www.pythonlabs.com/team.html ). > > That photo isn't a fake, is it? It excited me too, and it's certainly no fake. I had never seen myself before, at least not in the way people see me. It's hard to believe that an entity could fall in love at first sight with its own image! I have learned a lot about people from this experience, and I'm sure Python will become more narcissistic as a happy result. However, from analyzing several pvt e-mails, I think people misunderstood the photograph rather badly: that thing with the giant head and the cone on top is just the transceiver linking me to the timbot mainframe. My SIMIAN (Semi-Intelligent Mankind Interaction Activity Node -- the closest thing to "me" in the photo) is actually the adorable little unit in the lower right corner, misidentified by several as a monkey head. A monkey?! Let's get serious, folks -- Python is Big Business now, and playtime is over. next-thing-you-know-they'll-mistake-barry-for-his-guitar-ly y'rs - tim From rumjuggler at cryptarchy.org Wed May 31 23:04:19 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Thu, 01 Jun 2000 03:04:19 GMT Subject: Is it just Syntactic Sugar ? References: <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> <20000530213957.E469@xs4all.nl> <20000531090045.I469@xs4all.nl> <3935B383.469032AE@python.org> Message-ID: On Thu, 01 Jun 2000 02:48:55 GMT, cjc26 at nospam.cornell.edu (Cliff Crawford) wrote: >* Eric Hagemann menulis: >| At the risk of pushing on what seems to be a good idea let's not forget >| the 'other "and becomes" operators as well (*=,/=,>>=,<<=...... etc) > >These don't really make sense for non-numeric classes. For example, >what would *= used on lists do? You could say that l *= n is equivalent >to l = l * n, but is that really useful? I've never seen or used such a >construct before. They don't have to be defined for non-numeric classes, the way * is defined for lists currently but / isn't. -- Barnabas T. Rumjuggler I foresee that man will each day resign himself to new abominations, and that soon only bandits and soldiers will be left. -- Jorge Luis Borges, "The Garden of the Forking Paths" From gfor_ewu at ispchannel.com Sat May 20 23:15:15 2000 From: gfor_ewu at ispchannel.com (Greg Fortune) Date: Sun, 21 May 2000 03:15:15 GMT Subject: 1.6 Debugger Message-ID: <7xIV4.46$rw2.2245@news1.onlynews.com> I can't figure out how to invoke the 1.6 debugger with my file loaded. It worked great in 1.52, but the debugger menu selection has moved into a menu in the interpreter instead of the a menu in the editor. Thanks for any help, Greg Fortune From g2 at seebelow.org Fri May 26 18:04:32 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 26 May 2000 23:04:32 +0100 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <392411ED.8645F174@tammura.at> <392637EA.6028@seebelow.org> <392B0FEC.E74E4ADF@tammura.at> Message-ID: <392EF4F0.273E@seebelow.org> Tamer Fahmy wrote: > > Grant Griffin wrote: > > But there is a very real cost here. You have to decompress the whole > > thing to extract a single component. The compression saving gained by > > the tar approach is negligible in the scale of the capabilities of > > modern computers. > Hmm not really. One can say: > tar xvzf archive.tar.gz directoryInTar/fileInTar.dat > Here we go. Just one file I got. No need to decompress it in an extra > cycle. > > > also,-don't-be-rude-to-any-of-those-other-people-in-the-song--or > > even-us-windows-users--ly y'rs, > Granted! Your are so right with that! ;) But sometimes its very hard not > to be rude to a windows user! hehehe > > Never-be-rude-to-anybody-ly y'rs, > Tamer. Well, those are two very good reasons a very few of us Windows users feel compelled to fight FUD with FUD. ;-) i've-noticed-that-the-justice-department-hasn't-claimed-that -microsoft-has-a-monopoly-on-fud--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From ivanlan at home.com Mon May 22 18:41:29 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Mon, 22 May 2000 16:41:29 -0600 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> Message-ID: <3929B799.9A18F89E@home.com> Hi All-- Ben Cornett wrote: > > this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". > I bet you wrote a Python program to do this, didn't you? Post the code! -lY y'RS, iVaN ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From lminuti at eid.it Tue May 16 13:20:49 2000 From: lminuti at eid.it (Luca) Date: Tue, 16 May 2000 19:20:49 +0200 Subject: DCOracle installation Message-ID: <8F36C3D3Elminutieidit@192.6.1.10> I'm trying to install DCOracle-1.3.0 but I get this error: make[1]: *** No rule to make target `/usr/lib/python1.5/config/Makefile', needed by `sedscript'. Stop. I think it means that the makefile don't find this file. I read the rest of the makefile and I see that it needs other file of this directory, but I haven't the directory `/usr/lib/python1.5/config'! Could some one send to me its contents? bye, luca From ivanlan at callware.com Mon May 1 11:38:14 2000 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 01 May 2000 09:38:14 -0600 Subject: plain text python source -> HTML syntax highlighted source References: <65118AEEFF5AD3118E8300508B1248774CB2BF@ALTNET> Message-ID: <390DA4E6.29227E5A@callware.com> Hi All-- Mike Steed wrote: > [snip] > This is probably not what you were thinking of, but Vim can do this. Open > your file and choose Syntax->Convert to HTML. The output is an HTML-ized > version of your file with whatever syntax highlighting you have defined. > I didn't know you could do this. This is really cool, but be warned that it does not expand tabs into spaces, so the html version may *still* not look exactly like you want. ... -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From gfor_ewu at ispchannel.com Tue May 16 23:00:02 2000 From: gfor_ewu at ispchannel.com (Greg Fortune) Date: Wed, 17 May 2000 03:00:02 GMT Subject: Network statistics program Message-ID: I'm currently working on a program that will run some network statistics for me over the span of months. I want to send a ping every minute, collect the results, and then store that information in a database. I think I can get everything working, but the issue of the one minute interval is killing me. How do I make my program just sit there and do nothing until the system clock says it has been a minute? Never before have I *tried* to make a program do nothing :). I consider a while loop with a pass statement or a time check, but that seems like it would take up processor cycles for little reason. I also considered letting ping handle the interval and just use ping as the piped input. Although this may be the simplest solution for me at this time, I really want to learn how to implement delay. Any help is greatly appreciated, Greg Fortune From david_ullrich at my-deja.com Sun May 28 14:34:11 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sun, 28 May 2000 18:34:11 GMT Subject: Draft web text re vectors, quadrays, python, spatial geometry, crystallography, peer review solicited References: <39302E4F.64F92691@stud.ntnu.no> Message-ID: <8gror2$11s$1@nnrp1.deja.com> In article <39302E4F.64F92691 at stud.ntnu.no>, peter at schneider-kamp.de wrote: > Kirby Urner wrote: > > > > Hei Kirby! > > I do not know what your preferences for the source code, but > there is more than one way to do the example below (do I sound > like some p&rl-monkey?): Yup. > E.g. using map and reduce: > > from operator import add,mul > def dot(self,v1): > return reduce(add,map(mul,self.norm0(),v1.norm0())) Ah, that sounds better. [...] > > greeting-the-lisp-fellows-ly y'rs Will the lisp fellows be able to follow the *-*-*-ly syntax. ya think? (This is the one part of Python I could never find explained in the otherwise excellent docs.) > Peter > -- > Peter Schneider-Kamp ++47-7388-7331 > Herman Krags veg 51-11 mailto:peter at schneider-kamp.de > N-7050 Trondheim http://schneider-kamp.de > > Sent via Deja.com http://www.deja.com/ Before you buy. From pj at sgi.com Fri May 5 18:17:27 2000 From: pj at sgi.com (Paul Jackson) Date: 5 May 2000 22:17:27 GMT Subject: How to get terminal width? References: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <957559551.177803@cdwork.cvt.stuba.sk> Message-ID: <8evh9n$7k5s9$1@fido.engr.sgi.com> |> atlas13:pts/7:~% echo $COLUMNS |> 84 |> atlas13:pts/7:~% python |> ... |> >>> os.environ['COLUMNS'] |> KeyError: COLUMNS You don't have COLUMNS exported. In Bourne/Korn shell syntax export COLUMNS python In csh syntax setenv COLUMNS $COLUMNS python -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From tismer at tismer.com Sun May 28 11:24:09 2000 From: tismer at tismer.com (Christian Tismer) Date: Sun, 28 May 2000 17:24:09 +0200 Subject: DECREFing and PyArray functions in C Extensions References: Message-ID: <39313A19.5EA371A7@tismer.com> Roger Hansen wrote: ... > OK! Lets say I have a Python program with a NumPy array and a loop, > and for efficiency reasons I decide to write the loop as an extension, > like this: > > static PyObject * > foo(PyObject *self, PyObject* args) > { > PyArrayObject *array; > double* a; /* C ptr to the NumPy array data field */ > > if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) { > return NULL; /* Error indicator */ > } ... > I don't need to DECREF array in this > example since PyArg_ParseTuple does not increase the reference count, > right? Right. PyArg_ParseTuple just parsed the tuple and does not create extra references. The creator of the args tuple is responsible to decref it later on, and when it is disposed by that, the extra references to its elements are removed automatically. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From fiona at sitegnome.com Tue May 30 08:02:40 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 30 May 2000 12:02:40 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 30th, 2000 Message-ID: <20000530120240.617.qmail@synop.com> Hi Guys, Below are the entries I've entered into http://python.faqts.com tonight. cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How can I convert an integer to a string containing the bytes for that value? http://www.faqts.com/knowledge-base/view.phtml/aid/3321 ------------------------------------------------------------- Fiona Czuczman David Goodger What you want is the "struct" module: >>> import struct >>> struct.pack("h",300) '\001,' >>> a = 300 >>> b = struct.pack("h", a) >>> for c in b: ... print ord(c) ... 1 44 See the Library Reference for details. Please note that the conversion string limits the size of the integer (here, "h" is a short integer, two bytes on my platform). If your value is greater than the converter allows for, you'll get only the least significant bytes: >>> struct.pack("h", 1000000) 'B@' >>> struct.unpack("h", "B@") (16960,) >>> struct.pack("i", 1000000) '\000\017B@' >>> struct.unpack("i", "\000\017B@") (1000000,) "i" is for a regular integer, four bytes on my platform. ------------------------------------------------------------- How can I present output from md5.digest like md5sum from GNU textutils? http://www.faqts.com/knowledge-base/view.phtml/aid/3344 ------------------------------------------------------------- Fiona Czuczman Moshe Zadka try: for c in digest: sys.stdout.write("%02X" % ord(c)) ------------------------------------------------------------- Can I create a rpm with only pyc files or do I need the py file also to make package distrubution? http://www.faqts.com/knowledge-base/view.phtml/aid/3345 ------------------------------------------------------------- Fiona Czuczman Martin von Loewis No, just the bytecode will do. ------------------------------------------------------------- Can I take pyc file to different computer and will it run? http://www.faqts.com/knowledge-base/view.phtml/aid/3346 ------------------------------------------------------------- Fiona Czuczman Martin von Loewis Sure. The Python byte code format is the same on all machines. ------------------------------------------------------------- I update a class with 'reload (module)'. How can I update the instances too? http://www.faqts.com/knowledge-base/view.phtml/aid/3347 ------------------------------------------------------------- Fiona Czuczman Martin von Loewis You'd have to find the instance one-by-one. If you manage to get hold of them, you can set their __class__ attribute to the new class: >>> class A: ... def doit(self):print "old" ... >>> a=A() >>> class A: ... def doit(self):print "new" ... >>> a.doit() old >>> a.__class__=A >>> a.doit() new ------------------------------------------------------------- Is the match() function any different really then having search() with a ^ at the begenning of the string? http://www.faqts.com/knowledge-base/view.phtml/aid/3348 ------------------------------------------------------------- Fiona Czuczman Tim Peters Yes, although the difference doesn't become clear until you exploit the optional slicing arguments of compiled regexps: >>> import re >>> p = re.compile("^a") >>> p.search("cba", 2) >>> p = re.compile("a") >>> p.match("cba", 2) >>> That is, while there is an "a" at index 2 of "cba", and "match" finds it, a caret does *not* match starting at index 2 (caret means start-of-string, and may or may not mean more than that depending on "multiline" mode -- using "match" instead cuts all that magical crap out of the equation). ------------------------------------------------------------- Where can I find a Python script to download an entire web site? http://www.faqts.com/knowledge-base/view.phtml/aid/3349 ------------------------------------------------------------- Fiona Czuczman Andrew Dalke, Simon Try websucker, which is distributed with Python under Tools as part of webchecker. It isn't in Parnassus because it's part of Python itself. websucker.py, while an awesome utility, doesn't actually suck the entire site. For instance, it will pull the image files on a page if those images are statically SRC-ed. If there is an onmouseover directive, for instance, which changes the image source to another file, it will not grab the other file, even if it lies in the same directory as the first image. ------------------------------------------------------------- Is there a standard way to read-write the e-mail with python? http://www.faqts.com/knowledge-base/view.phtml/aid/3343 ------------------------------------------------------------- Fiona Czuczman Oleg Broytmann Write with smtplib.py. Read with mimetools.py Download and read docs for extract_mime - it is a template for reading e-mails from MTA (Mail Transfer Agent). Master site: http://sun.med.ru/~phd/Software/Python/#extract_mime Faster mirrors: http://skyscraper.fortunecity.com/unix/797/Software/Python/#extract_mime http://members.xoom.com/_XMCM/phd2.1/Software/Python/index.html#extract_ mime ## Edited Entries ############################################## ------------------------------------------------------------- How can I embed/port Python to Vxworks? http://www.faqts.com/knowledge-base/view.phtml/aid/3301 ------------------------------------------------------------- Fiona Czuczman Richard Wolff What follows are some of the details. This same information and the rest of the story can be found at http://daikon.tuc.noao.edu/python As usual, no warranty for fitness nor merchantability nor freedom from un-wanted side-effects of creeping featurism. --------------------------------------------------------------------- Here's how I set up Python as an embedded task in VxWorks. Note that building the system for VxWorks is not going to be as nicely set up as doing so for most systems. We can't run configure for one thing. So there are a number of changes that you have to consider/make by hand. Before getting to the details, a thank you to Paul Fernhout for some helpful advice in a recent comp.lang.python posting. Perhaps the best way to get started is to build Python on your workstation and use that as the start of the port. This way, many of the files you need will be present. For instance, the parser generator program will be built and run, so it isn't needed for the cross-compile. You'll also have config.h file that might well serve as a useful starting point. The files from the distribution that you need to modify are in Include, Modules, Objects, Parser, and Python. At the top level, you'll need to change Makefile and config.h. The diff file (pydiff) will make a lot of changes for you, but you should probably take a look at what's going on first. There may well be better ways of doing things. By the way, the diff is against Python 1.5.2 and is for VxWorks 5.2 (pre-Tornado). You'll need (or want) to do the following: 1) Edit the top level Makefile to reflect the correct definitions for CC, RANLIB, LD, and AR. Make the same edits in the Makefiles in Objects, Parser, and Python directories. Make the same edits in Makefile.pre in Modules. 2) Edit config.h 3) Get a version of getopt.c and put it in the top level directory, along with a suitable getopt.h, which can go in the Include directory. Or put getopt.c somewhere else and modify Makefiles suitably. 4) Edit Setup (and Setup.local, Setup.thread). 5) If you include modules that I didn't, you'll probably want to edit that module's ".c" file. If you have a different version of VxWorks, look for the VXWORKS define and modify as needed. 6) Modify Modules/python.c as you will. You probably will want to modify the arg0 value. 7) Remove the buildno file if you want. 8) In Modules, run makesetup to build the Makefile and config.c. If you have used both Setup and Setup.local, run makesetup Setup Setup.local 9) At the top level, run make. The output will be "python.o" in this directory. 10) Load that into your VxWorks system. On my system, Python took too much stack space to run under the shell, so I spawn the task, which is what "sppy" ("spawn python") does. If Python comes alive, but you get lots of xxx:yyy: No such file or directory and xxx:yyy: File exists, don't worry. Those messages are from 'stat' as it probes the file system on xxx looking for library files. I don't know how to stop this; it's both annoying and harmless. 10a) You should 'cd "python-top-level-directory"' before you load the python.o file, or you should be sure that you have the Lib directory in a standard place (or you have modified the Makefiles to reflect suitable prefix and exec-prefix directories). Or you might set the PYTHONHOME environment variable in Modules/python.c before Python goes through its initialization steps. 11) When the >>> prompt appears, it's likely that a carriage return will bring back the shell prompt. That's because the shell runs at much higher priority than Python and it grabs all the characters. It needs to be demoted, which is what the "demoteShell" code in Modules/python.c does (with a vengeance...there's probably no need to suspend the shell). So run that routine from the shell, and then run Python as you will. 12) To exit, the usual command sequence (or sys.exit) will get you back to the shell prompt, at which time, you should raise the shell priority back to 1 (use "restoreShell"). 13) You can make things more interesting by having Python code that will allow you to run VxWorks routines. You need a slight extension of Python, to be found in my "Modules/vxmodule.c". Modify Setup (or Setup.local, rerun makesetup, and then the top level make). 14) A simple VxWorks class makes use of the vxmodule code. See VxWorks.py Thus, i = VxWorks.Vxw("i","") builds an 'i' such that 'i()' gives the same task information table from the Python prompt as it does from the VxWorks shell. Or, routeAdd = VxWorks.Vxw("routeAdd", "ss") builds a routeAdd function that can be used to add a route to the VxWorks routing table (routeAdd("90.0.0.0, "gateway")), and so forth. 15) If you have the VxWorks module in place, you can then define rs = VxWorks.Vxw("restoreShell","") and when you run rs(), you have, for interactive use, effectively suspended Python, as the shell will get all the input characters. "demoteShell" and 'rs' thus allows you to switch back and forth between Python and the VxWorks shell. Richard Wolff May, 2000 P.S. I did this work because I want to run various routines in the VxWorks environment under the control of a "scripting" language. There are three approaches here...embed Python in VxWorks, which is what this note is about, connect Python running on a workstation to the VxWorks shell via telnet, or connect Python on the workstation to a process on the VxWorks box via a socket connection. Which way to go is nice question. The other question one ought to answer is, "why aren't you using rt-linux?". P.P.S. All this code is released under the same terms and conditions as the Python license. From emile at fenx.com Mon May 22 06:29:22 2000 From: emile at fenx.com (emile at fenx.com) Date: Mon, 22 May 2000 03:29:22 -0700 Subject: Random numbers Message-ID: <39290C02.7BD9FE08@fenx.com> Oops, forgot to include this: >>> print random.seed.__doc__ Seed the default generator from any hashable value. None or no argument returns (0, 0, 0) to seed from current time. Emile van Sebille emile at fenx.com Russell Wallace wrote in message news:<3929068F.622C at esatclear.ie>... > Oops sorry, pressed the wrong button. Trying again: > > Is there any difference between the random number generator in the' > random' module and that in the 'whrandom' one? > > What's the quality of the numbers generated? I don't need the absolute > best, but hopefully it's at least better than a linear congruential > generator? > > Is there a way to get a reproducible sequence of random numbers? > seed(0,0,0) doesn't seem to have any effect. > > Thanks, > > -- > "To summarize the summary of the summary: people are a problem." > Russell Wallace > mailto:rwallace at esatclear.ie > http://www.esatclear.ie/~rwallace > -- > http://www.python.org/mailman/listinfo/python-list > From paulb at infercor.no Wed May 3 10:37:48 2000 From: paulb at infercor.no (Paul Boddie) Date: Wed, 03 May 2000 16:37:48 +0200 Subject: database connection References: <8eov85$5ek$1@news.su.se> Message-ID: <391039BC.4C6EC6FC@infercor.no> Miguel wrote: > > I want to connect to a database using odbc. I have been searching the entire > www (almost) for the difference between odbc and ODBC. Now I turn to you, > could anyone explain the difference to me?? Is it possible to run ODBC on > any plattform?? Would it be better if I used a specific module for my > particular db?? I think that 'odbc' may be being used to refer to the Windows-only ODBC extension module, whereas 'ODBC' may be being used to refer to either the ODBC standard or perhaps the 'ODBC' package which one gets when unpacking mxODBC. mxODBC and the 'ODBC' package within it can be run on a number of platforms, and I have had quite a bit of success with it. Certainly, it is closer to DB-API conformance than many of the database modules I have seen. Take a look at this page which I made when I started to experiment with mxODBC: http://thor.prohosting.com/~pboddie/Python/mxODBC.html Have fun! (I'm sure you will...) Paul From hgg9140 at seanet.com Fri May 26 18:09:34 2000 From: hgg9140 at seanet.com (Harry George) Date: 26 May 2000 15:09:34 -0700 Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <8F3F72DB7davemrquizorg@212.27.32.76> <392E4163.668C3BC9@darmstadt.gmd.de> Message-ID: I've often ported Modula-3 NT<-->UNIX by just recompiling. The key seems to be abstraction of the os and file system interfaces. E.g., if you use hardcoded "/" vs "\", you are in trouble. If you go to the trouble of using abstracted path joins, it is a piece of cake. Python allows (but does not require) use of those abstractions. In contrast, I've lost portability in Java apps when one version of a needed library was not available on a given platform (e.g., swing). And you can of course still screw up by hardcoding those "/" and "\" paths. Robb Shecter writes: > > >Marketability? Hm. The thing that makes Java marketable is > > >the tremendous amount of money that Sun has poured into > > >getting it into every trade rag that they could possibly > > >find. ... is there any way we can effectively market Python as a > > >competitor to a language / platform with that kind of > > >agressive force behind it?... > > I don't this does justice to the Java idea. Java has the design goal > of hiding -all- system dependencies. And, features that are dependent > on certain operating systems are clearly seperate from the standard > Java packages. > > Python seems to go about half-way in this direction. Some libraries > seem to hide OS differences via an adapter sort of design, but there > are many standard libraries that are purely only for certain types of > systems. Not that this is bad, it's just different. > > I use Python for 90% of my new projects. (I work only on Linux.) > But, if I know that the software has to run on, say Linux and NT, then > I'll use Java. I've seen, first hand, successful cases of "porting" a > Java program that was written on Linux to NT by just copying the class > files. > > - Robb > -- Harry George hgg9140 at seanet.com From embed at geocities.com Thu May 4 09:36:02 2000 From: embed at geocities.com (Warren Postma) Date: Thu, 4 May 2000 09:36:02 -0400 Subject: python's acceptance References: Message-ID: I agree with all of Scotts ideas. I'd like Python to become just as flexible and efficient a producer of Windows executables as Delphi is currently for me. I think I'll always want and need Delphi around too. Different tools, different jobs. Delphi is a non-starter as a system scripting tool, whereas Python will always be great at that. I think Delphi will always be superior as a means of distributing binary single executables (requiring no runtime, vbrun.dll, .pyd files, or what have you). However Python is coming along surprisingly well, for such a new Thing. As for Python being a win for the customer, I think with PC performance at current levels, and users requiring the ability to tailor their software, Python is a great win for customers. I think the Windows philosophy of "everything is supposed to be a 50 megabyte monolithic executable" is being slowly pounded to death by the Internet and that Python and other tools with a kind of Unix "do one thing well" heritage are going to continue to gather steam on Windows. (Perl is another example.) Python acceptance is up to programmers. customers pretty much take the best product they can get. If python gains acceptance with Programmers, and Programmers build a better mousetrap, the customers will be there. Compare 2 contracts a company must choose between, Company A is writing in Python and Company B is producing for you an Executable using VB enterprise: 1. cost to customer to keep a copy of Python around for future maintenance by in house IT staff: $0 cost to customer to keep a copy of VB Enterprise around. ~$5K 2. Likelihood of aPython program being provided with Source is higher than the likelihood of a VB program being provided with source. 3. Portability of Python: Somewhat portable. VB is a non-starter on anything but Windows. Warren From thomas at xs4all.net Thu May 11 10:08:38 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 11 May 2000 16:08:38 +0200 Subject: Why should I switch to Python? In-Reply-To: ; from usenet@inter-slice.com on Thu, May 11, 2000 at 12:09:07AM -0500 References: <3919D30A.74DE@seebelow.org> <391A1253.BF50F9D0@yahoo.com> Message-ID: <20000511160838.E13281@xs4all.nl> On Thu, May 11, 2000 at 12:09:07AM -0500, James Felix Black wrote: > > Two big ones come to mind: using complex data structures, and > > modularizing your code. Both are much easier in python. > I won't dispute your second point, but I don't understand your first. I do. I'm trying to grok a colleagues' OO-perl code, and it has me dazzled. Not in how it works or what it does, but *why*. It seems to be a strange mix of normal classes and metaclasses, using hashes and identifier strings and indexes into arrays -- I have a nagging suspision this 1000+ lines Perl blob could be done in less than 200 lines Python, using regular classes. I wont know for sure until said colleague returns from his week off to France, partly because he took the Perl OO book with him, and I haven't read it yet, and partly because I'm not sure the code isn't intended to do more than implement generic classes with a bit of metaclass flavour. Perhaps I'll understand it better once I learn exactly how to work with OO perl -- writing it, I mean, instead of using it. And this is exactly the problem I have with Perl, compared to Python. In Python, if you can write a script, you can write a module. Move your functions & classes to a different file, or wrap your executing code in a 'if __name__ == '__main__':' block, and you have a module. In Perl, if you want anything more complicated than a package with subroutines (say, classes), you are entering a world of hurt. (Or at least I was ;) > > In perl, doing this is so painful to me that I'm not even going to > > try it now, and it only gets worse as your data structures get more > > complicated. > > I'm not sure exactly what you mean: > > %friends = { Bob => [ ], Jane => [ "Lisa", "Mabel", "Freddy" ], > Lisa => [ "Mabel" ] }; > > for $name (keys %friends) { > print "$name has these friends:\n"; > for $f (@{ $friends{ $name } }) { > print " ", $f; > } > print "\n"; > } Actually, the initialization of your hash is wrong! Using perl -w you'll see this error: Reference found where even-sized list expected at - line 1. Now guess what's wrong :-) (hint: literal dictionaries dont exist in perl, as such; you have to use lists. This is why 'reverse %hash' works as a key<->value swap ;-) I didn't notice this when reading the code, though, and I have to admit I was kind of surprised to learn HASH(0x80e54e0) didn't have any friends ;) As for the second part, for more Perl adventure, you can do it like this: for my $name (keys %friends) { print "$name has these friends:\n"; print join(' ', @{ $friends{ $name } }) . "\n"; } or even this: map { print "$_ has these friends:\n" . join(' ', @{ $friends{ $_ } }) . "\n" } keys %friends; Not that I used perl map much until I learned Python, though. > What I (as a perl programmer/python novice) really miss in python are > true closures. Is this a language feature yet? One marvelous thing > that python has, though, is reduce, which I find so massively useful > that I carry it around with me in perl land wherever I go. Well, you can more-or-less fake closures (enough to be functional, in any case) using lambda: >>> import string >>> l = ["spam", "ham", "eggs"] >>> characters = [", spam, ", " ", ", ham, ", ", eggs, "] >>> map(lambda x, l=l, s=string: s.join(l, x), characters) ['spam, spam, ham, spam, eggs', 'spam ham eggs', 'spam, ham, ham, ham, eggs', 'spam, eggs, ham, eggs, eggs'] -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From phd at phd.russ.ru Thu May 25 10:26:00 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 May 2000 14:26:00 +0000 (GMT) Subject: Timing out URLs In-Reply-To: <8gjchb$pqv$1@slb7.atl.mindspring.net> Message-ID: On 25 May 2000, Aahz Maruch wrote: > I wrote a patch for httplib that provided a default timeout, but Guido > raised some questions about the correctness of it that I haven't had > time to resolve. If anyone needs it, send me an e-mail; if I get more > than a couple of requests, I'll post it. Count my vote: I want to see it published and searchable on deja.com. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From wlfraed at ix.netcom.com Thu May 18 11:49:49 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 18 May 2000 08:49:49 -0700 Subject: Bit length of int or long? References: <392317CF.D6F878F5@python.org> Message-ID: On 18 May 2000 09:16:42 +0100, Michael Hudson declaimed the following in comp.lang.python: > ... > >>> bitlen(2**10000L) > inf > Ah, okay -- I did expect it to fail at some point with L's... though below that point, it reads fairly clean. Perhaps some preprocessing level to detect L's over the limit, and subset them some how (divide by the limit, for which you know the bit-length, and test the remains? just pondering...) -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From mck at iag.net Wed May 24 02:12:18 2000 From: mck at iag.net (Matt) Date: Wed, 24 May 2000 02:12:18 -0400 Subject: Python / Visual Basic mathematical comparison Message-ID: <47smis4m1e93nlq5smoskg8h5l46par5r5@4ax.com> I am new enough to Python that I do not yet have a full grasp of the language and it's elements. I would like to know if there is an existing comparision between the Python and Visual Basic languages, or if anyone can offer up opinions based on experience. Specifically, I am interested in where either language is more comprehensive in built-in elements used for prototyping or developing financial or mathematical programs. I am not concerned with GUI building capabilities, but the base ability to crunch numbers, by providing a wider range of functions and data types (without having to implement them by hand in the language). I would consider both languages to be somewhat "general purpose", not specifically geared to particular application types, such as FORTRAN or COBOL. But sometimes, if a tool is too general it can be lacking. From robin at jessikat.demon.co.uk Tue May 30 12:34:12 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 30 May 2000 17:34:12 +0100 Subject: new eGroups coroutine release References: Message-ID: In article , Martin Baker writes >Here at eGroups we use coroutines to build fast, scalable network servers. >Think Medusa, but easier. We get the performance of multi-threading >without thread overhead. > >We have released our implementation of coroutines in Python under a >Pythonish license. This can be installed as a dynamically loadable module >under an otherwise unmodified Python distribution. > >It doesn't work well under 1.5.1, it does under 1.5.2, and we don't know >yet about 1.6. Right now only Linux and FreeBSD are supported. The >assembler coro package we use only supports Linux out of the box, although >FreeBSD 3 might work without changes. > >You can find more details (including an explanation of coroutines and >links to the assembler coroutine package) in the README at >http://www.egroups.com/files/python-coro/egroups/README-2000-04-24.txt > >The software itself is available at >http://www.egroups.com/files/python-coro/egroups/egp-coro-20000424.tar.gz > >Enjoy! >Martin > > > Can't coroutines be implemented using C Tismer's stackless python implementation and continuations? -- Robin Becker From MSteed at altiris.com Mon May 1 11:12:00 2000 From: MSteed at altiris.com (Mike Steed) Date: Mon, 1 May 2000 09:12:00 -0600 Subject: plain text python source -> HTML syntax highlighted source Message-ID: <65118AEEFF5AD3118E8300508B1248774CB2BF@ALTNET> > From: Chuck Esterbrook [mailto:echuck at mindspring.com] > Sent: Monday, May 01, 2000 7:30 AM > To: python-list at python.org > Subject: plain text python source -> HTML syntax highlighted source > > I know there's a program out there that reads python source > and spits out an HTML version with syntax highlighting. > However, I don't remember where I saw it and my searching and > skimming on Parnassus missed it. > > Does anyone know where I can get this? This is probably not what you were thinking of, but Vim can do this. Open your file and choose Syntax->Convert to HTML. The output is an HTML-ized version of your file with whatever syntax highlighting you have defined. > -Chuck -- M. From scorder at incigna.com Thu May 18 16:54:00 2000 From: scorder at incigna.com (scorder at incigna.com) Date: Thu, 18 May 2000 16:54:00 -0400 Subject: TypeError: attribute-less object (assign or del) References: Message-ID: On Wed, 17 May 2000 09:49:21 -0400, scorder at incigna.com wrote: >Here is the line of VBScript that works: >site.frames("main").forms(1).item("txtpassword").value = 'foo' > >And here is the line of Python that doesn't work. >Site.Frames("main").Forms(1).Item("txtpassword").Value = 'foo' > >Maybe its the nested level of collections throwing things off? I >don't have any problems modifying any of the properties of objects >higher up the heiarchy. I'm definately at a loss here. Ok this code works. TheForm = Site.Frames("main").Forms(1) TheForm("txtpassword").Value = 'foo' Why I have to assign to a temporary variable first is beyond me but I'm just happy that it works now. Thanks for the help. -Sam Corder From gmcm at hypernet.com Fri May 19 11:55:59 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 19 May 2000 15:55:59 GMT Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <8g1as4$p9q$2@newshost.accu.uu.nl> <39245386.B350E309@sage.att.com> <3926363A.B1F@seebelow.org> Message-ID: <3925640f$0$28525@wodc7nh1.news.uu.net> Grant Griffin wrote: >... I have never seen a >Windows equivalent of "tar" (that is, a packager, less compression), Sure you have. Zip with compression level 0 (also known as a jar file). >...: if you're packaging, you might as well compress; >if you're doing both, they might as well both be in the same program. You might as well ask why the Windows way does it backwards: zipping a tar will almost always yield better compression than tarring a bunch of zips (more redundancy to work with). (Yes, it's easier to extract one file from the latter, but that's not the common usage.) From senn at maya.com Wed May 10 08:55:05 2000 From: senn at maya.com (Jeff Senn) Date: 10 May 2000 08:55:05 -0400 Subject: Stackless/microthreads merge news In-Reply-To: Christopher Medalis's message of "Tue, 9 May 2000 18:31:45 -0400" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39184C59.DD33AA67@tismer.com> <8fa2m4$98v$1@agate.berkeley.edu> Message-ID: Christopher Medalis writes: > #:And Jeff Senn writes: > #: - > #: - Several times I have considered what it would be like to have a > #: - 'simple-unified-VM' that supported continuations (if not full ... > Please don't hurt me for this one, but I know of one plan for the "run > every interpreted language VM" : > Windows Script Host ( aka: "I am the thing that lets vbs viruses cause a > billion dollars worth of damage in a few days") Note I said "simple" and "unified" -- neither of these adjectives applies in the least to describe WSA... :-) Neither is there any tractable notion of unified types or continuations... (Also note that it is MS's insistence that the default setting be "screw-up-the-world-for-the-novice-user" that is really causing the problem -- I wonder if someone will sue them.... ;-) ) -Jas From pdfernhout at kurtz-fernhout.com Tue May 23 11:31:10 2000 From: pdfernhout at kurtz-fernhout.com (Paul Fernhout) Date: Tue, 23 May 2000 11:31:10 -0400 Subject: Pointrel Data Repository System for Python Message-ID: <392AA43E.B3014C3B@kurtz-fernhout.com> This is the very first (rough!) version of the Pointrel Data Repository System. It is available for download here under an MIT/X11 (Python-ish/Software Carpentry-ish) type license from this web page: http://www.kurtz-fernhout.com/pointrel/ One example (versioned file system viewer) requires wxPython, but otherwise the code just uses plain Python. See the web page for more details. The Pointrel Data Repository System is a loosely coupled set of concepts for data representation. It can be thought of as an information storage architecture. The code presented here implements the simplest concepts in this system. William Kent's ROSE/STAR system described in his 1979 book "Data and Reality" is similar to the Pointrel Data Repository System in intent in many ways. The Pointrel Data Repository System includes a triadal data storage system. Using triads, one can build arbitrary complex networks of relationships. These dynamic relationships can define the equivalent of records or objects in a database. A primary concept in the Pointrel Data Repository System is a triad. A triad is an object with three links and an optional string. These links can point to other triads. This allows one to build arbitrarily complex structures, as well as add to these structures at any time. What is distributed here is one possible implementation in Python of this "idea", which I have been playing around with in various languages for about twenty years. I've been going for an elegant compromise between flexibility, speed, and simplicity in storing and retrieving information. The Pointrel system aims at having a small number of unifying concepts that can be arranged in endless ways to build layers of complexity above them. I'm also trying to avoid the bloat where it takes 100MB and endless DLLs just to install a database system, let alone use it for anything. The core Pointrel source is around 20K. That makes it nicer for embedded systems and stand-alone programs. To do (for anyone who wants to help): * Integrate with IDLE for version control / version differencing. * Integrate with Zope for general repository use (bug tracking, source code tracking, file sharing, etc.). * Make into a HTTP server version both using some sort of binary Python query object and using plain text CGI like calls. * Make wxPython interface to file system work under TK. * General graphical interface for manipulating triads and exploring the repository. * Lots of improvements to the versioning structure in the file system (wxPython example shows the content of each version of a python script, not a version name). * Make a CVS look-alike interface. * Use as a caching proxy for web page downloading. * Use to store and retrieve mail and newsgroups. * Use as part of a distributed file/knowledge system. * Create a suite of export / import Python scripts and related viewers. * Make a simple front-end that makes it look like a familiar "relational" database with tables. * Flesh out the transaction support. * Use it for implementing tuple-spaces. * Make optimized C version w/DLL. * Build optimized C version into base Python.exe so *.py libraries, *.pyc, and maybe DLLs can all be in one common file. A FAQ on deletion: you can only add to the Pointrel repository (not delete). Deletion needs to be handled at a meta level, by tagging items as deleted (hidden) and looking for the tag in an appllication using the data, by creating new indexes without referencing deleted items, or by cloning the entire repository and leaving behind data you don't want in the new copy. The system is still in flux, so think of it as more of an experiment in this version and a way to get useability & conceptual feedback. Comments appreciated (including pointers to similar work). -Paul Fernhout Kurtz-Fernhout Software ========================================================= Developers of custom software and educational simulations Creators of the Garden with Insight(TM) garden simulator http://www.kurtz-fernhout.com From dirck.IsGettingTooMuchSpam at pacbell.net Mon May 29 13:50:35 2000 From: dirck.IsGettingTooMuchSpam at pacbell.net (Dirck Blaskey) Date: Mon, 29 May 2000 10:50:35 -0700 Subject: update environment-vars (win32api) References: <8gtl3s$90n$1@nnrp1.deja.com> Message-ID: wrote in message news:8gtl3s$90n$1 at nnrp1.deja.com... > im trying to set some environment vars in the registry. > which actually is working fine with the win32api-module. > > but what bothers me (even so this is no python-problem) is the > fact that if i open a dos-box (winNT4.0sp5) and try to get > the new defined values it seems not to exist. > > only after i open up the system-dialog and there the environment-tab > (where i do see the new vars) and i click on set and ok, then the > vars appear in the dos-box too. > ... The Microsoft site says you have to send an event to tell everybody the environment changed (I haven't tried this): http://support.microsoft.com/support/kb/articles/Q104/0/11.asp Apparently this works for NT but not for Windows95. Good Luck, d ______________________ Dirck Blaskey Danbala Software http://www.danbala.com ______________________ From pinard at iro.umontreal.ca Tue May 16 22:10:58 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 16 May 2000 22:10:58 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: kain@cableadmin.com's message of "Tue, 16 May 2000 21:51:40 GMT" References: Message-ID: kain at cableadmin.com (Scott) writes: > I've come up with one solution to my problem. Its probably quite > inefficient, but it does what I need for now. Feel free to > tear it apart and/or give any advice on how to better implement it. OK, taken! As a kind of rest, I tried to do it as well, as I was teased by the fact your solution limits the denominator to be 2**N * 5**M. > This code will take either a number or a string (ie '0.5') and return > a string of the fraction (ie '1/2'). Here it is: The code below defines `fraction(VALUE, TOLERANCE)', and return a string representing the "simplest" fraction approximating VALUE, a float, with an error not exceeding TOLERANCE, also a float which should not be too close to zero (or else, the task may become impossible to achieve). The value of `pi' was approximated by 3 in old times. We often used 22:7 in school, probably you did that as well. I later learned that 355:113 was a more precise approximation, and an easy one to remember. We can find all these values with `fraction'! See: >>> fraction(3.14159265359, 1) '3:1' >>> fraction(3.14159265359, 0.1) '22:7' >>> fraction(3.14159265359, 0.01) '22:7' >>> fraction(3.14159265359, 0.001) '333:106' >>> fraction(3.14159265359, 0.0001) '333:106' >>> fraction(3.14159265359, 0.00001) '355:113' >>> fraction(3.14159265359, 0.000001) '355:113' >>> fraction(3.14159265359, 0.0000001) '103993:33102' >>> fraction(3.14159265359, 0.00000001) '103993:33102' >>> fraction(3.14159265359, 0.000000001) '103993:33102' >>> fraction(3.14159265359, 0.0000000001) '312689:99532' >>> fraction(3.14159265359, 0.00000000001) '833719:265381' Here is the code, which is rather short, after all. You may even delete `__repr__' to make it shorter, but it makes debugging fun. For example: >>> ContinuedFraction(3.14159265359, 0.00000000001) 3+1/(7+1/(15+1/(1+1/(292+1/(1+1/(1+1/(1+1/(2)))))))) I do not think GCD is necessary, but I did not prove this to myself. Also, the continued fraction may sometimes start with `0+' which can be simplified out, but it was not worth doing in this given application. def fraction(value, tolerance=0): return '%d:%d' % ContinuedFraction(value, tolerance).eval() class ContinuedFraction: def __init__(self, value, tolerance): integer = int(value) residual = value - integer self.integers = [integer] while residual != 0 and abs(value - float(self)) > tolerance: residual = 1.0 / residual integer = int(residual) residual = residual - integer self.integers.insert(0, integer) def __repr__(self): import string text = map(str, self.integers) text.reverse() return string.join(text, '+1/(') + ')' * (len(self.integers) - 1) def __float__(self): num, den = self.eval() return float(num) / float(den) def eval(self): num, den = 1, 0 for integer in self.integers: num, den = integer * num + den, num return num, den -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From andrew at andrewcooke.free-online.co.uk Thu May 11 11:59:45 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Thu, 11 May 2000 15:59:45 GMT Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> <8feioj$fei$1@nyheter.chalmers.se> Message-ID: <8feld6$8h8$1@nnrp1.deja.com> In article <8feioj$fei$1 at nyheter.chalmers.se>, d98aron at dtek.chalmers.se (Fredrik Aronsson) wrote: > Well, using Haskells syntax, I would suggest > map((\a,b,c -> a+b+c), p,q,r) what's that funny backslash for? > Python-with-haskell-syntax-would-be-a-dream-ly yours, hmmm.. i see strange characters in my dreams too ;-) andrew Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Tue May 2 22:15:54 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 02:15:54 GMT Subject: Backward chaining for __init__? Message-ID: <390F8C7E.9986DAE0@san.rr.com> I recently wrote a test program with a Parent class and a Derived class, each one implementing __init__. To my surprise and chagrine, only the Child's __init__ method was called. Worse, I can't figure out a way to call the method (or methods, in the case of multiple inheritance) in the Parent. How does one go about implementing backward chaining for constructor's in Python? C/ From tim_one at email.msn.com Fri May 5 03:12:58 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 5 May 2000 03:12:58 -0400 Subject: Freeze/Source Code Question? In-Reply-To: <3912558F.89778406@world.std.com> Message-ID: <000501bfb661$57a86580$d02d153f@tim> [David Lees] > I am taking an initial look at Python (total novice) and am puzzled > about the existence of Freeze. If you do not wish to show your source > code to the world, I gather the byte code in the form of *.pyc files can > be executed. Disguising source is not the purpose of freeze tools. > If the Freeze stuff, just embeds the byte code into a C program > (interpreter?) what is the difference from the viewpoint of > hiding the code? None. > I assume the C might be easier to run, because everything is in one > executable, Bingo. It's a convenience for the end user. > but is the byte code still not easily viewed with an octal or hex > dump, just as in the .pyc files? The standard library module "dis" supplies a symbolic disassembler for Python bytecode -- no need for binary dumps. > Are there really good decompilers that translate byte code into source > for Python, so that nothing is really hidden? "dis" is a start, and others have built fancier disassemblers on top of it. I don't know what "really good" means to you. Certainly good enough to extract whatever it is you hope to hide, but see below. > If so, is it really much different that Java or Visual Basic, where > presumably the same thing can be done? Very different: Python code works . BTW, if you think you're more secure distributing, for example, compiled C or Fortran code in binary form, you're mistaken: if my machine can execute it, I can trace the machine instructions, and they tell me everything your program does as well as how it does it. Python bytecode is less work to decipher, but a reasonably talented hacker can effectively "reverse compile" anything. hence-the-restriction-against-doing-that-in-all-the-software-licenses- you-accept-without-reading-ly y'rs - tim From jhauser at ifm.uni-kiel.de Wed May 3 03:52:20 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 03 May 2000 09:52:20 +0200 Subject: Numpy, map References: <390FCE45.70FF01E@udel.edu> Message-ID: <87n1m8kr4b.fsf@ifm.uni-kiel.de> There is an arraymap function in the cephes module. It does speed up the code for longer loops. >>> print cephes.arraymap.__doc__ c1,..,cn = arraymap(pyfunc,inputs{,outputtypes}) Loop over the elements of the inputs tuple, applying pyfunc to the set formed from each element of inputs. Place the output in arrays c1,...,cn. This function can make any pyfunc with scalar inputs and scalar outputs emulate a ufunc. HTH __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From aahz at netcom.com Tue May 30 01:27:08 2000 From: aahz at netcom.com (Aahz Maruch) Date: 30 May 2000 05:27:08 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8grnj1$sb3$13$1@news.t-online.com> <8guvc1$6ed$1@nnrp1.deja.com> Message-ID: <8gvjfc$vvi$1@slb3.atl.mindspring.net> In article <8guvc1$6ed$1 at nnrp1.deja.com>, Xtian wrote: > >Sorry - just to clarify one point... PL/SQL (in Oracle) is quite a >widely used programming language which is case insensitive, although >the case in the code is maintained by the system. In fact, pretty much >all SQL is case insensitive as far as I know. Don't be so sure of that. While I can't speak to Oracle, in MS SQL Server, you can set the underlying database to be case sensitive, which also affects all field/table names. This case sensitivity doesn't affect language keywords, which leads to a weird scenario where *part* of the SQL code is required to be case sensitive.... -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Have you coined a word today? --Aahz From psl at mitre.org Mon May 1 15:47:45 2000 From: psl at mitre.org (Pete) Date: Mon, 01 May 2000 15:47:45 -0400 Subject: calldll Message-ID: <390DDF61.D56FD666@mitre.org> Does anyone know how to handle it in call_foriegn_function when a C++ class is returned by the dll that you are calling? From loredo at spacenet.tn.cornell.edu Tue May 16 17:26:18 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Tue, 16 May 2000 17:26:18 -0400 Subject: Schwartzian Transform in Python? References: Message-ID: <3921BCFA.FCD3304D@spacenet.tn.cornell.edu> Tim Peters wrote: > > [Fran?ois Pinard] > > The "technique" called Schwartzian Transform by Perlers is as old > > as earth (OK, OK! I agree we should put eternity in some relative > > context, here :-). > > > > I just wanted to say that I'm surprised that someone could so easily > > give his name to such an old technique. I presume that there is > > some confusion between the syntax and the method? > > I don't think Mr. Schwarz named it after himself, it was an honor bestowed > upon him by a grateful community. Just another instance of "new money for > old rope" -- most people who get a reputation as a computer genius do so by > recycling 18th-century mathematics . Historian Stephen Stigler published a paper titled (IIRC) "Stigler's law of eponymy" several years back. It documents several examples of Stigler's law which goes something like: "No idea is named after its original discoverer (including Stigler's law)." 8-) Tom Loredo From jkraska1 at san.rr.com Wed May 24 20:39:08 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 00:39:08 GMT Subject: Good ideas :-), no time :-( References: <8ggfn6$dhd$1@newsserver.rrzn.uni-hannover.de> Message-ID: <392C76CF.27A5D18B@san.rr.com> > > So, I came with this "simple" idea, that we should have tools for converting > > Makefiles and shell scripts into specialised Python scripts. (And why not > > `sed' and `awk' as well, once on that road, the same as Perl once did.) As for make, I suspect you're using the wrong make program. Gnumake scripts are, if written correctly, very succint. With dependency evaluation and the like, make very much does what it's designed to do, IMO. C/ From digitig at cix.co.uk Sat May 27 18:32:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Sat, 27 May 2000 23:32 +0100 (BST) Subject: Timeout using tkinter? Message-ID: Using Python & tkinter, is it possible to build a (platform independent) time-out on a user response? From echuck at mindspring.com Wed May 10 14:17:15 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Wed, 10 May 2000 14:17:15 -0400 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> Message-ID: <3919A7AB.175BFACF@mindspring.com> Jacek Generowicz wrote: > > How would you rewrite the following code, in good > python style ? > > list1 = [ 1,2,3,4,5,6 ] > list2 = [ 6,5,4,3,2,1 ] > > count = 0 > for item in list1: > print item - list2[count] > count = count + 1 > > In other words, I want to loop through two lists, > performing some operation on elements in > corresponding positions . . . there must be a more > elegant way. > > Thanks, > > Jacek I'm surprised I haven't seen this version, yet: for x in map(lambda a,b: a-b, list1, list2): print x That doesn't feel obscure to me and in most of my programs I'm passing my results around more often than I'm directly dumping them to the console (where they're no longer usable). The point is I would probably "return" the map() above or stick in a var, except for really simple programs. -Chuck From faatdilac at my-deja.com Thu May 25 12:31:06 2000 From: faatdilac at my-deja.com (faatdilac at my-deja.com) Date: Thu, 25 May 2000 16:31:06 GMT Subject: Java vs Python References: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <8F3F72DB7davemrquizorg@212.27.32.76> Message-ID: <8gjkga$fjo$1@nnrp1.deja.com> In article , "John W. Baxter" wrote: > In article <8F3F72DB7davemrquizorg at 212.27.32.76>, nospam.mrquiz at free.fr > (Dave Simons) wrote: > > > I wasn't taking too much notice at the time, so can anyone tell > > me how much marketing went into C to make it the biggest-selling > > language the world has ever known? > > Not much "marketing" as we know it. However, giving Unix and C to > universities infiltrated C into the thinking of a generation of CS grads > (and not-quite-grads). I was out of that environment long before then, > so I wasn't infected...C looked pretty useless for a long time (and I > still don't much like it). > > --John (who about 5 years ago had to stop saying he had been around > computers twice as long as C had) > > -- > John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com > Oh yeah, and which language do you think the trio Larry, John and Guido use to develop Perl, Tcl and Python. BTW, Matz also uses C to develop Ruby. Amateur does not know to appreciate the very tool that creates the universe of programming languages, it's C. faatdilac Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Sun May 28 07:08:07 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 28 May 2000 11:08:07 -0000 Subject: [FAQTS] Python Knowledge Base Update -- May 28th, 2000 Message-ID: <20000528110807.12915.qmail@synop.com> Hi Guys, Below are the entries I've entered into http://python.faqts.com today. The knowledge base is growing really well, over 160 questions and answers! Thanks to everyone that has contributed and provided me with suggestions and feedback. cheers, Fiona Czuczman [In advance: I apologise if this mail comes into the list twice, I'm having trouble with my mail...] ## New Entries ################################################# ------------------------------------------------------------- How do I set environment variables in a Python script that is to be run on an Apache server? After setting environment variables in a script will they be changed after running the script? http://www.faqts.com/knowledge-base/view.phtml/aid/3298 ------------------------------------------------------------- Fiona Czuczman Cliff Crawford Problem: Say, I want to set ORACLE_HOME = /opt/app/ora/ I wrote the following code: import os os.system("ORACLE_HOME=/opt/app/ora/") os.system("export ORACLE_HOME") .... I executed the script under my user account but when I checked my enviroment variables with "env" there is no ORACLE_ENV added. Solution: That's because os.system spawns a new process (with a copy of the original environment of the parent process) each time it's called. You want to use os.environ instead: os.environ["ORACLE_HOME"]="/opt/app/ora/" This changes the environment for all future os.system calls. Once the process dies, the changed environment dies with it. ------------------------------------------------------------- How can I embed/port Python to Vxworks? http://www.faqts.com/knowledge-base/view.phtml/aid/3301 ------------------------------------------------------------- Fiona Czuczman Richard Wolff What follows are some of the details. This same information and the rest of the story can be found at http://daikon.tuc.noao.edu/python As usual, no warranty for fitness nor merchantability nor freedom from un-wanted side-effects of creeping featurism. --------------------------------------------------------------------- Here's how I set up Python as an embedded task in VxWorks. Note that building the system for VxWorks is not going to be as nicely set up as doing so for most systems. We can't run configure for one thing. So there are a number of changes that you have to consider/make by hand. Before getting to the details, a thank you to Paul Fernhout for some helpful advice in a recent comp.lang.python posting. Perhaps the best way to get started is to build Python on your workstation and use that as the start of the port. This way, many of the files you need will be present. For instance, the parser generator program will be built and run, so it isn't needed for the cross-compile. You'll also have config.h file that might well serve as a useful starting point. The files from the distribution that you need to modify are in Include, Modules, Objects, Parser, and Python. At the top level, you'll need to change Makefile and config.h. The diff file (pydiff) will make a lot of changes for you, but you should probably take a look at what's going on first. There may well be better ways of doing things. By the way, the diff is against Python 1.5.2 and is for VxWorks 5.2 (pre-Tornado). You'll need (or want) to do the following: 1) Edit the top level Makefile to reflect the correct definitions for CC, RANLIB, LD, and AR. Make the same edits in the Makefiles in Objects, Parser, and Python directories. Make the same edits in Makefile.pre in Modules. 2) Edit config.h 3) Get a version of getopt.c and put it in the top level directory, along with a suitable getopt.h, which can go in the Include directory. Or put getopt.c somewhere else and modify Makefiles suitably. 4) Edit Setup (and Setup.local, Setup.thread). 5) If you include modules that I didn't, you'll probably want to edit that module's ".c" file. If you have a different version of VxWorks, look for the VXWORKS define and modify as needed. 6) Modify Modules/python.c as you will. You probably will want to modify the arg0 value. 7) Remove the buildno file if you want. 8) In Modules, run makesetup to build the Makefile and config.c. If you have used both Setup and Setup.local, run makesetup Setup Setup.local 9) At the top level, run make. The output will be "python.o" in this directory. 10) Load that into your VxWorks system. On my system, Python took too much stack space to run under the shell, so I spawn the task, which is what "sppy" ("spawn python") does. If Python comes alive, but you get lots of xxx:yyy: No such file or directory and xxx:yyy: File exists, don't worry. Those messages are from 'stat' as it probes the file system on xxx looking for library files. I don't know how to stop this; it's both annoying and harmless. 10a) You should 'cd "python-top-level-directory"' before you load the python.o file, or you should be sure that you have the Lib directory in a standard place (or you have modified the Makefiles to reflect suitable prefix and exec-prefix directories). Or you might set the PYTHONHOME environment variable in Modules/python.c before Python goes through its initialization steps. 11) When the >>> prompt appears, it's likely that a carriage return will bring back the shell prompt. That's because the shell runs at much higher priority than Python and it grabs all the characters. It needs to be demoted, which is what the "demoteShell" code in Modules/python.c does (with a vengeance...there's probably no need to suspend the shell). So run that routine from the shell, and then run Python as you will. 12) To exit, the usual command sequence (or sys.exit) will get you back to the shell prompt, at which time, you should raise the shell priority back to 1 (use "restoreShell"). 13) You can make things more interesting by having Python code that will allow you to run VxWorks routines. You need a slight extension of Python, to be found in my "Modules/vxmodule.c". Modify Setup (or Setup.local, rerun makesetup, and then the top level make). 14) A simple VxWorks class makes use of the vxmodule code. See VxWorks.py Thus, i = VxWorks.Vxw("i","") builds an 'i' such that 'i()' gives the same task information table from the Python prompt as it does from the VxWorks shell. Or, routeAdd = VxWorks.Vxw("routeAdd", "ss") builds a routeAdd function that can be used to add a route to the VxWorks routing table (routeAdd("90.0.0.0, "gateway")), and so forth. 15) If you have the VxWorks module in place, you can then define rs = VxWorks.Vxw("restoreShell","") and when you run rs(), you have, for interactive use, effectively suspended Python, as the shell will get all the input characters. "demoteShell" and 'rs' thus allows you to switch back and forth between Python and the VxWorks shell. Richard Wolff May, 2000 P.S. I did this work because I want to run various routines in the VxWorks environment under the control of a "scripting" language. There are three approaches here...embed Python in VxWorks, which is what this note is about, connect Python running on a workstation to the VxWorks shell via telnet, or connect Python on the workstation to a process on the VxWorks box via a socket connection. Which way to go is nice question. The other question one ought to answer is, "why aren't you using rt-linux?". P.P.S. All this code is released under the same terms and conditions as the Python license. ------------------------------------------------------------- How can I create a Tkinter MessageBox with the MessageBox - option "YESNOCANCEL"? http://www.faqts.com/knowledge-base/view.phtml/aid/3297 ------------------------------------------------------------- Fiona Czuczman Robert Roy Problem: When I use - import tkMessageBox tkMessageBox.askquestion("equal","even better", icon=QESTION, type=YESNOCANCEL) The error message here is: NameError: QUESTION Solution: QUESTION is not in your namespace try tkMessageBox.askquestion("equal", "even better", icon=tkmessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) however this will bring up another a type error: keyword parameter redefined. so then instead of using askquestion use _show tkMessageBox._show("equal", "even better", icon=tkmessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) If you look at the sources you will see that askquestion is just a shortcut for _show(title, message, icon, type) where icon=QUESTION and type=YESNO ref: def askquestion(title=None, message=None, **options): "Ask a question" return apply(_show, (title, message, QUESTION, YESNO), options) ------------------------------------------------------------- Is it possible to set the minimum size of the window? http://www.faqts.com/knowledge-base/view.phtml/aid/3299 ------------------------------------------------------------- Fiona Czuczman Robert Roy Try this: import Tkinter root = Tkinter.Tk() root.minsize(400,200) Tkinter.Button(root, text='Hello").pack() root.mainloop() also see maxsize and geometry ------------------------------------------------------------- I'm trying to use the smtplib for sending mail, and I keep getting error: (10061, 'winsock error') when I try just to connect to the localhost. http://www.faqts.com/knowledge-base/view.phtml/aid/3296 ------------------------------------------------------------- Fiona Czuczman Andrew Henshaw I'm guessing that your code looks something like: import smtplib server=smtplib.SMTP('localhost') server.connect() If so, then your problem is that the server.connect() function was already called when you instantiated "server". The connection is automatically made when you provide the hostname as a parameter to SMTP. I believe that the SMTP example in the library documentation is in error, in this regard. From dalke at acm.org Thu May 25 11:52:28 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 25 May 2000 09:52:28 -0600 Subject: What's in a name? References: <392D06E1.415DFEF1@uab.edu> Message-ID: <8gji5v$2hl$2@slb1.atl.mindspring.net> Edward S. Vinyard wrote: >For example, forcing the first letter of class names to be capitalized >makes it visually clear which names are classes. I enjoy Python's lack of >block delimiters and I think I would enjoy the lack of implicitness here, >too. Will the following be allowed? import UserList x = UserList.UserList or will all assignment have to preserve case? What about: def f(): return UserList.UserList x = f() or will f() have to be capitalized if it returns classes, thus making x by capitalized because it gets something from F()? Sometimes you use factory functions instead of a constructor. Consider the following common idiom: try: from cStringIO import StringIO # function except ImportError: from StringIO import StringIO # constructor f = StringIO("This is some text") Would you prevent the first from occuring? Similarly, any sort of dispatch function will likely need to allow both functions and constructors to be used interchangeably: table = { "i", int, "sf", StringIO, ... } def unpack_object(s): datatype, data = string.split(s) f = table.get(datatype, None) if f is None: raise TypeError("unknown datatype", datatype) return f(data) Andrew dalke at acm.org From t.keil at zvs.zgs.de Tue May 9 14:02:07 2000 From: t.keil at zvs.zgs.de (Thomas Keil) Date: Tue, 09 May 2000 11:02:07 -0700 Subject: xitami configuration? References: Message-ID: <3918529F.60C9@zvs.zgs.de> Hi Steven, > setup file for Python/XITAMI: [Filter] .py=d:/python/python .pyc=d:/python/python [CGI] environment=1 # you need this for Python! form-fields=0 # to avoid overflow when having large fields [CGI-Environment] PYTHONPATH=d:\CGI-Prog\Library # directory for your Python-modules Note: All directories from XITAMIs point of view! _ o | )_/# T >> Image.open('f.GIF').save('f.jpg', 'JPEG') # ? References: <392A4E46.D7B93D86@darwin.in-berlin.de> Message-ID: <392A999D.F6BEB3CB@earthlink.net> "Dinu C. Gherman" wrote: > > after studying the PIL tutorial I don't think I found the > proper place explaining why I get an error like this when > I try to save a GIF file in JPEG format: > > >>> im = Image.open('sample.gif') > >>> im.save('sample.jpg', 'jpeg') > Traceback (innermost last): > File "", line 0, in ? > File "Image.py", line 665, in save > SAVE[string.upper(format)](self, fp, filename) > File "JpegImagePlugin.py", line 298, in _save > raise IOError, "cannot write mode %s as JPEG" % im.mode > IOError: cannot write mode P as JPEG > > Is it because palette mode images cannot be converted to > JPEG? If so, can it be done with the pilconvert utility? > I haven't tested this, but if pilconvert can do it, why > isn't it possible without? > Use the convert method of the Image: >>> from PIL import Image >>> Image.open('prev.gif').convert('RGB').save('prev.jpg') -greg -- greg Landrum (greglandrum at earthlink.net) Software Carpenter/Computational Chemist From rumjuggler at cryptarchy.org Thu May 25 20:54:57 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 26 May 2000 00:54:57 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> Message-ID: <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> On Thu, 25 May 2000 23:54:29 GMT, Courageous wrote: >"CUM HOC ERGO PROPTER HOC" > >It should be educational. I think you mean "POST" instead of "CUM". -- Barnabas T. Rumjuggler Is this going to be another episode where you have to be sodomized with the Clue Branch before you shut up and admit you're wrong? -- John S. Novak III, the Humblest Man on the Net. From m.faassen at vet.uu.nl Thu May 18 13:45:48 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 17:45:48 GMT Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l4e$gd2$2@newshost.accu.uu.nl> Message-ID: <8g1a8c$p9q$1@newshost.accu.uu.nl> Fredrik Lundh wrote: > Martijn Faassen wrote: >> That doesn't help us one bit if it's true what an earlier poster said and >> the 'string' module is deprecated. > who said that? Some poster in this thread; I forget who it was. :) > there's lots of stuff in the string module that you cannot > get at via the string methods. > *strop* is deprecated (but still there in 1.6a2), but I don't > think we'll get rid of string that easy... Ah, right. Then I was misinformed. In that case ' '.join() is still a minor weirdness, and we may want to rename the 'join' method to something slightly more readable, but if the documentation recommends use of string.join() then there shouldn't be large problems. Thanks, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jbauer at rubic.com Mon May 8 13:49:31 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 08 May 2000 12:49:31 -0500 Subject: RH6.1 coredump: float("10.01") References: <000601bfb8b4$06393620$b12d153f@tim> Message-ID: <3916FE2B.A9ADD774@rubic.com> [ Jeff gets a Segmentation fault using float() ] Tim Peters responded. > Look for platform library (libc and/or libm) corruption > or mismatch. Thanks to Tim and others. I took the easy way out. Rather than track down the errant library, I simply upgraded to RedHat 6.2. fixed-the-problem-and-hid-the-evidence-ly y'rs, Jeff Bauer Rubicon Research From markx.daley at intel.com Tue May 2 16:40:05 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Tue, 2 May 2000 13:40:05 -0700 Subject: Submitted for your perusal... Message-ID: <75F7304BB41CD411B06600A0C98414FC0A40F0@ORSMSX54> Hmmm, methinks my attachment got away. I will put the code directly in the message this time. Please forgive the text wrapping. -Mark # Data Collection Script v. 1.03 # 4/18/00 # Mark Daley # Python 1.5.2 # Feel free to use and distribute as you see fit. No guarantees on operability! It works ok the way it is. import dbi, odbc import time time1 = [957081600.0] # Sun 4/30/00 00:00:00 = 957081600.0 time2 = [time.time()] def timer(): "Timer that constantly checks against a set date and executes a function after set length of time." while time.time() > 0: while time.time()-time1[0] < 604800: # 1 hour = 3600, 1 day = 86400 pass time2 = [time.time()] collect() time1[0] = time2[0] def collect(): "Routine to query all data collection servers for all family names for time period defined in timer." servername = ['ServerA', 'ServerB', 'ServerC'] sql_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d %H'+":"+'%M'+":"+'%S', time.localtime(time1[0])) current_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d %H'+":"+'%M'+":"+'%S', time.localtime(time2[0])) file_date = time.strftime('%m'+"_"+'%d'+"_"+'%Y', time.localtime(time.time())) for index in servername: #try: familyname = ['name1', 'name2', 'name3', 'name4', 'name5', 'name6', 'name7', 'name8', 'name9', 'name10', 'name11', 'name12', 'name13'] dbc = odbc.odbc(index+'/username/password') crsr = dbc.cursor() for name in familyname: crsr.execute("""select * from subtestlist\n\ where (errorcode<>'null'\n\ AND familyname='"""+name+"""'\n\ AND Packagestarttime>'"""+sql_date+"""'\n\ AND Packagestarttime<='"""+current_date+"""');""") result = crsr.fetchall() f = open('/data/'+name+'_'+index+'_'+file_date+'.txt', 'a') # Headers for import to Excel f.write("modulename,subtestnum,subtestname,familyname,releasenum,productcode ,serialnum,servername,id,subtestendtime,packagestarttime,opid,errorcode,erro rmessage,isfinalsubtest,duration,firstsn" + '\n') z = 0 # Date converter for readability/consistency for item in range(len(result)): modulename, subtestnum, subtestname, familyname, releasenum, productcode, serialnum, servername, id, subtestendtime, packagestarttime, opid, errorcode, errormessage, isfinalsubtest, duration, firstsn = result[item] subtestendtime = time.ctime(subtestendtime) packagestarttime = time.ctime(packagestarttime) f.write(`modulename` + ',' + `subtestnum` + ',' + `subtestname` + ',' + `familyname` + ',' + `releasenum` + ',' + `productcode` + ',' + `serialnum` + ',' + `servername` + ',' + `id` + ',' + `subtestendtime` + ',' + `packagestarttime` + ',' + `opid` + ',' + `errorcode` + ',' + `errormessage` + ',' + `isfinalsubtest` + ',' + `duration` + ',' + `firstsn` + '\n') z = z + 1 f.write('\n' + "Total error count = " + `z`) f.close() #except dbi.opError: #servername.append(index) # Reference code; unable to invoke as function in collect() def subtestdateconv(): for item in range(len(result)): modulename, subtestnum, subtestname, familyname, releasenum, productcode, serialnum, servername, id, subtestendtime, packagestarttime, opid, errorcode, errormessage, isfinalsubtest, duration, firstsn = result[item] subtestendtime = time.ctime(subtestendtime) packagestarttime = time.ctime(packagestarttime) result[item] = (modulename, subtestnum, subtestname, familyname, releasenum, productcode, serialnum, servername, id, subtestendtime, packagestarttime, opid, errorcode, errormessage, isfinalsubtest, duration, firstsn) timer() # v 1.0 Initial release. # v 1.01 Added counter to provide total number of errors at end of file. Added Koa to familyname. # v 1.02 Changed how data files are written; easier to import to Excel. # v 1.03 Added error trapping for failed server connection attempts. Still needs work. -----Original Message----- From: Daley, MarkX Sent: Tuesday, May 02, 2000 11:03 AM To: 'python-list at python.org' Subject: Submitted for your perusal... All, Many thanks to those of you who have helped me to develop this little script. Find attached the first reasonably working copy of my data collection routine. There are a couple of points to make. 1) The try:/except: portion is pounded out because I am having difficulty manipulating the servername list to append the current server name in the event of a failed connection. The idea is, if the connection is lost or fails, the name is appended to the end of the list, to be repeated ad infinitum until data is successfully retrieved. 2) I'm sure some of the coding techniques I'm using are cumbersome, but this is my first attempt. Please be patient, and any and all input is appreciated. 3) Feel free to adapt this to your own uses. I don't know how handy this might be, but it has improved data retrieval in my workplace tremendously. Thanks again. - Mark From fannyy at idmail.com Fri May 5 03:20:55 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Fri, 5 May 2000 00:20:55 -0700 Subject: Error in trying to locate bitmaps files References: <7P5Q4.21796$H7.1348779@brie.direct.ca> Message-ID: Hi, It is me again with similar problem but this time is coming from PhotoImage can not find the file (lumber.gif). I try full path and even put @ before it but it still can't create the image. Any idea. from Tkinter import * root = Tk() ......... photo=PhotoImage(file='lumber.gif') text.image_create(END, image=photo) text.insert(END, 'I dare you to click on this\n', 'bite') text.pack(side=LEFT) scroll.pack(side=RIGHT, fill=Y) root.mainloop() Traceback (innermost last): File "E:\PROGRA~1\Python\Tools\idle\ScriptBinding.py", line 131, in run_module_event execfile(filename, mod.__dict__) File "E:\Program Files\Python\Tkinter Programming\Examples\chapter04\text.py", line 23, in ? photo=PhotoImage(file='lumber.gif') File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1874, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1839, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) TclError: can't invoke "image" command: application has been destroyed Thanks again. Mak Fanny Yeung wrote in message news:7P5Q4.21796$H7.1348779 at brie.direct.ca... > Hi Robert, > I hardcode the full path and it is working now. > Thank for your help. > > Mak > Robert Cragie wrote in message > news:newscache$dbpztf$hqb$1 at jenpc07.jennic.co.uk... > > The syntax of 'bitmap=@' goes straight to Tk, therefore > appending > > to sys.path won't make any difference . A snippet from the Tk help file > says > > this: > > > > > > @fileName > > > > FileName must be the name of a file containing a bitmap description in the > > standard X11 or X10 format > > > > > > Unfortunately, that doesn't help me much either; maybe some other kind > soul > > can help. > > > > If you specify the full path for the file it works, e.g. on my machine > > > > Label(f2,bitmap='@C:\\Program > > Files\\Python\\src\\Grayson\\examples\\chapter04\\bitmaps\\woman',text="My > > second label in tk",relief=RAISED).pack(side=LEFT, padx=5) > > > > works OK. That's why the example works - the pathname is valid relative to > > where the application is run. > > > > A word of warning - if you're trying to enter things interactively in > IDLE, > > you can get unstuck with Tkinter apps. as IDLE is written using Tkinter as > > well. The most notable thing is NOT to call the mainloop() method in IDLE. > > Also, I have found some problems with some of the examples if you are > using > > Python Megawidgets 0.8.3 - there are some subtle differences between 0.8 > and > > 0.8.3. > > > > Robert > > > > Fanny Yeung wrote in message > > news:e6RP4.21542$H7.1329941 at brie.direct.ca... > > | Hi everyone, > > | > > | I am new in python and just bough "python and tkinter programming" BY > John > > | Grayson. As I go thru some example, I run into the following error when > it > > | try to create a label. > > | > > | >>> Label(f2,bitmap='@bitmaps/woman',text="My second label in > > | tk",relief=RAISED).pack(side=LEFT, padx=5) > > | Traceback (innermost last): > > | File "", line 1, in ? > > | Label(f2,bitmap='@bitmaps/woman',text="My second label in > > | tk",relief=RAISED).pack(side=LEFT, padx=5) > > | File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1410, in > > | __init__ > > | Widget.__init__(self, master, 'label', cnf, kw) > > | File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1084, in > > | __init__ > > | self.tk.call( > > | TclError: error reading bitmap file "bitmaps\woman" > > | > > | I have python 1.5 and Tcl 8 installed in my NT machine. I think is > related > > | to configuration but I just don't have any idea on how to trace this > > | problem. > > | > > | Thanks in advance. > > | > > | Mak > > | > > | > > > > > > From cjensen at bioeng.ucsd.edu Sat May 27 20:47:51 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Sat, 27 May 2000 17:47:51 -0700 Subject: global name space and importing Message-ID: <39306CB7.B5419219@bioeng.ucsd.edu> How come the global declaration works when I define it from withing the interpreter, but not from within a file that I import? See following example. file: foo_bar.py: def foo(i): x = i def bar(i): global y y = i Python interpreter: >>> from foo_bar import * >>> bar(0) >>> print y Traceback (innermost last): File "", line 1, in ? NameError: y >>> def other(i): ... global z ... z = i ... >>> other(5) >>> print z 5 >>> ^D -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From mwh21 at cam.ac.uk Thu May 18 11:46:48 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 May 2000 16:46:48 +0100 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> <3924098E.EBC61E24@smith-house.org> Message-ID: Larry Smith writes: > Michael Hudson wrote: > > > I could cope with C++ if I was the only person on the earth allowed to > > write in it, if you see what I mean. > > Well, I added _that_ little gem to my quotes file. I know > exactly what you mean, and I agree. Except that _I_ should > be the only person on earth allowed to write in it... =) As a compromise, shall we just agree that those who wrote MFC (and ATL) should never have been told of its existence? Cheers, M. -- I really hope there's a catastrophic bug insome future e-mail program where if you try and send an attachment it cancels your ISP account, deletes your harddrive, and pisses in your coffee -- Adam Rixey From kajiyama at grad.sccs.chukyo-u.ac.jp Tue May 30 09:24:49 2000 From: kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) Date: 30 May 2000 13:24:49 GMT Subject: Compact syntax for 0-matrix? In-Reply-To: Kirby Urner's message of Sun, 28 May 2000 22:13:12 -0700 References: <3931D5F1.B1DEAA76@mit.edu> <61v3js0e35og41utcmv64cg5r82jlvjpus@4ax.com> Message-ID: Kirby Urner writes: > > Here's another function I like OK: > > def zeromatrix(n,m): > output = [] > for i in range(n): output.append([0]*m) > return output Or, more shortly, def zeromatrix(m, n): return map(lambda x: [0]*x, [n]*m) It seems more time-consuming, though ;) -- KAJIYAMA, Tamito -- KAJIYAMA, Tamito From tuttledon at hotmail.com Thu May 11 21:49:37 2000 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 12 May 2000 01:49:37 GMT Subject: Python Plans from ActiveState References: Message-ID: > Here's a heads-up regarding some of the things that ActiveState is planning > in the short term for Python users everywhere: > > - as Python 1.6 is released, we will be publishing an ActivePython > distribution. This distribution, like ActivePerl, will allow easy binary > installation on Windows, Solaris and Linux. It is intended as an > alternative to the source distribution and to Guido's installer for Win32. ??? Will this just be the standard Python distribution packaged by Installshield or the like, or will Activestate be adding new Python code or changing the existing Python code in ActivePython? > - our website (www.ActiveState.com) will be reworked to highlight our > Python efforts and provide Python-related information, Python-related > openings, etc. Great news! Don From moshez at math.huji.ac.il Sat May 20 12:09:22 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 20 May 2000 19:09:22 +0300 (IDT) Subject: Damnation! In-Reply-To: <153bb080.5c1c7462@usw-ex0104-031.remarq.com> Message-ID: On Sat, 20 May 2000, Hamish Lawson wrote: > If case insensitivity was introduced, I propose that there > should be a command-line switch to revert to case sensivity for > backwards compatibility Python 3000 will *not* be strictly backwards compatible: think of it as a new language, with roots in today's Python. And trust me, you don't want this switch. What if you download a module? Is it meant for case-sensitivity or case-insensitivity? What if you download two modules, one wishing for c-s and one for c-i? Would you mark each module? And what about the interfaces between modules? And "from foo import *"? Having a delicate syntactic decision decided by a run-time switch effectively creates two different languages. Either one will dominate, in which case we can mandate that behaviour from the beginning, or the two will flourish, which means that the Python community will be split. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From daniels at mindspring.com Sun May 28 21:45:09 2000 From: daniels at mindspring.com (Alan Daniels) Date: 29 May 2000 01:45:09 GMT Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> <8glvki$1sp$1@slb7.atl.mindspring.net> Message-ID: On 26 May 2000 13:53:22 GMT, Aahz Maruch wrote: >Actually, it's *precisely* the case that Guido disagrees with your >philosophical position. It was a design decision to consider [].sort() >and [].reverse() to work on the original list because the programmer >should *always* explicitly request a copy of what may be a 100K element >list. sort() and reverse() return None to force you to remember that. Not that I'm qualified to disagree with Guido :-), but I could see this going either way. I don't see anything in the name "sort" or "reverse" that implies that I'm getting a copy. It's only a method call after all. If I saw: blah.sort().reverse() by itself, I wouldn't think that an unsorted, unreversed version of blah was still hanging around somewhere. But then again, if I saw: blech = blah.sort().reverse() then maybe I would :-), so I see your point. Still the getting of a list of sorted keys is really, really handy, so hopefully keys = some_dict.sorted_keys() wouldn't be much to ask? Or would that be opening the door to polluting native types with convenience methods? chewing-my-thumbnail-and-staring-at-the-screen'ly yours, Alan. -- ============================================================ Alan Daniels daniels at mindspring.com From xavier.outhier at anfdata.cz Mon May 22 09:13:33 2000 From: xavier.outhier at anfdata.cz (Xavier Outhier) Date: Mon, 22 May 2000 15:13:33 +0200 Subject: bz2 support in Python? Message-ID: <3929327D.1F09D8BB@anfdata.cz> Hello, Is there in Python any bz2 tool? bz2 is the 2nd version of bzip. A compression algo. I have search in FAQ, DejaNews and I have found nothing. Greetings. Xavier. PS: if you want info about bz2 just go there http://sourceware.cygnus.com/bzip2/index.html From alois at intercom.es Wed May 31 07:32:20 2000 From: alois at intercom.es (alois at intercom.es) Date: Wed, 31 May 2000 11:32:20 GMT Subject: Pruebas Message-ID: <8L6Z4.5291$jq6.19253@telenews.teleline.es> Pruebas From slhath at flash.net Mon May 8 15:42:40 2000 From: slhath at flash.net (Scott Hathaway) Date: Mon, 08 May 2000 19:42:40 GMT Subject: finding a file Message-ID: How do I find a file on a drive (under Win 32)? For example, if I want to search the entire D: drive and all of it's subdirectories? Thanks, Scott From hgg9140 at seanet.com Fri May 26 18:03:32 2000 From: hgg9140 at seanet.com (Harry George) Date: 26 May 2000 15:03:32 -0700 Subject: Indented gonads. References: <8gjqer$k8v$1@nnrp1.deja.com> <20000525225425.Z13281@xs4all.nl> <392E3C88.DADE571@geneva-link.ch> <8F40861C1davemrquizorg@212.27.32.77> <392ebdba.34189549@news.telus.net> Message-ID: The key point is that the various "helpful" agents scattered through MS products default to on. It is one thing to allow someone to turn them on -- they will thus also know how to turn them off. It is quite another to turn them on by default. Frequently I've had to help casual MS users untangle the effects of those agents -- and had to work hard to find the off buttons (which sometimes move from release to release). That is either bad usability design or a deliberate mindshare absorption. Until I see some evidence of MS stupidity, I'll assume they know exactly what they are doing. Given the megabucks they spend on usability testing, I'll assume the decision to turn helper agents on by default is deliberate mindshare absorption. By that I mean roughly: The MS world is complete enough that many people (esp. upper mgmt) can do all their work in the MS mental model. The MS model is so alien to other computing mental models that straddling two or more models is difficult. [Anyone who works in both MS and UNIX knows what I mean.] Only people who seriously push their pain thresholds can do so -- and they are by definition nerds/geeks, who can be safely ignored by CIO's and CTO's. The harder it is to shift mental contexts in and out of MS products, the easier it is to lock in the customer base. Whether or not this is evil, it sure is good customer lockin. invalid.address at 127.0.0.1 (David) writes: > On Fri, 26 May 2000 10:54:29 GMT, nospam.mrquiz at free.fr (Dave Simons) > wrote: > >No more and no less than those who make the decisions in any of > >the other divisions of Redmond Garbage Creations Inc. - try > >typing out case-sensitive code in Word, for example (I know you > >don't normally write code in a word-processor, but you might > >want to write *about* code in a word-processor). > > Uh-huh. Evile Microsoft is out to screw you by having its autocorrect > feature work as it should, eh? > > Come on, man. I'm no lover of Microsoft, but you can hardly grouse about > Word doing things Word is designed to do, and that can be disabled by any > reasonably intelligent person. > > It's called "Autocorrect as you Type" and it's toggle-able. If you don't > like it, turn it off. > > Sheesh. > > RTFM. > -- Harry George hgg9140 at seanet.com From fannyy at idmail.com Wed May 3 04:17:54 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Wed, 3 May 2000 01:17:54 -0700 Subject: Error in trying to locate bitmaps files Message-ID: Hi everyone, I am new in python and just bough "python and tkinter programming" BY John Grayson. As I go thru some example, I run into the following error when it try to create a label. >>> Label(f2,bitmap='@bitmaps/woman',text="My second label in tk",relief=RAISED).pack(side=LEFT, padx=5) Traceback (innermost last): File "", line 1, in ? Label(f2,bitmap='@bitmaps/woman',text="My second label in tk",relief=RAISED).pack(side=LEFT, padx=5) File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1410, in __init__ Widget.__init__(self, master, 'label', cnf, kw) File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1084, in __init__ self.tk.call( TclError: error reading bitmap file "bitmaps\woman" I have python 1.5 and Tcl 8 installed in my NT machine. I think is related to configuration but I just don't have any idea on how to trace this problem. Thanks in advance. Mak From NOSPAMjason at NOSPAMstreetrodstuff.com Sat May 13 09:44:39 2000 From: NOSPAMjason at NOSPAMstreetrodstuff.com (Jason Long) Date: Sat, 13 May 2000 13:44:39 GMT Subject: PIL - inflateInit? Message-ID: Hey all, need a little help with PIL. I'm running a stock RH 6.1 system and I just installed PIL with *almost* no problems. If I fire up the python prompt, I am able to import Image, but when I try to import _imaging, I get the following: >>> import _imaging Traceback (innermost last): File "", line 1, in ? ImportError: /usr/lib/python1.5/site-packages/PIL/_imaging.so: undefined symbol: inflateInit_ Tried to look up similar errors on deja.com, but didn't see anything. Thanks in advance. Jason -- Jason Long Webmaster http://www.streetrodstuff.com From stain at nvg.org Sat May 27 00:46:15 2000 From: stain at nvg.org (Stian Soiland) Date: 27 May 2000 04:46:15 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: * esj at harvee.billerica.ma.us spake thusly: | okay, here's why I don't like case sensitive languages. I program by | voice. I know blind programmers that listen to code. An aural | interface and case sensitivity are not a good match. question: How do you deal with indention and the lack of {}? Would not Perl be a better choice, with oneliners and a lot of different characters that do magic stuff? -- Stian S?iland - Trondheim, Norway - http://stain.portveien.to/ From no at spam.net Tue May 9 23:19:30 2000 From: no at spam.net (Tom Vrankar) Date: Wed, 10 May 2000 03:19:30 GMT Subject: python win32all: Why Differences with C? Message-ID: <6z4S4.1006$Xl.81237@news.goodnet.com> I'm hacking with a Palm using pilot-xfer on Win98 (it's the only library I can find that's compiled for win32). I have an example program (kittykiller.c, if you know it) compiled from C which calls: // obtain the handle for the HotSync manager's window HWND hWnd = FindWindow(HOTSYNC_APP_CLASS,NULL); And the program works fine. It's small, and I would like to avoid the overhead of calling it via spawnv (any efforts to portably merge spawnv(os.P_WAIT...) into os.system?... but I digress), so I try to translate it to win32all build 129. After some stumbling around in the Python Win32 help files, I discover win32ui.FindWindow() which seems to have similar looking parameters, so I translate the above as: wnd =win32ui.FindWindow (HOTSYNC_APP_CLASS, None) But this gives me an exception: win32ui: The window was created in a different thread and can not be mapped. Same thing for FindwindowEx() with a pair of Nones added in. I understand Unix, tcl, python, and such things. I know nada about Windows. I have little idea of what the program above doing. Anyone have any suggestions about what I'm doing wrong and how to fix it? The only other thing I want to do in this translation is call wnd.SendMessage(). Thanks for any ideas. -- --------------------------------- Tom Vrankar twv at ici.net http://home.ici.net/~twv/ Rhode Island, USA From mikael at isy.liu.se Fri May 12 05:04:21 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 12 May 2000 11:04:21 +0200 (MET DST) Subject: [FAQTS] Python Knowledge Base Update -- May 10th, 2000 In-Reply-To: <391B5C62.D71F17BE@polyu.edu.hk> Message-ID: Fiona Czuczman wrote: > > I've started entering some of the questions, with answers, that make it > > onto the newsgroup into http://python.faqts.com . I'm planning on doing > > this on a daily basis. On 12-May-00 LUK ShunTim answered: > Would you consider setting this up as _another_ mailing list? The number > of messages on the python lists is very large for me to cope. What's one more message a day among ~130 messages a day? I prefer to get these messages through c.l.py. If one message a day is too much, I can accept a digest once a week. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 12-May-00 Time: 10:57:27 This message was sent by XF-Mail. ----------------------------------------------------------------------- From richard_chamberlain at ntlworld.com Fri May 5 07:58:11 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Fri, 5 May 2000 12:58:11 +0100 Subject: ftp return format Message-ID: Hi, Although its not directly a Python question, I know you guys are probably nice enough to answer it anyway ;) At work we run ftp to get files off an AS400 into a text file. These then get imported into Excel to mess around with. I would like to be able to use Python's ftplib to get the file and then use COM to import straight into Excel. The problem is then when I use ftplib I get the data back in a certain format, I've also used the dos ftp command and I get the data the same way. We use a thing called Rumba FileTransfer which is obviously translating somehow, anyone know how I can do the same? e.g. from python: 0183 0000100000000000000000000000000000000000K0000000000000K 0184 0000300000013200000000000000000000000000000000013200000 0185 0000300001185200000000000000006M0000000000000118520006M from Rumba: 0183 1 0 0 0 -2 0 -2 0184 3 132 0 0 0 132 0 0185 3 11852 0 -64 0 11852 -64 I realise that it's fix delimited, but then I get stuck on the K and M which crop up with negative numbers. Thanks, Richard From nickm at mit.edu Fri May 26 01:06:54 2000 From: nickm at mit.edu (Nick Mathewson) Date: Fri, 26 May 2000 05:06:54 GMT Subject: [PATCH] A compromise on case References: Message-ID: On Tue, 23 May 2000 17:18:25 GMT, Nick Mathewson wrote: [...] >So I tried to make a quick-and-dirty patch the Python interpreter to >do something more reasonable. Here's a sample interaction: >[tracebacks omitted, long lines wrapped] > [...] > >>> print MAP(square, [1,2,3]) > NameError: No such name as 'MAP'. Perhaps you meant 'map'? [...] > >>> import string, re > >>> print string.JOIN(['a', 'b', 'c']) > AttributeError: JOIN. Perhaps you meant 'join'? Update, for anybody who cares: I substantially rewrote my patch after advice and comments from Martin von Loewis, Guido, Mark Hammond, and Skip Montanaro; I've just sent the latest version to the patches list. It now handles all the cases above more efficiently and cleanly than before, and it can now catch another kind of error altogether: >>> class NumHolder: ... def __init__(self, num): ... self.x = num ... def get(self): ... return x ... >>> NumHolder(5).get() Traceback (most recent call last): File "", line 1, in ? File "", line 5, in get NameError: No such name as 'x'. Perhaps you meant 'self.x'? Forgetting 'self' is one of the most common beginner errors on comp.lang.python. The extra code required to detect it: 4 lines! -- Nick Mathewson http://www.mit.edu/~nickm/ From francis at robinton.demon.co.uk Thu May 11 11:10:46 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Thu, 11 May 2000 16:10:46 +0100 Subject: Const-Correctness of Python/C References: <20000511114535146.AAA71.378@pcfue9> <391AB63D.E768D78D@cfdrc.com> Message-ID: <5$6rjVB21sG5EwJa@robinton.demon.co.uk> In article <391AB63D.E768D78D at cfdrc.com>, Lyle Johnson writes >Some older C compilers wouldn't support the const keyword, so that could >be a problem. Really? After 12 years with const as part of the C standard. Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From mak at imakhno.freeserve.co.uk Sat May 27 13:22:48 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Sat, 27 May 2000 18:22:48 +0100 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> <8goufe$17n$1@newsg4.svr.pol.co.uk> <39300308.69576FD@mit.edu> Message-ID: <8gp0fh$2g4$1@newsg4.svr.pol.co.uk> >>> Does xrange create an array of numbers 1...1e8? >> >> Yes, it does >> >No, it doesn't. Well, if it did create an array Matlab-style, then that would account for why the C routine was faster. From cfelling at iae.nl Mon May 15 16:13:57 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 15 May 2000 22:13:57 +0200 Subject: A TYPICAL NEWBIE MISTAKE? References: <391F513B.CEA12592@san.rr.com> Message-ID: <8fplq5$1mq$1@animus.fel.iae.nl> Courageous wrote: > This has been an interesting experiment. While I > was aware that class variables in Python were "static" > until assigned, it took me until today to learn a bit > of a stinger of a lesson. To wit: append()ing to > a list or assigning to a dictionary does not count > as "assigned". actually class variables remain 'static' even after assignment! And as ever you can refer to them as Class.variable. The tricky point is that you can also refer to them as instance.variable as long as there is no instance variable yet with that name. Assignment to instance.variable creates an instance variable with that name, so hence forth the class variable is only accessible as Class.variable. Oh, and self is just an other name for the current instance:) > I spent quite a while this afternoon figuring this > out. This must be a fairly common error. The solution > is obvious. If you want to assign class variables as > commentary the way I do, make sure you assign everyone > in the __init__() method, ala: or keep refering to them as class variables (Class.variable) and not as instance variables (instance.variable), like: >>> class MyClass ... i = 'class variable init' ... def __init__(self): ... MyClass.i = 'class variable assignment' ... self.i = 'instance variable assignment' ... >>> instance = MyClass >>> print `MyClass.i`, `instance.i` 'class variable assignment' 'instance variable assignment' -- groetjes, carel From gmcm at hypernet.com Sat May 13 12:52:01 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 13 May 2000 16:52:01 GMT Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> Message-ID: <391d8831$0$13200@wodc7nh7.news.uu.net> Robin Becker wrote: > >In article <391d592e$0$13925 at wodc7nh6.news.uu.net>, Gordon McMillan > writes >>In practice, linked lists are O(really big 1). That is, for most usage, >>Python's supposedly O(n) lists will outperform them. >well it may be true for a lot of things, but it's certainly not true for >insertion and deletion intensive eg [snip] >produces >n= 10, t=0.0000181000 >n= 100, t=0.0000225000 >n= 1000, t=0.0000681000 >n= 10000, t=0.0006784000 >which is clearly not O(1) OK, now create a Python linked list implementation which is faster than 0.000678. >... arguing that making accesses O(1) is 'the >right thing to do' will get short shrift from the complexity experts who >will want to know about the overall usage. Huh? From akuchlin at mems-exchange.org Tue May 23 12:35:46 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 23 May 2000 12:35:46 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> Message-ID: <3du2fpxlzx.fsf@amarok.cnri.reston.va.us> Ben Cornett <> writes: > this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". thE masTEr WOuLd nOT aPPrOVe. There's a reason it's called Python 3000, after all. -- A.M. Kuchling http://starship.python.net/crew/amk/ Immediately I know that I've been sucked into hell and I can't get out. So anything that Adam Sandler is in, I just can't help it. -- Kevin Murphy of MST3K From glyph at twistedmatrix.com Mon May 8 12:51:31 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 08 May 2000 11:51:31 -0500 Subject: Copyright and License In-Reply-To: cjc26@nospam.cornell.edu's message of "Mon, 08 May 2000 14:55:54 GMT" References: <000801bfb8b9$f0fc7280$b12d153f@tim> Message-ID: cjc26 at nospam.cornell.edu (Cliff Crawford) writes: > I've actually heard the opposite said by people defending the GPL. > Supposedly if you release something as PD, or even with a BSD or other > license, then a Big Corporation can take your code, assert copyright on > it without even making any modifications or anything, and then sue you > for distributing "their" code. So that's why everyone should use the > GPL. At least, that's how their argument goes.. They *can* assert copyright on modified versions of it, but not on what you've released into the public domain. (two words: prior art) > I don't really have the time or the legal expertise to sit down and read > copyright laws, and there's so many different interpretations of the GPL > that I'm wary of using that too. So I just slap a BSD license on > everything and hope for the best :) I think I'll look more into PD > though, it sounds like it's not as dangerous as I thought it was. I think that after this thread I'm going to be putting stuff into the public domain... (thanks tim!) -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From senn at maya.com Fri May 12 12:17:02 2000 From: senn at maya.com (Jeff Senn) Date: 12 May 2000 12:17:02 -0400 Subject: New Language In-Reply-To: Andrew Maizels's message of "Sat, 13 May 2000 01:21:28 +1000" References: <8fh57c$19s$1@nnrp1.deja.com> <391C2178.CDCEB894@one.net.au> Message-ID: Andrew Maizels writes: > pohanl at my-deja.com wrote: > > This new language would have components with no constraints on values > > passed to it. > > as for the values, instead of being dedicated to a method in a > > component/class/function, it would be placed on a bloodstream/"bus". > > cells/components would grab it when they have appropriate functions > > that can use it. > > You seem to be talking about Linda. Do a web search on "tuple space". Ah -- the thing about Linda/Tspaces is that the transaction model is limited in a way that is unlike the physical universe -- there is no way to send a message to another computational entity w/o incurring the cost of opening a persistent memory segment somewhere... If you are writing production-systems this might seem like a good idea, but "natural" information systems tend to operate in more a data/message flow-like manner. IMHO - persistence should be layered on messaging and not vice-versa. [I just re-read this paragraph -- I'm not sure I'm communicating very well....] pohanl's comments on the history of systems and the stack are interesting: The heavy architectural reliance on the "process/thread function argument/return stack" is a holdover from the days of non-componentized systems -- it is a fine way to maintain state while traversing a hierarchical structure (e.g. evaluting a functional expression), but as a way to maintain running "component system" state it has severe shortcomings.... -Jas From tim_one at email.msn.com Fri May 26 01:27:05 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 May 2000 01:27:05 -0400 Subject: Java vs Python In-Reply-To: Message-ID: <000101bfc6d3$077265c0$c52d153f@tim> [John W. Baxter, on the "marketing" of C] > Not much "marketing" as we know it. However, giving Unix and C to > universities infiltrated C into the thinking of a generation of CS > grads (and not-quite-grads). I was out of that environment long > before then, so I wasn't infected...C looked pretty useless for a > long time (and I still don't much like it). In the early 80's, I was in a small group at Cray Research tasked with picking a new implementation language more maintainable than raw Cray assembler (yes, they were a bunch of crybabies ). After months of study, we managed to beat down the insane member of the group (i.e., the one who wanted to rewrite the OS and compilers in Fortran). The rest of us unanimously agreed that C was a bizarre experiment that would never spread beyond academia, and that the future clearly belonged to Pascal. The rest-- as they say --is history. there's-a-reason-some-of-us-can't-rest-on-our-laurels-ly y'rs - tim From bshomer at yahoo.com Thu May 18 10:26:40 2000 From: bshomer at yahoo.com (Benny Shomer) Date: Thu, 18 May 2000 14:26:40 GMT Subject: Control over Communication Processes Message-ID: <8g0ui9$61q$1@nnrp1.deja.com> Dear Folks, I know this problem has been "chewed up" before, but I couldn't find any single solid solution from all theh blurb I read. PROBLEM: ======== I have a web agent module that is used in web robots and spiders. I __must__ have a firm control over stalled connections, on a time base, since my program runs a very long and complex operation. The agent is an inheritting subclass of httplib. Possible Solutions: ------------------- 1. Spawn the actual reads (after performing httplib.getfile()) as a thread. Set a self.timer to the beginning of process. On each readline by the thread, reset the internal class timer, so that while large quantities of data still flow in, the timer doesn't tick. Once connection stalls, readlines are not operated and the timer ticks. BUT: I don't have a safe way to terminate the stalled thread. That leaves behind effectively a network zombie waiting for data that will never come sometimes. Even if I use getpid() in the thread and kill it externally I have a problem because it kills the spawning main class (...and is not safe to do anyway...) 2. Fork a child process, which can safely be killed in the even of stalled connections. BUT: The child, although it receives the self environment, can only read it, but can't modify it. So: a. It can't directly send the data back to the spawning class (this is solvable through using a temp file, or less likely a pipe, because the pipe will stall together with the connection) b. It has no effective way of resetting the class timer so the clock will be ticking even if the child works but simply reads large amounts of data (which is my case), so it gets killed when it's not supposed to... Argghhhh........... Any clever minds out there have descent solutions/offers? Thanks a zillion, Benny. -- ---- E pur si muove! (Galileo) ---- --------------------------------------------------------------------- Benny Shomer, Ph.D. Bioinformatics specialist Tel# +972 (8) 971-3165 email: bshomer at yahoo.com Mobile# +972 (54) 655-868 Fax# +972 (15154) 655-868 Public PGP Key (0x3610041C) at URL: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=index&search=0x3610041C Sent via Deja.com http://www.deja.com/ Before you buy. From lewinke at home.com Thu May 18 00:07:37 2000 From: lewinke at home.com (Karl Lewin) Date: Thu, 18 May 2000 04:07:37 GMT Subject: Thread Question Message-ID: Is there a way to "kill" a thread that is currently asleep. Example: thread t1 is currently executing "time.sleep(60)", is it possible to kill/delete/destroy the thread object before it finishes sleeping? If this isn't clear, I can post a better example tomorrow. From thomas at xs4all.net Mon May 15 03:22:43 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 15 May 2000 09:22:43 +0200 Subject: The REALLY bad thing about Python lists .. In-Reply-To: <09HT4.1708$qP3.159682@paloalto-snr1.gtei.net>; from jpet@eskimo.com on Mon, May 15, 2000 at 12:03:08AM +0000 References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> <8p6snvkyjdj.fsf@Eng.Sun.COM> <09HT4.1708$qP3.159682@paloalto-snr1.gtei.net> Message-ID: <20000515092243.S13281@xs4all.nl> On Mon, May 15, 2000 at 12:03:08AM +0000, Jeff Petkau wrote: > I fiddled around with timing tests (1.5.2 on Windows) to see what > Python's actual behavior is. If you're adding to a single list, it often > is linear, because the list is grown with realloc() which can get > lucky and just extend the size of the allocated block without having > to move it. But if you're allocating other stuff while building your list, > or > building two lists in parallel, realloc() doesn't get so lucky and growing > the list is O(N^2). > > I'd consider this a bug in Python. Really ? Why ? The code isn't wrong, is it ? It's merely suboptimal in some cases. If lists were to double instead of grow by 100 elements, you would get suboptimal performance in other cases. If you really need this speed, and frequently double the lists size, either use extend or dont use lists use arrays or write your own C extension to do the handling. I doubt the common usage of list requires them to double in size whenever you outgrow the previous allocation, but then I hardly use lists that large, and when i do use them, i dont modify them much. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mwh21 at cam.ac.uk Fri May 5 14:36:51 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 May 2000 19:36:51 +0100 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <39116EE5.8EFE6228@san.rr.com> <39124FE6.96D041FD@Lugoj.Com> Message-ID: Alex writes: > > I like how C++ templates are Turing complete. That means trying to > > determine whether or not a C++ program will even compile is equivalent > > to the Halting Problem. > > How do you do the equivalent of a for loop using templates? Noisily; it's been a while since I played with this kind of thing, but hopefuly this will give you some idea: #include template< int N > class SumOfSquares { public: enum { val = N*N+SumOfSquares::val }; }; template<> class SumOfSquares<0> { public: enum { val = 0 }; }; int main(void) { cout << SumOfSquares<7>::val << endl; } then: [mwh21 at atrus C]$ g++ templatefun.cc [mwh21 at atrus C]$ ./a.out 140 [ God, I know C++ too well - I hadn't written any for months before that, and I get template meta-programming right basically first time... (after I remebered the syntax of enums!) ] also-known-as-"how-to-crush-your-C++-compiler"-ly y'rs Michael -- A student, in hopes of understanding the Lambda-nature, came to Greenblatt. As they spoke a Multics system hacker walked by. "Is it true", asked the student, "that PL-1 has many of the same data types as Lisp?" Almost before the student had finished his question, Greenblatt shouted, "FOO!", and hit the student with a stick. -- AI koan From hzhu at rocket.knowledgetrack.com Wed May 31 13:31:56 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Wed, 31 May 2000 17:31:56 GMT Subject: MORE INFO - Array assigment with Numeric.py References: <3933D80E.172D09F7@americasm01.nt.com> <393508AD.8FB039E@americasm01.nt.com> Message-ID: On Wed, 31 May 2000 08:42:21 -0400, Morris, Brad [WDLN2:2W40:EXCH] wrote: [snip] >i.e. there appear to be three possible shapes for a vector where x >represents the number of elements: >1) (x,) >2) (x,1) >3) (1,x) >The difference between (2) and (3) are obvious (row vs column) but I >don't >understand how (1) is different from (2) or why sometimes (1) is >returned >and other times (2) or (3). I think this is part of the problem. Try the Matrix module enclosed below that has a Matlab-like interface. The usage is ilusstrated by the self-tests. I had this problem with NumPy and struggled for weeks. It's not worth it. The new module only took me less than one day to write and it worked reasonably well. I plan to put it on sourceforge as many people seem to have similar problems. Right now this is just a wrapper around NumPy but someday someone might implement some parts directly in C. Huaiyu #!/usr/bin/env python # (C) 2000 Huaiyu Zhu . Licence: GPL # $Id: Matrix.py,v 1.3 2000-05-30 19:02:10-07 hzhu Exp hzhu $ """ Matrix class with matlab-like interface. Row vec = 1xn mat. Col vec = nx1 mat. Scalar behaves as number. Matrix multiplication follows linear algebra rules Todo: sub matrices and block matrices """ import MLab, RandomArray, LinearAlgebra, string, __builtin__ eps = 2.2204e-16 mul = MLab.matrixmultiply sol = LinearAlgebra.solve_linear_equations _time = 0 def tic(): global _time; _time = time.time() def toc(): print "time lapse =", time.time() - _time def short(x): return "%-6.4g" % x def shortC(x): return "%-6.4g%+.4gj" % (x.real, x.imag) def long(x): return "%-11.8g" % x def longC(x): return "%-11.8g%+.8gj" % (x.real, x.imag) def array2str(a, format=short): return " " + string.join(map(format, list(a))) def array2strC(a): return array2str(a, format=shortC) #------------------------------------------------------------------ class MatrixType: pass class Matrix(MatrixType): "Matrix class similar to matlab" def __init__(self, data): if type(data) == type(MLab.array([])) or \ type(data) == type([]) or \ type(data) == type((1,)): self.data = MLab.array(data) m = self.data.shape if len(m) == 1: self.data.shape = (1, m[0]) elif len(m) != 2: raise ValueError, "Matrix of shape %s"%`m` elif isinstance(data, Matrix): import copy self.data = copy.copy(data.data) elif isinstance(data, Scalar): self.data = MLab.array([[data.data]]) else: try: assert data == data + 0 except: print "data is %s" % `data` raise self.data = MLab.array([[data]]) self.shape = self.data.shape self.typecode = self.data.typecode() def __repr__(self): if MLab.sum(self.shape) == 2: return `self.data[0][0]` else: if self.typecode == 'd' or self.typecode == 'l': s = map(array2str, self.data) elif self.typecode == 'D': s = map(array2strC, self.data) else: raise TypeError, "typecode =" + self.typecode return "[" + string.join(s,'\n ') + " ]" def __getitem__(self, i): if type(i) is type(1): if self.data.shape[0] == 1: return self.data[0,i] elif self.data.shape[1] == 1: return self.data[i,0] else: return self.data[i] def __setitem__(self, i, item): if type(i) is type(1): if self.data.shape[0] == 1: self.data[0,i] = item elif self.data.shape[1] == 1: self.data[i,0] = item else: self.data[i] = item def __add__(self, other): return Matrix(self.data + other) def __radd__(self, other): return Matrix(other + self.data) def __sub__(self, other): return Matrix(self.data - other) def __rsub__(self, other): return Matrix(other - self.data) def __mul__(self, other): if isinstance(other, MatrixType): other = other.data result = mul(self.data, other) if MLab.sum(result.shape) == 2: return Scalar(result[0,0]) else: return Matrix(result) def __rmul__(self, other): "There is a bug in MLab.matrixmultiply(scalar, matrix)" if isinstance(other, MatrixType): other = other.data if type(other) == type(MLab.array([])): result = mul(other, self.data) else: result = other * self.data if MLab.sum(result.shape) == 2: return Scalar(result[0,0]) else: return Matrix(result) def __div__(self, other): if isinstance(other, MatrixType): result = solve(other.T(), self.T()).T() else: result = Matrix(self.data / other) if MLab.sum(result.shape) == 2: return Scalar(result[0,0]) else: return Matrix(result) def __rdiv__(self, other): if isinstance(other, MatrixType): result = solve(self.T(), other.T()).T() else: result = other * self.I() if MLab.sum(result.shape) == 2: return Scalar(result[0,0]) else: return Matrix(result) def __neg__(self): return Matrix(-self.data) def __pow__(self, n): return Matrix(self.data ** n) def T(self): return Matrix(MLab.transpose(self.data)) def I(self): return Matrix(LinearAlgebra.inverse(self.data)) def eig(self): return Matrix(LinearAlgebra.eigenvalues(self.data)) def real(self): if self.typecode == "D": return Matrix(self.data.real) else: return Matrix(self) def imag(self): if self.typecode == "D": return Matrix(self.data.imag) else: return zeros(self.shape) #------------------------------------------------------------------ class Scalar: "Scalar class" def __init__(self, data): if isinstance(data, Matrix): self.data = data[0] else: self.data = data def __repr__(self): if type(self.data) == type(1j): return shortC(self.data) else: return short(self.data) def __add__(self, other): return self.data + other def __radd__(self, other): return other + self.data def __sub__(self, other): return self.data - other def __rsub__(self, other): return other - self.data def __mul__(self, other): return self.data * other def __rmul__(self, other): return other * self.data def __div__(self, other): return self.data / other def __rdiv__(self, other): return other / self.data def __cmp__(self, other): if self.data < other: return -1 elif self.data == other: return 0 else: return 1 def __int__(self): return int(self.data) def __float__(self): return float(self.data) #------------------------------------------------------------------ "New matrices" def Mrange(*i): return Matrix(apply(range,i)) def zeros(a, typecode='d'): return Matrix(MLab.zeros(a, typecode)) def ones(a): return Matrix(MLab.ones(a)) def eye(a): return Matrix(MLab.eye(a)) def rand(a): return Matrix(RandomArray.random(a)) "Element-wise functions" def abs(a): return Matrix(MLab.abs(Matrix(a).data)) def exp(a): return Matrix(MLab.exp(Matrix(a).data)) def sin(a): return Matrix(MLab.sin(Matrix(a).data)) def sinc(a): return Matrix(MLab.sinc(Matrix(a).data)) def sqrt(a): return Matrix(MLab.sqrt(Matrix(a).data)) def tanh(a): return Matrix(MLab.tanh(Matrix(a).data)) "Matrices of the same shape" def sort(a): return Matrix(MLab.msort(Matrix(a).data)) def diff(a): return Matrix(MLab.diff(Matrix(a).data)) def cumsum(a): return Matrix(MLab.cumsum(Matrix(a).data)) def cumprod(a): return Matrix(MLab.cumprod(Matrix(a).data)) "Reduce to row vector" def sum(a): return Matrix(MLab.sum(Matrix(a).data)) def prod(a): return Matrix(MLab.prod(Matrix(a).data)) def mean(a): return Matrix(MLab.mean(Matrix(a).data)) def median(a): return Matrix(MLab.median(Matrix(a).data)) def std(a): return Matrix(MLab.std(Matrix(a).data)) def min(a): return Matrix(MLab.min(Matrix(a).data)) def max(a): return Matrix(MLab.max(Matrix(a).data)) def ptp(a): return Matrix(MLab.ptp(Matrix(a).data)) "Matrix functions" def expm(a): return mfunc(MLab.exp, a) def logm(a): return mfuncC(MLab.log, a) def sqrtm(a): return mfuncC(MLab.sqrt, a) def powm(a, n): return mfuncC(lambda x,n=n:MLab.power(x,n), a) "Different objects" def diag(a): return Matrix(MLab.diag(a)) def sums(a): return Scalar(MLab.sum(MLab.sum(Matrix(a).data))) def norm(a): return Scalar(sqrt(sums(a ** 2))) def mnorm(a): return Scalar(sqrt(a.T() * a)) def cov(a): return Matrix(MLab.cov(Matrix(a).data)) #------------------------------------------------------------------ "Linear Algebra" def solve(A, b): AT = A.T() return Matrix(sol((AT*A).data, (AT*b).data)) def eig(a): """Return eigenvalues as an array, eigenvectors as a Matrix Definition: a * u.T = u.T * v """ s = a.shape assert s[0] == s[1] v, u = MLab.eig(a.data) return v, Matrix(u) def svd(a): "Return Matrix u, array x, Matrix v as svd decomposition" u, x, v = MLab.eig(a.data) return Matrix(u), x, Matrix(v) def mfunc_p(f, x): "Matrix function with positive eigenvalues" (v, u) = eig(x) if v.typecode() == 'D': if norm(Matrix(v.imag)) > norm(Matrix(v.real))*1e-14: raise TypeError, "%s only applicable to real numbers" % `f` else: v = v.real print v, v.typecode() if MLab.min(v) + eps < 0: raise TypeError, "%s only applicable to positive numbers" % `f` else: uT = u.T() y = u.T() * diag(f(__builtin__.max(v,0))) * uT.I() return approx_real(y) def mfunc(f, x): "Matrix function" (v, u) = eig(x) uT = u.T() y = uT * diag(f(v)) * uT.I() return approx_real(y) def mfuncC(f, x): "Matrix function with possibly complex eigenvalues" (v, u) = eig(x) uT = u.T() y = uT * diag(f(v+0j)) * uT.I() return approx_real(y) def approx_real(x): if x.typecode == 'D' and norm(x.imag()) < norm(x.real())*1e-14: return x.real() else: return x #------------------------------------------------------------------ if __name__ == "__main__": import time, sys print "-"*40, "basic vector" a = Mrange(-1, 3) print a a [2] = 2 print a.shape, a[0,2], a[2] print "-"*40, "basic matrix" b = zeros((2,2)) b [1,0] = 1; b[0,1] = 2 print b print b.shape, b[0,1], b[1,0] print 1 + b + 1 print 2 - b - 2 print 3 * b * 3 print b / 4 print 4 / b * b print "-"*40, "arithmatic, norm" print 1.1 * Matrix(a)*2 + 2 + a print Scalar(-2) * a * norm(a) print Scalar(3)*Scalar(0.99) < Scalar(1) + Scalar(2) == Scalar(3.) \ < Scalar(3)+eps*3 print "-"*40, "special matrices" c = ones(a.shape) * 2 + zeros(a.shape) + rand(a.shape) print c print "-"*40, "transpose, multiplication" d = -a.T() print d, d.shape, a print d*c, c*d print "-"*40, "max, min, sum, cumsum" X = rand((9,4)) print X print max(X) print min(X) print sum(X) print cumsum(X) print "-"*40, "linear transform" y = X * d print y.T() print "-"*40, "eigenvalues" C = rand((5,5)) print C print C.eig() print "-"*40, "matrix function" print norm(mfunc(lambda x:x, C) - C) print "-"*40, "sqrtm, powm" A = X.T() * X B = sqrtm(A) print B, norm(powm(B,2)-A) print "-"*40, "expm, logm" print expm(C) print logm(expm(C)), norm(logm(expm(C)) - C) print "-"*40, "inverse, eye" print A.I(), norm(A.I() * A - eye(4)) print "-"*40, "solve by inverse" tic() A = X.T() * X b = X.T() * y d1 = (A.I() * b) toc() e = d1 - d print norm(e), mnorm(e) print "-"*40, "linear equation" tic() d2 = solve(X , y) toc() print norm(d2 - d), norm(d2 - d1), norm(X*d2 - y) sys.exit() -- Huaiyu Zhu hzhu at knowledgetrack.com KnowledgeTrack Corporation Tel: 925 738 1907 7020 Koll Center Parkway, Suite 110 Fax: 925 738 1039 Pleasanton, CA 94566 From mwh21 at cam.ac.uk Sun May 28 17:44:29 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 28 May 2000 22:44:29 +0100 Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> <392f60e8.260627511@news.nikoma.de> <8gs2u0$m7m$4@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > If you feed this: > > if (1 == 1) { > printf("This won't work.\n"); > } > > To C you'll get compiler errors as well if somebody removes all the '}'s. :) Only if you forget to delete the '{'. But if you feed if (test) { printf("a"); printf("a"); } to a C compiler before and after deleting all the { and }'s you get different behaviour, which IMHO is worse. Cheers, Michael -- Famous remarks are very seldom quoted correctly. -- Simeon Strunsky From db3l at fitlinxx.com Mon May 1 21:39:33 2000 From: db3l at fitlinxx.com (David Bolen) Date: 01 May 2000 21:39:33 -0400 Subject: Reading in strings -> numbers ?? References: <390A2D23.7029E557@fenx.com> <8ede36$9r6$1@nnrp1.deja.com> <300420001022354625%pecora@anvil.nrl.navy.mil> Message-ID: "Louis M. Pecora" writes: > After three weeks of learning Python have I actually found a real wart? > A common requirment in programming (especially for numerical stuff) is > to read in data that is often generated by other programs and other > people. The common form is a "table" structure: > > data11(white space)data12(white space)...data1m(return/newline) > data21(white space)data22(white space)...data2m(return/newline) > ... > datan1(white space)datan2(white space)...datanm(return/newline/EOF) > EOF > > So you're saying that reading in something as basic as this is a > "work-around?" Sigh. I definitely don't think handling a file like this is a "work-around", but that's also because I don't think it requires a direct correlation to the [f]scanf function. Assuming for the moment that your lines are columns of integers, this would be one way to process the file: import string input = open('filename') while 1: line = input.readline() if not line: break columns = map(int,string.split(line)) This handles the file row by row, so you don't have to read the entire thing into memory first. Alternatively, using "input.readlines()" would return a list of all lines from the file that you could parse or access in any order you preferred, at the expense of memory. During this process, you could use columns[x], where x was 1-m. If your columns were a single but different datatype, you could change the first argument to map() (which is the function to iterate over the list) to something else, such as float or long. The reason for the map is that splitting the string yields a list of strings, which you'll likely need to convert into some numeric type for your actual computations. You could also use the "eval" suggested by a previous poster, which would actually allow Python expressions in each column. While not quite as flexible as a *rintf-like format string, it easily handles the most common case of matrix information or other consistent data types. If your columns were more varied, then you could just do the split, and process the columns however might be appropriate for them individually. As an aside, the [f]scanf functions were never something I suggest using in C code, simply because of the possibility for buffer overruns or mismatched pointer types in the arguments, and such. They could be convenient, but they could also leave a big gaping risk point in your program if you weren't careful. I always prefer splitting and parsing the input myself (which as it turns out is a bit closer to the Python approach) for more robust code. -- -- 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 sliang at oregon-lnx.cc.gatech.edu Mon May 22 11:41:30 2000 From: sliang at oregon-lnx.cc.gatech.edu (Shengquan Liang) Date: 22 May 2000 15:41:30 GMT Subject: Weird Database/Web Problem Message-ID: <8gbkfa$4c3$1@solaria.cc.gatech.edu> under Windows 2000 I wrote a python script which runs fine in my local directory. when i tried to invoke it in a html file by it generates an error saying dbc = odbc.odbc( # open a database connection dbi.operation-error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in LOGIN how comes that happened? -- Shengquan Liang ________________________________________ gt2558b at prism.gatech.edu 332558 GA TECH STATION Atlanta,GA 30332-1450 From emile at fenx.com Thu May 18 22:15:22 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 18 May 2000 19:15:22 -0700 Subject: How to get volume name under Win32? Message-ID: <3924A3B9.255AC236@fenx.com> If you're trying this from within IDLE, try it from the interactive prompt. (i.e., in a dos window, invoke python). I'm not sure why, but I get the same thing when I use IDLE. Emile van Sebille emile at fenx.com Dale Strickland-Clark wrote in message news:<8g21kl$93j$1 at supernews.com>... > Thanks for the info but I can't get your example to work: > > >>> import os > >>> info = os.popen(r'dir c:\missing.ext').readlines() > Traceback (innermost last): > File "", line 1, in ? > OSError: (0, 'Error') > > Have I missed something? > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > From ralf.claus at t-online.de Thu May 18 16:08:42 2000 From: ralf.claus at t-online.de (Ralf Claus) Date: Thu, 18 May 2000 22:08:42 +0200 Subject: How to create an .exe file from a python script Message-ID: <8g1ilm$pou$15$1@news.t-online.com> Hello, i try to solve the following problem : How can i create a stand alone "win32" executable file from a python script? Where can i get an example? I am happy for any suggestion. From chibaA at TinterlogD.Tcom Wed May 10 15:27:55 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 10 May 2000 19:27:55 GMT Subject: HELP! Simple question re: dictionaries Message-ID: <3919b810.430052072@news1.on.sympatico.ca> Hi, I just want to write a for statement to go through each element of a dictonary. I would have assumed it would look something like this (argumentList being the dictonary): for ___ in argumentList: # whatever... ... but I'm not sure of the exact syntax. If anyone knows, could you let me know? Thanks! kc From ehagemann at home.com Sun May 14 08:33:18 2000 From: ehagemann at home.com (Eric Hagemann) Date: Sun, 14 May 2000 12:33:18 GMT Subject: help with COM and Excel Message-ID: Anybody done much with Excel and COM? I am trying to get some COM stuff working -- specifically to generate a chart I have been able to open excel, create a workbook and push data into it. Further I can create a charts but now I am stuck on how to add data to the chart. I know I need to add a 'SeriesCollection' Object but when I try .....chart.SeriesCollection.Add I get an 'attribute error'. In this context SeriesCollection referes to a function to select _which_ series collection you want (As far as I can tell) and not an object (which is what I need to attach data to). I can find the SeriesCollection Object initself and indeed it has an Add method. But I cannot seem to get to or add the object to the Chart Object. Anybody tried this already ? Cheers Eric From scarblac-spamtrap at pino.selwerd.nl Wed May 31 12:11:05 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 31 May 2000 16:11:05 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <8h34v4$7ac$1@nnrp1.deja.com> Message-ID: Michael Hudson wrote in comp.lang.python: > david_ullrich at my-deja.com writes: > > > You sure about that "n!"? Seems more like n^2 to me. > > (Of course n^2 is big, but n! would be much worse. It's > > a theorem that n! is bigger than anything.) > > n^n is worse than n!, if you're after really bad algorithmic > performance. There exists some mathematical proof, by Ronald L. Graham, about an upper bound to a certain question of Ramsey theory (I don't know more about this, this is from some web page I saved once). It uses a rather large number. Really large numbers come in Knuth notation, like 3^3 or 3^^7 or 7^^^4. Defined by the following Python function: def knuth(num, power, arrownum): if not arrownum: return num*power answer = num for i in range(power-1): answer = knuth(num, answer, arrownum - 1) return answer So 2^4 = 2 ** 4 = 16. 3^^4 = 3^(3^(3^3)) 7^^^3 = 7^^(7^^7) 3^3 = 3*3*3 = 27. Easy. 3^^3 = 3^(3^3) = 3^27 = 7,625,597,484,987. "So small I can actually type it". Still a number you can visualize somewhat, ie the gross national product. 3^^^3 = 3^^(3^^3) = 3^3^3^3^3^3^3^3^3^.....^3^3 (7 trillion threes). Too big to understand. After the first few terms you're already far above small numbers like the number of particles in the universe. But at least you can store that expression (3^3^3^3...) in eight terabytes of memory. 3^^^^3 = 3^^^(3^^^3) = 3^^(3^^(3^^(3^^..... (repeat by the amount of the previous number...)))). There are no words for this number. To get Graham's number, you take x = 3^^^^3. Next, you set x to 3^^^...(x ^'s)...^^^3. Repeat 63 times. x = 4 for i in range(64): x = knuth(3,3,x) Now *that's* a large number. Of course, most finite numbers are much larger than that ;-). i-know-no-algorithm-that's-this-bad-but-i-wanted-a-silly-math-post-ly-y'rs, Remco -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "Does Dr. McCoy know?": FASA's Star Trek: The Role-Playing Game describes the Klingon Agonizer as hand-held device 'applied to the left shoulder just above where the ear is located in humans.' From wtanksle at dolphin.openprojects.net Fri May 12 14:01:56 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 12 May 2000 18:01:56 GMT Subject: Seeds References: <000101bfbbbd$f98f62c0$9ca2143f@tim> <8ffv65$a2fnm$1@fido.engr.sgi.com> Message-ID: On 12 May 2000 03:52:37 GMT, Paul Jackson wrote: >My favorite Random Number web site (being as I am from SGI) is: > http://lavarand.sgi.com/ >Lavarand: > ...harnessing the power of Lava Lite?? lamps to generate truly > random numbers since 1996. That's cool, but I've never trusted it. Lava lamps are chaotic, but they're _slow_, and SGI actually publishes the pictures from which they derive the random data -- I can envision a program which could take those pictures, interpolate between them, and then extrapolate to the next frame. (Of course, the result with any current technology would only be a picture which was visually identical; the hash would not possibly match, so that's not yet a "security hole".) Microscopic processes, such as a group of chains of NOT gates XORed together (producing fast, chaotic oscillators), seem a lot more useful for those purposes. It's impossible to reproduce or even measure the conditions bringing about the randomness. (Plus, it's a lot cheaper and less breakable.) Slap a DES encryption or SHA-1 hash over the result, and you've got a FIPS certifiable RNG. -- -William "Billy" Tanksley From bwinton at tor.dhs.org Sun May 14 22:11:08 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Sun, 14 May 2000 22:11:08 -0400 Subject: PalmPilot and python In-Reply-To: <14617.37067.507992.310545@malibu.aero.org> References: <8fc11i$9q8$1@nnrp1.deja.com> <14617.37067.507992.310545@malibu.aero.org> Message-ID: <200005150211.WAA06994@tor.dhs.org> In comp.lang.python, you wrote: >I have ported 1.5.1 and am in the process of porting 1.5.2/1.6. Aha! So it's you! I've been eagerly awaiting this since I read of its existance on the Stackless page... Is there any way I could get a preview copy? I'ld be more than happy to beta-test. ;) (And I've been programming on the Palm since the days of the Professional, so if I find a bug, I can probably track the cause down.) Thanks, Blake. -- 9:02pm up 23 days, 1:13, 1 user, load average: 1.08, 1.02, 1.01 From andrew.henshaw at gtri.gatech.edu Wed May 24 03:29:50 2000 From: andrew.henshaw at gtri.gatech.edu (Andrew Henshaw) Date: Wed, 24 May 2000 03:29:50 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> <8gcoij$60n$1@news-int.gatech.edu> <8gdla5$nju$3@newshost.accu.uu.nl> Message-ID: <8gfiei$5fh$1@news-int.gatech.edu> Martijn Faassen wrote: >Andrew Henshaw wrote: >> Ben Cornett wrote: >>> >>>this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". >>> >> ...snip... >> The interesting thing about this is that I could read it. A case-insensitive >> compiler couldn't handle a single case flip. That's why I don't understand >> the argument that (English-speaking) humans are case sensitive. In general >> we're not. We prefer that everyone follow case-usage rules, but we don't >> require it. In my opinion, that's the way programming should work. I would >> like to read a program that followed case usage for readability; but, I >> don't want an interpreter to barf when case is ignored. > >if 1: > print "This is " > print "incorrectly indented" > print "code" > >Now let's paraphrase: > >"The interesting this about this is that I could read it. A indentation >based compiler couldn't handle a single indentation misalignment. That's why >I don't understand the argument that humans are indentation sensitive. In >general we're not. We prefer that everyone follow indentation-usage rules, >but we don't require it. In my opinion, that's the way programming should work. >I would like to read a program that followed indentation usage for readability; >but, I do'nt want an interpreter to barf when indentation is ignored." > >Do you, or do you not, think about Python's indentation system this way? > You've (basically) made this argument in other threads, but I'm glad it showed up here so that I could address it in this same context. Python's indentation rules provide for instruction grouping. There **must** be some mechanism to indicate grouping, and indentation fills that need in Python. If indentation is not used, then block tokens are commonly used. These are both acceptable solutions to the problem. Your argument seems to be incomplete in that you haven't provided a replacement solution to the grouping problem. Given this argument, one must ask "Indentation provides a reasonable solution to a difficult compilation problem, what difficult compilation problem is solved by case sensitivity?" Perhaps your solution to instruction grouping is recognition of grouping by context. If your carefully chosen example was representative of most code then I would, perhaps, agree with you. However, if your code stopped with the second print statement, or was not an artifically-separated sentence, then I would say that the flow of control was ambiguous. Andrew Henshaw From markovitch at iso.ru Thu May 18 06:46:51 2000 From: markovitch at iso.ru (Yakov Markovitch) Date: Thu, 18 May 2000 14:46:51 +0400 Subject: Auto-insert of colons in Emacs References: Message-ID: <3923CA1B.29E3941E@iso.ru> An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: markovitch.vcf Type: text/x-vcard Size: 166 bytes Desc: Card for Yakov Markovitch URL: From grisha at ispol.com Sun May 14 13:59:23 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Sun, 14 May 2000 13:59:23 -0400 (EDT) Subject: mod_python - testers needed! In-Reply-To: <20000514133334.A24345@sz-sb.de> Message-ID: On Sun, 14 May 2000, Andreas Jung wrote: > I've been using your former code for a long time in one > of my projects. And mod_python seems to be a very good successor :) > > I am currently reworking my own project PMZ (Poor Mans Zope, > pmz.sourceforge.net) to get working with Apache. However it > seems to me that your mod_python will be much better. So I can > think of an implementation of PMZ using mod_python. > PMZ is some kind of HTML-embeded Python. I will take a closer > look how it will fit together with mod_python. It would be > great to have a fast solution for combining HTML and Python > (similar to PHP3/4). What's your opinion ? I don't know what it is, but if its all written in Python - it should be fairly easily implementable as a mod_python handler? Grisha From glyph at twistedmatrix.com Sat May 13 20:52:42 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 13 May 2000 19:52:42 -0500 Subject: HEAP/priority queue In-Reply-To: =?iso-8859-1?q?Fran=E7ois?= Pinard's message of "13 May 2000 18:22:21 -0400" References: <391CA714.3EB0E8B5@san.rr.com> Message-ID: Fran?ois Pinard writes: > Courageous writes: > > > Is there a heap anywhere in the python modules? > > Here is a second draft for a simple Heap module. This one has been tested. > See the `test()' function near the end to see an example of usage. [ code ] Could someone explain to a naive programmer here what the use of that lovely structure is? I understand what is going on, just not why... -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From jkraska1 at san.rr.com Tue May 2 01:50:57 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 02 May 2000 05:50:57 GMT Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> Message-ID: <390E6D60.781DAED9@san.rr.com> > Apparently one of Guido's doubts about stackless is that it seems > impossible (or merely hard?) to replicate in JPython Impossible, I think. C/ From moshez at math.huji.ac.il Tue May 16 00:43:26 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 16 May 2000 07:43:26 +0300 (IDT) Subject: Python vs Java : GUI, drag an drop In-Reply-To: Message-ID: On Tue, 16 May 2000, Jarek Wilkiewicz wrote: > As far as the OS goes, I'd like to be able to support NT, Solaris and Linux. > Native widgets are not important. Does Gtk+ work with Windoze ? Yes. > JPython sound good for scripts, but I'm rather hesitant to use it for a > "real" application. Why? -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From nascheme at enme.ucalgary.ca Sat May 6 17:28:00 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: 6 May 2000 21:28:00 -0000 Subject: Copyright and License In-Reply-To: <000101bfb78d$a61f3cc0$452d153f@tim> References: <000101bfb78d$a61f3cc0$452d153f@tim> Message-ID: <20000506212800.7453.qmail@cranky.arctrix.com> In comp.lang.python, you wrote: >If you assert copyright, you're making a legal claim. If you want to avoid >lawyers, avoid making legal claims . What about significant contributions to Python? Do you have the sign the CNRI copyright assignment form of you place your code in the public domain? Neil -- "Life is a tragedy for those who feel and a comedy for those who think." -- Trent A. Fisher From 340083143317-0001 at t-online.de Sun May 28 14:26:09 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Sun, 28 May 2000 20:26:09 +0200 Subject: Case-sensitivity: why -- or why not? References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: <8gro8c$sk9$13$1@news.t-online.com> > For (4), > > (first, an analogy) > You've mentioned that one of the reasons for Python's asbence of > curly braces is that it limits the amount programmer conventions; for > example, in Python the following would never be an issue: > > int func( ) { } > > int func( ) { > } > > int func( ) > { > } > > (this inconsistency tends to drive me nuts for large C functions). > > Python's elimination of braces does away with this. In other words, Python > restricts the programmer, and in doing so, yields more readable code > (it narrows down the quantity of disparate styles and conventions we use). > > If Python were made case-insensitive, wouldn't that lead to more > irregular programming conventions? I would rather introduce a restricted set > of conventions so that the student wouldn't go on fragmenting > from the norm and developing their own style. That's one more > style that I have to get used to when I read their code. very good point! Maybe guido never had to deal with code written by programmers from external companies ... From tomaz.ficko at agroruse.si Fri May 5 07:12:44 2000 From: tomaz.ficko at agroruse.si (Tomaz Ficko) Date: Fri, 5 May 2000 13:12:44 +0200 Subject: Generating combinations with repetitions References: Message-ID: That's it! Thank you. Tomaz > >Ah. Then perhaps the following will do. > >Jeff Raven > From hgg9140 at seanet.com Tue May 23 18:37:26 2000 From: hgg9140 at seanet.com (Harry George) Date: 23 May 2000 15:37:26 -0700 Subject: help with PYTHONHOME / unix References: <20000523.12035000@rfhsun1.rfhsm> Message-ID: This is typically done in your shell resource file, in your home dir. If you happen to have Beazley's Essential Reference (which is a good idea), see pg 84. For csh or tcsh, edit ".cshrc": setenv PYTHONHOME /opt/python For bash edit ".bashrc"; for ksh edit ".kshrc": export PYTHONHOME=/opt/python In both cases, PYTHONHOME can point to the general python home (as above) or to both the general home and the exec home, by doing a path concatenation, e.g.: export PYTHONHOME=/opt/python:/usr/local/my_special_python You will have to "source" the "rc" file before it will take effect -- the easiest way may be to just log out and log back in. Frank Mattes writes: > Hi all, > > I'm new in this group and my question might be silly for most of us, > however I could't find > the answer on the net. > I'm compiling a program "pybliographer-1.0.0" which needs python > 1.5.2. I have installed python from the binaries on my hp-ux, which > has a slightly different install tree. > > Python is installed in > > /opt/python > > with > > /opt/python/bin <------ the program > /opt/python/lib/python1.5 <------ the lib files > /opt/python/include/python1.5 <------ the include files > > the "configure" script gives the following error: > > checking for python... /opt/python/bin/python > checking python version... Could not find platform dependent libraries > > Consider setting $PYTHONHOME to [:] > 1.5 > checking python devel... Could not find platform dependent libraries > > Consider setting $PYTHONHOME to [:] > found > > However I don't know how to set-up the variable. > > Can anybody help me. > I appreciate any help > > Frank > Department of Virology > Royal Free Hospital, London > > > -- Harry George hgg9140 at seanet.com From bwarsaw at python.org Wed May 31 13:35:36 2000 From: bwarsaw at python.org (Barry A. Warsaw) Date: Wed, 31 May 2000 13:35:36 -0400 (EDT) Subject: [Python-Dev] What's that sound? References: <39353CCD.1F3E9A0B@prescod.net> <14645.17611.318538.986772@anthem.python.org> <393547A2.30CB7113@prescod.net> Message-ID: <14645.19816.256896.367440@anthem.python.org> >>>>> "PP" == Paul Prescod writes: PP> Look closer, big-egoed-four-stringed-guitar-playing-one. It PP> could just as easily be a J. Could be! The absolute value of my diopter is about as big as my ego. PP> And you know what you get when you put P and J together? A very tasty sammich! -Barry From scarblac-spamtrap at pino.selwerd.nl Mon May 1 14:49:34 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 1 May 2000 18:49:34 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <300420001008012011%pecora@anvil.nrl.navy.mil> <8ek3as$f0e$2@newshost.accu.uu.nl> Message-ID: Samuel A. Falvo II wrote in comp.lang.python: > In article <8ek3as$f0e$2 at newshost.accu.uu.nl>, Martijn Faassen wrote: > >In what way is 'cmd' hungarian notation? There's no prefix anywhere, unless > >it's all prefix. :) > > cmd is the type of string being sent to it, so it'd be all prefix (examples > in Windows would be a variable named hwnd instead of hwndDialogBox). So it's a count of... what's md? -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From tim_one at email.msn.com Sat May 13 00:56:32 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 00:56:32 -0400 Subject: NaN again - and IEEE arithmatics In-Reply-To: Message-ID: [posted and mailed] [Huaiyu Zhu] > Sometime ago I asked about reading back from a file containing arrays with > NaN as elements. Someone kindly suggested > > >>> from math import exp > >>> NaN = exp(1000)/exp(1000) > >>> NaN > nan > > However this breaks in 1.6 (or maybe because it is installed on another > machine). Different machine sounds more plausible. Python itself knows nothing about NaNs, and all visible behavior wrt them is a platform-dependent accident. > >>> import math > >>> NaN = math.exp(1000) / math.exp(1000) > Traceback (most recent call last): > File "", line 1, in ? > OverflowError: math range error > > Any suggestion of how to deal with it in this case? Is there a > generic way? THere's nothing you can do that's guaranteed to work. Here's a way to make a NaN that's quite *likely* to work on any IEEE-754 platform, though: >>> Inf = 1e300**2 >>> NaN = Inf - Inf >>> NaN -1.#IND >>> Inf 1.#INF >>> Since that was a Windows session, that's how Microsoft happens to spell NaN and infinity these days. > If I understand correctly, NaN is a standard feature in IEEE > floating point arithmatics. Yes. > So why isn't there a predefined class or object for NaN? Basically because IEEE-754 is primarily a hardware standard. The things it defines may as well not exist if your *software* doesn't know about them. In Python's case, Python is implemented in C, and it's C that provides no portable way to get at this stuff. So Python can't either, at least not without a huge pile of #ifdef's, one for each platform, and enough different people volunteering with the right combination of platform + 754 expertise to write all that crap. The next iteration of the C standard is supposed to address this. Then it will be much easier to address it in Python too. In the meantime, you're really on your own with this stuff, be it from Python, Perl, C, C++, Fortran, ... hard-to-express-what-there-are-no-words-for-ly y'rs - tim From anthony at interlink.com.au Mon May 8 06:49:03 2000 From: anthony at interlink.com.au (Anthony Baxter) Date: Mon, 08 May 2000 20:49:03 +1000 Subject: snmplib? In-Reply-To: Message from Siegmund Fuhringer of "Mon, 08 May 2000 09:39:18 +0200." <20000508093918.D15702@debian.atnet.at> Message-ID: <200005081049.UAA12645@mbuna.arbhome.com.au> There will be a (long overdue) update to SNMPY by the end of this week - keep an eye on snmpy.sourceforge.net. Anthony >>> Siegmund Fuhringer wrote > hi! > > i was unable to find a snmplib! is there anywhere a snmplib available? > > bye... sifu > > -- > http://www.python.org/mailman/listinfo/python-list > -- Anthony Baxter It's never too late to have a happy childhood. From intmktg at Gloria.CAM.ORG Mon May 29 16:16:09 2000 From: intmktg at Gloria.CAM.ORG (Marc Tardif) Date: Mon, 29 May 2000 16:16:09 -0400 Subject: retrieving from list Message-ID: If I have a multi-level list in a function, how can I pass some argument to the function in order to retrieve a specific member of the list? For example, supposing I have: def func(arg): a = [] a.append('foo') b = [] b.append('bar') a.append(b) # now I have a = ['foo', ['bar']] return a[arg][arg] The last line is where the problem lies. How can 'arg' be able to refer to 'foo' or 'bar'? Should 'arg' be a string of comma seperated values which would be parsed within the function in order to refer to the proper member of the list? For example, '0' for 'foo' and '0,0' for 'bar'? Any ideas to solve this little problem would be much appreciated, Marc From gmcm at hypernet.com Fri May 19 23:27:47 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 May 2000 03:27:47 GMT Subject: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3o85$esa$1@news.hants.gov.uk> Message-ID: <39260633$0$19925@wodc7nh7.news.uu.net> Graham Bleach wrote: >One of the most interesting ideas I have had recently was provoked by an >article I read (I think by one of the leading Gnome developers). He argued >that it should indeed be possible to do all that is possible on the command >line in a GUI, with the same flexibility. Visual query builders are an excellent example of the limits of this idea. They're great for those not fluent in SQL, but they're a hindrance to those who are. Not all algebraic problems can be expressed geometrically. - Gordon From relder at omegabit.com Fri May 12 08:35:29 2000 From: relder at omegabit.com (Rob Elder) Date: Fri, 12 May 2000 05:35:29 -0700 Subject: os.path.exists() error Message-ID: Hello, A file is created using (mac): output = open('ArtEngine:Desktop Folder:testFile','w') ... output.close() The file is created and is readable. Then using: temp = os.path.exists('ArtEngine:Desktop Folder:testFile') I would expect to get a logical response stored in "temp" but instead get a general interpreter error. I have tried to resolve this by searching the online info but can't see through the problem. How is this suppose to work? TIA. -r From emile at fenx.com Wed May 10 11:02:34 2000 From: emile at fenx.com (emile at fenx.com) Date: Wed, 10 May 2000 08:02:34 -0700 Subject: member by member copy??? Message-ID: <39197A0A.46C548BF@fenx.com> You could create a separate instance, or provide a copy function as part of the class. >>> a = A('bragi') >>> b = A('') >>> b.name = a.name >>> b.name 'bragi' >>> a.name = 'stini' >>> b.name 'bragi' >>> >>> class A: def __init__(self,name): self.name = name def copy(self): retval = A(self.name) # other copy functions return retval >>> a = A('bragi') >>> b = a.copy() >>> b.name 'bragi' >>> a.name = 'stini' >>> b.name 'bragi' >>> HTH Emile van Sebille emile at fenx.com wrote in message news:<8fbska$4ti$1 at nnrp1.deja.com>... > How do I copy on object into another without having them > refer to each other. > Example: > > >>> class A: > ... def __init__(self,name): > ... self.name = name > ... > >>> a = A('bragi') > >>> b = a > >>> b.name > 'bragi' > >>> b.name= 'stina' > >>> a.name > 'stina' > > I would have liked to see > >>> a.name > 'bragi' > > How do I do this? > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > From dalcolmo at mediaone.net Tue May 2 20:22:42 2000 From: dalcolmo at mediaone.net (Josef Dalcolmo) Date: Wed, 03 May 2000 00:22:42 GMT Subject: Numpy, map Message-ID: Hello, NumPy Wizards! I am still missing something equivalent to map() When I define a function, it is not always possible to use only ufuncs for it. When I then want to apply such a homemade function to an array, I either have to loop, or to map and then convert. I wish there was something like 'amap()', which takes an arbitrary function and returns an array. - Josef From nanotech at pacifier.com Sat May 27 20:42:27 2000 From: nanotech at pacifier.com (noone) Date: 27 May 2000 17:42:27 -0700 Subject: Scoping: Is Python and does it matter? References: <392C3782.3675@europa.com> <392d1d14$0$23937@wodc7nh0.news.uu.net> Message-ID: <39306b73$1_1@news.nwlink.com> gmcm at hypernet.com (Gordon McMillan) writes: >Quentin Crain wrote: >>In Perl one may do something like: >> >>$success=1; >>foreach ... { >> my($success); # $success is "local" to this loop >> . . . >>} >>print $success; # $success holds whatever value it did before >>In Python, loops have no scope. Correct? >Right - Python does not have a separate scope for code inside a >loop. >>Does this matter? What do the "experts" do in cases like this? >In this particular case, there's a nice idiom that makes a flag variable >unnecessary: >for ...: > if : > break >else: > # never hit the break > print "succeeded!" I am attempting to get the word out about Python in my company. We use a lot of Perl. Whitespace is NOT a concern but scoping seems to be. What is Python's philosophy? Guido has a whitepaper on Style; has he or someone done one on Scoping? Here is another example that concerns my coworkers (though I have not had this issue, do not see the issue, and would not code this way--what can you do?!!): Python 1.5.1 (#37, Apr 27 1998, 13:36:17) [CW CFM68K w/GUSI w/MSL] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> x=1 >>> def print_X(): ... print x ... >>> print_X() 1 >>> def print_X(): ... print x ... x=2 ... >>> print_X() Traceback (innermost last): File "", line 1, in ? File "", line 2, in print_X NameError: x >>> In Perl, the second 'print_X' would succeed because 'x' would be found in the outer scope. Python scopes the var to the function due to the assignment (it seems). One could use 'global', but then the assignment would affect the module var (where in Perl, the assignment might be my($x)=2, in which case the "global" x would not be modified). Again, I am looking for Python's philosophy (reasoning, excuses, whatever! :) so that my coworkers will switch and I will not have to look and ugly/bad code because it was fast hacked! Thanks!! Quentin ('Q') >- Gordon Thanks again Gordon for your time! -- ------------------------------------------------------------------------- I think we are miscommunicating. I actually expected some confusion with my last response and I am not sure if there actually was some, but I feel like it. So, my message is going to assume I did not make my points, but From rpm at wag.caltech.edu Wed May 10 12:24:37 2000 From: rpm at wag.caltech.edu (Richard P. Muller) Date: Wed, 10 May 2000 09:24:37 -0700 Subject: Python Short Course Report and Lecture Two Message-ID: <39198D45.66939084@wag.caltech.edu> The first lecture in my Python Short Course went very well. I spoke to a standing-room-only crowd! I would like to thank all of the helpful people who responded with suggestions. The second lecture is on Numerical Python. I'm covering the Numeric and LinearAlgebra modules, with a focus on quantum mechanics applications, since that's what I do. The slides are available at http://www.wag.caltech.edu/home/rpm/python_course (html, pdf, and ppt formats) in case anyone wants to use them in a similar course. I would again welcome any suggestions anyone has on how to make the course better. Rick -- Richard P. Muller, Ph.D. rpm at wag.caltech.edu http://www.wag.caltech.edu/home/rpm From brandonirons at topmail.de Tue May 30 15:41:46 2000 From: brandonirons at topmail.de (Brandon Irons) Date: Tue, 30 May 2000 19:41:46 GMT Subject: os.linesep under Windows Message-ID: import os import sys sys.stdout.write( os.linesep ) Under Windows, run this program with: python test.py > huh.txt The result is a file size of 3 (not 2) for huh.txt. This is because sys.stdout.write( os.linesep ) is equivalent to: sys.stdout.write( os.linesep[0] ) # aka '\015' sys.stdout.write( os.linesep[1] ) # aka '\012' and, apparently, when writing a '\012' to stdout, this is expanded to: 0D 0A When writing os.linesep, I expect to get: 0D 0A in the output (under Windows.) Instead I get: 0D 0D 0A. So now I have hard-coded my newline because I can't use os.linesep. NL = '\012' sys.stdout.write( NL ) # yields the expected 0D 0A So what use is os.linesep if it works in a useless manner under Windows? oBrando From dana at oz.net Wed May 10 01:52:24 2000 From: dana at oz.net (Dana Booth) Date: 10 May 2000 05:52:24 GMT Subject: Why should I switch to Python? References: <3919D30A.74DE@seebelow.org> Message-ID: <8fateo$5h1$1@216.39.141.21> Grant Griffin wrote: GG: Like you, I have been doing Perl for about 3 years. It's a wonderful GG: thing for what it is, but having discovered Python, I now consider GG: myself a "Perl Refugee". Python is like Perl--except without so much GG: "Perl". What could be better?! I'm a fan of any scripting language that's easy to learn. :) Hence, I love Perl, Python, and TCL. One of the things I really dig about Python is that it seems like such a perfect mix of traditional C style coding, and the ease of high level languages like Perl and TCL. -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From jeffp at knowwonder.com Mon May 15 13:44:00 2000 From: jeffp at knowwonder.com (Jeff Petkau) Date: Mon, 15 May 2000 10:44:00 -0700 Subject: The REALLY bad thing about Python lists .. In-Reply-To: <20000515092243.S13281@xs4all.nl> Message-ID: <002801bfbe95$277978e0$9401000a@knowwonder.com> Thomas Wouters sez: > On Mon, May 15, 2000 at 12:03:08AM +0000, Jeff Petkau wrote: > > [jp] building two lists in parallel, realloc() doesn't get > > so lucky and growing the list is O(N^2). > > I'd consider this a bug in Python. > [tw] Really ? Why ? The code isn't wrong, is it ? It's merely > suboptimal in some cases. If lists were to double instead > of grow by 100 elements, you would get suboptimal > performance in other cases. If you really need this speed, > and frequently double the lists size, either use extend or > dont use lists use arrays or write your own C extension to > do the handling. > > I doubt the common usage of list requires them to double in > size whenever you outgrow the previous allocation, but then > I hardly use lists that large, and when i do use them, i dont > modify them much. It's merely suboptimal, yes, but it's *severely* suboptimal in the very common case of appending to a list, and a much better solution is known. It's no different than if list.sort() was O(N^2)--it's just a speed difference, but it's a huge one with a well known good solution. (Also, if you really can't stand the thought of lists sometimes overallocating by a factor of 2, note that any exponential growth will give you nice constant-time appends, just with a higher constant. So you can grow by a factor of, say, 1.25 instead. Saves a bit of memory but a bit slower.) I wrote a patch for this last night. Now to figure out how to send the thing in... --Jeff (jpet at eskimo.com) From shapr at uab.edu Wed May 24 19:18:36 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 24 May 2000 23:18:36 GMT Subject: Pass by reference? References: <8ghcq1$opl$1@supernews.com> Message-ID: <392C683E.AF7398D4@uab.edu> Dale Strickland-Clark wrote: > > How do I pass a value by reference so the called routine can update it? > > Here's an extract from a routine that uses ADO on NT to access a database. > ADO will return the number of records deleted in the second parameter but > it's not working like this. > > DBCon.Execute("delete from parts where path='%s' and drive='%s'" % > (drive, path), delcnt) That's not enough information for me to figure out what's wrong... can you post five to ten lines of code and what you think they should do? for every case I've ever seen, pass by reference is the norm in python. you can explicity make a copy of a variable if you like though. here's a quick demo using the 'is' operator: class TestClass(): def update(self, val): self.strx = val >>> testy = TestClass() >>> x = 4 >>> testy.update(x) >>> x is testy.strx 1 The 'is' operator returns 1 (aka true) if the two references point to the same thing, which means they 'is' the same thing. I've heard that the Redneck version of Python (they read Py3K as PyKKK) returns "ain't" for false. I-have-the-right-to-make-fun-of-my-home-state!'ly y'rs -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre Control - 9 out of 10 Freaks prefer it. From m.faassen at vet.uu.nl Tue May 16 06:28:07 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 May 2000 10:28:07 GMT Subject: python improvements (Was: Re: New Language) References: <8fpfoj$e0m$1@nntp6.u.washington.edu> <8fpnc6$o8u$1@newshost.accu.uu.nl> Message-ID: <8fr7rn$7eo$1@newshost.accu.uu.nl> Bernhard Herzog wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: >> Russell E. Owen wrote: >> [snip] >> > - class methods (e.g. ClassName.doSomething(...)). Often useful where >> > global functions might otherwise be wanted. By requiring the class name >> > one gets namespace protection and categorizes the function as relevant >> > to objects of the given class. >> >> Hm, how would this provide you with more namespace protection than the >> current module system? By being in the same module, a function also >> gets categorized as relevant to objects of the classes defined in the >> module, too.. > I used to think this too, but recently I actually had a situation where > class methods would have been useful. I had a list of classes, so the > classes were effectively anonymous and I didn't know where each class > came from, yet I wanted to get some class specific information that I > wanted to compute at that time and not at class creation time (when the > class statement is executed). Right, that's a good point. > I couldn't just instantiate the classes to get at real methods because > the constructors required some arguments I couldn't supply at that time > and while it's possible to get at the module the class was defined in[1] > but I didn't want to rely on that. You could give each class a list of associated module level functions, I suppose, though? > In that situation, real class methods would have been useful and cleaner > than any other solution. In the end, I fell back to normal class > attributes that are computed at class definition time because it works > well enough for the time being. Right, I'd agree class methods would be a cleaner solution here. I don't think that other potential solutions are that much worse, though. But you're right, this is an example of when they'd be convenient. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From petersc at stud.ntnu.no Sat May 20 03:03:26 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Sat, 20 May 2000 09:03:26 +0200 Subject: Checksum routine - new to Python References: <8g1no6$8uc$1@supernews.com> <3924D14D.85BF9A35@stud.ntnu.no> <20000519120721.D13281@xs4all.nl> Message-ID: <392638BE.DD502E36@stud.ntnu.no> Guido van Rossum wrote: > > Note that this is the same crc32 algorithm as the one in zlib! (Dunno > about which is faster, but I wouldn't be surprised if they both derive > from the same code as well.) Excuse me, but how can you be sure it is the same algorithm? As far as I can read the sources to zlibmodule.c it uses the function crc32 defined in zlib.h of the underlying platform. Now I would almost dare to bet that any sane system uses the standard algorithm in its zlib, but who can tell? gotten-careful-about-inheriting-from-platform-behaviour-ly y'rs P.S.: Just being curious: Is there a problem with my arraymodule patches for index,count,remove and pop? -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From thiele at muc.das-werk.de Wed May 24 16:10:32 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 24 May 2000 22:10:32 +0200 Subject: What's in a name? References: <392c17d3$0$17863@wodc7nh7.news.uu.net> Message-ID: <392C3738.58C41202@muc.das-werk.de> > > > 1. Remove a (potential) hurdle for new programmers. > I really don't undersytand why case-sensitivity should be a hurdle? Is orthography a hurdle to learn reading and writing? From wmcclain at salamander.com Tue May 9 14:50:57 2000 From: wmcclain at salamander.com (Bill McClain) Date: Tue, 09 May 2000 18:50:57 GMT Subject: How to use nntplib efficiently? References: <39183DE8.A911F9D3@erols.com> Message-ID: In <39183DE8.A911F9D3 at erols.com>, ""Edward C. Jones" " wrote: > I have written various special purpose news-downloading programs. > It appears that my code downloads headers slower than Netscape > for Linux. What is the best way to download new headers? My ISP > does not allow the "newnews" command. I keep track of the first and last article numbers returned by "group" and use "xover" to fetch headers in the ranges I haven't yet retrieved. Normally, I get only the range "higher" than my last highest article, but I also have a "backfill" mode to fill in gaps in article sequencing, which seems to be a big problem these days. I haven't timed it, but it seems fast to me. Mail me if you would like source. -Bill From c.evans at clear.net.nz Wed May 10 06:02:07 2000 From: c.evans at clear.net.nz (Carey Evans) Date: Wed, 10 May 2000 10:02:07 GMT Subject: ftp return format References: <87em7eeq99.fsf@psyche.evansnet> Message-ID: <873dnq910g.fsf@psyche.evansnet> "Richard Chamberlain" writes: > OK that sounds about right - I installed the Client Access ODBC drivers and > was able to return correct data. > > Is there anyway I can do this without having to install Client Access and an > ODBC driver on each client? Hmm, where I work it's getting Python installed that's the problem. ;) Here's a few ideas, not all of them particularly helpful: ? Parse the data as the other posts suggested, including the }JKLMNOPQR sign character, and hope you don't get any packed decimal in the future. ? FTP the data in binary, so you don't have to worry about the EBCDIC -> ASCII conversion making things more confusing. I posted a couple of functions here a few weeks ago to help with this. ? Get the Client Access Express manuals and RedBook (all available for download as PDFs) and automate the ODBC install so that you don't have to click on half a dozen dialog boxes to install it. ? Use CPYTOIMPF on the AS/400 to copy the data into a different format in a stream file, then use FTP or NetServer to download this file. You can submit remote commands over an AS/400 FTP session, so you could do this on request from the Python program. ? Write a program on the AS/400 that will return the data in a useful format when you connect to it over TCP/IP. ? Run the program under JPython and use the AS/400 Toolkit for Java classes to connect to the AS/400 (this works, I've tried it). ? Download the Java source for the Toolkit for Java and port it to Python. :) This would be a rather large job... -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "I'm leaning towards blind panic myself." From cut_me_out at hotmail.com Wed May 31 12:22:49 2000 From: cut_me_out at hotmail.com (Alex) Date: 31 May 2000 12:22:49 -0400 Subject: Please help with python extension problem Message-ID: Hi. I am having trouble using the Makefile.pre.in file to compile a dynamically loaded python extension. When I run the command Makefile.pre.in -f boot I get this error: /usr/lib/python1.5/config/makesetup \ -m Makefile.pre -c /usr/lib/python1.5/config/config.c.in Setup -n (...other Setup files elided) Bad word tuplesmodule.c*noobjects* in tuples tuplesmodule.c*noobjects* make[1]: *** [Makefile] Error 1 make[1]: Leaving directory `/d/alex_c/mouse/tuples' make: *** [boot] Error 2 I have fiddled around with makesetup a bit, printing out variables, and it seems as if makesetup actually thinks it's reading the line "tuples tuplesmodule.c*noobjects*" from my Setup file. However, there is no such line. Here is my actual Setup file: ''' *shared* tuples tuplesmodule.c ''' Can anyone tell me what I ought to do, here? Alex. From m.faassen at vet.uu.nl Mon May 15 06:14:48 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 May 2000 10:14:48 GMT Subject: Seeds References: <000101bfbbbd$f98f62c0$9ca2143f@tim> Message-ID: <8foimo$31m$2@newshost.accu.uu.nl> Fredrik Lundh wrote: > Tim Peters wrote: >> 2. For one random bit, provoke Fredrik on c.l.py. Note whether he >> laughs or snips back. > RFC 1750 provides a whole lot of information on this topic: > http://www.faqs.org/rfcs/rfc1750.html > "Computer clocks, or similar operating system or hardware values, > provide significantly fewer real bits of unpredictability than might > appear from their specifications." No laughing. No snipping. So that was the third state of the bit, right, Tim? [watches comp.lang.python drift into discussion of trinary logic, old hardware which supported this, department of defense plans for trinary machines that could survive a direct nuclear strike, mathematical consequences of it all, and whether 'trinary' is the right word for it at all] Or is Fredrik claiming he's a "computer clock, or similar operating system or hardware value" here? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From effbot at telia.com Thu May 11 10:13:44 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 11 May 2000 14:13:44 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> <8fee9t$csg$2@newsserver.rrzn.uni-hannover.de> Message-ID: Bernhard Reiter wrote: > >> The FreeGIS Project (freegis.org) > > > > Yikes! I hope there isn't somebody out there working on an > > open-source Regis-Philbin-bot. > > I don't get it. > Please explain. freegis = free regis? do you have the "Who Wants To Be A Millionaire" show in germany? (we have it here in sweden...). Regis Philbin is hosting the US version of that show. see also: http://www.smashregis.com From jbauer at rubic.com Thu May 4 22:40:38 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 04 May 2000 21:40:38 -0500 Subject: How to get terminal width? References: <8457258D741DD411BD3D0050DA62365907A13B@huina.oceanic.com> <8epl60$1b42$1@nntp6.u.washington.edu> <8es8fr$rjm$1@nntp6.u.washington.edu> Message-ID: <391234A6.1AB90028@rubic.com> Donn Cave wrote: > Quoth newsbunny at noether.freeserve.co.uk (Martin P Holland): > | stty size > | > | just gives the rows and columns here (linux) but may be this is > | not standard. > > It looks pretty good to me! Ultrix 4.2, Digital UNIX 4.0, AIX 4.2, > HP/UX 10.20, FreeBSD 4.0, 2 versions of Linux and BeOS 4.5 pass on > this one, and that's all I can dig up to try, so it looks to me like > the best bet so far. Easiest to handle in Python, too. Donn/Martin: It fails on Solaris 2.6 (and probably other versions of Solaris): $ stty size unknown mode: size $ stty ispeed 88840 baud; ospeed 88824 baud; -parity cstopb hupcl loblk rows = 24; columns = 80; ypixels = 274; xpixels = 490; quit = ; erase = ^h; swtch = ; -inpck -istrip icrnl -ixany ixoff onlcr echo echoe echok echoctl echoke iexten However, it might be worth coding a special stty.py module to hide platform differences, similar to what Marc-Andre Lemburg has done with platform.py. Jeff Bauer Rubicon Research From thomas at cintra.no Thu May 4 10:16:33 2000 From: thomas at cintra.no (‘5ŰHH575-UAZWKVVP-7H2H48V3) Date: Thu, 04 May 2000 14:16:33 GMT Subject: Map lots of words to lots of integers References: <39176ae0.613278087@news.online.no> Message-ID: <39188472.619823849@news.online.no> On Thu, 4 May 2000 09:28:42 -0400, "Warren Postma" wrote: >> >> I need a fast way of mapping words to integers. A single word must be >> able to point to many, *many*, integers. Tried stuff like a dict, >> words as keys, pointing to a list of integers. This is all fine and >> nice if the thing is located in memory. I want to (or need ) to store >> all of this on disk. And the method must be fast. Thought I could use >> a Berkley DB file using words as keys, but what should they point to? > >I use the Berkely DB Version 2.0 - the version that ships with Python 1.5 is >very old, archaic even. Hopefully Python 1.6 or later will actually be up >to date. Look for Robin Dunn's precompiled BSDDB 2.x for Python. > >The berkeley db is very fast on both insert and retrieve of data, the key >can be any string. For my own combination of speed and flexibility, I use a >marshalled key and marshalled data tuple, and return the whole row as a >list. In my database application, I have rows of N columns, arranged with N >key fields first (I sometimes have more than one field forming my primary >key) and append the lists together when I get the row from the database like >so: > >row = marshal.loads( key) + marshal.loads( bsddb[key] ) # unmarshal key list >and append the data list. > >To store a row, I store it like this: > >bsddb[ marshal.dumps( row[1:keycount] ) ] = marshal.dumps( row[keycount:] ) > >I have wrapped this all in a class, by the way, because this would otherwise >be UGLY! > >Anyways, the row objects I deal with are lists, with key fields followed by >data fields, and my row object has an attribute called keycount allowing me >to split the rows for most efficient storage. Storing the key data as part >of the rest of the row is redundant and wasteful. here's a sample row: > >[ 'key field 1', 'key field 2', 1,2,3,4,5,.... ] > >Assuming the key was composed of a list of two items, followed by N data >values of any primitive Python type. > >I think Marshalling is a wee bit faster than cPickle, if all you need is a >flat array of simple Python types, no class instances, etcetera. I chose to >do it this way rather than use dbShelve, because I found pickling wasteful >and too large for my embedded system, which is constricted for storage >space. If the right side of your bsddb is always going to be integers, you >could use something else on the right side instead of marshal, such as >xstruct, or some other binary array manipulation. > >If you want some sample code, feel free to email me and I'll send it to you. > >Warren > That looks like my last approach. Used dbhash and stored stuff like db[key] = [(321,32,473),(54,543,34),(543543,5453,43)] Each tuple forms an id. 1. Would it make any sense to pickle/marshall the list before storing it? 2. What if the list is HUGE? It`s read from disk, but still; it gotta go into memory. How many ids can I store like this using tuple of integers before we`re talking about gigabytes of data or the will the size of data affect the speed of lookups? I mean, then the list of tuples/integers are several megabytes, if not hundred of megabytes, won`t the damn thing eventually crash and burn? In my application I need to make an intersection of several lists returned from lookups in the database, so if they`re all huge I might run out of memory. I`m indexing files on cd-roms and the number of ids can be up into the millions. Thanks for your input. Thomas From felixt at dicksonstreet.com Tue May 9 21:57:28 2000 From: felixt at dicksonstreet.com (Felix Thibault) Date: Tue, 09 May 2000 20:57:28 -0500 Subject: Figuring out an object's type In-Reply-To: <8fab7p$4kh$1@bob.news.rcn.net> Message-ID: <3.0.5.32.20000509205728.009bb3f0@mail.dicksonstreet.com> At 19:40 5/9/00 -0500, David Allen wrote: >Hello, > >How can a python programmer figure out the type of an object? I >read the library reference, and the only helpful thing was the type >library > >from types import * >type(someObject) > >etc. But types doesn't seem to distinguish between different types >of user defined classes. I.e. if I say: > >class Foobar: > pass > >class Baz: > pass > >x = Foobar() >y = Baz() > >then type(x) == type(y) yeilds 1. > >Which kinda sucks. :) > >How do I tell the difference between a Foobar and a Baz? >Is there some way each class can have a unique typename, so >I can do something like: > >def someFunction(arg): > if type(arg) == SomePredefinedObject: > doSomething() > elif type(arg) == Foobar: > doSomethingElse() > >etc. Besides comparing arg.__class__ to Foobar, you can also use the isinstance built-in function, which works for classes or types: >>> class Empty: pass >>> e = Empty() >>> isinstance(e, Empty) 1 >>> isinstance([1,2,3], types.ListType) 1 and is true for superclasses, as well... >>> class HalfEmpty(Empty): pass >>> h = HalfEmpty() >>> isinstance(h, Empty) 1 -Felix >Any help would be appreciated. >-- >David Allen >http://opop.nols.com/ > >-- >http://www.python.org/mailman/listinfo/python-list > > From akuchlin at mems-exchange.org Sun May 7 10:11:51 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 07 May 2000 10:11:51 -0400 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39143EA4.556B4743@tismer.com> <39144E9E.4928C7E2@tismer.com> Message-ID: <3dln1m1mc8.fsf@newcnri.cnri.reston.va.us> Christian Tismer writes: > Glyph Lefkowitz wrote: > > > > Christian Tismer writes: > > > > > Well, I got the Kaffe sources. This was easy. > > > > Yay open source! Kaffe is really quite nice. I hear they've even > > fixed the lack of BigDecimal, etc... > > > > > Now I'm trying to get the Blackdown Sources, since I'd like to read > > > the green threads implementation. These should be sitting in some > > > patches, I think. Whether I'll work on either of them is still > > > open, but I want to read them. > > > > I'd recommend against reading them. They will make your brain dirty, > > in two ways: you will have to look at Sun source code (green_threads > > was not implemented by blackdown) and you will end up being unsuitable > > for cleanroom efforts such as Kaffe and Classpath. > > Aaahh. Good advice. Is Classpath something where I > should look at, too? Probably not; it's an effort to write an LGPL'ed version of Sun's APIs, so no VM work is required. (http://www.classpath.org) BTW, another Java VM is Japhar (www.japhar.org). I can't say which VM is more complete, or more commonly used. And can either of them handle JPython at this point? (It's surprising how anemic the free Java projects are. Classpath's most recent snapshot release is dated 1999-02-06, over a year ago; the last Kaffe release was in October, and the last Japaher release in March 1999. I would think that a Java VM + API, because the APIs are so large and can be developed incrementally, would be really suited to frequent smaller releases.) --amk From mwh21 at cam.ac.uk Thu May 4 09:52:29 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 May 2000 14:52:29 +0100 Subject: n = lambda x: print x References: Message-ID: "Warren Postma" writes: > In a moment of perverse glee, I decided to type the statement in to see what > it does. The question I wondered was, if Python accepted this: > > n = lambda x: print x > > What would it do with this: > > n = (lambda x: print x,y) > > Is the comma part of the print statement, or would n become a tuple of two > values? :-) > > Is the first construct s pecifically disallowed in the python grammar > somehow? print is a bit of a weirdball function in that it is invoked > without parenthesis. (The most BASIC-like feature of Python). It's not a function, it's a statement (like exec, though that was once a function). And you can't have statements in lambda expressions. FWIW, "lambda" binds tighter than ",": >>> lambda x:1,1 ( at 812a220>, 1) > Could we in fact say that if fewer exceptions to rules makes a language > simpler then the PRINT statement is a bad idea and a PRINT( x,y,z) function > would have been a much better idea? >From http:starship.python.net/crew/amk/quotations/python-quotes.html: I mean, just take a look at Joe Strout's brilliant little "python for beginners" page. Replace all print-statements with sys.stdout.write( string.join(map(str, args)) + "\n") and you'll surely won't get any new beginners. And That Would Be A Very Bad Thing. Fredrik Lundh, 27 Aug 1996 I.e. print is a convenience. Python generally emphasises consistency over convenience, but in this case, the convenience functionality is so convenient it has been included. > Why did Guido not parenthesize arguments to PRINT when designing Python? Maybe so you can do >>> print 1, ? I don't really know. > Look, a Syn! Otherwise, this language is perfect. No, it isn't; but there's another quote about Python that I like very much (I have lots of these): Python is a language that gets its compromises exactly right. I think that on was Don Beaudry, but I'm not sure. I'd like multimethods, myself. > ;-) I love Python. So do I. Cheers, Michael -- I saw `cout' being shifted "Hello world" times to the left and stopped right there. -- Steve Gonedes From claird at starbase.neosoft.com Fri May 19 09:53:28 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 May 2000 08:53:28 -0500 Subject: Decimals to fraction strings References: <8fu1e3$3h4$1@news.wrc.xerox.com> Message-ID: <64F193943BAA03E6.7FECF09640C05940.AE1C20813B2555BA@lp.airnews.net> In article , Jeff Raven wrote: . . . >Dirichlet proved that given any number alpha and integer N, there >is always a 'good' approximation p/q such that q < N. This fraction >can be calculated directly using a rather clever argument, but >the method of continued fractions ought to give you the same thing. . . . Let me be sure I understand your quantifiers. "Dirichlet proved that ... there is always at least one 'good' ...", correct? Here's where I'm ignorant: how is Dirichlet's construction more of a "direct calculation" than a standard continued- fraction computation? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jkraska1 at san.rr.com Sun May 21 00:35:07 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 21 May 2000 04:35:07 GMT Subject: Case sensitivity/insensitivity References: <392684EF.B0801837@san.rr.com> Message-ID: <3927683A.61E5AF5C@san.rr.com> > .. and so on. Many seem to prefer the first one, and as far as I > recall, it's also the 'standard' within Java. I'm all-right with > BabyFoodGenerator, but doesn't food_dispenser look a bit better then > foodDispenser? No, not really. But food-dispenser isn't so bad, and you don't have to hit that damn shift key. :)- I was disappointed to see that Java overlooked Motif's standard (more or less where the coding standard came from) on functions. In motif, you call a function LikeThis(), not likeThis(). C/ From lxssox at glasspipes.com Mon May 22 10:22:25 2000 From: lxssox at glasspipes.com (lxssox at glasspipes.com) Date: Mon, 22 May 2000 14:22:25 GMT Subject: do you smoke? 2647 Message-ID: for the best prices on the sweetest pyrex pipes and glass art, please visit http://www.EyeblowGlass.com please excuse if I posted this in the wrong group tsvirqjgniyvbgsziedqywcluwynpmfxivxpfxxlnpvtlm From lexberezhny at email.msn.com Tue May 16 14:50:01 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Tue, 16 May 2000 14:50:01 -0400 Subject: pyORBit & pyGTK Message-ID: Hi, I am writing a program that I would like to be CORBA compliant, and I am using pyGTK and gnome-python, so pyORBit seemed like what I would need. But I cant find any examples or documentation on using pyORBit and pyGTK with gnome. Any help would be greatly appreciated. Thanks. - Lex Berezhny From unknown at unknown.com Thu May 18 06:57:07 2000 From: unknown at unknown.com (Unknown) Date: Thu, 18 May 2000 10:57:07 GMT Subject: JPython and Socket.py Message-ID: <70QU4.754$SK.9978@newsread1.prod.itd.earthlink.net> It is noted that the socket.py implementation under JPython is "limited". Are there plans to improve (bring up to standard socket.py) this? If so when? Thanks in advance! From effbot at telia.com Wed May 31 17:24:49 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 31 May 2000 21:24:49 GMT Subject: don't use bind variables (was Re: Using strings with ' in them in SQL-queries) References: <39342055.1301760@news.c2i.net> <393510AB.D62AE9A5@infercor.no> <8h38ak$s1f$1@slb6.atl.mindspring.net> Message-ID: Aahz Maruch wrote: > I've been keeping silent for a while, but I'm now going to start > speaking forcefully against this style. It's a real PITA to maintain > when you have complex queries, because you can't use dicts and named > parameters. I find that it works much better to do something like this: > > dict = {....} > q = """ > SELECT %(field)s FROM %(table)s > WHERE %(key)s IN (SELECT %(key)s FROM %(jointable)s) > """ % dict maybe the really right thing here would be to implement a small helper function which implements "pyformat" parameter handling, no matter what parameter format your database happens to use. how about (almost completely untested): import re PARAMTYPE = "qmark" def fixup(query, params, pattern=re.compile("%\((\w+)\)s")): if PARAMTYPE == "pyformat": return query, params paramlist = [] def map_parameter(match, params=params, paramlist=paramlist): paramlist.append(params[match.group(1)]) if PARAMTYPE == "qmark": return "?" elif PARAMTYPE == "numeric": return ":%d" % len(paramlist) elif PARAMTYPE == "format": return "%s" return pattern.sub(map_parameter, query), paramlist dict = { "field": "myfield", "table": "mytable", "key": "mykey" } query = """SELECT %(field)s FROM %(table)s WHERE %(key)s = 10""" apply(db.query, fixup(query, dict)) (or something) > (This is a stupid example, but it demonstrates the problem that > frequently occurs when you have to use the same variable more than > once.) Remember that the Python Way is to write code as clearly as > possible until such time as speed is proven to be an issue. sure, but designing your way around FAQ's is also a good idea. (but I'm just a code monkey, so what do I know ;-) From sabren at manifestation.com Tue May 23 15:59:49 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Tue, 23 May 2000 15:59:49 -0400 (EDT) Subject: [PATCH] A compromise on case In-Reply-To: <3dn9nnkt.fsf@SNIPE.maya.com> Message-ID: On 23 May 2000, Jeff Senn wrote: > nickm at mit.edu (Nick Mathewson) writes: ... > > So I tried to make a quick-and-dirty patch the Python interpreter to > > do something more reasonable. Here's a sample interaction: > ... > > >>> print MAP(square, [1,2,3]) > > NameError: No such name as 'MAP'. Perhaps you meant 'map'? > > Merits of the patch aside (I like the idea!), it still doesn't get to > the core of *why* Guido suspects there are benefits to making the > language case-insensitive. > > Just consider how to handle the more complex case of code like: > > CountOfLumberJacksAvailable = 12 > if something.or.other(): > CountOfLumberjacksAvailable = CountOfLumberJacksAvailable + 1 > print CountOfLumberJacksAvailable > > Code, which you will notice, generates no "errors"... But this is a seperate kind of problem, and not necessarily confined to case issues. Perl (and many other languages) handle this by forcing you to declare all variables. (It's optional in Perl.. "use strict". In VB, it's "Option Explicit") > Guido's assertion (which I believe) is that we humans are not used to > reading case as being significant to the meaning of a word -- in > addition our ability to even perceive the case of a word is pretty > poor. I'm sure that there are studies in the cog-sci reading- > comprehension area that support this result and demonstrate that memory > for case is pretty pathetic. But that's because you don't know by looking at a token like "onceUponatime" what the capitalization means... But, if you use a set of conventions, eg... AClass, aFunction(), anInstance.aMethod(), anAttribute... then capitalization gives you extra information. BTW -> Nick: great idea! Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From cpr at emsoftware.com Fri May 26 23:22:31 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Sat, 27 May 2000 03:22:31 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> <392DD013.6E44EFF4@san.rr.com> <392E299B.9D8D0D54@san.rr.com> Message-ID: Then wouldn't that be "Dum hoc ergo proper hoc"? (Cum is with, not during.) -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Courageous" wrote in message news:392E299B.9D8D0D54 at san.rr.com... > > > > >"CUM HOC ERGO PROPTER HOC" > > > > > > > >It should be educational. > > > > > > I think you mean "POST" instead of "CUM". > > > > No. > > Being in a more talkative mood now, I should like to point out that > there is a very small difference between concluding that because > something happened AFTER an event then the event must be the causal > factor and concluding that because something happened DURING an event > then the event must be the causal factor. Really, though, these > two latin terms from fallacy-speak really aren't very distinguishible, > so it's not particularly "more" proper to use one term in lieu of > the other unless you really care about splitting hairs. :)- > > > > C/ From moshez at math.huji.ac.il Sat May 27 17:19:42 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 28 May 2000 00:19:42 +0300 (IDT) Subject: Python performance notes... In-Reply-To: Message-ID: On Sat, 27 May 2000, Brett g Porter wrote: > > Remember that map> is invalid. > Are you making up rules here? Of course you meant map >. No, I meant that "map>" is an invalid piece of C++ -- you have to use "map >". If I were making that up, it would be funny, but since Stroustroup made this one up, we can only mourn. From francis at robinton.demon.co.uk Sat May 20 18:57:11 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Sat, 20 May 2000 23:57:11 +0100 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> <8g742q$2jv3$1@thoth.cts.com> Message-ID: <+yJ6QZAHhxJ5Ewg9@robinton.demon.co.uk> In article <8g742q$2jv3$1 at thoth.cts.com>, Will Rose writes >Some >people just do see the tokens 'token' and 'Token' as being identical, >and are very irate if their behaviour differs; others, like me, see >them as different and hate the additional complexity of trying to >memorise possible matches. There is a largish minority for whom using case sensitive tokens is a menace -- those that rely on text-speech because their eyesight is severely impaired. Another problem that will become more visible over the next half dozen years are the problems of those using voice recognition systems. Of course these are only issues in the context of identifiers only being disambiguated by the use of uppercase/lowercase. Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From teemu.keskinarkaus at ramk.fi Wed May 10 04:29:38 2000 From: teemu.keskinarkaus at ramk.fi (Teemu Keskinarkaus) Date: Wed, 10 May 2000 08:29:38 GMT Subject: Python, cgi and redirect Message-ID: <39191ca8.537672021@news.ramk.fi> Is there simple cgi module for python that can do redirect?? Now I'm doing redirect in cgi-script like this: print "Status: 302 Moved" print "Location: http://url.to.somewhere" That works fine except I get 'Premature end of script headers' errors in apache error_log everytime I use that script.(but browser is redirected to url I give) Is there something missing or is there ready cgi/web module to do stuff like that?? I use cgi module that comes with python but I haven't found redirect in it. TK From ejr at lotus.CS.Berkeley.EDU Tue May 9 18:15:32 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 9 May 2000 22:15:32 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39184C59.DD33AA67@tismer.com> Message-ID: <8fa2m4$98v$1@agate.berkeley.edu> And Jeff Senn writes: - - Several times I have considered what it would be like to have a - 'simple-unified-VM' that supported continuations (if not full - continuations -- then at least micro-threading) and could run Python, - Java Script, Ruby, ... [Visual] Basic?, Perl??, ... Java????... Like a Virtual Virtual Machine? See http://www-sor.inria.fr/projects/vvm/ . Other people might say that the x86 is the unified VM. It doesn't necessarily need to run on x86 hardware, as Transmeta and IBM have shown (www.transmeta.com, http://www.research.ibm.com/daisy/). Bochs is kinda in this space, too. And yet other people might eschew virtual machines for intermediate representations that can be compiled quickly while keeping the information necessary for advanced optimizations (see the slim binary work at http://www.ics.uci.edu/~franz/SlimBinaries.html and the pubs under publications.html). And then there are those folks who have been working on a Scheme interpreter to serve precisely this role, Guile. So lots of people have thought about this. Which of these approaches make sense? I'm not at all sure. Having bytecode-like format that can be efficiently compiled and optimized (and recompiled and reoptimized) while still being ok to run directly would be nice. Once upon a time, some of the Guile developers pondered a threaded tree coding, one that might be like crossing byte-code with the slim binary approach, but I don't know what became of that. If I weren't a lazy bastard, I'd look into something like that myself. The compilation to whatever hardware is running under it is key for high-performance, though. And recompilation is the best way (imho) to beat on the abstraction and dynamic typing penalties. A system designed with those in mind should prove useful. Jason From phd at phd.russ.ru Fri May 5 04:26:36 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 5 May 2000 08:26:36 +0000 (GMT) Subject: BLOBS and python In-Reply-To: <8esivv$l5k$1@nnrp1.deja.com> Message-ID: On Thu, 4 May 2000, sp00fD wrote: > con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % image) con.execute("INSERT INTO foo (myblob) VALUES ('%s')" % MySQL.escape(image)) ^^^^^^^^^^^^ !!! Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From g2 at seebelow.org Wed May 10 16:31:29 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 10 May 2000 21:31:29 +0100 Subject: HTMLParser tag contents References: <3913CBAA.64BB@seebelow.org> <8f773p$i1f$1@nntp9.atl.mindspring.net> <39191553.26AA@seebelow.org> <3918744D.1FD9B23D@prescod.net> Message-ID: <3919C721.78BB@seebelow.org> Paul Prescod wrote: > > Grant Griffin wrote: > > > > Therefore, for Python 1.6, I would like to recommend that SGMLParser be > > modified to provide a method called "get_tag_contents" (or whatever) > > which can be called at the point of any "end_xxx" to convey the tag's > > contents (which would include not only text but contained tags and their > > text.) (The reason SGMLParser has to be modified is that its index into > > its "rawdata" array is local to its parser routine.) > > You could be parsing a 100MB HTML/SGML document 1 K at a time. I don't > think you want SGMLLIB to keep around the entire 100MB "just in case" > you ask for the contents of the BODY tag. > I guess some sort of size limit could be put in it to cover all but extreme cases. Then again, maybe you're right: maybe the solution I had posted was best. ;-) when-the-exception-doesn't-prove-the-rule-it-must-prove-the -exception-ly y'rs, =g2 p.s. BTW, how long do you 'spose it would take for somebody to _read_ a web page containing 100MB HTML?! (Lemme see...carry the six...that would take...waitaminute...about... ;-) -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From glyph at twistedmatrix.com Fri May 12 05:30:06 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 12 May 2000 04:30:06 -0500 Subject: Python for Kids References: <004601bfb477$4990d680$390110ac@Programmer1.magpie> Message-ID: Sorry for the long delay on this response! I accidentally hit 'save to draft' when I meant 'send', and just found it lying around in my drafts folder... "Jeff Massung" writes: > Interesting. I first learned Basic, Pascal, C/C++, then Hypercard (it was > all we had at our school). So it is good to see the perspective from the > orther side. Well, happy to be of service :-) > >It's also a very bad way of thinking about programming -- the > >HyperTalk reference lists hundreds of "commands" that are bindings to > >specific functionality, rather than methods or functions; there's no > >good way to define a new kind of class, let alone inherit from an > >existing one; there are scads of subtly special syntaxes, the language > >is hard-wired into a vastly substandard development environment, and > >Apple has no intention AFAICT of supporting this under OSX. > >Abstraction? Hah! > > Definitely no disagreement here, I just thought that with the GUI idea of > Hypercard would help the learning process. It is interesting to learn the > exact opposite! I wonder why...? :) The GUI in hypercard is completely different than the GUI everywhere else. Take the (I believe valid, tho it's been a few years) statement: put 5 into card field "bob" of card 2 of background 3 of window joe or this one: lock screen get the value of card field 6 put it into x set the label of button "bob" to x unlock screen Any sane, reasonable programmer would then assume you could do things such as put card field 6 into cf get the value of cf except the first statement is invalid. "card field 6" is not an object, it's just an expression which has a certain meaning in some contexts, and not in others The python way of doing these things looks less like english: window('joe').background(3).card(2).field('bob').value=5 or screen.lock() x=self.card.field(6).get_value() self.card.button('bob').set_title(x) screen.unlock() ... but then, if you want a programming language that looks like english, use COBOL. At least it does math right. ;) > >No offense to the poster of this message, but HyperCard was what > >taught me never to rely on commercial software :-) and I really feel > >strongly about discouraging its use (no matter what the context) > > None taken ;), but I'd like to know why, is there psych. behind it? Failure > to see what is "really going on behind the curtains" that inhibits the child > later? There's some psychology behind it ("scripting is something users do and programming is something developers do" was one of the most damaging assumptions about programming I ever internalized -- I was *determined* to stay a "user" because "scripting is easy and programming is hard" - I'm not the only one who felt this way, either); but there are some very practical concerns as well. Take, for example, the standard way of building data-structures in hypercard. The only data-type available is the scalar: which is assumed to be a string. Numbers are only a performance hack, since if you wanted addition, you'd just add two scalars (termed "variables" by the reference, I think): "3"+"5" = 8. (3 && 5, btw, is "35"). Since there is no concept of a "list" (except perhaps "list of words", as in the statement 'put word 5 of "this is a list of some words" into card field 5') the way you build complex data-types is by (1) creating a graphical component in the development environment, (2) making sure that said component has some way of being created from a script, and (3) putting text fields onto that component. So every time you want a struct which is basically 2 booleans, a string and an int, you end up creating an entire GUI layout which is then (wait, this is the best part) saved to disk! (but even cooler, in the earlier versions, was this DIDN'T mean you get persistence for free (not that this persistence model scales beyond 100k of data)... the data will only be saved if you explicitly request it, but the layouts will be saved automatically. go fig.) And once you've gone through that whole mess, you've got a data structure which is about as easy to access as string manipulation in INTERCAL. Observe: here is a (again, I don't remember the syntax completely... I think I'm screwing some stuff up) function to retrieve a person's age from their name: function getAgeOfPerson PersonName get the value of bg fld 3 of cd PersonName of bg 1 of wd 3 return it end function And to create a person: function newPerson PersonName new cd PersonName of bg 1 of wd 3 end function And there you have it. Only 4 lines of code and about 30 words to incompletely and special-case describe the python '.' operator in a purportedly high-level language that should have it already, and with 80x the overhead, at that. And tie-ins to the GUI that are hardcoded in the most arbitrary and bizarre ways. I could go on, but I think you probably get the point by now. programming-should-be-taught-with-nothing-but-a-text-editor'ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From dgoodger at bigfoot.com Sat May 27 22:05:07 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 27 May 2000 22:05:07 -0400 Subject: coverting numbers to strings In-Reply-To: <8gpnqb$ki7$1@bob.news.rcn.net> References: <8gpnqb$ki7$1@bob.news.rcn.net> Message-ID: on 2000-05-27 20:03, Z 3 Penguin (z3penguin at penguinpowered.com) wrote: > i want to convert an integer to a string contaning the bytes for that value, > i.e > > >>> a=300 > >>> b= func(a) > >>> for i in len(b): > ... print ord(b[i]) > ... > 1 > 44 What you want is the "struct" module: >>> import struct >>> struct.pack("h",300) '\001,' >>> a = 300 >>> b = struct.pack("h", a) >>> for c in b: ... print ord(c) ... 1 44 See the Library Reference for details. Please note that the conversion string limits the size of the integer (here, "h" is a short integer, two bytes on my platform). If your value is greater than the converter allows for, you'll get only the least significant bytes: >>> struct.pack("h", 1000000) 'B@' >>> struct.unpack("h", "B@") (16960,) >>> struct.pack("i", 1000000) '\000\017B@' >>> struct.unpack("i", "\000\017B@") (1000000,) "i" is for a regular integer, four bytes on my platform. BTW, Emile, the wierd character sequences you saw were because Penguin's message was encoded in the Unicode UTF-7 character set. Your email reader probably doesn't recognize it. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From m.faassen at vet.uu.nl Tue May 23 19:19:56 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 May 2000 23:19:56 GMT Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> Message-ID: <8gf3ms$jce$2@newshost.accu.uu.nl> Arnold deVos wrote: > The real problem is that a module exports all the symbols it has imported. You mean the real problem with importing '*'? I hardly ever use it. :) > This sometimes creates a chain of unintentional dependencies between > modules - a bit like the sort of thing that happens with .h files in C. > e.g. if I forgot to import string, my code might still work because I import > x that imports y that imports string. No amount of testing can reveal this > error. Later someone changes the implementation of y, removing string. > Later still, I run my previously tested code and the error is unexpectedly > (confusingly) revealed. This is only the case if you use 'from foo import *'. If you don't do that, this problem doesn't exist; I can't use 'string' if I don't import the 'string' module in my particular module. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Mon May 22 05:27:36 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 09:27:36 GMT Subject: Damnation! References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> Message-ID: <8gaui8$bhu$2@newshost.accu.uu.nl> Fran?ois Pinard wrote: > Roy Katz writes: >> 1. Python 3000 may be case-insensitive. > Horror, hell, and damnation! April 1st should be far behind us by now! Oh, ick, too late. I see this thread exploded. I suppose it's too late to throw in references to Haskell, non-euclidian geometry and evolutionary biology to douse the flames, hm? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rcc at nospamthanks_jennic.com Wed May 10 07:33:16 2000 From: rcc at nospamthanks_jennic.com (Robert Cragie) Date: Wed, 10 May 2000 11:33:16 GMT Subject: import modules at runtime References: <8f6jd5$7mg$1@nnrp1.deja.com> Message-ID: This was in a post dated 31/03/00. This works fine for a class which has the same name as the module. ######### in module MyClass.py ######### class MyClass: def __init__(self, data): print data #################################### class ArbitraryClass: def getClass(self, cmName): return __import__(cmName, {}, {}, []) def newInstance(self, cmName, *args, **kwargs): return apply (getattr(self.getClass(cmName), cmName), args, kwargs) if __name__ == '__main__': arbitrary = ArbitraryClass() target = 'MyClass' arg1 = 'Hello world' instance = arbitrary.newInstance(target, arg1) wrote in message news:8f6jd5$7mg$1 at nnrp1.deja.com... | Hi * | | Is there a way to create an object instance giving its classname at | runtime? | | In java you can say: | | ... | Class c = Class.forName(stringWithTheNameOfTheClass); | Object o = c.newInstance(): | ... | | Thanks in advance | M. | | | Sent via Deja.com http://www.deja.com/ | Before you buy. From corg at copernic.com Wed May 17 09:13:21 2000 From: corg at copernic.com (Gaetan Corneau) Date: Wed, 17 May 2000 09:13:21 -0400 Subject: Python to be Renamed! Message-ID: Strange, the URL has changed (or it is generated on the fly?) http://www.segfault.org bottom of page: Perl is finished ______________________________________________________ Gaetan Corneau Software Developer Copernic.com http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Les T?l?tubbies, c'est de la musique d'ascenseur pour les yeux" From fwang2 at yahoo.com Wed May 10 01:49:47 2000 From: fwang2 at yahoo.com (oliver) Date: Wed, 10 May 2000 01:49:47 -0400 Subject: variable access question Message-ID: hi, A beginner question: say I have the following classes A and B defined. And B wants to access the variable "queue" inside A. How do i do that? or what is the most conventional way of doing it? class A: self.queue = Queue(10) Class B: thanks oliver From jkraska1 at san.rr.com Fri May 26 03:41:59 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 26 May 2000 07:41:59 GMT Subject: IDEs, ID or EGO? (was: Decimals -> Fraction strings, my solution References: <3921D4C6.91B2090F@acm.org> <39221911.C3FB9056@san.rr.com> <392EE927.38A0@seebelow.org> Message-ID: <392E2B73.7D63BA08@san.rr.com> > This is probably a good time to confess that I've recently taken to > using Visual Studio as my Python IDE. "Hi, my name is Grant Griffin, and I'm a Visual Studio user." *everybody now!* "Hi, Grant!" :)- > I tried Pythonwin, which is very, very good, but I got frustrated with > the fact that each time I tried to run my revised Python code, it seemed > to remember the old version. (Maybe there's a workaround, but the > easiest one I've found is to use an IDE that isn't written in Python. Hrm. Funny. I just use a command line (yes, this is on NT) and simply run my test python code straight through the interpreter. I don't see much point in loading everything into idle or what not again and again, unless I have a specific need/desire to poke at the code. Typically, I just type: % python .py ... and it does the rest. ??? > Now, if only Visual Studio could be configured to do Python syntax > highlighting... Well, emacs and gvim are both quite good at it, IMO. For example, I use gvim in VC6.0, and use the rest of VC (debugging, compiling), but avoid its editing capabilities. This, too, is very easy. I use a paged virtual desktop manager which maps a set of keys to virtual screens (none of this picking a region with the mouse shit, I just hit a button and flip). One page has VC, one email/usenet, another code hacking, a fourth telnet sessions and the like. ima-powa-usa-baybee ly y'rs From aahz at netcom.com Thu May 4 09:50:45 2000 From: aahz at netcom.com (Aahz Maruch) Date: 4 May 2000 13:50:45 GMT Subject: Extracting DB schemas/table definitions from ODBC database References: Message-ID: <8erv7l$mtv$1@slb0.atl.mindspring.net> In article , Huy Do wrote: > >I am trying to extract the database schema(table definitions/structure) >i.e table names, field names, field data types etc. from an ODBC >database (eg. sql server) using mxODBC and iODBC. I am developing on a >Linux box and the database server is an NT box (inconsequential). You need to use the system catalog. Look up INFORMATION_SCHEMA. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From dalke at acm.org Sat May 27 23:15:30 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 27 May 2000 21:15:30 -0600 Subject: Getting Variables from a file References: <39305D9F.B1201DD4@fenx.com> Message-ID: <8gq3pm$kpd$2@slb0.atl.mindspring.net> emile at fenx.com wrote: >for line in vars.split("\n"): > try: > k,v = line.split(" = ") > exec (line) > except: > # doexn't parse out as tuple w/ interspersed = > pass > >print dof,elements,mesh_dof > >is safer. I'm sure there's still a hole in that, I just >don't see it right now. Consider a line of the form: a = __import__('os').system('nasty command, like: remove the file system') Don't think you would like the results. Back to the original poster ... Since the file contains lines which are also Python code, if you trust the file contents, then the easiest command is execfile("filename") You don't say why you want this ability. The most obvious thing is to read in some configuration parameters for code which expects those variable names. If you expect to make it available in a possibly hostile environment (like the web) then you'll need better protection so make sure the lines are of the right format. For example: vars = open("filename".read() import re line_format = re.compile(r"^\s*\w+\s*=\s*\d+\s*$") for line in vars.split("\n"): if line_format.match(line): exec line else: raise "Line not in the proper format: " + line A better overall solution would be to have the function take keyword parameters, like: def do_something(dof = 6, elements = 1, mesh_dof = 300): # Your code here pass then read in the values into a dictionary then use 'apply', like: infile = open("filename") variables = {} while 1: line = infile.readline() if not line: break name, val = string.split(line) variables[name] = int(val) apply(do_something, [], variables) You could also do variables = {} # don't allow access to any functions exec open("filename").read() in {'__builtins__': {}}, variables for k,v in variables.items(): variables[k] = int(v) # make sure the values are integers apply(do_something, [], variables) which is just as safe, but more complicated. Oh, and I haven't tested any of this. Andrew dalke at acm.org From tim_one at email.msn.com Sat May 13 00:56:27 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 00:56:27 -0400 Subject: Fun with primality testing In-Reply-To: Message-ID: [Fran?ois Pinard] > For your mere enjoyment! Here is Python code which prints primes > below 1000. > At the local Perl mongers meeting, someone showed this nicety to me. > > import re > for n in range(2, 1000): > if not re.match('(11+)\\1+$', '1'*n): > print n Well, the thing is, the Perl folk usually write that as a one-liner. Then they can show that Python is wordier and slower, while pretending to be clearer without actually succeeding : import re composite_matcher = re.compile(r""" ( # it's composite if (?: prime ){2,} # something >= 2 ) \1+ # matches 2 or more times in all $ # exactly """, re.VERBOSE).match for n in range(2, 1000): if not composite_matcher("prime" * n): print n parsing-is-as-powerful-as-anything-ly y'rs - tim From egprice at goodnet.com Sat May 13 14:28:52 2000 From: egprice at goodnet.com (Eric Gene Price) Date: Sat, 13 May 2000 11:28:52 -0700 Subject: Newbie question. Message-ID: <391D9EE4.8D7F789A@goodnet.com> Hi All: I just downloaded python version 1.52 from the python website and have started dinking around with it Are there any commercial applications out there ? Thank You, Eric Price. -- Those that would sacrifice liberty to ensure security, ... deserve neither. Benjamin Franklin (Poor Richard's Almanac) -------------- next part -------------- A non-text attachment was scrubbed... Name: egprice.vcf Type: text/x-vcard Size: 172 bytes Desc: Card for Eric Gene Price URL: From ryang at synthesys.com Wed May 3 17:22:10 2000 From: ryang at synthesys.com (Ryan Golden) Date: Wed, 03 May 2000 16:22:10 -0500 Subject: Any python code prettifiers out there? References: Message-ID: <8251hs430fnc5382cscfpfn9kra18m0i1m@4ax.com> On 03 May 2000 09:46:41 -0400, Alex wrote: > >> Have you looked at the standard 'pprint' module? > >That's for printing out complex data structures. It wouldn't help very >much for formatting python code. > >Alex. Thanks for your input. However, as Alex noted, this module does not appear to be suitable for formatting source code. I'm looking for something that might: 1) line up consecutive assignment statements 2) change tab width throughout an entire file to a specified value 3) enforce spacing conventions for all sequence types and function/method parameters, e.g., [1,2,3] to [ 1, 2, 3 ] 4) change where possible the kind of string quotation mark (single or double) used in your code to a specified kind. 5) format all the comments in the code a certain way, and 6) perhaps allow me to resize the overall width of the code I suppose I could attempt to make my own tool, but I'm not a regular expression guru, and was wondering if there were any tools already available. I would certainly find it useful. Can any cronies tell me if this tool does or does not exist? Thanks again, --Ryan From ullrich at math.okstate.edu Tue May 9 11:37:20 2000 From: ullrich at math.okstate.edu (ullrich at math.okstate.edu) Date: Tue, 09 May 2000 15:37:20 GMT Subject: Name mangling References: <8f6vti$n0v$1@nnrp1.deja.com> Message-ID: <8f9bbe$akc$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > ullrich at math.okstate.edu wrote: > > But usually when I don't get something it's because > > I haven't found the right page in the docs. Here that's > > not the case - I don't see how the bit in the docs about > > name mangling says that the code above should not work. > > ??? > > section 9.6 in the tutorial discusses this: > > http://www.python.org/doc/current/tut/node11.html > > "Any identifier of the form __spam (at least two > leading underscores, at most one trailing under- > score) is now textually replaced with > _classname__spam, where classname is the > current class name with leading underscore(s) > stripped. This mangling is done without regard > of the syntactic position of the identifier, so it > can be used to define class-private instance > and class variables, methods, as well as globals, > and even to store instance variables private to > this class on instances of other classes" Thanks. But actually I'd found that part in the docs, but I don't see how it implies that the silly snippet I posted should not work. Probably I'm just being dense, but usually when I find the right page in the docs I get an "aha" out of it - here I don't get it at all... What was the snippet, something like __foo = 42 class C: def __init__(self): self.value = __foo c = C() Is it the global __foo getting mangled? (That's not part of a class definition.) Or is it the __foo we see in the __init__ method getting mangled? I would have guessed that it would be attributes of the class that got names mangled, but the words "without regard of the syntactic position of the identifier" might mean that the __foo in the __init__ gets mangled, I suppose(?). Except if that's what happened then why is _C__foo a NameError? I must be looking at something totally backwards. You'd think I'd be used to that by now... > the language reference tells you that two leading under- > scores means class-private idenfifiers, but doesn't say > much more that that... Indeed. Of course there's a note saying that there should be a link to an explanation added... > (send patches to python-docs at python.org!) > > > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From debl.nospammm at world.std.com Fri May 5 01:07:33 2000 From: debl.nospammm at world.std.com (David Lees) Date: Fri, 05 May 2000 05:07:33 GMT Subject: Freeze/Source Code Question? References: <3912558F.89778406@world.std.com> Message-ID: <3912570A.DE6FA4D6@world.std.com> Should have mentioned that these questions are triggered by reading the Editorial review by Peter Leopold on the Amazon site, of the book Python Essential Reference by David Beazley. In particular he says: "...If writing the byte-compiled code to a file is not possible, Python suffers from the limitations of other scripting languages: the executable is the source and cannot be hidden from the user, at least not without some difficulty. Despite its extensibility, embeddability, and pleasing architecture, Python is like other scripting languages: appropriate for solving small nonproprietary problems.." David Lees wrote: > > I am taking an initial look at Python (total novice) and am puzzled > about the existence of Freeze. If you do not wish to show your source > code to the world, I gather the byte code in the form of *.pyc files can > be executed. If the Freeze stuff, just embeds the byte code into a C > program (interpreter?) what is the difference from the viewpoint of > hiding the code? I assume the C might be easier to run, because > everything is in one executable, but is the byte code still not easily > viewed with an octal or hex dump, just as in the .pyc files? > > Are there really good decompilers that translate byte code into source > for Python, so that nothing is really hidden? If so, is it really much > different that Java or Visual Basic, where presumably the same thing can > be done? > > David Lees From wlfraed at ix.netcom.com Mon May 15 11:52:56 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 15 May 2000 08:52:56 -0700 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> <391E9E84.D1A0D74A@prescod.net> Message-ID: On Sun, 14 May 2000 08:39:32 -0400, Paul Prescod declaimed the following in comp.lang.python: > > Still, there are no unbreakable rules in Python development and I > bet many programmers are unaware of complex as it is. I would vote for > an "i" in Py3K. And how confusing, visually, will that get with the "L" used for long integers? Especially if one may use either case for entry. I note Python uses "L" and "j" on output, "L" and "i" may stand out -- but when editing one could just as easily use "l" and "J", or in the proposed change, "l" and "I". If you are on a Windows box, look at the following using Ariel as the font, and tell me which is the complex... 1000l 1000I 1000J In Courier, the confusion doesn't apply, but I'm sure there are some folks using proportional and/or san serif fonts for code editing. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From embed at geocities.com Tue May 16 08:54:59 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 16 May 2000 08:54:59 -0400 Subject: socket programming References: <8fr4vf$k96$1@nnrp1.deja.com> Message-ID: wrote in message news:8fr4vf$k96$1 at nnrp1.deja.com... > A server application can bind to a socket and listen for connections > (e.g. smtp:25). Is it possible, say for testing purposes, for another > program to bind to the same socket at the same time and monitor the > data i/o ? Why not write a Python program to be a server on port 25, which just opens another port and relays the data. Then reconfigure your original server (say SMTP) to go somewhere else, like 8881, and your Python program can redirect (with a small delay) as well as dumping out what comes in? You can't leave your server app on the port and let anyone else use it, but you can fake it with a relay+dumping program. You could also (on Windows NT/2000 but not on Unix) "hook" the Winsock DLL functions. For more on how to build DLL hooks, go to the Microsoft Research web page and look for "DLL hooks". Warren From benpark at my-deja.com Sat May 6 22:10:28 2000 From: benpark at my-deja.com (Ben Park) Date: Sun, 07 May 2000 02:10:28 GMT Subject: Irix 6.5, gcc 2.95.2, readline and control-C problem References: Message-ID: <8f2jab$2ma$1@nnrp1.deja.com> I would like to know the answer too. In article , George White wrote: > For python 1.5.2 or 1.6, built with readline (2.x or 4.1) using gcc 2.95.2 > on Irix 6.5, typing control-C results in stack overflow on my Indigo2. > I've tried building python with and without threads. There was one report > several months ago (using slightly older tools) of the same problem, but > no solution. > > Does anyone have readline working for n32 python on Irix 6.5? > > -- > George White tel: 902.426.8509 > Bedford Inst. of Oceanography, Nova Scotia, Canada. > > Sent via Deja.com http://www.deja.com/ Before you buy. From mwh21 at cam.ac.uk Wed May 10 12:57:32 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 May 2000 17:57:32 +0100 Subject: Passing by value instead of reference References: Message-ID: "Jeff Massung" writes: > >>> z=5 > >>> id(z) > 6532920 > >>> def test(x): > print id(x) > >>> test(z) > 6532920 > > Is there a way to pass the value of z and not the address? Thanks. Then what would you expect your "test" function to do? Cheers, M. -- SCSI is not magic. There are fundamental technical reasons why it is necessary to sacrifice a young goat to your SCSI chain now and then. -- Anon. From guido at python.org Sat May 20 22:01:37 2000 From: guido at python.org (Guido van Rossum) Date: Sun, 21 May 2000 02:01:37 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: "Thomas Malik" <340083143317-0001 at t-online.de> writes: > I've just convinced our whole department (at a german bank) to use Python > instead of Perl. A case - insensitive language won't be acceptable by any of > us. So, Guido, should i start looking for another job ...? This is an example of what I meant when I said "voting doesn't help". You're saying it's unacceptable -- a vote. But you don't say *why* you vote that way, so your vote gets multiplied by zero (rather than by the size of your department or the capital of your bank, as you seem to hope by bringing them into the argument :-). Here's a way to make your vote count: explain what it is about case sensitive languages that you hate. Then we can have a discussion about it. I am a very case-sensitive person myself: it bothers me when people don't start their sentences with capital letters or when they refer to themselves as "i" in lowercase -- or when people refer to Python as "python" or "PYTHON". (Come to think of it, it bothered me when you wrote "german" instead of "German" :-). Yet, here are some of the reasons why I am considering making Python case-insensitive: (1) Randy Pausch, a professor at CMU, found, when teaching Python to non-CS students in the context of Alice (www.alice.org), that the number one problem his students were having was to remember that case matters in Python. (The number two problem was 1/2 == 0; there was no significalt number three problem.) (2) I've met many people who are experienced and accomplished Python programmers but who still, when referring to Python modules or functions in an informal context (e.g. email), make up their own case conventions. E.g. people will write me about the String module or about FTPLib. I also know some of the things I plan to do to make the transition painless and to make the usual problems with case insensitivity more palatable. E.g. I may add a case insensitivity feature to IDLE which makes sure that all identifiers are written in a consistent case, I may add flags to pre-Py3k Python interpreters to turn on case insensitivity or case sensitivity or a special warning mode. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From g2 at seebelow.org Fri May 26 17:53:52 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 26 May 2000 22:53:52 +0100 Subject: why tar is strange (was: The REALLY bad thing about Python lists ..) References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> Message-ID: <392EF270.7C79@seebelow.org> Neil Hodgson wrote: > > > But to go back to tarring and feathering tar, the user has little need > > for packaging without compression, so packaging and compression > > constitute a single gizmo from the modern user's perspective. QED > > Separating the functionality is more flexible. But flexibility is often at the opposite end of the spectrum from ease-of-use (or at least ease-of-learning). So I guess it's mainly a matter of what your values are. > File system features are > continuously changing (for the better?). Heck, not much of _anything_ ever changes in Windows: it evolves at the rate of a sea urchin! (Only DOS evolved slower. Then again, hasn't Unix been with us since the '70s? ;-) > You may want to produce archives of > files that use newer features such as Unicode file names or multiple forks > now. In the past long file names were a problem for a while. By separating > the two components each may evolve independently. It looks to me that *x > users are seeing better compression more quickly in the form of .bz2 while I don't know what the compression ratios are between the best currently available and zip, but if the new methods aren't, say, 25% or more better than old ones (for large files!), I'll stick with the old ones, thanks. (Sure, achieving the greatest possible compression is a neat party trick, but otherwise small differences don't matter.) > Windows is still standardised on .zip. Again, I would humbly suggest that this is an advantage. Obviously there's a tradeoff between "the latest and the greatest" versus "standardization"; I prefer the latter. it's-not-a-coincidence-that-windows-users-are-windows-users-and -linux-users-are-linux-users,-but-isn't-it-nice-that-we-both -can-be-python-users?--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From donn at u.washington.edu Wed May 17 13:54:16 2000 From: donn at u.washington.edu (Donn Cave) Date: 17 May 2000 17:54:16 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <3921A17C.F995CEFB@tismer.com> Message-ID: <8fumc8$11og$1@nntp6.u.washington.edu> Quoth Jeff Senn : | Hm -- I've been trying to find a way to explain the "stackless zen". | | It seems that we all (people who write high level software) take the | program stack, as a method of flow control and messaging between | function invocation, as a given. Really the stack is just another | data/object type -- not any more special than a queue or a heap... | | Given our usually math notation, methods of functional composition and | early compiler/OS development I'm not surprised that the stack is | viewed so. (Consider as a counter example how asynchronous circuit | design is done and microcode is developed) | | IMHO this dependence on making the stack of higher importance has made | the implementation of multi-"threaded" operating systems complex and | limited the ways in which alternative approaches could reduce the | difficulty of implementation of async/parallel systems. | | Anyway I hope this stimulates some thought... It's certainly stimulates some desire for thought. I have problems with flow control in asynchronous parallel threaded systems, where hierarchical function call/return flow of control is replaced by I/O ("messages") between threads. I use Python because I'm not smart enough for C++, though, so can I try to pose a more tangible example? Suppose my interface thread tells a service thread to do its thing, and report back. That's in function UserX line 135. It then goes on to process whatever other interface events may occur. The service thread does its thing, and reports back. Now among the interface events, there's an event from the service thread that reports the results from the request at UserX line 135, and I have to figure out which data item I was looking at, etc., basically the state of the program at UserX line 135 that time. Normally, I'd cope with this with some ad hoc state data, maybe stored by the interface thread, or passed to the service thread who is expected to pass it back, or some combination of these two. I sort of get that with this stackless system, I'd have some way to suspend after UserX line 135 that time, and continue from the receipt of that event. So maybe I'd pass the service thread a unique key to my interface thread suspended-functions space, and use the key when I get it back in a message? That continuation is invoked from the message processing loop, which probably also originally called the function in the first place; the original call must have returned immediately from the suspend, and the second returns from the continuation? This still looks at the program in terms of call and return, though, right? It only accommodates asynchrony within that relationship. If instead of wanting to pick up from UserX line 135, my program often needs to communicate results from one service thread call to _several_ interface threads, then I'm going to have to write off "return" and work on the program in terms of state data, and stackful or stackless makes no difference. Which I admit can get pretty gnarly, at least in my limited experience. Donn Cave, donn at u.washington.edu From ajung at sz-sb.de Wed May 17 11:53:59 2000 From: ajung at sz-sb.de (Andreas Jung) Date: Wed, 17 May 2000 17:53:59 +0200 Subject: DCOracle and handling of package OUT parameters broken ?! In-Reply-To: ; from phd@phd.russ.ru on Wed, May 17, 2000 at 01:35:01PM +0000 References: <8fu6b3$qj3$1@news.hants.gov.uk> Message-ID: <20000517175359.A4428@sz-sb.de> On Wed, May 17, 2000 at 01:35:01PM +0000, Oleg Broytmann wrote: > On Wed, 17 May 2000, Graham Bleach wrote: > > > oci.error: (6502, 'ORA-06502: PL/SQL: numeric or value error: character > > string buffer too small\012ORA-06512: at "AJUNG.SELECT_LOB", line > > 22\012ORA-06512: at line 2\012') > > > > Hmm, this looks like the buffer mentioned above is the OCI buffer > > used/created by DCOracle. I'm not familiar with DCOracle (not enough time). > > Is there anything that's specifically designed to handle CLOBs being > > returned from Oracle? > > DCOracle (or may be OCI) cannot return LOB - you need to SELECT it > separately. For example, instead of returning the LOB, return ROW ID, and > then SELECT the row by ID. I never tried this in my example! The LOB is read inside the stored procedure ! Andreas From chibaA at TinterlogD.Tcom Tue May 9 12:34:00 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Tue, 09 May 2000 16:34:00 GMT Subject: General question re: print statement Message-ID: <39183e03.333330824@news1.on.sympatico.ca> I'm trying to use python for html pages - and I was curious if there was a way to do a large output of text using print. Confused? Here's an example. In Perl, you can use the following snippet of code to output HTML: print <<"(BLOCK OF CODE)"; Content-type: text/html ..... </html> (BLOCK OF CODE) The basic point of this code above - is the print<<"(WHATEVER)"; part of it --> whatever is between the (WHATEVER)s, can be free form text which will just be outputted as is (with the spaces, new lines, etc). And I don't have to use escape characters to output reserved characters. Does anyone know if this is possible - or how to do this in Python? Thanks in advance, kc From bwinton at tor.dhs.org Sun May 14 22:45:57 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Mon, 15 May 2000 02:45:57 GMT Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> Message-ID: <slrn8hulsh.6pb.bwinton@tor.dhs.org> On Mon, 8 May 2000 00:55:37 +0200 (MET DST), Vetle Roeim wrote: >on 2000-05-07, Glyph Lefkowitz wrote: >Some people ask me: "why should I use Linux?" >I usually answer: "if you need it, you'll know." Good answer. I'll have to use it sometime. >> > but some people see that Python is all nice and tidy, and so they >> > dislike it because they can't write ugly, unmaintainable code[2] >> First of all, this is NOT an admirable goal as an engineer, and it's a >> problem with the software industry at large, not with Python... >anyway; many programmers are _not_ engineers. they may have learned >programming on their spare time, and therefore approach programming in a >different way. > >I'm not saying people without degrees are stupid, but programming is a lot >of things. It is an art, a science, a hobby, and engineering. > >Sometimes an engineer is needed. Not an artist. I would go further and say that in this industry, we need far more engineers, and far fewer artists (and hobbyists). Of course, you can become an engineer (in spirit at least) without a degree, but it seems to take quite a long time. >But it's difficult to write nice code in Perl. At least I think so.. when >I start using references, everything blows up in my face.. Perhaps this is >my fault. Heck, even when I don't use references, it blows up in my face. ;) >A few years ago, someone asked me about the origins of the other "P" >language. He said: "It was created for web-programming.. right?" Yeah, by Al Gore and Microsoft, just after they invented the Internet. :) >Those frigging sane people! Why can't they be more like the Java-people?! Because they're not getting paid to promote Python? Later, Blake. -- 9:02pm up 23 days, 1:13, 1 user, load average: 1.08, 1.02, 1.01 From gmcm at hypernet.com Wed May 24 13:56:35 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 24 May 2000 17:56:35 GMT Subject: What's in a name? References: <Pine.SOL.4.05.10005241201170.14111-100000@spgsun1.arlut.utexas.edu> Message-ID: <392c17d3$0$17863@wodc7nh7.news.uu.net> Edward S. Vinyard <vinyard at arlut.utexas.edu> wrote: > >In some instances, case sensitive languages are exploited: > >1. Case can add semantic information to the names of classes, > functions, and instances. >2. Case can be used to delimit multi-word names. An example: > spam_counter vs. spamCounter. Certainly. These are conventions that Python (being case sensitive) allows. I like them. But you have to learn to recognize the conventions. That is, in the context of Python I recognize spamServer as different from SpamServer. (Personally, I would expect the first to be a function and the latter to be a class, but if the author uses different conventions, it won't take me long to figure it out.) That's because, in the context of Python, I've trained myself to pay attention to case. In the context of email, I've trained myself to ignore case (else I'd never parse an effbot posting). In the context of the Windows filesystem, I ignore case. And then suffer (briefly) when I go to *nix and have to pay attention. For a newbie, the context is unfamiliar and they have no grasp of the conventions. There's liitle similarity to written language rules of capitalization, (why are classes proper nouns, but not instances?). So I'm all in favor of tools with training wheels. Once a newbie has learned to pay attention to case, they can take off the training wheels. - Gordon From philipc at NOSPAM.erinet.com Fri May 5 07:43:46 2000 From: philipc at NOSPAM.erinet.com (Phil) Date: Fri, 5 May 2000 07:43:46 -0400 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <slrn8h2h2i.1bs.kc5tja@garnet.armored.net> <39116EE5.8EFE6228@san.rr.com> <slrn8h3u48.a3r.kc5tja@garnet.armored.net> <39124FE6.96D041FD@Lugoj.Com> Message-ID: <3912b3bc$0$73579@news.voyager.net> "James Logajan" <JamesL at Lugoj.Com> wrote in message news:39124FE6.96D041FD at Lugoj.Com... <snip> > I am generally opposed to strict adherence of Hungarian notation. It is not > an evil notation though. Some of its adherents may be evil, but the notation > isn't. It was probably useful for the audience it was originally targeted > to: inexperienced programmers who have to work in a team environment. > > In dynamically typed languages or in C++ templates I think it can actually > be misleading. Come to think of it, if you want to declare anything evil, I > think you should declare C++ templates evil. Another case where Python got > it right (EVERYTHING in Python is a sort of template!). It never ceases to amaze me how people can take a thing such as software (programming languages, operatings systems, applications) and attribute to them human notions such as "good" and "evil"... Regards, Phil From effbot at telia.com Wed May 10 03:40:40 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 10 May 2000 07:40:40 GMT Subject: glob References: <391909E6.94A0E5AA@lawson.appcomp.utas.edu.au> Message-ID: <Yn8S4.3476$wYl.203433472@newsb.telia.net> Douglas Partridge <dpartrid at lawson.appcomp.utas.edu.au> wrote: > Is there a recursive glob? no, but you can easily roll your own using os.path.walk and the fnmatch module. or you can use this iterator class, adapted from an example in the eff-bot library guide (see below): # # adapted from os-path-walk-example-3.py import os import fnmatch class GlobDirectoryWalker: # a forward iterator that traverses a directory tree def __init__(self, directory, pattern="*"): self.stack = [directory] self.pattern = pattern self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # got a filename fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname): self.stack.append(fullname) if fnmatch.fnmatch(file, self.pattern): return fullname for file in GlobDirectoryWalker(".", "*.py"): print file </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From emile at fenx.com Sat May 20 12:57:48 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 20 May 2000 09:57:48 -0700 Subject: Damnation! References: <Pine.GSO.4.10.10005201905150.5989-100000@sundial> Message-ID: <0baa01bfc27c$8f9e1b20$1906a8c0@fc.fenx.com> > On Sat, 20 May 2000, Hamish Lawson wrote: > > > If case insensitivity was introduced, I propose that there > > should be a command-line switch to revert to case sensivity for > > backwards compatibility <snip> > Having a delicate syntactic decision decided by a run-time switch > effectively creates two different languages. Either one will dominate, in > which case we can mandate that behaviour from the beginning, or the two > will flourish, which means that the Python community will be split. > <not specifically directed to command switches, but more so the general python 1.x vs 3K discussion> Which may always be an option. I certainly don't expect the changes made to py3k to render the language unusable by the complete range of programmers out there. It is cp4e after all. I do expect backward incompatibilities. If existing software or packages do not migrate to py3k, and certainly most in-place functioning software won't for the short term, then there will be two distinct cpythons. Choosing *not* to upgrade in this case may make sense to some. At least the dividing line will be distinct, as opposed to what happened to VB, where the major release number changed when it should have been the minor, and compatibility was broken almost as a matter of course. I also expect the 1.x line to continue life with bug fixes for some time as long as there is an active community using it. If Guido can achieve his vision of making a language that can both be taught at grade school level, and used as a serious development platform for modern applications, and if that requires compromises such that inconsistencies and syntactic idiosyncrasies are swept from the language, then so be it. I-never-liked-how-VB-changed-case-to-match-my-last-entry- -why-couldn't-it-follow-the-def?-le y'rs Emile van Sebille emile at fenx.com ------------------- From akuchlin at mems-exchange.org Mon May 8 11:05:20 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 08 May 2000 11:05:20 -0400 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <yayk8h66otu.fsf@ganglot.ifi.uio.no> <jaln1mgdfy.fsf@helix.twistedmatrix.com> <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> Message-ID: <3dr9bdhykv.fsf@amarok.cnri.reston.va.us> claird at starbase.neosoft.com (Cameron Laird) writes: > <URL:http://www.oreilly.com/catalog/prkunix/info/more_jpl.html>. > In fact this page is somewhat dated; JPL is farther along than > is apparent from this write-up. But JPL seems to embed a Perl interpreter inside a Java VM through JNI. Like Finn Bock's Tkinter module for JPython, which wraps Tcl/Tk using JNI, it's a useful trick that sacrifices some features, such as ease of distributing the resulting code and the ability to write applets. That's much less impressive than Jim Hugunin's accomplishment of a from-scratch reimplementation in Java. (Or Skaller's accomplishment of a from-scratch reimplementation in OCaML, for that matter.) -- A.M. Kuchling http://starship.python.net/crew/amk/ Tabs are good, spaces are bad and mixing the two just means that your motives are confused and that you don't use enough functions. -- John J. Lehmann, 19 Mar 1998 From irmen at --nospam--bigfoot.com Thu May 11 17:21:18 2000 From: irmen at --nospam--bigfoot.com (Irmen de Jong) Date: Thu, 11 May 2000 23:21:18 +0200 Subject: ANNOUNCE: Pyro 1.1 (distributed objects) Message-ID: <8ff875$3q4$1@news1.xs4all.nl> PYRO - Python Remote Objects - version 1.1 by Irmen de Jong - irmen at bigfoot.com WHAT IS PYRO? Pyro is an acronym for PYthon Remote Objects. It is a basic Distributed Object Technology system written entirely in Python, and for use in Python only. With this, it closely resembles Java's Remote Method Invocation (RMI). It has less similarity to CORBA - which is a system- and language independent Distributed Object Technology and has much more to offer than Pyro or RMI. However, Pyro has some interesting features: - Naming Service which keeps record of the location of objects. The location of the NS can be discovered using a broadcast mechanism, amongst others. - Support for Python types only restricted by those that the standard 'pickle' module handles (all builtin types, and user created classes). Objects as arguments are also supported when the code for those user defined classes is also available on the server side. - Support for all Python argument types (variable argument lists and keyword arguments, *args and **keywords). - Exceptions that occur in the remote object will actually be raised too on the client, just as if the error occured locally. Pyro's exception transportation mechanism makes this possible. - Proxy compiler which automates the task of creating wrapper (proxy) classes. - Dynamic Proxies if you don't like to have pregenerated proxies. - Full source code in Python. The most important changes since the previous version (1.0) are: - Hierarchical naming scheme. Extended NS with hierarchical object naming functions. This allows for more structured and controlled object naming while being fully backwards compatible. - Configuration files to easily specify a set of Pyro configuration items - Fixed some bugs and made the protocol more stable and less sensitive to weird data. - More tests and cleaned up test code - Documentation update - A lot of other small changes and fixes. WHERE CAN I GET IT ? >From my Pyro homepage: http://www.bigfoot.com/~irmen/pyro.html It comes with a Python-style license, but is otherwise free for commercial and non-commercial use. REFERENCE: <P><A HREF="http://www.bigfoot.com/~irmen/python.html"> Pyro 1.1</A> - Distributed Object system for Python (7-May-2000) -- Irmen de Jong -- irmen @ bigfoot.com From m.faassen at vet.uu.nl Mon May 1 10:05:48 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 May 2000 14:05:48 GMT Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <slrn8ghc6t.f01.scarblac-spamtrap@flits104-37.flits.rug.nl> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <m3bt2tonyg.fsf@atrus.jesus.cam.ac.uk> <300420001008012011%pecora@anvil.nrl.navy.mil> <20000430170952.A502@datapro.co.za> <B531EC9B.57C1%abrahams@mediaone.net> <slrn8gp7ei.ilf.kc5tja@garnet.armored.net> <B53241E5.580F%abrahams@mediaone.net> <slrn8gqf3a.k65.kc5tja@garnet.armored.net> Message-ID: <8ek2vs$f0e$1@newshost.accu.uu.nl> Samuel A. Falvo II <kc5tja at garnet.armored.net> wrote: > In article <B53241E5.580F%abrahams at mediaone.net>, Dave Abrahams wrote: >>As Simonyi, the author of the Hungarian notation concept writes, "the basic >>idea is to name all quantities by their types". If you are naming quantities >>by their interface, you are taking a step away from Hungarian. Do as I do, >>naming quantities by their *role*, and you have taken a long leap away from >>Hungarian. > If an object exposes a particular interface, then it is guaranteed to be of > a particular type. Defining parameters in terms of their roles is > analogous. Again, I just don't see the distinction. Not in Python it ain't: class Foo: def do_it(self): print "Foo!" class Bar: def do_it(self): print "Bar!" Are Foo and Bar of the same type? They definitely expose the same interface. But by convention, not type. You seem to be aware of this, so I'm not sure why you don't see any distinction. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Sat May 13 08:14:58 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 May 2000 12:14:58 GMT Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> <yayk8h66otu.fsf@ganglot.ifi.uio.no> <jaln1mgdfy.fsf@helix.twistedmatrix.com> <m3itwqt2ji.fsf@atrus.jesus.cam.ac.uk> <8feh9q$3gn$1@nnrp1.deja.com> <8feku2$5ap$0@216.39.141.36> <391b087a.203308261@news.iol.ie> <8fhl1e$nk0$2@newshost.accu.uu.nl> <391DC577.55A@seebelow.org> Message-ID: <8fjh02$l6k$1@newshost.accu.uu.nl> Grant Griffin <g2 at seebelow.org> wrote: > Martijn Faassen wrote: >> > ... >> Oh me too. Python's now really at the very edge of the 'straight up into >> infinity' part of the exponential curse, um, curve. > And I--for one--am *delighted* to be an "early adopter"--for once. (I > know, I know: Python has been around for many years...) I'm a mid-to-late early adopter myself. That is, I started with both the internet and Linux about 3 years before they got really really popular, but also a number of years after they got usable. I think I'm a bit behind schedule with Python, as I've adopted it only a year and a half ago, and it won't take a year and a half more; it'll be sooner. :) > When I bought "Learning Python", I ended up finding it and the other > Python books by accident in the "Unix" section of Barnes & Noble, after > having first scoured the "Languages" section for them. Since Python > isn't especially Unix-inspired, perhaps this suggests the need to > increase Python awareness. They have a good computer section in the big bookstore here in Utrecht, but last I checked the Python books were placed under 'web servers'. I pointed out to them they would be better placed somewhere between Java and Perl. Perhaps they've moved them now; I might check this afternoon. Of course it's hard for a bookstore when the Python 'section' explodes from a single book to a lot of them quite suddenly. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aahz at netcom.com Fri May 5 10:37:35 2000 From: aahz at netcom.com (Aahz Maruch) Date: 5 May 2000 14:37:35 GMT Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <slrn8h3u48.a3r.kc5tja@garnet.armored.net> <39124FE6.96D041FD@Lugoj.Com> <3912b3bc$0$73579@news.voyager.net> Message-ID: <8eumbf$dv0$1@slb0.atl.mindspring.net> In article <3912b3bc$0$73579 at news.voyager.net>, Phil <philipc at NOSPAM.erinet.com> wrote: > >It never ceases to amaze me how people can take a thing such as software >(programming languages, operatings systems, applications) and attribute to >them human notions such as "good" and "evil"... They are creations of human beings, therefore they pick up attributes of their creators. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "It's not because my mind is made up that I don't want you to confuse me with any more facts. It's because my mind isn't made up. I already have more facts than I can cope with. So SHUT UP, do you hear me? SHUT UP!" _The Shockwave Rider_, 1975 From robert_kuzelj at my-deja.com Mon May 29 07:42:54 2000 From: robert_kuzelj at my-deja.com (robert_kuzelj at my-deja.com) Date: Mon, 29 May 2000 11:42:54 GMT Subject: update environment-vars (win32api) Message-ID: <8gtl3s$90n$1@nnrp1.deja.com> im trying to set some environment vars in the registry. which actually is working fine with the win32api-module. but what bothers me (even so this is no python-problem) is the fact that if i open a dos-box (winNT4.0sp5) and try to get the new defined values it seems not to exist. only after i open up the system-dialog and there the environment-tab (where i do see the new vars) and i click on set and ok, then the vars appear in the dos-box too. does anybody knows a workaround? ciao robertj >>> key = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, win32con.KEY_ALL_ACCESS) >>> print win32api.RegQueryValueEx(key, "CLASSPATH") ('.;%CP_JDK%;%CP_JPYTHON%;%CP_OLEBRIDGE%;%CP_DOCWIZ%;', 2) >>> win32api.RegSetValueEx(key, "CP_BBB", 0, win32con.REG_SZ, "BBB") >>> print win32api.RegQueryValueEx(key, "CP_BBB") ('BBB', 1) Sent via Deja.com http://www.deja.com/ Before you buy. From dale at out-think.NOSPAMco.uk Tue May 2 16:51:45 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 2 May 2000 21:51:45 +0100 Subject: Python Programming on Win32 - Hammond/Robinson Message-ID: <8enf56$sof$1@supernews.com> I've seen Mr. Hammond hereabouts and I have a question about your book which I'm working through at the moment. Have I missed something or is there a mistake on page 309. Should Table 17-1 say os.path.isdir, os.path.isfile, etc? I hope its not me because otherwise I think I understand it! Thanks for the book, by the way. Very handy. I'm new to Python and I'm sure I'm going to find it handy. I hope you and Mr Robinson have been well rewarded for your efforts :-) -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Experts From rwallace at esatclear.ie Wed May 24 22:16:57 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Thu, 25 May 2000 03:16:57 +0100 Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> <392C4B4F.60C4@esatclear.ie> <392C7F0F.64BA39D0@cosc.canterbury.ac.nz> Message-ID: <392C8D19.28D7@esatclear.ie> Greg Ewing wrote: > I'd much rather have an honest, well-defined "wrap around" > operator that I can rely on, even if I have to look up the > language definition now and then, than have to wade through > code that's been obfuscated to work around its absence. So define one. def wrapmod(x, y): while x < 0: x = x + y # simple implementation, could do it more efficiently return x % y IMO this isn't a sufficiently common thing to warrant an extra operator; and having two integer mod operators is very likely to lead to people using the wrong one. -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From jwbnews at scandaroon.com Sun May 21 17:43:29 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 21 May 2000 14:43:29 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <392846F1.C89F7CED@Lugoj.Com> Message-ID: <jwbnews-7812B7.14432921052000@news.olympus.net> In article <392846F1.C89F7CED at Lugoj.Com>, James Logajan <JamesL at Lugoj.Com> wrote: > 3) Professional programmers must have learned to deal with case-sensitive > languages at the very beginning of their career. At the very beginning of my career, 'a'...'z' did not exist. (On the machines I used.) There wasn't a problem. And there was a time before C (a much better time, from my perspective, but that's another flame war). Cheers...John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From froydnj at rose-hulman.edu Thu May 11 17:45:18 2000 From: froydnj at rose-hulman.edu (Nathan Froyd) Date: 11 May 2000 21:45:18 GMT Subject: Object type problem References: <391B17EA.97E72E9F@ldis.com> Message-ID: <slrn8hmad5.tq0.froydnj@froydnj.laptop.rose-hulman.edu> In article <391B17EA.97E72E9F at ldis.com>, Jonathan Donald wrote: >I've tried testing for strng==None, but this doesn't stop the error from >being reported. Funny, what version of python are you using? On my version (1.5.2), executing: str = None if str == None: print "duh!" works just fine. If excuting: str == None doesn't give back 1, you might try str is None and using that to test instead. I'm sure python gurus will correct me if I'm wrong. -- </nathan> froydnj at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ From mazza at radiumsystems.com.br Fri May 12 11:05:56 2000 From: mazza at radiumsystems.com.br (Fabio Augusto Mazzarino) Date: Fri, 12 May 2000 12:05:56 -0300 Subject: Fwd: Q: Expanding an Inherited Interface? References: <8fgnkf$30b7$1@otis.netspace.net.au> <391BF134.DD7E19B4@tversu.ru> Message-ID: <8fh74p$qvf$1@news.sysnet.net.tw> from comp.object i know many of you read comp.object, but i thought some of you would like to see this... mazza.br Pavel A. Perikov <pavel at tversu.ru> escreveu nas not?cias de mensagem:391BF134.DD7E19B4 at tversu.ru... > First I'll try to answer to the "PS" in your letter > > > (PS: Can anyone tell me why this question was rejected on > > comp.object.moderated??) > > I suggest, that the reason for the question been rejected is because the answer > can be found in some FAQ. And the answer is somethin like "it depends". I > personaly didn't read such FAQ but here's my very own opinion compiled from > reading and own experience. > > There're many ways you can use inheritance. Someone told me - more then a dozen. > > Inheritance often is treated as a mean to support particular design principle > > First we can speak about type inheritance. This is where Liskov's Principle come > into concern. Classes in common programming languages (esp. C++) are more then > just types. Java's interface inheritance seems to be a good approximation for > type inheritance. Adding public methods to derived interface doesn't violate the > possibility of using derived interfaces in place of base. > > Second, you can share code via inheritance. This has generealy nothing to do > with type inheritance. You just split responsibilities into the classes in the > inheritance hierarhy. > > You can combine interface with implementation via inheritance. C++: > class Interface {/* all public pure virtual functions */}; > class Implementation {/*virtual implementation of the functions from interface > */}; > class My: virtual public Interface, private Implementation {...} > > You can just provide implementation for the interface using "public virtual" > inheritance of the interface class. > > There're many others. > > My rule for using inheritance: use it in analysis, where gen-spec relation > exists between concepts in problem domain. Use it in design/implementation > according to your coding style and requirements of the enviroment (you can have > libraries imposing their particular way). And please always consider what you're > trying to express with the inheritance. It's quite easy to abuse inheritance. > > Yours, Pavel. > P.S. Please ignore my poor English ;) > > "" wrote: > > > I have often heard that inheritance hierarchies should not violate the > > Liskov Substitution Principle (derived classes must be usable through the > > base class interface without the client having to know the > > difference). But does this also imply that you should not add public > > methdos to the derived class interface? Or can you do this if you are using > > inheritance as a method of code sharing; which raises a second question... > > should you use inheritance as a method of code sharing, or should > > aggregation always be used? > > > > Thanks, > > - Peter > > > > (PS: Can anyone tell me why this question was rejected on > > comp.object.moderated??) > From guido at python.org Wed May 31 19:49:57 2000 From: guido at python.org (Guido van Rossum) Date: Wed, 31 May 2000 23:49:57 GMT Subject: Is it just Syntactic Sugar ? References: <k7lW4.96338$E85.1941352@news1.rdc1.md.home.com> <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> <20000530213957.E469@xs4all.nl> <mt4s7f7q62.fsf@astron.berkeley.edu> <m3u2ffydwy.fsf@atrus.jesus.cam.ac.uk> <mtog5n68ak.fsf@astron.berkeley.edu> <20000531090045.I469@xs4all.nl> Message-ID: <3935B383.469032AE@python.org> I know I shouldn't be posting in this thread, and I won't be there to read the responses, but here's what I thought would be cool. x+=y is syntactic sugar for x=x.__add_ab__(y); the "ab" means "and becomes" (an old Algol-68 naming convention; we could pick something better later but this will do for the explanation). For immutable types, this is defined as def __add_ab__(self, other): return self+other For mutable types, this is defined as a self-mutating operation, e.g. for lists it could be def __add_ab__(self, other): self.extend(other) return self Thus, i = 1 i += 1 does the right thing (i is set to 2), and a = [0] b = a a += [1,2,3] modifies the object in place, so that both a and b are [0,1,2,3]. User classes can do whatever their author likes. A base class can be provided that defines __add_ab__, __sub_ab__ etc. in terms of self.__add__, self.__sub__, etc. -- --Guido van Rossum (home page: http://www.python.org/~guido/)  From mikael at isy.liu.se Wed May 17 02:40:46 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 17 May 2000 08:40:46 +0200 (MET DST) Subject: Decimals to fraction strings In-Reply-To: <oqbt25lwkt.fsf@titan.progiciels-bpi.ca> Message-ID: <XFMail.000517084046.mikael@isy.liu.se> On 17-May-00 Fran?ois Pinard wrote: > Not necessarily. 0.6667 is well approximated by 1:3, for example, while > if you force the denominator to be an exponent of 10, you will obtain a > fraction which is not only uglier, but less precise. Precise in what respect? Given the (possibly rounded) number 0.6667, we do not know if its origin is 2/3 or something else. It might very well be 6667/10000. The latter is definitely closer to the given number than the former, thus more precise. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 17-May-00 Time: 08:34:44 This message was sent by XF-Mail. ----------------------------------------------------------------------- From issotyo at centrin.net.id Sat May 27 23:46:31 2000 From: issotyo at centrin.net.id (Issotyo P.B.S) Date: Sun, 28 May 2000 10:46:31 +0700 Subject: wxPython mailing list ? Message-ID: <002301bfc859$280c4300$e4f192ca@Buddy> Did anybody know where I could subscribe for good wxPython Mailing list ? TIA [^_^] IPBS -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20000528/be2651f2/attachment.html> From collins at seal.aero.org Mon May 15 11:40:26 2000 From: collins at seal.aero.org (Jeff Collins) Date: Mon, 15 May 2000 08:40:26 -0700 Subject: PalmPilot and python In-Reply-To: <200005150211.WAA06994@tor.dhs.org> References: <8fc11i$9q8$1@nnrp1.deja.com> <14617.37067.507992.310545@malibu.aero.org> <200005150211.WAA06994@tor.dhs.org> Message-ID: <14624.5381.818849.934455@malibu.aero.org> Thanks for your interest! I will add you to the list of interested parties and will notify you when the beta testing begins. Jeff Blake Winton writes: > In comp.lang.python, you wrote: > >I have ported 1.5.1 and am in the process of porting 1.5.2/1.6. > > Aha! So it's you! I've been eagerly awaiting this since I read of its > existance on the Stackless page... Is there any way I could get a > preview copy? I'ld be more than happy to beta-test. ;) (And I've been > programming on the Palm since the days of the Professional, so if I find > a bug, I can probably track the cause down.) > > Thanks, > Blake. > -- > 9:02pm up 23 days, 1:13, 1 user, load average: 1.08, 1.02, 1.01 > From nhv at cape.com Sat May 20 18:54:31 2000 From: nhv at cape.com (Norman Vine) Date: Sat, 20 May 2000 18:54:31 -0400 Subject: command history in the interpreter? References: <3926D1F3.8D07DC60@kurir.net> <3926C50A.C1D34064@endea.demon.nl> Message-ID: <8g75a0$1keb$1@newsie2.cent.net> > > the python interpreter in win98 (1.52 and 1.6) also don't give me the > > history function. > > Sorry, there just isn't any readline library on win32. Use IDLE or > PythonWin instead. Yes there is :^) http://starship.python.net/crew/kernr/binaries/PyReadline-w32.zip From warlock at eskimo.com Mon May 8 01:30:04 2000 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 08 May 2000 05:30:04 GMT Subject: PyBalsa? References: <m3ya5mxktc.fsf@wilma.george.org> <yayem7e6oo8.fsf@ganglot.ifi.uio.no> <m3ln1mt2xx.fsf@atrus.jesus.cam.ac.uk> Message-ID: <slrn8hckfj.pm.warlock@troll.myth> On 07 May 2000 23:23:22 +0100, Michael Hudson, in the persona of <mwh21 at cam.ac.uk>, brought forth the following words...: >Vetle Roeim <vetler at news.ifi.uio.no> writes: > >> * Harry George >> > I like the look-and-feel of the gtk-based balsa emailer. But it has >> > classic C-based crashes in the current pre-release. I was wondering >> > if anyone knows of a python-based rendition? A lot of replicated >> > funcionality, I know, but I hate non-gc'd languages. >> >> I really can't understand why someone would *want* to write an >> application like this in C. It makes me angry and frustrated. >> >> It could probably have been done faster and better in Python. >> >> Sorry about this.. I just had to let out some steam. > >Well, they could have done it in C++... > >I agree wholeheartedly with you. To me, implementing a MUA in C/C++ >is just silly. Use Python, use scheme, use lisp, use smalltalk, use >ocaml, use tcl, use perl (shudder) - use just about anything else, and >you're pretty likely to end up with a better, more stable solution >faster. > >Mind you, I hate all forms of GUI programming, some I'm not going to >write that killer MUA in Python ... it does surprise me that noone has >written one yet though. Or maybe they have, and I just don't know >about it? It's not python, and it does have it's quirks, but TkRat is nice. -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From R.Brodie at rl.ac.uk Thu May 11 09:27:19 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Thu, 11 May 2000 14:27:19 +0100 Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> <LisS4.3645$wYl.205593088@newsb.telia.net> <391A58E5.C9487C30@san.rr.com> <391A7AB4.B132D9DA@one.net.au> <391A92A4.F64FF43A@san.rr.com> Message-ID: <8fecfp$pli@newton.cc.rl.ac.uk> "Courageous" <jkraska1 at san.rr.com> wrote in message news:391A92A4.F64FF43A at san.rr.com... > I see. Well, then all things considered, I have no idea why one > would want to use python/OS threads at all. The uthread implementation > on stackless really rips. It depends on your reason for using threads. Sometimes, it just means that you can write cleaner code. Having a multiprocessor, and using multiple threads, and caring about the execution time of the Python interpreter are putting you in something of a minority. For one thing, it means that you are using an interpreted language for something performance critical. In a lot of problems, the inner loop is likely to end up in external modules which will multiprocess fine anyway. If yours isn't one of them them sure, go ahead. From jkraska1 at san.rr.com Thu May 11 06:56:04 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 10:56:04 GMT Subject: Python threads: backed by OS threads? References: <391A4EDE.EC2BB3AB@san.rr.com> <LisS4.3645$wYl.205593088@newsb.telia.net> <391A58E5.C9487C30@san.rr.com> <391A7AB4.B132D9DA@one.net.au> Message-ID: <391A92A4.F64FF43A@san.rr.com> > Unfortunately, the locking mechanism is very simple: it doesn't know > whether you're going to run into trouble or not, so it always acquires > the lock so that only one thread of Python code can run at any time. > > However, I/O operations can effectively multithread, so if you're doing > a lot of I/O, you may see a performance improvement. One of my programs > ran up to 80% faster when moved from a single-processor to a > dual-processor machine. I see. Well, then all things considered, I have no idea why one would want to use python/OS threads at all. The uthread implementation on stackless really rips. C/ From amitp at Xenon.Stanford.EDU Sun May 28 19:39:14 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 28 May 2000 23:39:14 GMT Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> <39311C09.75F70C54@tismer.com> <8gsakr$827$1@nntp.Stanford.EDU> Message-ID: <8gsan2$82n$1@nntp.Stanford.EDU> Amit Patel <amitp at Xenon.Stanford.EDU> wrote: | | Actually what I'm envisioning is that the __parent__ is not the | caller, but the namespace of the function that defined the current | function: | Oops, sorry, I missed where you wanted dynamic scope. I'd much rather have lexical / static scope, so that's what I had in mind when I wrote up the __parent__ thing. - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From gmcm at hypernet.com Fri May 12 22:22:39 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 13 May 2000 02:22:39 GMT Subject: Distro for IBM OS/390 References: <391bf7b1@wwwproxy3.westgroup.com> <20000512183053.B15594@bigskytel.com> Message-ID: <391cbc6f$0$27874@wodc7nh0.news.uu.net> David Porter <jcm at bigskytel.com> wrote: > >* Chris Lada <chris.lada at westgroup.com>: >> Does anyone know if there is a Python distribution for IBM's OS/390 ? >> >If there were, I think it would be mentioned here: > >http://www.python.org/download/download_other.html > >which it isn't. No,there's no pre-built distribuion. But sometime around last December, IBM had a web page somewhere with instructions for building Python 1.4 on big iron. I remember mentioning it in the Python-URL!, so the archives should have it (search for "heavy metal", I think). From mwh21 at cam.ac.uk Wed May 10 13:53:22 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 May 2000 18:53:22 +0100 Subject: Python's parser. Message-ID: <m3d7mus359.fsf@atrus.jesus.cam.ac.uk> I thought I might waste some time by having a crack at implementing += and friends in Python. I think I know what I want to do on the codegen side, but at the moment that hurdle looks some way off. How much effort is involved to get Python to accept a '*=' token? I've 1) Added a line aexpr_stmt: testlist '*=' testlist at the end of Grammar/Grammar, and changed small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt to small_stmt: expr_stmt | aexpr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt 2) changed #define DOUBLESTAR 36 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ #define OP 37 in Include/token.h to #define DOUBLESTAR 36 #define TIMESEQUAL 37 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ #define OP 38 3) Added "TIMESEQUAL" to _PyParser_TokenNames in tokenizer.c 4) Changed switch (c2) { case '=': return GREATEREQUAL; case '>': return RIGHTSHIFT; } break; in Parser/tokenizer.c:PyToken_TwoChars to: switch (c2) { case '=': return GREATEREQUAL; case '>': return RIGHTSHIFT; } break; 5) Made clean, made the parser, made python. But when I fire up the new ./python I get: XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! XXX ambiguity! Python 1.6a2 (#6, May 10 2000, 17:36:56) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam File "/home/mwh21/.pythonrc", line 7 readline.set_completer(mycompleter.complete) ^ SyntaxError: invalid syntax >>> which, I take it, is bad. Help? Anyone? This can't be *that* hard, can it? TIA, Michael -- About the use of language: it is impossible to sharpen a pencil with a blunt axe. It is equally vain to try to do it with ten blunt axes instead. -- E.W.Dijkstra, 18th June 1975. Perl did not exist at the time. From mhammond at skippinet.com.au Sun May 7 05:10:46 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 07 May 2000 09:10:46 GMT Subject: How do I embed Python on Windows NT? Docs don't help! References: <852568D8.0014D5A1.00@aamta02.avid.com> Message-ID: <qqaR4.13463$v85.89420@news-server.bigpond.net.au> > I'm an experienced C++ > developer, but am new to both Python and DLL's. In that case it will all be fine once a few things click... > I successfully built "pythonw_d.exe" in the PCbuild directory, but it > doesn't do anything! No console, no output, no error messages, > nothing. It is designed that way - the "w" means "windows" - when really it should ge "g" for "gui". Definately start with python(_d).exe. pythonw.exe is only used for certain types of programs, and even then only late in the development cycle. > I tried to write a super-simple console app that includes the Python > interpreter, using the program in the PCbuild directory as a guide, > but I can't even get it to link. "WinMain" calls "Py_Main", but > neither links it not explicitly loads a DLL, and it comes up > undefined at link time (no surprise). How is this symbol resolved?!? Note that WinMain is the entry point for GUIs. You will have the exact same issue for python.exe, except the top-level entry point is simply "main". It is resolved with a #pragma in the source code. One of the headers has a #pragma comment(lib, "python_d.lib") (or minus the "_d" for none-debug) line, informing the linker to attempt to locate that named lib. > There's a mysterious file in the "pythonw" project called > "python15" that I assume has something to do with the DLL, That is simply an MSVC dependency - it tells MSVC that the DLL must be built before the .exes. > How do I embed the Python interpreter using a DLL? Just include the .h files, and call the functions :-) > Should I even bother with this DLL stuff, or should I just try to embed it directly > (compile & link all the Python files into my app)? Definately go the DLL way. Mark. From aahz at netcom.com Fri May 26 10:22:07 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 May 2000 14:22:07 GMT Subject: Java vs Python References: <KzLT4.3373$Kc3.20912@news-server.bigpond.net.au> <jaem6zy61t.fsf@helix.twistedmatrix.com> <8F3F72DB7davemrquizorg@212.27.32.76> <392E4163.668C3BC9@darmstadt.gmd.de> Message-ID: <8gm1af$mi1$1@slb6.atl.mindspring.net> In article <392E4163.668C3BC9 at darmstadt.gmd.de>, Robb Shecter <shecter at darmstadt.gmd.de> wrote: > >I use Python for 90% of my new projects. (I work only on Linux.) >But, if I know that the software has to run on, say Linux and NT, then >I'll use Java. I've seen, first hand, successful cases of "porting" a >Java program that was written on Linux to NT by just copying the class >files. I've seen the same thing, many times over, with Python. And I'm working in a Linux/NT shop. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From claird at starbase.neosoft.com Wed May 31 22:14:28 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 31 May 2000 21:14:28 -0500 Subject: [Python-Dev] What's that sound? References: <Pine.LNX.4.10.10005310928270.30220-100000@nebula.lyra.org> Message-ID: <3302A334E7FAFD16.1D3E89521AAD6B9B.465172EF8E4C146A@lp.airnews.net> In article <Pine.LNX.4.10.10005310928270.30220-100000 at nebula.lyra.org>, Greg Stein <gstein at lyra.org> wrote: >On Wed, 31 May 2000, Paul Prescod wrote: >> ActiveState announces four new Python-related projects (PythonDirect, >> Komodo, Visual Python, ActivePython). >> >> PythonLabs announces four planet-sized-brains are going to be working on >> the Python implementation full time. > >Five. > >> PythonWare announces PythonWorks. >> >> Is that the sound of pieces falling into place or of a rumbling >> avalanche "warming up" before obliterating everything in its path? > >Full-on, robot chubby earthquake. > >:-) > >I agree with the basic premise: Python *is* going to get a lot more >visibility than it has enjoyed in the past. You might even add that the >latest GNOME release (1.2) has excellent Python support. . . . Good points, Greg. Well, if someone's keeping score--Barry? Is there a place for that at www.python.org?--a handful of others also impress me: 1. mod_python will soon take its place in Apache land (true, Greg?); 2. Red Hat's installer is a Python application; 3. Intel's adopted Python for its highest-profile extension language; 4. Zope and Mailman's get good at- tention; and 5. Bruce is starting to release chapters of *Thinking in Python*. Wow. Blessed are the cheesemakers. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From hafeez at lancom.com.au Thu May 18 00:52:27 2000 From: hafeez at lancom.com.au (Hafeez Bana) Date: Thu, 18 May 2000 04:52:27 GMT Subject: Python COM : Wierd Behaviour Message-ID: <39237638.8472457E@lancom.com.au> Hi, I have a python object for generating formatted Order documents which I have exposed via COM so that the API could be used by some order taking software written in Delphi 4. The Python version in use is 1.5.2. The code has been working fine for a couple of days and then yesterday it kept on raising the following error. "Unexpected Python Error. Exception TypeError: too many arguments; expected 1 got 2" on a method in the object called "printToFile" (which writes out the document to a specified file name. The actual method declaration is def printToFile(self,py_uni_filename): The code has been working fine so far. So in an effort to debug it further (I suspected that some mandatory fields in the document were being left out which turns out not to be true) I implemented another function "def rawPrint(self):" which returns a string representation of objects field values. This function calls no other functions..it simply returns a string representation of a list via str(self.document_values). Surprisingly rawPrint fails with the same error as printToFile. I changed rawPrint to do nothing ie. def rawPrint(self): pass and even to def rawPrint(self): return 1 The same error keeps on being raised "Unexpected Python Error. Exception TypeError: too many arguments; expected 1 got 2". Even stranger .. the printToFile method is now working, add an extra function rawPrint seems to fix other problems!!! I then changed rawPrint to def rawPrint(self, value = 9): return 1 and rawPrint calls stops raising the above exception and everything is working withouth a hitch!!! I have sample test code written in python and create tried creating the COM object via win32com.client.Dispatch and win32com.client.dynaminc.Dispatch but the python test code reports no errors. Only test code that is written in delphi has this strange behavior. Does anyone have an ideas,suggestions. The code seems to be temperamental :) Thanks, Hafeez From andy at petdance.com Wed May 24 10:39:56 2000 From: andy at petdance.com (Andy Lester) Date: Wed, 24 May 2000 09:39:56 -0500 (CST) Subject: Python equivalent to Perl's warn/confess/die In-Reply-To: <392BE833.EC8EBBA5@earthlink.net> References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> <Pine.WNT.4.21.0005240907250.269-100000@nt_alester> <392BE833.EC8EBBA5@earthlink.net> Message-ID: <Pine.WNT.4.21.0005240938480.269-100000@nt_alester> > You could write your own. Put this in a file called warn.py which lives > somewhere in your PYTHONPATH: Well, yah, I could write my own of EVERYTHING! That's what I was trying to avoid. :-) I really like the semantics of warn and die in Perl, so I think I'm just going to have make a module out of it. Thanks, Andy -- Andy Lester, andy at petdance.com, http://www.petdance.com "Inflammable material is planted in my head It's a suspect device that's left two thousand dead." "Hey, is this the new Green Day?" From mhammond at skippinet.com.au Thu May 4 18:32:18 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 04 May 2000 22:32:18 GMT Subject: Interrupting a running program References: <8epqfn$ofl$1@supernews.com> <Nq8Q4.10668$v85.70506@news-server.bigpond.net.au> <n5f3hs8fn95ipbk0o2b60j23dm6iuc17ah@4ax.com> Message-ID: <STmQ4.11322$v85.75643@news-server.bigpond.net.au> <robin.escalation at ACM.org> wrote in message news:n5f3hs8fn95ipbk0o2b60j23dm6iuc17ah at 4ax.com... > "Mark Hammond" <mhammond at skippinet.com.au> wrote: > Any chance of some basic debugger improvements? Like a resizable > window (its tiny tiny) and watch values that stay where you put 'em > (tree folds back up after every step -- bother). All done in the latest versions. 129 should go public in a day or 2, and it is there. All the 1.6 builds (eg, 131) have this. > Just a Python newbie. But already an evangelist! hehe - it has a habit of doing that to people :-) Mark. From moonseeker at my-deja.com Tue May 16 09:24:04 2000 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Tue, 16 May 2000 13:24:04 GMT Subject: how to use a proxy? Message-ID: <8fri52$25o$1@nnrp1.deja.com> Hi! How can I use a proxy (I'm behind a firewall) to get HTML pages from the net? I hade a look on HTTPlib and URLlib but there is no comment about proxies. Regards, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From nospam.newton at gmx.li Mon May 29 01:31:40 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Mon, 29 May 2000 05:31:40 GMT Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> <392f60e8.260627511@news.nikoma.de> <8gs2u0$m7m$4@newshost.accu.uu.nl> Message-ID: <3931fb92.45603755@news.nikoma.de> On 28 May 2000 21:26:24 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: > Philip 'Yes, that's my address' Newton <nospam.newton at gmx.li> wrote: > [snip] > > Try feeding this to python, then: > > > if 1 == 1: > > print "This won't work" > > > You'll get a SyntaxError if somebody removes all leading indentation. > > If you feed this: > > if (1 == 1) { > printf("This won't work.\n"); > } > > To C you'll get compiler errors as well if somebody removes all the '}'s. :) > > If-malicious-somebody's-start-removing-stuff-all-code-is-lost-ly yours, However, removing indentation is more common than removing random characters such as '{' or '}' (or, with Pascal, 'BEGIN'), wouldn't you agree? For example, if someone writes HTML without remember that two or more spaces get treated as one? We're talking about what happens in real life. Indentation is more often smashed than characters are lost. Cheers, Philip -- Philip Newton <nospam.newton at gmx.li> If you're not part of the solution, you're part of the precipitate. From invalid.address at 127.0.0.1 Sat May 27 14:27:57 2000 From: invalid.address at 127.0.0.1 (David) Date: Sat, 27 May 2000 18:27:57 GMT Subject: Indented gonads. References: <8gjqer$k8v$1@nnrp1.deja.com> <20000525225425.Z13281@xs4all.nl> <392E3C88.DADE571@geneva-link.ch> <8F40861C1davemrquizorg@212.27.32.77> <392ebdba.34189549@news.telus.net> <m3g0r5ezpn.fsf@wilma.george.org> Message-ID: <39300dde.41161466@news.telus.net> On 26 May 2000 15:03:32 -0700, Harry George <hgg9140 at seanet.com> wrote: >The key point is that the various "helpful" agents scattered through >MS products default to on. It is one thing to allow someone to turn >them on -- they will thus also know how to turn them off. It is quite >another to turn them on by default. Frequently I've had to help >casual MS users untangle the effects of those agents... There are faults in Word, including some gullywhumpers that will hose your entire document in a heartbeat (the Master Document scenario) and some that are just endlessly annoying (some inconsistencies in the UI, less-than-perfect handling of dash/en-dash/em-dash autoconversion). But to whinge on about how Word automagically corrects 'accidental use of cAPS LOCK KEY' by default -- and I hate to be this blunt in the Python newsgroup, because it is a truly friendly community -- is plainly asinine. By far the majority of word processor users are NOT writing program code, or writing about program code: it makes far more sense for this behaviour to default on than off. And that you've had to help them turn this feature off is proof that they wouldn't be able to turn it on by themselves, and probably would never have realized that such a feature even existed -- and if you really have been helping 'casual MS users,' then you know this already. Let me be even more blunt: you shot your mouth off and got called on it. Your cheap sniping at a perfectly valid MSWord default behaviour isn't legitimate. Your singularly uncommon and unlikely use of Word is not adequate reason to inconvenience the greatest majority of users. The only flaming you're receiving regards 'accidental user of cAPS LOCK KEY' and your assertion that it should be disabled by default, your attempt above to muddy the waters by dragging in other 'helpful agents' notwithstanding. Pick your sniping more carefully next time. There are Word features that you can legitimately criticize, should it ever be appropriate to do so -- highly unlikely in a Python forum. Flame over and out. From emile at fenx.com Tue May 23 22:27:24 2000 From: emile at fenx.com (emile at fenx.com) Date: Tue, 23 May 2000 19:27:24 -0700 Subject: case sensitivity and XML Message-ID: <392B3E0C.AD68C604@fenx.com> Blake Winton <bwinton at tor.dhs.org> wrote in message news:<slrn8imb6a.1hp.bwinton at tor.dhs.org>... > On Tue, 23 May 2000 08:43:26 -0700, Emile van Sebille wrote: > > > >>>> class Foo: > > pass > > > >>>> foo=Foo() > >>>> foo.FOo=1 > >>>> foo.FOo=[1,2,3,4] > > I think you mispelled Foo... No, really... :) > and I'm not sure who's point I'm proving by pointing this out... > i'M NoT sURe WhOse POInt I wAS MakinG, ONly thAt BAd cOdE COmeS fRoM THe tYPiSt! WoUlD-SoMEOne_paSS-tHe-HUnGaRiAn-NoTATioN-lY Y"rS Emile van Sebille emile at fenx.com From m.faassen at vet.uu.nl Mon May 22 09:08:13 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 13:08:13 GMT Subject: Damnation! References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <8gaui8$bhu$2@newshost.accu.uu.nl> <oqu2fq9754.fsf@titan.progiciels-bpi.ca> Message-ID: <8gbbft$peo$1@newshost.accu.uu.nl> Fran?ois Pinard <pinard at iro.umontreal.ca> wrote: > m.faassen at vet.uu.nl (Martijn Faassen) ?crit: >> Fran?ois Pinard <pinard at iro.umontreal.ca> wrote: >> > Roy Katz <katz at Glue.umd.edu> writes: >> >> 1. Python 3000 may be case-insensitive. >> > Horror, hell, and damnation! April 1st should be far behind us by now! >> Oh, ick, too late. I see this thread exploded. I suppose it's too late >> to throw in references to Haskell, non-euclidian geometry and evolutionary >> biology to douse the flames, hm? > There are modest tries with Teletypes and such things :-) Yeah, I noticed afterwards. Not that I didn't contribute to the case sensitivity discussion! :) > P.S. - Do you read this message in the list? I got two rejects with: > <python-list at python.org>: Command time limit exceeded: > "/home/mailman/mail/wrapper post python-list" I read it through the newsgroup (comp.lang.python), not through the mailing list gateway. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From lexberezhny at email.msn.com Fri May 12 22:27:28 2000 From: lexberezhny at email.msn.com (lexberezhny) Date: Fri, 12 May 2000 22:27:28 -0400 Subject: AI and Python References: <OwZBsfGv$GA.306@cpmsnbbsa04> <Yi2T4.266$mh3.4671@news> Message-ID: <#26g7HIv$GA.269@cpmsnbbsa04> Hi, I was wondering if there was a version of eliza in python? - Lex Chris Ryland <cpr at emsoftware.com> wrote in message news:Yi2T4.266$mh3.4671 at news... > http://www.norvig.com/python-lisp.html > > is a good comparison of Lisp and Python (Lisp being the canonical AI > language). There's more on that web site as well. > -- > Cheers! > / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com > > "lexberezhny" <lexberezhny at email.msn.com> wrote in message > news:OwZBsfGv$GA.306 at cpmsnbbsa04... > > I was wondering if anyone has dont any artificial inteligence with Python. > > I am writing a program for my school, which is ment to talk to kids in > > trouble, it will ask some simple questions based on the student answers, > > there is already a list of questions that we might want answered, so its > not > > really AI. But I wanted any opinions on this topic. Thanks. > > > From hinsen at cnrs-orleans.fr Mon May 29 05:52:24 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 29 May 2000 11:52:24 +0200 Subject: NumPy and Octave (qestion and discussion) References: <slrn8ionh8.vq.hzhu@rocket.knowledgetrack.com> <slrn8itueg.111.hzhu@rocket.knowledgetrack.com> Message-ID: <m34s7hwunb.fsf@chinon.cnrs-orleans.fr> hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) writes: > However, linear algebra is not just another application domain. It is one > of the foundations of numerical computation. It would be a pity that it > could not be expressed efficiently in an otherwise almost perfect language. It is perfectly possible to implement linear algebra classes on top of NumPy. For some reason, nobody has done it yet. I use linear algebra a lot myself, but I haven't really missed linear algebra style matrix operations in Python. I always end up implementing problem-specific classes that use NumPy internally. Of course this approach might not suit other applications. Anyway, implementing basic matrix and vector classes should be an afternoon job. Perhaps many people have written some and not considered them worth publishing! > So my point is that perhaps the importance of numerical computation warrant > an (expressional) syntax that's more convenient. I think this can be done > without conflict with python's general syntax. It just need to be different > from NumPy's special choices. The only limits are those imposed by Python. For example, you can't use square bracket notation for arrays because they are already used for lists. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From dworkin at ccs.neu.edu Wed May 10 18:23:36 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 10 May 2000 18:23:36 -0400 Subject: Figuring out an object's type In-Reply-To: "David Allen"'s message of "Tue, 09 May 2000 19:40:11 -0500" References: <8fab7p$4kh$1@bob.news.rcn.net> Message-ID: <vndbt2e3uzb.fsf@camelot-new.ccs.neu.edu> "David Allen" <s2mdalle at titan.vcu.edu> writes: > But types doesn't seem to distinguish between different types > of user defined classes. I.e. if I say: > > class Foobar: > pass > > class Baz: > pass > > x = Foobar() > y = Baz() > > then type(x) == type(y) yeilds 1. > > Which kinda sucks. :) > > How do I tell the difference between a Foobar and a Baz? Well, there is 'isinstance()': >>> class Spam: ... pass ... >>> class Eggs: ... pass ... >>> x = Spam() >>> isinstance(x, Spam) 1 >>> isinstance(x, Eggs) 0 In my own use, however, things like hasattr() are often more useful, since in Python the name of an instance's class is generally much less important than the interface that it exposes. But that depends on what you really want, which you didn't say. -Justin From spamfranke at bigfoot.de Sun May 7 22:14:00 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Mon, 08 May 2000 02:14:00 GMT Subject: PythonWin win32all-131 editor crash Message-ID: <39162102.611545@news.btx.dtag.de> I get a reproducable segfault in the PythonWin editor (win32all-131 / Python 1.6a2) both on a Win98 and NT4 box whenever I have a source file large enough (~70kB) and hit the ^ key (requires two keystrokes on my german keyboard: ^ and space). I guess it's a scintilla problem - did not happen with 1.5.2 / win32all-128). Can anyone confirm this? - Just copy a couple of lines a few hundred times and try it. Stefan From emile at fenx.com Sat May 27 19:43:27 2000 From: emile at fenx.com (emile at fenx.com) Date: Sat, 27 May 2000 16:43:27 -0700 Subject: Getting Variables from a file Message-ID: <39305D9F.B1201DD4@fenx.com> This should get you started: vars = """dof = 8 elements = 10 mesh_dof = 300""" for line in vars.split("\n"): exec (line) print dof,elements,mesh_dof You should be careful exec'ing things though, so maybe: vars = """dof = 8 elements = 10 mesh_dof = 300""" for line in vars.split("\n"): try: k,v = line.split(" = ") exec (line) except: # doexn't parse out as tuple w/ interspersed = pass print dof,elements,mesh_dof is safer. I'm sure there's still a hole in that, I just don't see it right now. Emile van Sebille emile at fenx.com Curtis Jensen <cjensen at bioeng.ucsd.edu> wrote in message news:<39305B84.A06745E9 at bioeng.ucsd.edu>... > I have a text file of the form: > > (var = integer) > dof = 8 > elements = 10 > mesh_dof = 300 > . > . > . > . > > I want to read the file from within Python and then create a variable in > python of the same name as what is in the text file, and holding the > assigned value. Assuming I don't already know the names of the > varialbes; how do I do this? I can do the file I/O, but how do I change > a character string into a variable name? Thanks. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > -- > http://www.python.org/mailman/listinfo/python-list > From ullrich at math.okstate.edu Thu May 4 13:06:11 2000 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 04 May 2000 17:06:11 GMT Subject: python's acceptance References: <pZdQ4.7603$wb7.519676@news.flash.net> <F4fQ4.15250$HG1.409063@nnrp1.uunet.ca> Message-ID: <3911adfe.180898921@news> On Thu, 4 May 2000 09:36:02 -0400, "Warren Postma" <embed at geocities.com> wrote: >I agree with all of Scotts ideas. I'd like Python to become just as flexible >and efficient a producer of Windows executables as Delphi is currently for >me. I think I'll always want and need Delphi around too. Different tools, >different jobs. Delphi is a non-starter as a system scripting tool, whereas >Python will always be great at that. I think Delphi will always be superior >as a means of distributing binary single executables (requiring no runtime, >vbrun.dll, .pyd files, or what have you). Irrelevant to real Python guys, but as long as you mention Delphi: You know there's a very nice set of Python for Delphi components out there (I have no idea whether http://www.imaginet.fr/~mmm/python.html is still the right url; if not Morgan Martinet at mmm at imaginet.fr might know where to go.) Makes it very easy to use a Delphi program as a front end for Python scripts. (Or to let Python programs execute a little bit of compiled code for the hard parts, or to let Delphi programs use a little Python for the interesting parts.) Another useful aspect is that then you can make a little Delphi program that you use in place of the interactive mode of Python. There are two big advantages to this: First, it works exactly the way you want, and second, you can easily forget what modules you automatically import on startup, allowing you to post really stupid questions on comp.lang.python from time to time... DU From vetler at news.ifi.uio.no Mon May 8 06:11:29 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 08 May 2000 12:11:29 +0200 Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <slrn8hc7lg.8p7.neelk@brick.cswv.com> Message-ID: <yay4s89z6zy.fsf@ganglot.ifi.uio.no> * Neel Krishnaswami > Vetle Roeim <vetler at ifi.uio.no> wrote: > > on 2000-05-07, Glyph Lefkowitz wrote: > > > > he uses a lot of them. Common Lisp, Ada, Simula, C++, C, Haskell, > > ML. he knows languages impose restrictions, but he dislikes the > > restrictions Python impose. > > Incidentally, Haskell uses whitespace much as Python does. hmmmm.. I'll have to ask him about this! vr From scarblac-spamtrap at pino.selwerd.nl Wed May 3 05:34:22 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 3 May 2000 09:34:22 GMT Subject: Backward chaining for __init__? References: <390F8C7E.9986DAE0@san.rr.com> <B5350B1F.2B7F%dgoodger@bigfoot.com> <390FA242.C6DC9BBC@san.rr.com> Message-ID: <slrn8gvsij.oe9.scarblac-spamtrap@flits104-37.flits.rug.nl> Courageous wrote in comp.lang.python: > > class Derived(Parent): > > def __init__(self): > > Parent.__init__(self) > > # do whatever else > > Thank you. Somehow in the various pieces of documentation > I have, it wasn't at all obvious to me that you could treat > the type as an object. This makes sense now in retrospect. It's not a type but a class, and not only can you treat it like an object, in fact it *is* an object like any other :-). > I'm curious, however, as to the philosophical justification > for leaving backward-chaining ctors out of Python? While > it's just synactic sugar, some kinds of sugar really taste > good. For one thing, __init__ isn't really a constructor but an initializer. The object is first constructed, then a function called __init__ is called. It's just a normal method, otherwise. So if the interpreter were to call the parents' versions of this method too (with which arguments?!), it would have to do the same thing for any other method call. So if class A: def m(): print "A" class B: def m(): print "B" class C(A,B): def m(): print "C" C().m() Would you want that to print "C", "A", and "B"? > What would be really nice is some use controlled way of > making backward chaining methods in general, as opposed > the the limited __init__ case. Everywhere you want to call a method in the parent (like the one you're overloading), you just call Parent.method(self, args). What would you suggest that is better? (and still consistent with the rest of Python). Main philosophical reasons: __init__ is just a method like any other. Explicit is better than implicit. -- Remco Gerlich, scarblac at pino.selwerd.nl This is no way to be Man ought to be free -- Ted Bundy That man should be me From jkraska1 at san.rr.com Wed May 24 22:14:17 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 02:14:17 GMT Subject: Good ideas :-), no time :-( References: <oqwvkkp5q6.fsf@titan.progiciels-bpi.ca> <8ggfn6$dhd$1@newsserver.rrzn.uni-hannover.de> <392C76CF.27A5D18B@san.rr.com> <oqln0zz8vd.fsf@titan.progiciels-bpi.ca> Message-ID: <392C8D1D.C5DEB536@san.rr.com> > All is relative, you know. The complexity is inherent to some setup, > and `make' is no magician to reduce that complexity, which it then ought > to represent. This is inescapable. *Shrug*. Look into combining wildcarding with suffix substitution. For example, this GNUMakefile builds an entire server. Basically the SRC:= line says "every cap-C file in this directory", and the OBJ:= line says "substitute every .C file with a .o equivalent including a directory prefix of whatever $OBJDIR is". So dozens of .C files get built with this makefile. I use something similar for libraries (which builds both static and dynamic versions): ################################################################################# include $(PROJECTDIR)/project.mk include $(MAKEINFO)/basic include $(MAKEINFO)/cc include $(MAKEINFO)/world.proj ################################################################################# ## DRAFT TARGETS ################################################################################# SRC := $(shell echo *.C) OBJ := $(SRC:%.C=$(OBJDIR)/%.o) EXE := $(BINDIR)/wrldsrv.exe ################################################################################# ## TARGETS ################################################################################# local: dirs $(EXE) dirs: mkdir -p ./$(OBJDIR) $(EXE): $(OBJ) $(CC) $(OBJ) -o $@ $(LFLAGS) $(LIBS) $(LASTLIBS) $(OBJDIR)/%.o: %.C $(CC) -c $(CFLAGS) $(DEBUGF) $(IFLAGS) $(DEFINES) $< -o $@ What's notable is that I can generally drop this makefile into just about any .C source directory and have stuff up and compiled on very short notice. Most source directories are either an executable or a library, I've found. For combination directories, it get's tougher of course, but in my experience, the *better* thing to do is to break out the combination directory into seperate directories, keeping everything infinitely manageable. While I seldom toot my own horn about anything, managing very large source (multiple platform, multiple language, multiple configuration) is something I'm very, very good at, so I hope you appreciate it when I say that GNUmake is one of the very best build tools I've ever found for anything like this. IT REALLY ROCKS. C/ From p.redondo at optichrome.es Tue May 23 05:12:26 2000 From: p.redondo at optichrome.es (Pedro Redondo) Date: Tue, 23 May 2000 11:12:26 +0200 Subject: Photo and Image (Tkinter) Message-ID: <8gdhv7$4s59@esiami.tsai.es> Hello: I need samples for create and modify Images with Tkinter. -- Pedro Redondo Vergara p.redondo at optichrome.es Optimus, El Sistema de Gesti?n para la Industria Gr?fica Optichrome Computer Systems Espa?a, S.A. C/ Andr?s Tamayo, 3 - 28028 Madrid ES: Tel: +34 917 242 670 Fax: +34 917 130 360 From neelk at brick.cswv.com Tue May 2 22:52:57 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 3 May 2000 02:52:57 GMT Subject: How many is "too many" with lists? References: <Pine.LNX.4.10.10005020824370.13821-100000@propylaea.anduin.com> <meh9-068C25.11551802052000@news.cit.cornell.edu> <8emtqt$dsf$1@nntp9.atl.mindspring.net> <meh9-9A73FA.12480102052000@news.cit.cornell.edu> <slrn8guv40.ocb.jraven@corvus.local> <390F80C7.20CBBEFC@san.rr.com> Message-ID: <slrn8gv76m.5kv.neelk@brick.cswv.com> Courageous <jkraska1 at san.rr.com> wrote: > > Well, this is a bit off the subject, but in recent Python > misadventures, I'm pretty sure that > > for i in range ( 1000000 ): > > definitely isn't the right way to loop............ You can use xrange(), which doesn't allocate a whole list, but instead returns an object with __getitem__ methods that return the right integers to emulate a range. When you need to loop over 10 million elements it becomes helpful. :) Neel From thomas at xs4all.net Mon May 15 11:04:19 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 15 May 2000 17:04:19 +0200 Subject: Question In-Reply-To: <8fophf$e7n$1@fe1.cs.interbusiness.it>; from pgiacomelli@netics.net on Mon, May 15, 2000 at 02:16:00PM +0200 References: <8fophf$e7n$1@fe1.cs.interbusiness.it> Message-ID: <20000515170419.V13281@xs4all.nl> On Mon, May 15, 2000 at 02:16:00PM +0200, Piero Giacomelli wrote: > Sorry if I make the ultra-faq but where can I find a good online manual on > Python (better if downloadable) www.python.org, click on ''Documentation''. (Or go directly here: http://www.python.org/doc :-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sandysj at asme.org Tue May 2 15:42:54 2000 From: sandysj at asme.org (Jeffrey P. Sandys) Date: Tue, 2 May 2000 19:42:54 GMT Subject: Python for Kids References: <20000501185503.718041CD28@dinsdale.python.org> <390E07B7.72EA3E00@wag.caltech.edu> <390F674F.9C5C9F1E@exceptionalminds.com> <IMAP4.14259$HG1.387791@nnrp1.uunet.ca> Message-ID: <390F2FBE.B01C882F@asme.org> Warren Postma wrote: > Timothy Grant wrote: > > OK, I'm going to piggyback on Rick's question. > > > > My son's school district has asked me to teach an introductory > > programming class to some of the talented and gifted students this > > summer. They want me to teach for eight days. 1.25 hours a day for > > 1-2 graders, 1.25 hours a day for 3-6 graders. > > > > I want to use Python, but have no experience with Python on the Mac, > > which is what the school district uses. > > > > First question: what do I need to be careful of, if anything when > > using Python on Mac? > > I think the bigger issues than using a Mac are how to teach > programming to young kids. Has anyone got books on this? I remember > Logo, but I don't know how much work has been done since then on > these things. I agree. >From my experience I would not teach Python (or Logo) to first and second graders, they will become frustrated from the syntax rules and spelling problems. Fourth graders are ready for programming in Logo. There are still lots of Logo books available. The book _Minds in play: computer game design as a context for children's learning_ by Yasmin Kafai is mostly about how to help managing children's programming classes, and would be useful for teaching python. > Is anyone else interested in designing a Python-based Game for Kids, > to teach programming? Then, perhaps intuition will take flight, and > they'll come up with new ideas. Once they "grok" python, watch out! ;-) Yes! I thought of teaching python to a group of 6-7th graders this year. I decided to stick with Logo (LISP without parenthesis). I think the python syntax and concepts might be more difficult for this age group to grasp. I would be interested in trying to teach python at the middle school level if course materials were available. Let us know how your class goes at the elementary level. > Other stops along this road could include classic simulations like > the LIFE simulator, and simple artificial-intelligence toys like the > "What kind of animal are you?" game, or Eliza. What really captivated > me as a kid was how much it seemed that computers, mere circuits, > where alive, once you programmed them with an interesting program. > That hasn't changed much. Life, Eliza and Animal are all staples of the Logo classes I run. > > Thoughts? > > Warren Postma Thanks, Jeff Sandys From jkraska1 at san.rr.com Mon May 15 22:04:57 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 16 May 2000 02:04:57 GMT Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <jazoq2i8ty.fsf@helix.twistedmatrix.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <jaitwfo0ee.fsf@helix.twistedmatrix.com> Message-ID: <3920AD73.BC4B6783@san.rr.com> > The python community, dispite being waaay smaller, seems more diverse > and generally more fun. Certainly, less deluded about the limitations > of the language. I suspect that it's the nature of the game. You have to be a fairly flexible and explorative kind of person who doesn't fall into language worship in order to be an early adopter of a programming language which isn't popular. That sort of selection process by nature excludes an entire range of personalities, many of them who are people you really don't want around, anyway. This group is much more friendly than, say, comp.lang.lisp or comp.lang.c++. > Because he didn't make C stackless: he made Python-in-C stackless, and > CPython is an implementation of a virtual machine as well as a > language. JPython relies upon the Java virtual machine, and is just > an implmentation of the Python language. Therefore, in order to make > JPython stackless, he has to edit the Java virtual machine, in order > to make CPython stackless, he had to edit the Python virtual machine. Exactly. He didn't even make the python virtual machine stackless (he couldn't... it's written in C!), what he did was make python frames and their usage within the python interpreted environment stackless. Since Mr. Tismer's around, I'm sure he'll comment soon, right Christian? :)- > In fact, he commented that making C itself stackless would be too hard > to really consider seriously and nobody in the community would > appreciate it at all. Hey, now take that back! I'd appreciate it whole lots. :) But I think you'd have to write a full fledged compiler for this, and that *is* a lot of work. C/ From effbot at telia.com Sun May 28 09:50:56 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 28 May 2000 13:50:56 GMT Subject: ob_refcnt INCREF and so on... References: <39301826.91D0E17D@san.rr.com> Message-ID: <4v9Y4.9857$Za1.154871@newsc.telia.net> jkraska1 at san.rr.com wrote: > In my efforts to grok references, I wrote a function to print the > ob_refcnt of python objects so I could test my understanding of > the reference system. in other words, you've reimplemented sys.getrefcount: http://www.python.org/doc/current/lib/module-sys.html > In the above code fragment, checkref(o) prints "2". The object "o" > has two references to it, and I'm not sure why. The closest thing > I have to a theory is that at the point of creating the argument, > "o" is assigned to a temporary tuple which grabs a reference count > to "o" (I based this theory on the knowledge that I have to parse > a tuple in the C extension code). that's correct (also see the getrefcount docs). </F> From pinard at iro.umontreal.ca Sun May 28 22:20:04 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 28 May 2000 22:20:04 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: danielt3@gte.net's message of "Fri, 26 May 2000 03:23:17 GMT" References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <20000522183552.A29224@mudge> <3929D3F6.DE9CCCBC@prescod.net> <CF125757AB5DD5D5.094581AB6FCF9F26.41037540192780A3@lp.airnews.net> <naNQvMAD8aL5Ewhx@gol.com> <danielt3-2505002323170001@1cust233.tnt4.clearwater.fl.da.uu.net> Message-ID: <oqpuq69jxn.fsf@titan.progiciels-bpi.ca> danielt3 at gte.net (Daniel T.) writes: > I also personally find it much easer if I don't have to worry about > whether the variables name is seatbelt, or seatBelt. :-) Or seabelt, or saetblet, or stealbelth, or whatever. Yes, _much_ easier! When I was a regular student, and learning many programming language (besides programming techniques), we started to say among ourselves that some were Kleenex-languages, that is, meant for writing programs to be executed once or twice, then thrown away shortly thereafter, as the code was clearly not designed for later contemplation. Most Kleenex-languages we studied were especially easy to write, in that "much easier" category. Now that I'm grown up, I'm not much interested in Kleenex-languages anymore, and would feel sorry if Python was becoming one. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From cjc26 at nospam.cornell.edu Wed May 31 23:12:35 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 01 Jun 2000 03:12:35 GMT Subject: Marking hyperlinks in a Text widget References: <8h04jo$lgh$1@zingo.tninet.se> <oq7lcc41zr.fsf@titan.progiciels-bpi.ca> <8h0kn5$6pv$1@cubacola.tninet.se> <slrn8j94er.ebv.cjc26@localhost.mindriot.net> <8h4d2e$ap4$1@cubacola.tninet.se> Message-ID: <slrn8jblag.jua.cjc26@localhost.mindriot.net> * Andr? Dahlqvist <andre at beta.telenordia.se> menulis: | > def click(event): | > os.system("netscape -remote 'openURL(%s)'" % \ | > textw.tag_names('@%d,%d' % (event.x, event.y))[1]) | | Is openURL a function that you have written? If so, can I check it out? That's actually a command-line argument of Unix versions of Netscape. I don't know if it would work on Windows. If you're using Unix, try typing the following at a shell prompt (with Netscape already running): % netscape -remote 'openURL(www.python.org)' It should make Netscape go to the Python page. | If I understand the code above correctly textw.tag_names() in this | case returns the name of the tag associated with the text positioned | where the mouse is. But how do you actually get the URL? It actually returns the entire tuple we stored as its tag, not just the first tag name. Since the url was already entered as the second element of this tuple, we just do textw.tag_names(...)[1] to retrieve it. | I mean to | use textw.get(...) you need to know the index of the first and last | character in the URL we want, right? Nope; you just need to know the coordinate of one of the characters within the url. The character closest to where the mouse was clicked is the most convenient one to use :) | tag_ranges seam interesting. With the help of that one I can get the | positions of all the words tagged with 'url'. What I don't understand is | how to know which of these was just clicked. The callback function takes an argument (event), and you can get the x and y positions where the mouse was clicked using event.x and event.y. So if you want to use tag_ranges, you could just look for the range which contains (event.x, event.y). -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From ben at co.and.co Thu May 11 11:19:58 2000 From: ben at co.and.co (ben at co.and.co) Date: Thu, 11 May 2000 15:19:58 GMT Subject: Why should I switch to Python? References: <LOBBJCAMDNLNCGCCHGEICELEEHAA.charlie@intelligenesis.net> Message-ID: <ycAS4.22098$oI2.45871@afrodite.telenet-ops.be> Charlie Derr <charlie at intelligenesis.net> wrote: > [Tim Peters] > ~ > ~ [Grant Griffin] > ~ > Speaking of C, I find myself missing the "x=" operators, and "++". > ~ > However, I understand and endorse the reasons Python omits them. > ~ > ~ While ++ makes little sense in a language with immutable numbers, > > I'm probably missing something obvious here, but why? > > The only weird part that i see is that in order to implement it you would > have to do a type check and make sure the operand is of type integer, which > certainly seems to violate python's spirit, but I don't understand what's > relevant about numbers being immutable. I never write "5++" it's always > "varName++", which can obviously be done the long way with "varName = > varName + 1". Couldn't this be implemented with assignment in this > fashion? (not that i would want it to be done, i'm just curious) There will be some surprises: def malicious_print(i): i++ print i malicious_print(5) # Huh? b = 5 malicious_print(b) print b # Huh? Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From blablu at gmx.net Tue May 30 04:24:56 2000 From: blablu at gmx.net (Mike 'Cat' Perkonigg) Date: 30 May 2000 08:24:56 GMT Subject: how can I reload 'from *' ? References: <8F407AF9Dmikecat@192.168.10.38> <392EA245.58D09773@codeit.com> <8F435DDB4mikecat@192.168.10.38> <39333E51.B612DEAE@cosc.canterbury.ac.nz> Message-ID: <8F4468E7Dmikecat@192.168.10.38> greg at cosc.canterbury.ac.nz (Greg Ewing) wrote in <39333E51.B612DEAE at cosc.canterbury.ac.nz>: >Or more precisely, although you can > > import HUGO > reload(HUGO) > >to reload the module HUGO, that won't make any difference >to the values you've already imported from it into the >namespaces of other modules. > >On the other hand, if you just 'import HUGO' and then >use HUGO.whatever everywhere, there is no problem. > >YARNTUFMI* (yet another reason not to use 'from module import *'). > I keep one class definition in one file, because I try to keep them easily maintainable. But in my program I want to have the class definitions in one module because they should be easily reachable. Another code block checks the class files and reloads them if changed. Thats the reason why I have to use these strange constructs. Regards, Mike From scorder at incigna.com Wed May 17 09:49:21 2000 From: scorder at incigna.com (scorder at incigna.com) Date: Wed, 17 May 2000 09:49:21 -0400 Subject: TypeError: attribute-less object (assign or del) References: <CPEKKMGLLILAJEKJNAPDMEKMCAAA.scorder@incigna.com> <kmgU4.7733$Za1.119950@newsc.telia.net> Message-ID: <gc75is413flpgguqf5lb2i1pvf503k2e6d@4ax.com> Here is the line of VBScript that works: site.frames("main").forms(1).item("txtpassword").value = 'foo' And here is the line of Python that doesn't work. Site.Frames("main").Forms(1).Item("txtpassword").Value = 'foo' Maybe its the nested level of collections throwing things off? I don't have any problems modifying any of the properties of objects higher up the heiarchy. I'm definately at a loss here. Thanks, -Sam On Tue, 16 May 2000 18:23:12 GMT, "Fredrik Lundh" <effbot at telia.com> wrote: >Sam Corder <scorder at incigna.com> wrote: >> I'm using the windows script control to allow scripting in a VB project that >> I am working on. My app exposes a website object which users can script >> different things like clicking a link or looking for text (feedback). It >> works fine using VBScript but I want to use a more feature full language >> like Python. The problem is I keep getting a "TypeError: attribute-less >> object (assign or del)" error when trying to assign a value to an input text >> box. Does anybody have any clues? > >the error message means that you're trying to assign to (or remove) >an attribute, but the target variable doesn't have any attributes, e.g: > > >>> a = None > >>> a.foo = 10 > TypeError: attribute-less object (assign or del) > >>> del a.foo > TypeError: attribute-less object (assign or del) > ></F> > ><!-- (the eff-bot guide to) the standard python library: >http://www.pythonware.com/people/fredrik/librarybook.htm >--> From shapr at uab.edu Fri May 26 06:10:45 2000 From: shapr at uab.edu (Shae Erisson) Date: Fri, 26 May 2000 10:10:45 GMT Subject: IDLE, ID or EGO? References: <slrn8i3grk.dg.kain@cableadmin.com> <3921D4C6.91B2090F@acm.org> <b634is8k3hlocsljj3kuueni0jnsvjnh4f@4ax.com> <39221911.C3FB9056@san.rr.com> <392EE927.38A0@seebelow.org> Message-ID: <392E5331.A62B0C5E@uab.edu> Grant Griffin wrote: > I tried Pythonwin, which is very, very good, but I got frustrated with > the fact that each time I tried to run my revised Python code, it seemed > to remember the old version. (Maybe there's a workaround, but the > easiest one I've found is to use an IDE that isn't written in Python. > ;-) I rather like using IDLE. you hit F5 to load/reload the python code you're looking at. It also has a rather nice stack viewer that allows you to change the values of any variables, or double-click on a class and pull up its definition in the code. The ability to set breakpoints and the spiffy debugger are also quite useful. an-IDLE-coder-is-a-happy-coder-ly y'rs -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From richard_chamberlain at ntlworld.com Mon May 1 03:03:55 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Mon, 1 May 2000 08:03:55 +0100 Subject: COM question References: <390CDC8B.779DB0C3@world.std.com> <fc7P4.1061$Q47.842764@news.pacbell.net> <390D16B7.B2524B@world.std.com> Message-ID: <8_9P4.3745$Px3.100662@news2-win.server.ntlworld.com> David, What version of Office have you got? In the COM Browser on my machine I get Microsoft Word 8.0 Object Library. This is for Office 97 and I can start Word as: x=win32com.client.Dispatch('Word.Application') You may have a problem with your installation try reinstalling Word. Richard "David Lees" <debl.nospamm at world.std.com> wrote in message news:390D16B7.B2524B at world.std.com... > You are correct, I forgot to mention I am using Pythonwin. Thanks for > pointing out the COM browswer. Unfortunately, while it does tell what > is registered it does not tell me the name to use to access it. For > example, > x1 = win32com.client.Dispatch("PowerPoint.Application") works fine, but > > x1 = win32com.client.Dispatch("Word.Application") > > gives error message, thought I do see something registered as > word.document.6 when I look with the COM Browser. Any more suggestions? > > David Lees > > Sam Schulenburg wrote: > > > > I assume that you are using Pythonwin. If this is the case you can browse > > the registery for your COM objects. The particular example that you give > > "Word.Application" should work. Verify that when you browse the registery > > with the COM Browser provided in the tools menu, that you see Word. > > Sam Schulenburg > > > > David Lees <debl.nospamm at world.std.com> wrote in message > > news:390CDC8B.779DB0C3 at world.std.com... > > > I am working examples in Hammond book on Python. How do I get a list of > > > names of COM objects? I am on page 67 and and to know how to figure out > > > what is the name for a Microsoft Word object. In the example it is > > > referred to as: > > > "Word.Application", but this gives a name error. I am doing the client > > > call correctly, because when I substitute "Excel.Application" or > > > "Access.Application" I have not problem opening and closing Excel or > > > Access. Apparently Word must have a different name for COM stuff on my > > > system, so I thought that if someone can tell me how to look at the list > > > of COM objects the name will be obvious. I have Norton Utility under > > > Win95 OSR2, so I can easily look at the Registry (though as a Win95 > > > newbie, much of it is not intelligible) > > > > > > Thanks in advance. > > > > > > David Lees > > > From sabren at manifestation.com Sun May 21 15:01:07 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sun, 21 May 2000 15:01:07 -0400 (EDT) Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <fITV4.93734$E85.1918985@news1.rdc1.md.home.com> Message-ID: <Pine.BSF.4.10.10005211446370.22164-100000@chi.pair.com> On Sun, 21 May 2000, Eric Hagemann wrote: > This is a major point that drew me to Python and away from Perl. In Perl if > you use a variable on the right of an equal sign before it is used on the > left, Perl creates it for you and initializes it to the most logical form of > Null/0/"". I do not know how many hours I have spent looking for errors > induced by these kinda of 'benifits' of the langauge. Python on the other > hand puts up a fit if the varable is not first defined by having it on the > left side of the equal sign. That cuts way down on the errors -- especialy > subtle ones. Score one for Python ! ummmm... in Perl: use strict; $x = 1; yields: Global symbol "$x" requires explicit package name at - line 2. to fix it: use strict; my $x; $x = 1; > As far as typing help in the IDE has anyone notice the VB editor lately. I > was doing a bit of VB coding and noticed that as I created variables in the > editor and used the same spelling but different case the editor would 'go > back' to a previously same named variable in the same funtion and modify > it's case as well (spoooooooky!) but perhaps a mode like that (which would > probably cause havoc to some programmers -- so make it optional) could be an > enabler for the young and tender. Some VB-style editors (like the one in MS-Access) will do two things: 1. If you edit the topmost use of the variable in the file, it changes the case on all subsequent variables. 2. If you edit any other use, it changes whatever you just typed to match the case of the previous use. This still doesn't help the x = X() problem though... Any code that did this would wipe out the class X: >>> class X: ... pass ... >>> X = X() >>> X <__main__.X instance at a7e80> >>> X() Traceback (innermost last): File "<stdin>", line 1, in ? AttributeError: no __call__ method defined >>> (although.. come to think of it.. if X is in its own namespace, this wouldn't happen, because you'd have x = namespace.X() ...) > As a quick thought, how about the IDE undelining each _new_ variable as > defined in the code. Perhaps seeing a visual indication of variable > creation might help this problem This makes sense! You know... Somebody ought to just implement a tool-based solution NOW, and try it out in a usability test... Then we can have a solution long before comes around. :) Maybe a simple rule in IDLE: IF the file already has mixed case when you load it, don't mess with the cases.. ELSIF a case sensitivity training wheel flag is set (on by default), do cases the VB way.. ELSE ignore case. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From dalke at acm.org Tue May 2 17:49:40 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 2 May 2000 15:49:40 -0600 Subject: Do I always have to write "self." ? References: <270420001706386648%pecora@anvil.nrl.navy.mil> <slrn8ghc6t.f01.scarblac-spamtrap@flits104-37.flits.rug.nl> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <m3bt2tonyg.fsf@atrus.jesus.cam.ac.uk> <300420001008012011%pecora@anvil.nrl.navy.mil><20000430170952.A502@datapro.co.za> <B531EC9B.57C1%abrahams@mediaone.net><slrn8gp7ei.ilf.kc5tja@garnet.armored.net> <B53241E5.580F%abrahams@mediaone.net><slrn8gqf3a.k65.kc5tja@garnet.armored.net> <B533A0CB.592A%abrahams@mediaone.net> <slrn8guafv.pf0.kc5tja@garnet.armored.net> Message-ID: <8enie0$9n8$1@slb7.atl.mindspring.net> Samuel A. Falvo II wrote: >*I* don't think >Hungarian is nasty -- I see it as a tool a programmer can use to keep things >straight in his head, and on paper, precisely as a Physicist would use units >to keep things straight in his/her head. But particle and nuclear physicists (at least) don't use units :) There are a couple of notations where basic physical constants are set to 1, eg: c == speed of light == 1 h_bar == planck's constant/(2 pi) == 1 This reduces the need for carrying around a lot of extra constants, like c**3/h**2. When the calculations are finished, you then say "and because the final terms must be units of spam, we add eggs**3/viking". Andrew dalke at acm.org From effbot at telia.com Mon May 29 02:42:21 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 29 May 2000 06:42:21 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <sj3ejda85pj169@corp.supernews.com> Message-ID: <hjoY4.6071$wYl.223614464@newsb.telia.net> Eric Jacobs wrote: > Doesn't seem like it would have to. Just imagine a method in the sequence > "class" that said: > > def join(self, separator): > result = self[0] > for x in self[1:]: > result = result + separator + x > return result > > No new operators are necessary, unless you want join to do something > completely different... like, for example, joining strings efficiently? (If you don't see my point, try benchmarking your code vs. string.join on 10, 1000, 100000 substrings. Do you think the timing difference can be eliminated by writing your code in C?) </F> From jkraska1 at san.rr.com Mon May 15 01:16:54 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 May 2000 05:16:54 GMT Subject: Java vs Python References: <KzLT4.3373$Kc3.20912@news-server.bigpond.net.au> Message-ID: <391F88EB.D25BB0F8@san.rr.com> > I would just like to know how serious python is taken in the IT industry Python hasn't even made their radar. > If a web applicatoin was written in both Java and Python, > which would companies prefer ? Duh. Java. This is because IT professionals pick products that they can't get fired for picking. An old setting in the IT industry: "nobody ever got fired for picking Oracle." > 1. Which is more maintainable ? Python. No comparison. > 2. Which is more scaleable ? Hrm. Hard to say. Do keep in mind that a lot of your python can connect to third party tools at native speeds, if you learn a trick or two. > 3 Which is faster eg. Java servlets or Python CGI with mod_python ? Someone who's tried both will have to answer this one. Python can be kind of slow. The primary question to ask yourself at this point is how performance critical your application is. > about to start a major web project using Java but have been referred > to python as an alternative so I am investigating this option. Well if it's performance you want, ASP and embedded COM is probably what you want. *running for cover*. C/ From jmassung at magpiesystems.com Thu May 11 18:09:37 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Thu, 11 May 2000 16:09:37 -0600 Subject: number base conversion? (ASCII to Hex) References: <391b2bd5.66612734@news1.on.sympatico.ca> Message-ID: <56GS4.519$cZ3.27675@news.uswest.net> chibaA at TinterlogD.Tcom wrote in message <391b2bd5.66612734 at news1.on.sympatico.ca>... >How would I go about getting the base-16(hex) value of a character, >into a string? > Why would you need to do this? The decimal and hexadecimal values are the same. Just use itoa() on the decimal value (which is already the character value). Perhaps I am misuderstanding the question? >take character word[1] (for example) >and retrieve the hex value of 31 31h = (16)*3+1 = 48+1 = 49 char *_itoa( int value, char *string, int radix ); /* The radix parameter is the base you want your string is: */ itoa(49,myString,2); /* myString = "110001" */ itoa(49,myString,10); /* myString = "49" */ itoa(49,myString,16); /* myString = "31" */ Make sense? Good luck! Jeff From benji_york at my-deja.com Fri May 26 11:37:15 2000 From: benji_york at my-deja.com (benji_york at my-deja.com) Date: Fri, 26 May 2000 15:37:15 GMT Subject: Client side scrypting in Python Message-ID: <8gm5n9$ab1$1@nnrp1.deja.com> Interesting news item: Python (and Perl) to be added to Mozilla's client side scripting... "Our contributions to the Mozilla open source effort will start with adding Python and Perl bindings to XPCOM, Mozilla's component architecture. This change will open the Mozilla architecture and eventually make it available to Perl and Python programmers." -- Dr. David Ascher, Senior Developer and Mozilla Product Leader, ActiveState Press Release: http://www.activestate.com/Corporate/Media_Center/News/Press959150636.ht ml More Info: http://www.newsalert.com/bin/story?StoryId=CosTtWbKbytaXodG There is also a discussion on Slashdot (http://www.slashdot.org) about this. Benji York benji_york at calsonic dot com Information Technology Department Calsonic North America, Inc. Sent via Deja.com http://www.deja.com/ Before you buy. From kiyolee*remove* at ctimail.com Sun May 28 20:01:13 2000 From: kiyolee*remove* at ctimail.com (Kiyo Kelvin Lee) Date: Mon, 29 May 2000 10:01:13 +1000 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> Message-ID: <8gsc0q$80b$1@nina.pacific.net.au> If you want fast for this kind of do-nothing loop, why not simply remove the loop. If you want somekind of delay, why not using those time-delay functions. Reminded that Python is interpreted language and C is compiled language. Actually, some smart C compiler will remove this kind of do-nothing loop during optimization. Kiyo "Alexander" <alecdem at mit.edu> wrote in message news:392F8286.13371C4E at mit.edu... > Hi > > I have implemented loop in Python > > for k in xrange(1,100000000): > pass > > and the same one in C > for ( i = 0 ; i < 1e8; i++ ) ; > > and the second one seems to be working hundreds of times faster than the > first one > > Can I do anything with that. > > Thank you > > From nikolai.kirsebom at siemens.no Wed May 3 04:11:00 2000 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Wed, 03 May 2000 08:11:00 GMT Subject: COM Method/Property access Message-ID: <390fd2c3.84648107@news.mch.sni.de> I'm using Python as COM client with Outlook 97 as the server. In the documentation on Outlook, a received mail item has the method 'Forward', which according makes a new mail item which may be forwarded to another recepient (like pressing the forward button in outlook 97). I've noticed that I have to use the following syntax to get this to work. fwdItem = mailItem.Forward fwdItem.To = "someone at world" Since forward is a method I would have expected the following syntax to be the correct one: fwdItem = mailItem.Forward() Can anyone explain why the 'method' should be called without the braces. Nikolai From mhammond at skippinet.com.au Wed May 24 00:27:59 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 24 May 2000 04:27:59 GMT Subject: case-sensitivity compromise proposal References: <4.3.1.2.20000523075551.014d9e70@phear.dementian.com> <ibvW4.1719$bZ3.10015@news-server.bigpond.net.au> <020501bfc4b8$3ad35c20$4500a8c0@thomasnb> Message-ID: <jTIW4.2099$bZ3.13792@news-server.bigpond.net.au> "Thomas Heller" <thomas.heller at ion-tof.com> wrote in message news:020501bfc4b8$3ad35c20$4500a8c0 at thomasnb... > Not long ago I proposed to extend instance-objects to accept mappings > (UserDict or even C-extensions) as __dict__ instead of real dictionaries > only. hehe - there are some wicked tricks you could start pulling there :-) Ive got a feeling that if we re-propose this on python-dev after 1.6 has been released, we will get a more sympathetic ear. Im sure I will forget, so feel free to remind me in a couple of months, and we can work out how best to propose this then - more along the lines of "extending the abstract dictionary interface" than a case-sensitivty related proposal ;-) Mark. From guido at python.org Sat May 20 22:24:48 2000 From: guido at python.org (Guido van Rossum) Date: Sun, 21 May 2000 02:24:48 GMT Subject: <file object>.truncate() References: <slrn8ie82s.fkt.magog@orcs_bane.localdomain> Message-ID: <39277350.E4887549@python.org> Bjoern Lindstroem wrote: > > When I do the following: > > f = open('file', 'w') > f.truncate(3) > f.close() > > the file becomes corrupted. It has the wished size, but it is all null > bytes. > > The Library Reference says that 'the availability of this function > depends on the operating system version'. So if it helps, I am running > Linux 2.2.14. > > If it really is the case that <file object>.truncate() is not > available, what is the best way to get the same result? Opening the file with mode 'w' erases its contents. Try 'a'. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From alex_c at mit.edu Sun May 14 16:41:27 2000 From: alex_c at mit.edu (Alexander S Coventry) Date: 14 May 2000 16:41:27 -0400 Subject: learning References: <391effd1.9894246@news.callnetuk.com> Message-ID: <etdya5cvp8o.fsf@nerd-xing.mit.edu> > Does anyone know any good site for learning python. http://www.python.org/doc/tut is good imo. Alex. From pem at my-deja.com Wed May 31 14:21:40 2000 From: pem at my-deja.com (pem at my-deja.com) Date: Wed, 31 May 2000 18:21:40 GMT Subject: Perl chop equivalent in Python? References: <8f7ih8$cj2$1@nntp6.u.washington.edu> <oqvh0on1o7.fsf@titan.progiciels-bpi.ca> <m3ya5mxktc.fsf@wilma.george.org> <yayem7e6oo8.fsf@ganglot.ifi.uio.no> <gsf7f8.7t3.ln@odin.henning-schroeder.de> <8g1b86$rpm$1@nntp6.u.washington.edu> Message-ID: <8h3l78$iv5$1@nnrp1.deja.com> Is there an equivalent command to chop (the perl command) in Python? If not, is there some easy way to use existing commands to do this simple task? I need to do it frequently and would like to have a readily available command that does not require much programming. Thanks in advance. Cheers, Patrick Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at cintra.no Fri May 26 09:02:32 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 26 May 2000 13:02:32 GMT Subject: XML to SQL or XML into Tables SomeHow References: <392e080f.1310806219@news.online.no> <392d9fa5@news.server.worldonline.co.uk> Message-ID: <39357467.1404078608@news.online.no> Eh .. yes, I`m looking into that right now. Realized that would probably much more generic and easier to change than python-code. I`ll post any module or whatever comes out of my efforts. Thanks to Robert Roy for making a code example, like I asked for. Thomas On Thu, 25 May 2000 22:45:23 +0100, "Phil" <pharris at crosswinds.net> wrote: >Couldn't you use xslt to do the transformation, since that is its purpose > > >"Thomas Weholt" <thomas at cintra.no> wrote in message >news:392e080f.1310806219 at news.online.no... >> Hi, >> >> I want to submit a special formattet xml, nothing more than xml based >> on a specified DTD, to a module/script that "transforms" the xml data >> to a valid SQL insert-statement. >> >> Ex. >> >> <xml-data> >> <database name="test"> >> <table name ="person"> >> <row> >> <field field_name="name" value="thomas"> >> <field field_name="sex" value="male"> >> </row> >> <row> >> <field field_name="name" value="bill"> >> <field field_name="sex" value="male"> >> </row> >> <row> >> <field field_name="name" value="jane"> >> <field field_name="sex" value="female"> >> </row> >> </table> >> </database> >> </xml-data> >> >> I want an output like : >> >> # SQL-statements >> >> use test; >> insert into person >> (name, sex) >> values >> ("thomas", "male"); >> >> insert into person >> (name, sex) >> values >> ("bill", "male"); >> >> insert into person >> (name, sex) >> values >> ("jane", "female"); >> >> ################## >> >> Perhaps the entries must have a specified type like >> <field field_name="name" value="thomas" field_type="string"> etc. >> >> For simple insertion statements this shouldn`t that hard to do, but >> I`m having a hard time locating the stuff to do it. >> >> I`ve looked at RAX, SAX, Pyxie etc. If somebody could give me a hint >> on how to "transform" the example above I`d be happy to try and make a >> more generic module out of it. I just need some help to get started. >> >> Thomas > From nascheme at enme.ucalgary.ca Mon May 8 03:22:59 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 May 2000 07:22:59 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> <8f5e1l$vud$1@slb0.atl.mindspring.net> <39164058.76D2B781@san.rr.com> <slrn8hckcq.3dr.nascheme@cranky.arctrix.com> <391645E3.3B850279@san.rr.com> <slrn8hcn7k.3o0.nascheme@cranky.arctrix.com> <39165663.666406EB@san.rr.com> Message-ID: <slrn8hcuf4.bh.nascheme@cranky.arctrix.com> Courageous <jkraska1 at san.rr.com> wrote: >Do all string constants which are lexically equivalent obey >the identity rule? IOW, does the python byte compiler know >how, upon compilation, to make two seperate instance of >"joe" point to the same single instance? A very good question. I believe that the magic happens when code objects are created. Importing a module causes code objects to be created from marshalled code objects. String constants are interned during the creation of new code objects. >If so, what are the limits of the byte compiler at merging >string identities? For example, will eval() do a prepass >through the code and determine identity? If my hypothese above is correct then it should work: >>> a = "a" >>> eval("'a' is a") 1 Mmm, support. Pretending to be a guru is hard work. :) Neil -- "God, root, what is difference?" - Pitr "God is more forgiving." - Dave Aronson From ajs at ix.netcom.com Mon May 22 22:33:42 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 22 May 2000 22:33:42 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <21052000.2@sanctum.jae.ddns.org> <23OV4.5070$wYl.214479360@newsb.telia.net> Message-ID: <8gcqrj$hti$1@slb6.atl.mindspring.net> "Fredrik Lundh" <effbot at telia.com> writes on Sun, 21 May 2000 11:44:08 GMT: > "During the course of development, we tried very hard not to > modify the Python language. /.../ Unfortunately, we were ulti- > mately forced to abandon pure Python when testing revealed > two flaws in the language that made Python unusable by our > target audience: integer math and case sensitivity." >Q: Is the Alice projects target audience identical to that of Python? To the best that I can comprehend the target audience are 'animators', or let's say graphic artists. Alice's specifc purpose is to allow its audience to get as much 3D world-building done as possible, given and fully accepting that this audience has no current or future interest in programming. We have to draw the CP4E line someplace. Perhaps everyone except those with an active lack of interest. Alice's audience. Which is in no way a shot at Alice or its mission. Until Guido's recent post up here I was willing to accept the possibility that it was me - that I had misinterpreted and misunderstood the importance he attached to Alice. But, he announced here unequivocally that the Alice studies are central to his thinking about the future of Python. The future of Python. Personally, don't care much about whether Python is or is not case sensitive. If Guido concludes a case insensitive Python is the more elegant Python, I certainly have no basis or reason to doubt his judgement. The question is way out of my league, but I'll go every time with a track record - and Guido's as a designer is impeccable in my view. But the assessment of the relevancy of the Alice study seems to me cake. That question I can handle. Very, very little. Is Guido simply being devilish in posing this to us? On the issue itself - that of case - I've come full circle. I accept Guido's instinctual design decisions on faith, and if that is what P3K is in the end about I would be amazed if I or anyone else were disappointed. They boo-ed when Dylan went electric. But for me its about the instincts of a designer, and the faith of a fan. Not science. So much the better. From jkraska1 at san.rr.com Mon May 8 22:06:18 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 09 May 2000 02:06:18 GMT Subject: Arg. Silly question! References: <3913BBF0.5F255D1E@san.rr.com> <dHFR4.6372$Za1.98672@newsc.telia.net> Message-ID: <39177369.D57A1965@san.rr.com> Fredrik Lundh wrote: > > Courageous <jkraska1 at san.rr.com> wrote: > > Arg. I'm getting a headache. :) > > > > (And I ordered my copy of Guido's Essential Python 2 days > > ago, but don't have it yet). > > I assume you mean David Beazley's "Python Essential Reference"? Err. Probably. I ordered it from Amazon, and I believe it was David Beazely with Guido. C/ From tseaver at starbase.neosoft.com Thu May 25 17:23:45 2000 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 25 May 2000 16:23:45 -0500 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <20000522183552.A29224@mudge> <3929D3F6.DE9CCCBC@prescod.net> Message-ID: <CF125757AB5DD5D5.094581AB6FCF9F26.41037540192780A3@lp.airnews.net> In article <3929D3F6.DE9CCCBC at prescod.net>, Paul Prescod <paul at prescod.net> wrote: >> However, I am having trouble imagining how removing case-sensitivity from >> the language could improve usablility for any programmer, regardless of >> his/her skill level. Most people seem to have no particular trouble with >> case-sensitivity in natural languages; > >If you review the variety of formatting conventions in this list, you'll >find that that is not the case. Guido himself documented how people >speak of the String and FTPLib modules and python programming language. > >> why should a computer language be any different? On the other hand, >> maybe I am just too ingrained in my old thought patterns. > >I prefer case sensitivity. But I think that most of the arguments people >make in favor of it are bunk. > >1. If you spend time with newbies -- especially Windows-trained newbiews >-- you will note the case sensitivity is a problem. > >2. Code written in a case insensitive language is roughly as robust and >readable as that in a case sensitive language. As one who has worked for a long time in a case-insensitive language (ObjectPascal), I cannot disagree more strongly. ObjectPascal code which is written by case-neglecting programmers is painful to read, and harder to maintain. It *also* tends to be sloppier, and therefore buggier, in other ways (fencposts, etc.) Case sensistivity provides exactly the same kind of benefit as indentation: it reduces the space in which individual "style" impacts the code, in order to increase sharability of code. Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at digicool.com http://www.zope.org Digital Creations From fw at deneb.cygnus.argh.org Sun May 7 07:25:58 2000 From: fw at deneb.cygnus.argh.org (Florian Weimer) Date: 07 May 2000 13:25:58 +0200 Subject: Python - Next Release Questions References: <NDBBKEGCNONMNKGDINPFEEJCDEAA.infonuovo@email.com> <m3ya64nq09.fsf@flash.localdomain> Message-ID: <87u2gabnzt.fsf@deneb.cygnus.argh.org> Mark Atwood <mra at pobox.com> writes: > I.E., the various cultural groups that dislike the Unicode Han > unification because they wish to continue their racial illusion that > C, J, & V characters are completely different and seperate sets, and > that it's somehow corrupting to stir them together. I have been told that the irritation was caused by the fact that in the Unicode Standard, the glyphs were printed only in the Chinese form. ;) From jmassung at magpiesystems.com Wed May 10 14:51:13 2000 From: jmassung at magpiesystems.com (Jeff Massung) Date: Wed, 10 May 2000 12:51:13 -0600 Subject: Passing by value instead of reference References: <C0gS4.336$x32.14627@news.uswest.net> <m3hfc6s5qb.fsf@atrus.jesus.cam.ac.uk> Message-ID: <S5iS4.456$x32.20763@news.uswest.net> Michael Hudson wrote in message ... >"Jeff Massung" <jmassung at magpiesystems.com> writes: > >> >>> z=5 >> >>> id(z) >> 6532920 >> >>> def test(x): >> print id(x) >> >>> test(z) >> 6532920 >> >> Is there a way to pass the value of z and not the address? Thanks. > >Then what would you expect your "test" function to do? > >Cheers, >M. Just print a different address. If test was: def text(x): x=1 test(z) print z I would want this to print the original value of z (5), not 1. Jeff From moonseeker at my-deja.com Mon May 15 06:15:29 2000 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Mon, 15 May 2000 10:15:29 GMT Subject: how does global work? Message-ID: <8foinq$o9k$1@nnrp1.deja.com> Hi! How does the statement 'global' works? I can't figure out how to use it correct. I have read the Python reference but it didn't clear my mind... Regards, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From ullrich at math.okstate.edu Sat May 6 16:11:27 2000 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 06 May 2000 20:11:27 GMT Subject: python's acceptance References: <pZdQ4.7603$wb7.519676@news.flash.net> <F4fQ4.15250$HG1.409063@nnrp1.uunet.ca> Message-ID: <39147c0e.15493180@news> Sorry if anyone sees this twice - there's been strange problems with the news server here... On Thu, 4 May 2000 09:36:02 -0400, "Warren Postma" <embed at geocities.com> wrote: >I agree with all of Scotts ideas. I'd like Python to become just as flexible >and efficient a producer of Windows executables as Delphi is currently for >me. I think I'll always want and need Delphi around too. Different tools, >different jobs. Delphi is a non-starter as a system scripting tool, whereas >Python will always be great at that. I think Delphi will always be superior >as a means of distributing binary single executables (requiring no runtime, >vbrun.dll, .pyd files, or what have you). Irrelevant to real Python guys, but as long as you mention Delphi: You know there's a very nice set of Python for Delphi components out there (I have no idea whether http://www.imaginet.fr/~mmm/python.html is still the right url; if not Morgan Martinet at mmm at imaginet.fr might know where to go.) Makes it very easy to use a Delphi program as a front end for Python scripts. (Or to let Python programs execute a little bit of compiled code for the hard parts, or to let Delphi programs use a little Python for the interesting parts.) Another useful aspect is that then you can make a little Delphi program that you use in place of the interactive mode of Python. There are two big advantages to this: First, it works exactly the way you want, and second, you can easily forget what modules you automatically import on startup, allowing you to post really stupid questions on comp.lang.python from time to time... DU From ivanlan at home.com Wed May 10 00:17:13 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Tue, 09 May 2000 22:17:13 -0600 Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <slrn8hc7lg.8p7.neelk@brick.cswv.com> <3916F04F.7647B829@zipzap.ch> <etdem7dm0fx.fsf@w20-575-109.mit.edu> <391790A2.26CB9618@home.com> <etdhfc7ap0d.fsf@w20-575-109.mit.edu> <FuAnpr.HD8@world.std.com> <391812BF.4C226C55@home.com> <etdem7bakza.fsf@w20-575-109.mit.edu> <etdaehza7j0.fsf@w20-575-109.mit.edu> Message-ID: <3918E2C9.7F4AF974@home.com> Hi All-- Alex wrote: > > > This-is-amusing'ly yrs Alex. > > Blargh, I mean it's amusing to fool around with this code, not that it's > amusing that it won't run. Hope I didn't offend. > > Wish-I-could-take-my-stupid-comment-about-postscript-back'ly yrs Alex. > -- > http://www.python.org/mailman/listinfo/python-list 70 614 M 2 0.5 0.82 313 136 currentpoint 9 Rbbx You have to have a currentpoint. Rbbx uses some sort of trickery to define _rbar itself. ... <let-me-know-if-it-works>-ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From greglandrum at earthlink.net Wed May 24 10:01:42 2000 From: greglandrum at earthlink.net (greg Landrum) Date: Wed, 24 May 2000 14:01:42 GMT Subject: print, sys.stdout & % complete HELP References: <8gfbre$d64$1@nnrp1.deja.com> Message-ID: <392BE18F.D5F21F27@earthlink.net> bragib at my-deja.com wrote: > > Hi: > > I am trying to print a status message to a terminal window which tells > the user percent complete. > > This is the way I went about it in pseudo terms > > def percentComplete(lineNo, lines, fileName): > msg = 'Scanning file %s, %i%s complete.' > percentComplete = int(round(100*lineNo/lines)) > if divmod(percentComplete, 5)[1]: # every 5% > backspace = '\b'*len(oldStatus) > msg = backspace + msg %(fileName, percentComplete, '%') > print msg, > oldStatus = msg > > Now I have the problem as follows: > prompt>Scanning file longLongLongName.fil, 100% complete. > > Then when I start scanning a file witha shorter name I > get > prompt>Scanning file short.fil, 20% complete. ete. <--- Oops something > did not get erased. I could not get things to work properly with print (I assume this is due to buffering problems) under kdeterm, but the following works just fine for me: for i in xrange(100): sys.stdout.write('\rDoing %d'%i) sys.stdout.flush() time.sleep(.1) -greg -- greg Landrum (greglandrum at earthlink.net) Software Carpenter/Computational Chemist From irmen at --nospam--bigfoot.com Wed May 17 15:19:10 2000 From: irmen at --nospam--bigfoot.com (Irmen de Jong) Date: Wed, 17 May 2000 21:19:10 +0200 Subject: ANNOUNCE: Pyro 1.1 (distributed objects) References: <8ff875$3q4$1@news1.xs4all.nl> <391B3833.26EDAD18@colconsulting.com> Message-ID: <8furat$bk3$1@news1.xs4all.nl> "Frank V. Castellucci" <frankc at colconsulting.com> wrote in message news:391B3833.26EDAD18 at colconsulting.com... > What about object versioning? If someone changes a remote objects > interface or data I may need to rely on earlier versions of the object. Pyro doesn't have this yet. There are other issues I want to implement first. You could, for now, use the same approach as with (D)COM; just require that once published, all interfaces remain unchanged. New versions have new names. Nevertheless, I will put this on the Pyro wish list. Cheers, Irmen de Jong. From jkraska1 at san.rr.com Tue May 30 01:27:21 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 30 May 2000 05:27:21 GMT Subject: destructors -- when are they called? Message-ID: <393351D2.3533AEFF@san.rr.com> When writing a C language extension, is it guaranteed that the moment your object's reference count is reduced to zero it's destructor will be called? (I have a situation in which this may matter). C/ From jkraska1 at san.rr.com Wed May 31 11:31:08 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 31 May 2000 15:31:08 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <8h34v4$7ac$1@nnrp1.deja.com> Message-ID: <393530D7.D495D3F9@san.rr.com> > > a deque is O(n), while the cost of removing all n members > > from a python list is O(n!). > > You sure about that "n!"? Seems more like n^2 to me. > (Of course n^2 is big, but n! would be much worse. It's > a theorem that n! is bigger than anything.) Yeah, that was an error. What I was thinking when I wrote n! was n+n-1+n-2... It's been a long time since my complexity theory class, so I don't recall if that's identical to n^2 or not. Anyway, I knew that n! would come back to haunt me. :)- C/ From kzaragoza at mediaone.net Thu May 18 19:39:32 2000 From: kzaragoza at mediaone.net (Kris J. Zaragoza) Date: Thu, 18 May 2000 23:39:32 GMT Subject: A PYTHON PREPROCESSOR References: <Pine.GSO.4.10.10005180819130.14709-100000@sundial> <392385D1.31135956@san.rr.com> Message-ID: <slrn8i8vpl.88j.kzaragoza@kzaragoza.ne.mediaone.net> On Thu, 18 May 2000 05:52:25 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >> I think the collective wisdom is "don't do this". Not because of >> whitespace issues -- these can be dealt with, with some thoughts. It's >> because it's not needed -- Python is *so* flexible right now, there's not >> much you need macros for. > >The longer term effort might be to -- in conjunction with >eval, apply, and friends -- give python true metalinguistic >capability. That's quite possibly a larger bite than I can >chew at the moment, though. :)- > > >C/ I think you may be on the right track with this one. The biggest mistake would be, IMHO, to build a text transformation preprocessor (source to source, a la CPP, the C preprocessor). As has been seen in the C and C++ development world, this is a sub-optimal solution. The better path, I believe, is to build a macro system or metalanguage into Python itself, operating on the syntax tree after parsing, but before actual compilation. This would allow incredible amounts of power in transforming the code while avoiding all the problems that come with slicing and dicing text. Common Lisp and Scheme have shown the power of this approach. It's quite common in the Lisp world to use macros to tailor the language to the problem, rather than the problem to the language. Why not do the same in Python? (Mind you, this is easier said than done, and I understand how difficult this is, but I'm allowed to dream. :) Just imagine a large system where you're regularly repeating certain idioms, such as complex exception handling. Here's a purely hypothetical example. def generateHTMLForm(response, record_id): # Get the record information from the database conn = getDBConnectionFromPool() try: ... # Build the HTML code returnString = ... ... # Write it to the given response object try: response.write(returnString) except IOError e: # Log the exception ... # Dump the state of the response/socket ... except DatabaseError dbe: # Log the exception ... # If it's a critical error, email the DBA ... except IOError ioe: # Log the exception ... And so on in all sorts of places throughout the code. Now, I'm sure this can be done a bit more cleanly with a good OO design and proper passing on of exception handlers, but imagine how much cleaner the code would be if all you had to write was: def generateHTMLForm(response, record_id): withDatabaseConnection (conn, getDBConnectionFromPool()): withResponseStream(response): # Build the HTML code returnString = ... # Write it out response.write(returnString) All of the proper error handling would be taken care of by the user-defined constructs "withDatabaseConnection" and "withResponseStream". Now, as for what the macro/metalanguage would actually look like, I have no clue. :-) Thoughts? -Kris -- Kris J. Zaragoza | "Unfortunately, most people can't out-think a kzaragoza at mediaone.net | grapefruit." --Jon Bodner From elb at cfdrc.com Tue May 2 10:03:15 2000 From: elb at cfdrc.com (Ed) Date: Tue, 02 May 2000 09:03:15 -0500 Subject: CGI File Size Limit? References: <_h6P4.14007$g4.347236@newsread2.prod.itd.earthlink.net> <390DA15A.EAF8D635@cfdrc.com> <3d4s8i5i7a.fsf@amarok.cnri.reston.va.us> Message-ID: <390EE023.17C4AF75@cfdrc.com> Thanks a lot. I looked inside cgi.py and found: class FieldStorage( self, fp=None, .... ) and self.fp = fp or sys.stdin So all I have to do, I think, is create a file object that reads standard input, with mode binary, and pass it to FieldStorage when I create my cgi.FieldStorage object. I'm sure I'll feel stupid later, but I have to ask, how do I do this? Would it be something like: "binary_stdin = open( sys.stdin, 'rb')" ? Thanks... "Andrew M. Kuchling" wrote: > Ed <elb at cfdrc.com> writes: > > More information: > > If I test the len(form["userfile"].value), it is only 3134 instead of > > 18k (the "CONTENT_LENGTH"). That means the CGI.py module is not getting > > the data. Something wrong with CGI module reading binary data off of > > the standard input stream. > > Given that you seem to be using Windows, you'd have to open stdin in > binary mode; it's probably hitting a Ctrl-Z and ending early. I don't > remember the incantation for doing this; someone else will doubtless > remember it. > > -- > A.M. Kuchling http://starship.python.net/crew/amk/ > Destiny smells of dust and the libraries of night. He leaves no footprints. He > casts no shadow. > -- From SANDMAN: "Season of Mists", episode 0 From m.faassen at vet.uu.nl Fri May 12 19:19:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 23:19:06 GMT Subject: Tiny FTP server References: <8fhrd8$2esq$1@news1.wire.net.au> Message-ID: <8fi3ha$jb2$1@newshost.accu.uu.nl> Steven Adams <sada7681 at mail.usyd.edu.au> wrote: > is there a VERY small ftp server module in python? I've (tried) looking at > Starship, and Parnassus, and everywhere else I could think of, but can't > find one. > Does anyone know of anything that comes close? I don't know how small it is, but Zope's ZServer (based on Medusa which uses asyncore, as far as I understand) has a builtin FTP server. You may want to take a look there. Perhaps you can seperate it out easily. Of course looking at asyncore and Medusa may be helpful here too. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From parkw at better.net Thu May 11 18:06:36 2000 From: parkw at better.net (William Park) Date: Thu, 11 May 2000 18:06:36 -0400 Subject: number base conversion? (ASCII to Hex) In-Reply-To: <391b2bd5.66612734@news1.on.sympatico.ca>; from chibaA@TinterlogD.Tcom on Thu, May 11, 2000 at 09:54:26PM +0000 References: <391b2bd5.66612734@news1.on.sympatico.ca> Message-ID: <20000511180636.A3265@better.net> On Thu, May 11, 2000 at 09:54:26PM +0000, chibaA at TinterlogD.Tcom wrote: > How would I go about getting the base-16(hex) value of a character, > into a string? > > take character word[1] (for example) > and retrieve the hex value of 31 > and assign it to value hexValue in an ascii format (ie. as the number > 31). hex(ord('1')) --William From gfor_ewu at ispchannel.com Sun May 21 00:58:14 2000 From: gfor_ewu at ispchannel.com (Greg Fortune) Date: Sun, 21 May 2000 04:58:14 GMT Subject: Network statistics program References: <SWnU4.313$yX.43992@news1.onlynews.com> Message-ID: <G1KV4.52$rw2.4080@news1.onlynews.com> Thanks to everyone who responded. By making use of the time and string modules, I was able to make my program ping at almost exactly the turn of a minute and return the results. All I had to do was send the remaining seconds in the current minute (60-current second) to time.sleep() and it worked great. Now I'll try to get the database interface to work... <g> Thanks again, Greg Fortune <snip> From ivanlan at home.com Wed May 3 08:25:04 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Wed, 03 May 2000 06:25:04 -0600 Subject: Teach Yourself Python Book/Website Message-ID: <39101AA0.CBA45BD0@home.com> Hi All-- Just a little BSP here. ... 1) I finally got to see my book in an actual bookstore here in Salt Lake City. Sam Weller's, in downtown, had a copy. They had a Perl book faceout, so I replaced it with mine;-) Barnes & Noble and Borders, both having several stores in the area, had no copies and couldn't find it their databases;-( 2) Those of you who, for whatever misguided reason, wish to visit the book's website and are having trouble because pauahtun.org isn't responding or isn't in the nameserver tables, may do so at the below URL: http://63.64.27.76/TYPython/ I'm no longer working for Callware, who used to provide a connection to the internet for my server. I'm putting up a new server today at one of our local ISPs, Aros.net, so in a little while the real address, http://www.pauahtun.org/TYPython/ will start to be resolvable as the new IP records start to percolate through the nameservers on the net. The IP address above will only work for about a week. <wink-wink-nudge-nudge>-ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From bhella at ce.mediaone.net Sat May 20 12:51:05 2000 From: bhella at ce.mediaone.net (Opinderjit Singh Bhella) Date: Sat, 20 May 2000 11:51:05 -0500 Subject: Python and COM Message-ID: <3926C279.CDCB6252@ce.mediaone.net> I have been studying the PythonCOM model and I do have the Python Programming on Win32 by Mark Hammond & Andy Robinson. However, I am unable to find references on the following questions: Do COM servers created with PythonCOM support the dual interface? Also, do PythonCOM servers expose the vtable to the client for use with early-bound IDispatches? Any information will help, thanks in advance. From thomas at cintra.no Fri May 5 08:36:42 2000 From: thomas at cintra.no (‘5ŰHH575-UAZWKVVP-7H2H48V3) Date: Fri, 05 May 2000 12:36:42 GMT Subject: Fixing xmlrpclib Message-ID: <391cbf98.700502699@news.online.no> Hi, Trying out the xmlrpclib with my local zope-site. Read in the How-To by Amos, located at zope.org, that the pythonware "version" of xmlrpclib needed some fixing, even found the code to do it. But it seems like it is used as a seperate class, not a method or part of the server-class in the pythonware module. I`m using the XMLRPC-tutorial at the XML.COM site to learn this stuff. Could somebody tell me where to paste in the lines from Amos` HowTo in the xmlrpclib so that works, or how I should go about doing this?? Thomas From martinb at egroups.net Tue May 30 05:36:04 2000 From: martinb at egroups.net (Martin Baker) Date: Tue, 30 May 2000 02:36:04 -0700 (PDT) Subject: new eGroups coroutine release Message-ID: <Pine.BSF.4.21.0005300219080.32125-100000@magrathea.corp.onelist.com> Here at eGroups we use coroutines to build fast, scalable network servers. Think Medusa, but easier. We get the performance of multi-threading without thread overhead. We have released our implementation of coroutines in Python under a Pythonish license. This can be installed as a dynamically loadable module under an otherwise unmodified Python distribution. It doesn't work well under 1.5.1, it does under 1.5.2, and we don't know yet about 1.6. Right now only Linux and FreeBSD are supported. The assembler coro package we use only supports Linux out of the box, although FreeBSD 3 might work without changes. You can find more details (including an explanation of coroutines and links to the assembler coroutine package) in the README at http://www.egroups.com/files/python-coro/egroups/README-2000-04-24.txt The software itself is available at http://www.egroups.com/files/python-coro/egroups/egp-coro-20000424.tar.gz Enjoy! Martin From mfletch at tpresence.com Tue May 9 13:06:22 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 9 May 2000 13:06:22 -0400 Subject: Converting a Binary Message-ID: <CC59868A0A76D311B1F50090277B321C1F3308@VRTMAIL> Yes, and considering how often this question comes up, I'm a bit embarrassed not to have thought of that interpretation in my explanation. Ah well, to err is human, the bots' divine and all that... Mike -----Original Message----- From: Warren Postma [mailto:embed at geocities.com] Sent: Tuesday, May 09, 2000 12:47 PM To: python-list at python.org Subject: Re: Converting a Binary > > struct.pack( 'i', yourinteger ) > > Enjoy, > Mike Interesting how ambiguous "convert to binary is". I assumed he meant "print an integer variable as a base-2 (binary) string representation". ;-) Warren -- http://www.python.org/mailman/listinfo/python-list From jcm at bigskytel.com Sat May 13 01:56:59 2000 From: jcm at bigskytel.com (David Porter) Date: Fri, 12 May 2000 23:56:59 -0600 Subject: AI and Python In-Reply-To: <#26g7HIv$GA.269@cpmsnbbsa04>; from lexberezhny@email.msn.com on Fri, May 12, 2000 at 10:27:28PM -0400 References: <OwZBsfGv$GA.306@cpmsnbbsa04> <Yi2T4.266$mh3.4671@news> <#26g7HIv$GA.269@cpmsnbbsa04> Message-ID: <20000512235659.C17569@bigskytel.com> * lexberezhny <lexberezhny at email.msn.com>: > Hi, > I was wondering if there was a version of eliza in python? http://strout.net/python/ai/therapist.py |david| From jkraska1 at san.rr.com Thu May 11 01:02:46 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 05:02:46 GMT Subject: A REALLY COOL PYTHON FEATURE: Message-ID: <391A3FD4.25C87CB4@san.rr.com> While all the oldtimers here already know this, I thought I might share something really cool with some of my newbie peers.... :) >>> somenames = ["fred", "barney", "wilma", "betty"] >>> reallycool = reduce ( lambda x, y: x+", "+y, somenames ) >>> reallycool 'fred, barney, wilma, betty' >>> Check that out. Do you know what a royal pain in the ass it is in most languages to do this? It's a godawful pain in the ass, let me tell you. And there it is, in all it's glory: reduce ( lambda x, y: x+", "+y, somenames ) Gawd. Beautiful. C/ From fig at oreilly.com Thu May 4 20:07:49 2000 From: fig at oreilly.com (Stephen R. Figgins) Date: Fri, 05 May 2000 00:07:49 GMT Subject: Installing numpy References: <3910b8e1.0@news2.cluster1.telinco.net> <3911776F.25845625@oreilly.com> <3911dd31.0@news2.cluster1.telinco.net> Message-ID: <39120F74.580732B9@oreilly.com> Duncan Smith wrote: > > Thanks for responding to my posting. I still can't get it set up properly. > I've tried the zip and the tar.gz. I unzip them to my python directory and > get a subdirectory (Numerical-15.2) with 5 subdirectories (Demo, Include, > Lib, Src and Test). No .pth file anywhere. That sounds like you are getting the source file, both as a zip file and as a tar.gz. Try using the .zip file available from: http://sourceforge.net/project/?group_id=1369 The link to the zip file is at the right, under File Releases. Easy to miss, but that is the one you want. Unzip that one to your python directory, and everything should be fine. Stephen From phd at phd.russ.ru Wed May 17 07:06:25 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 11:06:25 +0000 (GMT) Subject: DCOracle installation In-Reply-To: <8F36C3D3Elminutieidit@192.6.1.10> Message-ID: <Pine.LNX.4.21.0005171106060.31722-100000@fep132.fep.ru> On Tue, 16 May 2000, Luca wrote: > I haven't the directory `/usr/lib/python1.5/config'! Install python-dev rpm. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From jkraska1 at san.rr.com Wed May 17 22:00:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 18 May 2000 02:00:43 GMT Subject: A PYTHON PREPROCESSOR References: <392345E4.6F94832E@san.rr.com> <etdya58ipsp.fsf@w20-575-92.mit.edu> Message-ID: <39234F83.86BD52E0@san.rr.com> Alex wrote: > > Hi, Courageous. > > What do you want to use a preprocessor for? I can't think of any uses > that can't be affected in python itself. More of a theoretical challenge than anything. One advantage of a preprocessor is that it lets you do conditional sections, and in some cases avoid function invocation overhead. One thing I'm interested in is: is anyone interested in this? If there are, I'm willing to hear a request for features. C/ From wware at world.std.com Sun May 21 09:39:57 2000 From: wware at world.std.com (Will Ware) Date: Sun, 21 May 2000 13:39:57 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com><Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu><392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu><vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA><cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com><cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <3.0.6.32.20000520233958.00839560@earthlink.net> <c_PV4.8672$Za1.134344@newsc.telia.net> Message-ID: <FuwwML.HMM@world.std.com> Quoting Alice project literature, Fredrik Lundh (effbot at telia.com) wrote: > "... It may be that Microsoft's Visual Basic programming > environment provides the best of both worlds by following the user > to type in a case-insensitive way, while the programming environment > applies the proper case to the program text on behalf of the user > whenever possible." Maybe case-insensitivity should be a feature for something like IDLE rather than the core language. As a newbie types stuff in, the first occurrence of each symbol is recorded as the preferred-case version, and subsequent differing-case versions could be translated to that before being shipped to the interpreter. The interpreter could then remain case-sensitive for the benefit of non-newbies. Efficiency considerations might make it preferable to implement case- insensitivity somewhere in the Python executable. In that case, maybe it could be switched on with a command line switch, and be switched off by default. Future versions of IDLE would use the command line switch, but experienced programmers could simply ignore it. This would mean that newbies could use code written by experienced people (the Python library, stuff on Parnassus) but case-wobbly newbie code would need to be processed by CaseNanny.py before it could be used by case-aware folks. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From mwh21 at cam.ac.uk Wed May 10 15:33:24 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 May 2000 20:33:24 +0100 Subject: Passing by value instead of reference References: <C0gS4.336$x32.14627@news.uswest.net> <m3hfc6s5qb.fsf@atrus.jesus.cam.ac.uk> <S5iS4.456$x32.20763@news.uswest.net> <m37ld2s026.fsf@atrus.jesus.cam.ac.uk> <IKiS4.492$lZ1.4948@news.uswest.net> Message-ID: <m31z3aryij.fsf@atrus.jesus.cam.ac.uk> "Jeff Massung" <jmassung at magpiesystems.com> writes: > Michael Hudson wrote in message ... > >It will. I don't think you understand assigment yet... > > > > Sorry, I don't ;) - I was thinking like this (I understand how my previous > example was wrong). > > >>> def test(x): > x.append(3) > >>> z = [1,2] > >>> test(z) > >>> z > [1, 2, 3] > >>> > > How can I get x to have the value of z, modify it, and use the modified > value, without z being modified overall? Thanks, guys ;) In general, something like: def test(x): import copy x=copy.copy(x) # or x=copy.deepcopy() (to taste) x.append( ... ) just for lists: def test(x): x=x[:] x.append(3) The latter is fairly idiomatic; I've never used the former (I don't think). Cheers, M. -- 112. Computer Science is embarrassed by the computer. -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html From jraddockNOjrSPAM at hotmail.com.invalid Fri May 19 13:09:47 2000 From: jraddockNOjrSPAM at hotmail.com.invalid (JRHoldem) Date: Fri, 19 May 2000 10:09:47 -0700 Subject: HTML search engine written in Python - is there one? References: <34575A892FF6D1118F5800600846864D2F0636@intrepid> <39256d44.306110109@news1.on.sympatico.ca> Message-ID: <0b091c30.8b839c95@usw-ex0101-008.remarq.com> You might want to try using Index Server/ASP combo before going to any third party solution...full text searching is no trivial matter and chances are it'll give you all the tinkering options you could want. Now if you want to Tkinter with it, that's a different story... I-wanna-get-an-eggo-waffle-and-my-friend-are-cheap-and-won't-eat- at-a-real-restaurant-bad-bad-man! - JR * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From jbauer at rubic.com Thu May 11 11:40:20 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 11 May 2000 10:40:20 -0500 Subject: Type Inference Life Preserver References: <8feh9v$3gs$1@nnrp1.deja.com> Message-ID: <391AD464.CE235AE0@rubic.com> jerry_spicklemire at my-deja.com wrote: > now be possible to wrap an entire Type Inference > Module in a Try that catches type errors? The Try > would discover the type, then call back to the > point in the "continuation" where type was > inferred, and force the correct type! Consider the following type error: >>> int('2') + str(1) Did I intend to construct a string value of "21", an integer, or some other type? First you would need to write a Psychic Coder Module for your Type Inference Module to work. and-if-your-psychic-coder-module-was-working- you'd-have-already-known-my-response-ly y'rs, Jeff Bauer Rubicon Research From buster2642 at my-deja.com Tue May 23 13:05:23 2000 From: buster2642 at my-deja.com (buster2642 at my-deja.com) Date: Tue, 23 May 2000 17:05:23 GMT Subject: numpy for linux(ppc)? Message-ID: <8gedo6$o6q$1@nnrp1.deja.com> I'm mostly familiar with Jack Jansen's terrific MacPython installer for Macintosh, where Numpy is included. (Jack should get some kind of award!) I notice that, at least for LinuxPPC, Numpy isn't part of the "standard" RPM distributions. (why?) Where's the best place to get linux RPMs for Numpy? Thanks! Chuck Sent via Deja.com http://www.deja.com/ Before you buy. From noone at do.not.use Mon May 15 11:04:57 2000 From: noone at do.not.use (Russell Turpin) Date: Mon, 15 May 2000 10:04:57 -0500 Subject: The REALLY bad thing about Python lists .. References: <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> <8fmket$n29$1@nnrp1.deja.com> <391ED8C9.BC2BAE8D@san.rr.com> <8fmnat$q1h$1@nnrp1.deja.com> <m33dnlowv4.fsf@atrus.jesus.cam.ac.uk> <8p6snvkyjdj.fsf@Eng.Sun.COM> <slrn8hu5nl.2s0.scarblac-spamtrap@flits104-37.flits.rug.nl> <09HT4.1708$qP3.159682@paloalto-snr1.gtei.net> <20000515092243.S13281@xs4all.nl> <39200341.40DAF4A2@do.not.use> <20000515163513.U13281@xs4all.nl> Message-ID: <39201219.C7E163A2@do.not.use> Thomas Wouters wrote: > Perhaps your test was just realistic ? Have you seen > *real-life* performance problems because of the low > overallocation yet ? I've written MANY real-life programs that built up two or more large arrays. Large, meaning over 100,000 elements. An O(n^2) cost to doing this would make Python unusable for quite a few real-life applications. HOWEVER .. it may be that Python is twice lucky. I suspect that the realloc() on Linux does the smart thing: allocating exponentially increasing blocks, as needed, and expanding within the block if possible. I have not been able to demonstrate O(n^2) behavior for list allocation in test programs. If anyone can do this, I would be interested in seeing the test program. Russell From tomega at earthlink.net Mon May 29 01:55:55 2000 From: tomega at earthlink.net (Simon) Date: Mon, 29 May 2000 05:55:55 GMT Subject: request: web site copy utility References: <grg3jsg899nhuhl5sua80ookjop9cuk8j0@4ax.com> <8gsr3m$ufr$1@nntp9.atl.mindspring.net> Message-ID: <393207A4.C04E6BDB@earthlink.net> websucker.py, while an awesome utility, doesn't actually suck the entire site. For instance, it will pull the image files on a page if those images are statically SRC-ed. If there is an onmouseover directive, for instance, which changes the image source to another file, it will not grab the other file, even if it lies in the same directory as the first image. --S. Andrew Dalke wrote: > robin.illusionsescalation at ACM.org wrote in message ... > >I realize this must be a common request, but I can't find the answer > >anywhere (Deja, Parnassus, Grimoire...). So before I cook my own... > > > >I'm looking for a Python script to download an entire web site. > > Try websucker, which is distributed with Python under Tools as part > of webchecker. It isn't in Parnassus because it's part of Python > itself. > > Andrew > dalke at acm.org From shapr at uab.edu Thu May 25 07:39:30 2000 From: shapr at uab.edu (Shae Erisson) Date: Thu, 25 May 2000 11:39:30 GMT Subject: IDLE startup prblem. - solution References: <34575A892FF6D1118F5800600846864D33CF8E@intrepid> Message-ID: <392D1663.D1CD3150@uab.edu> Simon Brunning wrote: > > How do I get IDLE to run a script on startup? I've created a script > called $IDLESTARTUP.py in the IDLE directory, and I'm running > idle.pyw with the -s switch, but it doesn't appear to be working. > > (Running IDLE 0.5 on Win98.) $IDLESTARTUP actually means "read the value of the environment variable IDLESTARTUP" That means if you add a line in your autoexec.bat that says: SET IDLESTARTUP="C:\Program Files\Python\Tools\idle\autoidle.py" then the -s switch will work (as long as you have a file name autoidle.py in the correct path that's a python file that is :) you can of course change the value of that variable to start with any file you prefer. For shell variables, you don't need to surround them with double quotes if there aren't any spaces in the path you're giving it. ex: SET IDLESTARTUP=C:\Python\Tools\idle\idlesetup.py that will work fine since there aren't any spaces (like "Program Files") in the directory specification. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From lellinghaus at bellsouthips.com Wed May 31 18:11:35 2000 From: lellinghaus at bellsouthips.com (LANCE ELLINGHAUS) Date: Wed, 31 May 2000 18:11:35 -0400 Subject: RMON module Message-ID: <15390003.1379@bellsouthips.com> Has anyone created a RMON module for python? Thanks! -- Lance Ellinghaus Sr. Architect eConnections From pinard at iro.umontreal.ca Mon May 22 04:33:26 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 04:33:26 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: Dennis Lee Bieber's message of "Sun, 21 May 2000 22:15:31 -0700" References: <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <jwbnews-BD2A42.12280221052000@news.olympus.net> <oqzopjs5h7.fsf@titan.progiciels-bpi.ca> <jwbnews-283406.19515521052000@news.olympus.net> <oqd7mfs15y.fsf@titan.progiciels-bpi.ca> <jdghisg714d5v58ir14t36pdve7tdoi6ao@4ax.com> Message-ID: <oqitw79e7d.fsf@titan.progiciels-bpi.ca> Dennis Lee Bieber <wlfraed at ix.netcom.com> ?crit: > > If you mean those oscilloscopes which simultaneously drove the X and Y > > coordinates, with separate analogic hardware for each character, the only > > one I knew were the CDC 6x00 consoles, and these were pretty expensive > Hmmm, my first thought would have been Tektronix storage display > tubes... Yes, of course. Tektronix were also vector drawing, characters included. Those were not cheap, but in no way as expensive as the CDC 6x00 consoles. > The infamous "killer" displays (hearsay, but I've heard that > the vacuum in a cracked display tube was sufficient to drive the gun > end out the front of the tube to impale the user <G>) Surely, the glass of the bigger Tektronix memory displays was getting dangerously hot, we could not touch them, and people were joking about baking eggs on them :-). The CDC 6x00 consoles were no memory display, they ought to be refreshed by continuously redisplaying their whole contents, and one of the eleven computers making up the machine was dedicated to that sole clever task. Since then, I've _never_ seen anything like these (not even approaching) for "feeling" in real time how an operating system behaves inside. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From boris at i3.informatik.rwth-aachen.de Wed May 31 05:31:42 2000 From: boris at i3.informatik.rwth-aachen.de (Boris Boehlen) Date: Wed, 31 May 2000 11:31:42 +0200 Subject: JPython: Disabling compilation of Python scripts Message-ID: <3934DBFE.665D36F0@i3.informatik.rwth-aachen.de> Hello, It seems to me that JPython compiles every script to Java Bytecode before it is executed. However, this causes a problem in our application because the code for one method passes the 64Kb limit which the virtual machine sets on the size for a method. Does anybody now how I can disable this behaviour? Regards, Boris -- Dipl.-Inform. Boris Boehlen Department of Computer Science III email: boris at i3.informatik.rwth-aachen.de Ahornstrasse 55 phone: +49 (2 41) 80 21 315 Aachen University of Technology fax: +49 (2 41) 88 88 218 From g_will at cyberus.ca Tue May 16 08:33:06 2000 From: g_will at cyberus.ca (Gordon Williams) Date: 16 May 2000 12:33:06 GMT Subject: Attempt to export non-public symbol References: <8fpp73$4da$1@nnrp1.deja.com> Message-ID: <01bfbf32$f9949ec0$5541c3d1@Cyberus> Sounds like you need a .def file to change the name from _initoptprice to initoptrice. It should contain something like Exports initoptprice = _initoptprice I dont know what compiler you are using. I wrote a HOWTO for creating extensions using the free Borland compiler where you might find more information at http://www.cyberus.ca/~g_will/pyExtenDL.shtml . Regards, Gordon Williams nicshane at my-deja.com wrote in article <8fpp73$4da$1 at nnrp1.deja.com>... > > > I am currently trying to enable my c code to be called from python. I > have written a simple module which worked fine but am now trying to > incorporate a much larger module following the same procedures and am > not having any success. One difference which I guess is the problem is > a warning message I get when linking : > > Warning : Attempt to export a non-public symbol '_initoptprice' > > This is the only difference between the working and non-working > versions. As it is on the init function it is more than likely the > problem ?? > > Any ideas how to eradicate this ?? > > > Regards, > > Shane. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > From glyph at twistedmatrix.com Tue May 16 18:09:57 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 16 May 2000 17:09:57 -0500 Subject: Stackless/microthreads merge news In-Reply-To: JRHoldem's message of "Tue, 16 May 2000 13:43:35 -0700" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <jazoq2i8ty.fsf@helix.twistedmatrix.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <jaitwfo0ee.fsf@helix.twistedmatrix.com> <3921A17C.F995CEFB@tismer.com> <043ee7d0.5c606b3d@usw-ex0101-008.remarq.com> Message-ID: <ja66sekuyy.fsf@helix.twistedmatrix.com> Okay. I wanted to make a point, that C. Tismer's time would be better spent with something other than making a stackless Java VM ... and that point having been made, we should leave this little subthread... ObOnTopic -> One thing that's been bugging me lately though; Java is definitely faster than python, but Python and Java both use virtual machines. The difference, as far as I can tell, is that Python objects (namespaces, classes, class instances, etc) are actually all *hashtables*. Java's are similiar to C structs, at least in how bytes are arranged, linked, and accessed. Java's speed advantage is significant, but from what I've seen so far, it doesn't seem to be the massive leap beyond python that I'd expect. Is there a good technical reason for this, or is it just a poor implementation? I haven't had a chance to read enough of Python's sources yet, I guess, but is it doing any tricks with attribute access to make them faster than regular hashtables? (or is my estimation of the speed difference really just erroneous?) The obvious next question is "if not, why not?" but I think I understand that, if it's the case ^_^. JRHoldem <jraddockNOjrSPAM at hotmail.com.invalid> writes: > I'm new to this board but you're right - Glyph is a programming > god and he's 100% on target with his Java rants. I say this not > only as a business partner and friend of his but also as a Java > programmer who has faced several of these issues myself. This is so blatant, I almost want to accuse myself of using tentacles ;-) (thank you, JR) > And yes, any language which has attracted the attention of the > Cobol community probably is the work of Satan. I?! Shub Microsystems! python-is-cool-and-so-is-stacklessness-so-perhaps -I-should-be-more-on-topic-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From effbot at telia.com Sun May 21 07:44:08 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 21 May 2000 11:44:08 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com><Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu><392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu><vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA><cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com><cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <3.0.6.32.20000520233958.00839560@earthlink.net> Message-ID: <c_PV4.8672$Za1.134344@newsc.telia.net> Robert Citek <rwcitek at uci.edu> wrote:> > >Did he try a Python that was case-insensitive? > > Excellent point. Guido, you are assuming that when you make Python > case-insensitive the students will have an easier time learning Python. Is > this assumption true? The answer may depend on how "case-insensitive" is > implemented. Has anyone tested this assumption (perhaps with another > language)? Guido's not assuming anything; he has read research papers and talked to the researchers, just like he did when he "stole" a lot of unconventional ideas from ABC. so instead of assuming that people don't know what they're talking about, how about reading up on the Alice project yourself? I suggest starting with Matt Conway's dissertation, available from: http://www.alice.org/advancedtutorial/ConwayDissertation.PDF some relevant quotes: "During the course of development, we tried very hard not to modify the Python language. /.../ Unfortunately, we were ulti- mately forced to abandon pure Python when testing revealed two flaws in the language that made Python unusable by our target audience: integer math and case sensitivity." "Python is case sensitive. While we, as programmers, were com- fortable with this language feature, our user community suffered much confusion over it. At least 85% of users who were observed using the Alice tutorial made a case error at some point during the experience. While explaining the case rule was simple enough ("upper and lower case mean different things to Alice"), this was not sufficient to instill a "case aware" sense in our users. Of the users who had problems with case, most continued to type case- incorrect tokens in their programs for a short period. Coming to terms with case sensitivity is a difficult skill for many to learn, a fact that can often be lost on experienced programmers." "I note with some embarrassment that Hypercard, Pascal and LOGO were designed for novice or infrequent programmers and each was case insensitive. It may be that Microsoft's Visual Basic programming environment provides the best of both worlds by following the user to type in a case-insensitive way, while the programming environment applies the proper case to the program text on behalf of the user whenever possible." </F> From mfletch at tpresence.com Wed May 24 00:04:41 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Wed, 24 May 2000 00:04:41 -0400 Subject: Micro-threads: a simple example, UDPPort wrapper Message-ID: <CC59868A0A76D311B1F50090277B321C1F3357@VRTMAIL> Attach to find a fairly simple UDP port wrapper which uses three micro-threads to perform polling of a basic socket. As you can see, without select support, this is inefficient (it is constantly checking to see if it can read/write). More on that in a follow-up :) . Enjoy, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch -------------- next part -------------- A non-text attachment was scrubbed... Name: udpport3.py Type: application/octet-stream Size: 7159 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20000524/f4faac7e/attachment.obj> From wjarek_nospam at hotmail_rem_ove_.com Tue May 16 02:06:46 2000 From: wjarek_nospam at hotmail_rem_ove_.com (Jarek Wilkiewicz) Date: Tue, 16 May 2000 06:06:46 GMT Subject: Python vs Java : GUI, drag an drop References: <Pine.GSO.4.10.10005160742560.2582-100000@sundial> Message-ID: <Wz5U4.109$%35.9231@typhoon.sonic.net> I've written GUIs in Java before, mainly using awt, and it was a pain in the neck. All of the Java-based GUIs I've used lately are terribly slow, so while there seem to be a lot of improvement on the server side, the speed of Java UIs is less then satisfactory (or to put it more bluntly: they suck!), at least in my humble opinion. Also, the complexity of awt and swing is something I'd prefer to avoid. Thanks, Jarek "Moshe Zadka" <moshez at math.huji.ac.il> wrote in message news:Pine.GSO.4.10.10005160742560.2582-100000 at sundial... > On Tue, 16 May 2000, Jarek Wilkiewicz wrote: > > > As far as the OS goes, I'd like to be able to support NT, Solaris and Linux. > > Native widgets are not important. Does Gtk+ work with Windoze ? > > Yes. > > > JPython sound good for scripts, but I'm rather hesitant to use it for a > > "real" application. > > Why? > > -- > Moshe Zadka <moshez at math.huji.ac.il> > http://www.oreilly.com/news/prescod_0300.html > http://www.linux.org.il -- we put the penguin in .com > > From gregor at hoffleit.de Fri May 19 10:26:38 2000 From: gregor at hoffleit.de (Gregor Hoffleit) Date: Fri, 19 May 2000 16:26:38 +0200 Subject: Question about umlauts and locale Message-ID: <20000519162638.A4344@53b.hoffleit.de> I wonder if it is correct behaviour that "print ('foo','k??k')" prints "('foo', 'k\344\344k')" regardless if the umlauts are letters according to the locale set. One could also expect "('foo','k??k')", iff '?' was a letter in the used locale. Is this quoting of the umlauts a bug or intentional behavior ? $ unset LC_ALL $ python Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian +GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a=('foo','k??k') >>> print a ('foo', 'k\344\344k') >>> $ export LC_ALL=fi_FI $ python Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian +GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a=('foo','k??k') >>> print a ('foo', 'k\344\344k') >>> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20000519/188a56b4/attachment.sig> From darrell at dorb.com Wed May 17 00:54:08 2000 From: darrell at dorb.com (Darrell Gallion) Date: Tue, 16 May 2000 21:54:08 -0700 Subject: Stackless/microthreads merge news References: <Pine.GSO.4.10.10005160723180.2582-100000@sundial> <39219E7B.364C6EA6@tismer.com> Message-ID: <009f01bfbfbb$f1995290$6401a8c0@home> Here's some other things you might want to save other than the data stack. Program counter Return stack and return stack pointer Word pointer I think Forth implements multitasking by swapping these out. Save all this stuff in the dictionary. Then you restore a copy and bam, your time machine kicks in. --Darrell Gallion Christian Tismer > > it's-just-like-making-forth-stackless-ly y'rs, Z. > > Making Forth stackless means to add a word that is able > to switch stacks, and use that in places where it makes > sense: Where we want to be able to grab a continuation. > > While we are at it: How would you name such a Forth-word? > From kent at tiamat.goathill.org Tue May 23 14:55:12 2000 From: kent at tiamat.goathill.org (Kent Polk) Date: 23 May 2000 18:55:12 GMT Subject: urllib/ftpwrapper References: <Pine.LNX.4.21.0005190810221.493-100000@fep132.fep.ru> <cpem6xvjhc.fsf@cj20424-a.reston1.va.home.com> <959023972.859403@fezzik.endicor.com> <392A2EEE.ADB075A@stroeder.com> Message-ID: <959106495.82884@fezzik.endicor.com> On Tue, 23 May 2000 09:10:38 +0200, Michael Str?der wrote: >Kent Polk wrote: >> >> What would be a suggested method to allow outgoing port 20 connections >> from a Python setuid'd server such as Medusa? > >Isn't it possible to bind to the privileged port 20 and do a setuid >afterwards? If you use connect, since it doesn't create a new socket, but you could use it for only one connection as the first one would have to be closed to terminate the connection. I think... From pinard at iro.umontreal.ca Sat May 13 13:33:36 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 May 2000 13:33:36 -0400 Subject: OT [Way OT]: Unicode Unification Objections In-Reply-To: mjackson@wc.eso.mc.xerox.com's message of "8 May 2000 18:14:36 GMT" References: <oqem7dos3f.fsf@titan.progiciels-bpi.ca> <8f706c$imk$1@news.wrc.xerox.com> Message-ID: <oqu2g2jqxb.fsf@titan.progiciels-bpi.ca> mjackson at wc.eso.mc.xerox.com (Mark Jackson) ?crit: > Franc[approximately]ois_Pinard <pinard at iro.umontreal.ca> writes: > > Agreed that Japanese people are themselves on this. Some are ready to > > accept Han unification together with Microsoft Windows, if they really > > have to be bundled together, they just don't care. Others do. > Has their Justice Department determined whether said bundling is, in > fact, an anticompetitive attempt to stamp out other Han vendors? Are you really asking me? :-) :-) > > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > You see that my newsreader handles the cedilla in your name just fine, You probably mean that your newsreader did not handle it at all, and that Latin-1 is displayed by default on your system :-). The message containing the above quote, as I received it, lacks MIME headers, so there is no way to ascertain that the contents has to be interpreted as Latin-1. It just happened to right, by random chance. My original message left my machine with MIME headers, which were ripped off somewhere on the way. I'm not familiar with where Usenet currently stands for MIME support, yet the need for it, or something equivalent, is real. > [...] the one in the header gets munged into an imbedded break into the > ISO-8859-1 character set. There is no way to ascertain that this 8-bit code (meaning c-cedilla in Latin-1) has to be interpreted as Latin-1 in headers, unless this is explicitely stated in some way. Even if you had correct MIME headers to describe that the message body is Latin-1, one may not induce that headers _also_ are Latin-1, as it is not necessarily the case (Polish or Chinese people might well write to me in French, for example). RFC 2047 describes how to code non ASCII characters in headers. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From urner at alumni.princeton.edu Tue May 30 16:44:05 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 30 May 2000 13:44:05 -0700 Subject: Wondering about Domingo's Rational Mean book Message-ID: <c588jscm3oqjlfnc723pmafemjcl99ihpm@4ax.com> Have folks on sci.math already discussed http://www.etheron.net/usuarios/dgomez/Roots.htm to anyone's recollection? I'd be interested in comments and/or pointers to previous postings. I don't have the necessary background to evaluate the significance of this work, but the algorithms made interesting programming exercises. Using them, I was able to get: 3rd root of 2 is about: 65379522 --------- 51891761 3rd root of 10 is about: 91969780593702397138462508494860 --------------------------------- 42688590663356403236303435376201 You can push these things further. E.g. 10^(1/3) ~= 2196555918195778106276024585870817879185576760 ---------------------------------------------- 1019550942230358826790302872023722041913882251 I also liked his concise presentation of Halley's method, which gives me the floating point nth rooth of an integer. Here's a recursive version: def halley(P,n,d=10,x=1): # Source: http://www.etheron.net/usuarios/dgomez/Roots.htm # P -- find nth root of this number # n -- whole number root # d -- level of depth for recursion (default 10) # x -- initial value of x (default 1) if d>1: newx = ((n+1.0)*P*x + (n-1)*(x**(n+1)))/((n-1)*P + (n+1)*x**n) return halley(P,n,d-1,newx) else: return x Usage: >>> halley(10,3) # 3rd root of 10 to depth 10 2.1544346900318838 >>> halley(2,3) # 3rd root of 10 to depth 10 1.2599210498948732 >>> halley(12931021,7) # 7th root of 12931021 to depth 10 10.336898680701067 >>> halley(12931021,7,40) # same to depth 40 (more accurate) 10.374031092075427 Sorry if this is old hat on sci.math -- thought it was pretty cool myself. Kirby Cc: people at fluidiom.com (from whence I first learned of Domingo's work): ============= >From: "Robert Coulter" <rcoulter at mvrpc.org> >To: <people at fluidiom.com> >Subject: fluidiom: math stuff >Date: Tue, 9 May 2000 16:55:14 -0400 > >Anybody out there follow what this guy (Domingo Gomez Morin) is up to...? >Kirby? Allen? >Would this be useful in fluidiom ... *IS* this "New and Improved"? >He doesn't seem bashful even as he bashes cartesian thought... >so he oughta fit in OK around here. > >http://www.etheron.net/usuarios/dgomez/default.htm > >Core9 From claird at starbase.neosoft.com Wed May 17 19:55:13 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 17 May 2000 18:55:13 -0500 Subject: Python multiplexing is too hard (was: Network statistics program) References: <SWnU4.313$yX.43992@news1.onlynews.com> <8ftqtk$25a$1@ites.inria.fr> <sZBU4.1751$%8.7965@news1.onlynews.com> Message-ID: <70473664761982E0.213BD232030AF5BF.3DC75D82647B8DFC@lp.airnews.net> In article <sZBU4.1751$%8.7965 at news1.onlynews.com>, Greg Fortune <gfor_ewu at ispchannel.com> wrote: >Right now, I'm just sending the output of the ping to a text file and then >reading it from there. > >os.system('ping -t 1 208.152.8.1 > convertor_temp.txt') >#Read input file and extract result >#Store result > > That circumvents the need for the select. The only reason I've done this >is because the os.system call will not return the output from the call (and >I'm very new to this language as well as "real-world" programming <g>). Is >there another way (possibly the select you mentioned) to get the output from >a call back to the program? I need to use this on both Linux and Windows so >I can't use the UNIX specific commands module. > >Greg > >Cedric Adjih <adjih at crepuscule.com> wrote in message >news:8ftqtk$25a$1 at ites.inria.fr... >> >> You can use module time, function sleep: >> time.sleep(1.1) # sleep 1.1 seconds >> Or if you are waiting for events or for a timeout, select >> will be helpful: >> select.select([file desc list]..., timeOutInSeconds) >> For instance if you are waiting for a ping reply. >> >> -- Cedric >> > > What's the really cool, idiomatic way to multiplex in Python? I'm not happy with anything I do in this regard. First, I recognize this is far afield from Mr. Fortune's needs. He's best served either by direct ICMP calls, or a simple os.popen("ping -c 1 ...").read() which gives him all of what I understand he's after. Mr. Fortune, let me know if it's not obvious how this answers your question, and I'll be more explicit. Suppose, though, that he really did need multiplexing. Is there a tutorial I haven't noticed yet that models the Python way to process (let's call them) stream-based events? We can put stuff in a thread, but that's a lot of mechanism; we can select, but, gosh, isn't that the low-level error-prone OS system-level programming Python's s'posed to transcend? All the Python code I've seen in this area just "has too many notes". It makes me think it's fragile. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jkraska1 at san.rr.com Wed May 31 19:35:12 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 31 May 2000 23:35:12 GMT Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <8h34v4$7ac$1@nnrp1.deja.com> <393530D7.D495D3F9@san.rr.com> <39353A47.10EC15FB@do.not.use> Message-ID: <3935A24C.35198018@san.rr.com> > I wish the default implementation for lists were deques, so > that I didn't have to worry about which end of a list I add > to or remove from. Well, as you saw from my notes, this matters not at all for lists <100 elements. If you want my deque implementation, let me know. It's fairly complete, albeit doesn't implement many of the sequence operations (slicing, indexing, mapping). C/ From thomas at xs4all.net Thu May 4 16:15:23 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 4 May 2000 22:15:23 +0200 Subject: signal module question In-Reply-To: <Pine.LNX.4.10.10005031414180.22611-100000@worf.mcnc.org>; from fwang2@yahoo.com on Wed, May 03, 2000 at 02:21:41PM -0400 References: <Pine.LNX.4.10.10005031414180.22611-100000@worf.mcnc.org> Message-ID: <20000504221522.A3309@xs4all.nl> On Wed, May 03, 2000 at 02:21:41PM -0400, oliver wrote: > I think two or more alarms can be installed, say, one alarm is fired up at > 10 seconds interval, the other one 30 seconds interval. My question is can > i use one handler to deal with both alarms? You cannot install more than one alarm. At least, not using standard UNIX 'alarm()' mechanisms, which the signal module is using. Setting a new alarm erases the previous one. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From cjensen at bioeng.ucsd.edu Sat May 27 19:34:28 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Sat, 27 May 2000 16:34:28 -0700 Subject: Getting Variables from a file Message-ID: <39305B84.A06745E9@bioeng.ucsd.edu> I have a text file of the form: (var = integer) dof = 8 elements = 10 mesh_dof = 300 . . . . I want to read the file from within Python and then create a variable in python of the same name as what is in the text file, and holding the assigned value. Assuming I don't already know the names of the varialbes; how do I do this? I can do the file I/O, but how do I change a character string into a variable name? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From spamfranke at bigfoot.de Sun May 14 17:52:46 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sun, 14 May 2000 21:52:46 GMT Subject: Code sanity checker? Message-ID: <39201fc1.10448224@news.btx.dtag.de> Is there a tool which checks if classes or functions are defined twice in the same scope of a Python script? Stefan From wlfraed at ix.netcom.com Mon May 29 23:49:36 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 29 May 2000 20:49:36 -0700 Subject: auto increment operator?? References: <3933001E.D63F1A46@uniserve.com> <DxDY4.6197$wYl.222053888@newsb.telia.net> Message-ID: <had6jso24h68j2tu0mlll3tua7k7s0kth2@4ax.com> On Tue, 30 May 2000 00:01:39 GMT, "Fredrik Lundh" <effbot at telia.com> declaimed the following in comp.lang.python: > Bob van der Poel wrote: > > First off, why are there no operators equivalent to C's > > ++, --, +=, etc.? Very useful, and readable. Writing things > > like: 'var = var+1' is getting old real fast. > > if you write things like "var = var + 1" a lot, you might be > missing some important python idioms... <snip> Or, from a different angle (one who had to learn C on his own, from a time when FORTRAN, COBOL, and assembly were king [Okay, BASIC gets a nod too])... If one does not find the time to program in C, why should one have the right to insist that others languages incorporate C-like operations? The x++, x-- type operators were naturals for C, as C was sort of a super-assembly in its origins; and the original C hardware incorporated instructions just for increment/decrement. Not all subsequent processors had/have such instructions in their architecture... Nor is "increment" (or add&assign) meaningful to many objects in an OO type language. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From bgdarnel at my-deja.com Mon May 8 21:32:57 2000 From: bgdarnel at my-deja.com (Ben Darnell) Date: 9 May 2000 01:32:57 GMT Subject: Free hosting with python support? References: <39172EC9.FCC63B46@yahoo.com> Message-ID: <slrn8heqma.rja.bgdarnel@Sull-04-227.rh.ncsu.edu> In article <39172EC9.FCC63B46 at yahoo.com>, Paul Winkler wrote: >I'm looking for a new host that donates space to open source >projects AND allows python CGI so I can automate some of the mundane >maintenance. Anyone know of anything like that? Sourceforge.net fits the bill. -Ben -- Ben Darnell bgdarnel at unity.nc su.edu http://thoughtstream.org From nospam.newton at gmx.li Mon May 1 04:40:56 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Mon, 01 May 2000 08:40:56 GMT Subject: [Python-Dev] Re: Python 1.6a2 Unicode bug (was Re: comparing strings and ints) References: <l03102805b52ca7830b18@[193.78.237.154]> <39072F0C.5214E339@lemburg.com> <BlHN4.1719$wYl.195075584@newsb.telia.net> <oqvh14fikb.fsf@titan.progiciels-bpi.ca> <45919986@data.franken.de> <048501bfb0b4$c793d760$4add3fcb@neil> <45919991@data.franken.de> <pl5P4.8409$v85.54219@news-server.bigpond.net.au> Message-ID: <390d3d72.74901005@news.nikoma.de> On Mon, 01 May 2000 01:45:57 GMT, "Neil Hodgson" <neilh at scintilla.org> wrote: > Well, depends on how far you stretch 'more or less'. UTF-16 has room to >encode about 900,000 characters by using two 16 bit elements. Is this the "surrogate" thingies? Cheers, Philip -- Philip Newton <nospam.newton at gmx.li> If you're not part of the solution, you're part of the precipitate. From moshez at math.huji.ac.il Tue May 16 00:21:18 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 16 May 2000 07:21:18 +0300 (IDT) Subject: python improvements (Was: Re: New Language) In-Reply-To: <m3ln1bqw4q.fsf@greebo.nodomain.de> Message-ID: <Pine.GSO.4.10.10005160717000.2582-100000@sundial> On 16 May 2000, Bernhard Herzog wrote: > In that situation, real class methods would have been useful and cleaner > than any other solution. In the end, I fell back to normal class > attributes that are computed at class definition time because it works > well enough for the time being. Let me reiterate the way to get class methods: class Function: def __init__(self, func): self.func = func def __call__(self, *args, **kw): return apply(self.func, args, kw) class SomeClass: def class_method(a, b, c): return a+b+c class_method = Function(class_method) At the addition of a constant overhead (the "Function" definition), and one-line per class method (which you'd need anyway, to signal it is a class method), you get a no-brainer solution. try-meta-classes-for-more-fun-ly y'rs, Z. -- Moshe Zadka <moshez at math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From akira.kiyomiya at autodesk.com Mon May 8 17:58:13 2000 From: akira.kiyomiya at autodesk.com (Akira Kiyomiya) Date: Mon, 8 May 2000 14:58:13 -0700 Subject: Regular Expression Hell? Message-ID: <8f7d9n$ii7@autodesk.autodesk.com> Okay, these two regular expression codes are from Python Essential Reference book and I am pretty confused about these. Could someone dare to explan step by step? e_mail = re.compile(r'([a-zA-Z][\w-]*@[\w-]+(?:\.[w-]+)*)') # I know [a-zA-Z] any lower or upper word.....[\w-]?? any alphabetical character?? what is "-" after "\w"? # I know @, you need it for the e-mail.... Then, I am lost.... URL = re.compile(r'((ftp | http)://[\w-]+(?:\.[\w-]+)*(?:/[\w-]*)*)') # I know ftp or http part plus "://" you need it for URL. Then,..... I am lost.... Akira From d98aron at dtek.chalmers.se Thu May 11 11:14:27 2000 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 11 May 2000 15:14:27 GMT Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> Message-ID: <8feioj$fei$1@nyheter.chalmers.se> In article <8666smcfwv.fsf at g.local>, Gareth McCaughan <Gareth.McCaughan at pobox.com> writes: > > But my preference, which is for some notation along the > lines of > > map({a,b,c -> a+b+c}, p,q,r) > > isn't very Pythonic. Especially as we already have a {...} > syntax for dictionaries. > Well, using Haskells syntax, I would suggest map((\a,b,c -> a+b+c), p,q,r) Python-with-haskell-syntax-would-be-a-dream-ly yours, Fredrik From bigjoe615 at my-deja.com Wed May 3 18:43:52 2000 From: bigjoe615 at my-deja.com (bigjoe615 at my-deja.com) Date: Wed, 03 May 2000 22:43:52 GMT Subject: Embedding Python in Borland C++ Application References: <8enfcr$u9d$1@nnrp1.deja.com> Message-ID: <8eqa35$42u$1@nnrp1.deja.com> I guess I will answer that... ... PyObject* mathModule = PyImport_ImportModule("math"); PyObject* mathDict = PyModule_GetDict(mathModule); PyObject *s; String result = 0; s=PyRun_String(exp.c_str(),eval_input,mathDict,mathDict); PyObject* so =PyObject_Str(s); result=PyString_AsString(so); ShowMessage("Value of expression:"+result); ... In article <8enfcr$u9d$1 at nnrp1.deja.com>, bigjoe615 at my-deja.com wrote: > I have been able to compile and link a C++ > (Borland C++ Builder 4.0) with Python 1.5.2. > > I can use the following code to evaluate simple > arithmetic expressions (like 9*9): > > ... > PyObject *s; > PyObject *PyGlobal=PyDict_New(); > AnsiString exp=mFormulaTextDBMemo->Text; > // struct _node*pn=PyParser_SimpleParseString > (exp.c_str(),Py_single_input) ; > s=PyRun_String(exp.c_str > (),eval_input,PyGlobal,PyGlobal); > total=PyInt_AsLong(s); > ShowMessage("Value of expression:"+FloatToStr > (total)); > ... > > I am trying to understand how to use built in > functions like sqrt, pow, etc. PyRun_String > does not seem to work. How would I do this? > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From dana at oz.net Sun May 14 22:30:03 2000 From: dana at oz.net (dana_booth) Date: 15 May 2000 02:30:03 GMT Subject: (gulp) newbie question - portablity of python References: <LsCT4.65940$fV.4043974@bgtnsc05-news.ops.worldnet.att.net> <8fmtjo$3ub$0@216.39.141.21> <lnFT4.66185$WF.3671458@bgtnsc04-news.ops.worldnet.att.net> Message-ID: <8fnnfb$6au$0@216.39.141.21> Keygrass <nospam at sorry.com> wrote: K: I could ask a network adminstator if he or I could install Python. But ... K: I don't think it will receive a warm welcome On UNIX, you can simply install Python to your home directory tree for your use without affecting the rest of the system at all. -- ----- Dana Booth <dana at oz.net> Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From phd at phd.russ.ru Wed May 17 07:54:53 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 11:54:53 +0000 (GMT) Subject: Q? Calling nearest inherited method In-Reply-To: <392286f1.3796291238@news.u-psud.fr> Message-ID: <Pine.LNX.4.21.0005171154200.31722-100000@fep132.fep.ru> On Wed, 17 May 2000, Laurent POINTAL wrote: > Given a class hierarchy like this: > A > B inherits A > C inherits B > > A define dothis method. > C define dothis method. > > In the C.dothis, I wants to call my nearest parent class dothis > method. That is, call B.dothis if it is defined, or A.dothis if it is > defined... I think B.dothis() will do it just right, no? Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tim_one at email.msn.com Fri May 19 04:10:18 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 19 May 2000 04:10:18 -0400 Subject: Bit length of int or long? In-Reply-To: <000b01bfc14d$7c7ef1c0$6401a8c0@home> Message-ID: <000601bfc169$abcc8f20$722d153f@tim> [Darrell Gallion] > Assuming it never hurts to ask. It doesn't hurt me, but others may scream <wink>. > >>> x=0xffffffff > >>> x >> 1 > -1 > > Wouldn't 0x7fffffff be nice, Python exposes no unsigned integer type now. For the integers (whether int or long) it does support, it's guaranteed that i >> j == i / 2**j now, and many integer programs rely on that identity. So, no, it wouldn't be nice to break that, notwithstanding that it may yet be nice to implement a *different* zero-fill shift primitive (e.g., Java does that). > maybe even a rotate function. Maybe. > My last hot idea to allow re to match nested patterns, produced > only polite interest. So I'm sure my interests must be on the > fringe :) Many decades ago, I had the hot idea that printers should produce output in color. That only produced polite interest at the time too <wink>. not-to-mention-my-hot-ideas-for-matter-transport-beams-ly y'rs - tim From tiddlerdeja at my-deja.com Thu May 25 09:37:50 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Thu, 25 May 2000 13:37:50 GMT Subject: python cgi browser detection??? Message-ID: <8gjabb$7f2$1@nnrp1.deja.com> I'd like to use Python for a CGI script which would detect the type of browser a request has been made from and then return an apporpriate response. E.g. If I get a request from IE5 I'd like to return HTML If I get a request from a WAP browser, I'd like to return WML. Any information greatly appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From karl-sve at dsv.su.se Mon May 8 02:01:44 2000 From: karl-sve at dsv.su.se (Kalle Svensson) Date: Mon, 8 May 2000 08:01:44 +0200 Subject: PyBalsa? In-Reply-To: <m366spvm1n.fsf@wilma.george.org> References: <m3ya5mxktc.fsf@wilma.george.org> <4CCD34DC434D6019.93763A3431326470.47F9322EA18914C1@lp.airnews.net> <m366spvm1n.fsf@wilma.george.org> Message-ID: <Pine.GSO.4.20.0005080748260.2728-100000@luna.dsv.su.se> On 7 May 2000, Harry George wrote: > I like the idea of pmail, so I downloaded and built it, but it didn't > run for me. I was trying to run it in fvwm2. Is it > enlightenment-specific? Don't think so, a guess based on the following lines is that the problem is somewhere in your gnome/gtk/libglade/PyGTK/python-gnome setup. Check the pmail README, there is a section on requirements, maybe you have an older, or indeed newer (maybe the changed some interfaces somewhere), version of something? > ** WARNING **: unknown widget class 'GnomeApp' > gtkf.MainWindow.MainWindow: ERROR: GladeWindow: could not find widget: MainWindow HTH, Kalle Svensson -- * krftkndl at hem.passagen.se * http://www.dsv.su.se/~karl-sve/ * From frankc at colconsulting.com Thu May 4 10:58:59 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Thu, 04 May 2000 10:58:59 -0400 Subject: Copyright and License Message-ID: <39119033.8BC1A4EA@colconsulting.com> Does anyone have the text for the standard Python license for distributing Python language source? NOT for Python itself, but for source written to be run BY Python. TIA -- Frank V. Castellucci From akuchlin at mems-exchange.org Mon May 8 13:51:19 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 08 May 2000 13:51:19 -0400 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <yayk8h66otu.fsf@ganglot.ifi.uio.no> <jaln1mgdfy.fsf@helix.twistedmatrix.com> <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> <3dr9bdhykv.fsf@amarok.cnri.reston.va.us> <jaitwolwei.fsf@helix.twistedmatrix.com> Message-ID: <3dog6hhqw8.fsf@amarok.cnri.reston.va.us> Glyph Lefkowitz writes: >1) is there a free OCaML? It's LGPLed: http://caml.inria.fr/ >2) is OCaML-Python free? I'm not sure what the licence is, but vaguely recall it's the same as Python's. Could be wrong... >3) Where can I get a copy of it? http://vyper.sourceforge.net/ . Note that it's a test bed for various modifications to Python that Skaller is interested in, so there are various language extensions: ML-style pattern matching, new statements, etc. >4) Why don't we hear more about this? What is all this jpython hype >about? ;-) It's not very widely advertised, perhaps because it's still an alpha. Some of the extensions seem difficult to implement in CPython or JPython, but it's quite possible that Vyper could go on to become the first languages that derives from Python. -- A.M. Kuchling http://starship.python.net/crew/amk/ And the state of his bathroom -- I'm not one to gossip, but there are things crusted on his sink that have not simply developed intelligent life but have in all probability by now evolved their own political systems. -- Cain describes Abel in in SANDMAN #70, "The Wake" part one From phd at phd.russ.ru Mon May 29 04:14:27 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 29 May 2000 08:14:27 +0000 (GMT) Subject: Cookies / CGI In-Reply-To: <280520000010584565%timo@alum.mit.edu> Message-ID: <Pine.LNX.4.21.0005290811190.27243-100000@fep132.fep.ru> On Sun, 28 May 2000, Timothy O'Malley wrote: > Oleg Broytmann <phd at phd.russ.ru> wrote: > > # ----- create ----- > > #! /usr/local/bin/python -O > > > > def set_cookie(): > > import time > > t = time.gmtime(time.time()) > > t = (t[0] + 10,) + t[1:] # add 10 years :) > > > > import Cookie > > cookie = Cookie.Cookie() > > > > cookie["id"] = str(1024) > > cookie["id"]["expires"] = time.strftime("%a, %d-%b-%Y %T GMT", t) > > > You don't have to format the time string yourself. Cookie.py will > do it for you. Just set the value to the number of seconds: > > > cookie["id"]["expires"] = 10 * 365 * 24 * 3600 The program was written in a haste, a little while before I really read Cookie.py (excellent work, Tim!) and understand it. :) You can also mention I don't need to cast the value itself into string: cookie["id"] = 1024 instead of cookie["id"] = str(1024) and Cookie.py will use pickle to dump/load the value. Beware of broken pikles! Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From Jhlee at Brooks.com Mon May 15 11:15:57 2000 From: Jhlee at Brooks.com (Lee, Jaeho) Date: Mon, 15 May 2000 11:15:57 -0400 Subject: [Q] how to find process id on windows? (anyone have killProcName .py?) Message-ID: <857F15D7E3D8D3118D290008C7CF05862707EB@mail-naeast1.brooks.com> Hello, I want to find process id from process name. I read about 'killProcName.py' shows how to do that, in 'python programming on win32'. But I could not find it. Anyone can point me where I can find it? Or could you let me know how to find process id from process name (on NT 4.0)? Thanks in advance, Jaeho Lee From effbot at telia.com Wed May 31 19:05:29 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 31 May 2000 23:05:29 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <sj3ejda85pj169@corp.supernews.com> <hjoY4.6071$wYl.223614464@newsb.telia.net> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <ZoDY4.6196$wYl.229414400@newsb.telia.net> <39333CC3.32805F5@cosc.canterbury.ac.nz> <saMY4.6222$wYl.223847936@newsb.telia.net> <3933a92e$0$25480@personalnews.de.uu.net> Message-ID: <ZUgZ4.6388$wYl.229561856@newsb.telia.net> Johannes Stezenbach wrote: > >that's really a different topic. > > You tell us to reason because voting doesn't help. > We reason and you tell us we're reasoning about the wrong topic. Umm. Looks like you're confusing me with someone else... </F> From rwallace at esatclear.ie Tue May 23 17:00:02 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Tue, 23 May 2000 22:00:02 +0100 Subject: Random numbers References: <000401bfc45d$882e46c0$9ea2143f@tim> Message-ID: <392AF152.3AD1@esatclear.ie> Tim Peters wrote: > > [Russell Wallace] > > Is there any difference between the random number generator in the > > 'random' module and that in the 'whrandom' one? > > No, but you shouldn't use whrandom: whrandom is an interal implementation > detail of random.py. whrandom.py should probably be renamed to _whrandom.py > (or something) to stop people from tripping over it. Got it, thanks. (The HTML docs only mention the basic random number functions in the whrandom module, which confused me a bit.) > > What's the quality > > If you know enough about random numbers to understand an answer to that > question, then telling you it's the standard Wichman-Hill (that's where "wh" > comes from) generator is all the answer you need <wink>. I don't, except to know how much I don't know :) > Seriously, test it > and determine whether it's adequate for your application; if you can't test > it objectively, then you have no way of knowing whether any other package is > adequate either (and neither does anyone else, so don't ask). > > Ivan Frohne wrote a very nice package of stronger generators, which should > be available from his Starship page. But unless you're doing extreme work, > WH should be adequate for a start. I'm not, for this application anyway; it's a game, and player actions generally throw in enough unpredictability that the random number generator doesn't have to be all that great. Basically I mainly wanted to check that it's not *notoriously bad*, like the common implementation of C's rand(); from what you say, I'm sure it'll be fine. Thanks. -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From m.faassen at vet.uu.nl Sat May 27 18:45:24 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 May 2000 22:45:24 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <CC59868A0A76D311B1F50090277B321C1F3348@VRTMAIL> <slrn8ikrtj.48f.bwinton@tor.dhs.org> <rKHwzJA12oK5EwJ6@jessikat.demon.co.uk> <m2aehehfcg.fsf@netmeg.net> <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> <392DD013.6E44EFF4@san.rr.com> <392E299B.9D8D0D54@san.rr.com> Message-ID: <8gpj64$h70$1@newshost.accu.uu.nl> Courageous <jkraska1 at san.rr.com> wrote: >> > >"CUM HOC ERGO PROPTER HOC" >> > > >> > >It should be educational. >> > >> > I think you mean "POST" instead of "CUM". >> >> No. [discussion on Latin, causality ensues] Thank G*d*..this started to look suspiciously like the Usenet Flamewar Vulgaris for a moment! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From JamesL at Lugoj.Com Sat May 20 21:38:40 2000 From: JamesL at Lugoj.Com (James Logajan) Date: Sat, 20 May 2000 18:38:40 -0700 Subject: Case sensitivity/insensitivity References: <39260CB6.464EE302@san.rr.com> Message-ID: <39273E20.508C90D0@Lugoj.Com> Courageous asked: > Does anyone out there actually make use of > case sensitivity? Yes. I use it more now than I used to after I worked with ASN.1 for a while. In that notation types are mandated to start with upper case characters and field identifiers are mandated to start with lowercase characters. So in C/C++ I now feel vindicated in doing something like: struct Person { char *name; int age; }; void Fenestrate(Person &person); From jsliv at jslove.net Sat May 20 11:02:07 2000 From: jsliv at jslove.net (Jay Love) Date: Sat, 20 May 2000 11:02:07 -0400 Subject: Dictionaries and Threads Message-ID: <3926A8EF.C3C1914B@jslove.net> Are dictionary lookups threadsafe? ie, can I lookup and retrieve an item in a dictionary while another thread is adding an item? Thanks, Jay Love From wlfraed at ix.netcom.com Fri May 26 23:43:35 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 26 May 2000 20:43:35 -0700 Subject: Help! SMTPlib References: <8gmti4$sf5$1@nnrp1.deja.com> Message-ID: <irguisg9c58f8p29qmrh859p2u3h5gflam@4ax.com> On Fri, 26 May 2000 22:24:19 GMT, sjoshi at ingr.com declaimed the following in comp.lang.python: > Hello > I'm trying to use the smtplib for sending mail, and I keep getting > error: (10061, 'winsock error') when I try just to connect to the > localhost. > M$VC> WSAECONNREFUSED M$VC> M$VC> (10061) M$VC> M$VC> Connection refused. M$VC> M$VC> No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host - i.e. one with no server application running. M$VC> Most of the 100xx winsock errors seem to map to common UNIX/C errno if you drop the 100 prefix. Off hand, I'd say you don't have an active SMTPd running. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From jilanik at tin.it Wed May 24 17:40:42 2000 From: jilanik at tin.it (Jilani Khaldi) Date: Wed, 24 May 2000 23:40:42 +0200 Subject: E-Commerce solution using Python and Zope. Message-ID: <392C4C5A.FB94DD60@tin.it> Hi All, do you know about something written in Python for e-commerce solutions? Thanks. Jilani -- <jk> ___________________________________________________ http://space.tin.it/scuola/jkhaldi FreeBSD ~ The Power To Serve From tchur at bigpond.com Wed May 3 00:00:26 2000 From: tchur at bigpond.com (Tim Churches) Date: Wed, 03 May 2000 14:00:26 +1000 Subject: resource.getrusage() broken under Linux? Message-ID: <390FA45A.E9653A1E@bigpond.com> I checked the FAQs and email archives but couldn't find anything on this. Using Python 1.5.2 compiled under SuSE Linux 6.1 (kernel 2.2.7), the getrusage() function in the resource library module correctly returns the user and system mode time used by the Python process as the first two items of its return value, but all the other items, which are supposed to indicate memory utilisation, return zero. Is this a known problem under Linux? Any work-arounds? I am trying to build some classes which heuristically pickles data objects out to disc if too much memory is being consumed by the Python process. Should I just use ZODB and let it do the worrying? Cheers, Tim C From phd at phd.russ.ru Wed May 17 09:32:44 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 17 May 2000 13:32:44 +0000 (GMT) Subject: PyApache - scripts now not working In-Reply-To: <39229419.386206796@news1.on.sympatico.ca> Message-ID: <Pine.LNX.4.21.0005171329170.7782-100000@fep132.fep.ru> On Wed, 17 May 2000 chibaA at TinterlogD.Tcom wrote: > .. how would I go about checking that? (I'm sorry, but I'm a bit new > to this). Try to compile as LITTLE as possible. Reompile Python and make all modules not-shared (make a minimum set of modules - no MySQL and all that). Install new python. Recompile Apache with PyApache and try. If this helps - continue investigating: recompile python with minimum set of modules, but make these modules shared; install; recompile Apache; try... And so on, until you'll find the offensive module. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From jkraska1 at san.rr.com Sun May 21 22:53:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 22 May 2000 02:53:43 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <392877EE.4992@esatclear.ie> Message-ID: <3928A1CB.71890CEC@san.rr.com> > Quick question: Any chance of removing the requirement for colons at the > end of class, def, if, for, while lines? That's the only thing about > Python's syntax I truly dislike, and I still keep tripping up on it; > pretty nearly all the rest I find fine. I wouldn't say I dislike it, but I do find myself tripping up on it all the time, particularly after else, but often in other conditions as well. (It's also my most frequent error). C/ From shrub at yahoo.com Mon May 22 21:23:29 2000 From: shrub at yahoo.com (Paul Schreiber) Date: Mon, 22 May 2000 18:23:29 -0700 (PDT) Subject: Python 1.6a2 -- patch for urllib https POST support Message-ID: <20000523012329.2798.qmail@web119.yahoomail.com> I was futzing with urllib and noticed it supported POST and GET for http but only GET for https. So I added support. :-) This worked for me, but I haven't tested it thoroughly. Here's a context diff... Paul *** /usr/local/lib/python1.6/urllib.py Mon May 22 15:46:39 2000 --- /home/shrub/urllib.py Mon May 22 18:14:25 2000 *************** *** 299,305 **** raise IOError, ('http error', errcode, errmsg, headers) if hasattr(socket, "ssl"): ! def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): --- 299,305 ---- raise IOError, ('http error', errcode, errmsg, headers) if hasattr(socket, "ssl"): ! def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): *************** *** 323,338 **** h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) ! h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: ! return self.http_error(url, fp, errcode, errmsg, headers) def open_gopher(self, url): """Use Gopher protocol.""" --- 323,349 ---- h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) ! if data is not None: ! h.putrequest('POST', selector) ! h.putheader('Content-type', 'application/x-www-form-urlencoded') ! h.putheader('Content-length', '%d' % len(data)) ! else: ! h.putrequest('GET', selector) ! if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() + if data is not None: + h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: ! if data is None: ! return self.http_error(url, fp, errcode, errmsg, headers) ! else: ! return self.http_error(url, fp, errcode, errmsg, headers, data) def open_gopher(self, url): """Use Gopher protocol.""" ===== shad 96c / 4A CS / mac activist / eda / fumbler fan of / jewel / sophie b. / sarah slean / steve poltz / emm gryner / / x-files / buffy / dawson's creek / habs / bills / 49ers / t h i n k d i f f e r e n t. __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ From ngps at madcap.dyndns.org Tue May 16 10:23:57 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 16 May 2000 14:23:57 GMT Subject: SSL on Windows? References: <etdr9bht1b3.fsf@w20-575-109.mit.edu> <39152AC9.AFBCF2FA@studcs.uni-sb.de> <8fc03c$1eg$1@coco.singnet.com.sg> <D77CA61AE8DE96BA.450526DD8955149E.27177558A09E660A@lp.airnews.net> Message-ID: <8frllt$g65$1@coco.singnet.com.sg> According to Robert Towster <rtowster at emerging.com>: > now I only need to do a SSL client (to hit an existing server). I > started > playing with the demos.. (specifically echo.py) Also take a look at http_cli.py in the same directory as echo.py. > I keep getting PRNG not seeded. (see traceback below) > The line that apparently seeds PRNG is this: > Rand.load_file('../randpool.dat', -1) In the demo/ directory, there is a file called randpool.dat. This file was created from a FreeBSD's /dev/random. Please try again with this file. > I can get a perl library to do this.. but.. I wanna use python =) ;-) Cheers. -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps From none at none Fri May 19 00:50:38 2000 From: none at none (Eric Jacobs) Date: Thu, 18 May 2000 23:50:38 -0500 Subject: [OT] fcntl.flock problems on FreeBSD References: <20000517184228.19805.qmail@c391458-a.sttln1.wa.home.com> Message-ID: <si9dtvb5ius23@corp.supernews.com> In article <20000517184228.19805.qmail at c391458-a.sttln1.wa.home.com>, sblakey at freei.com wrote: > I'm having some trouble with flock in the fcntl module on a FreeBSD 4.0 > box. Most of the flock operations work perfectly (LOCK_SH, LOCK_EX, > LOCK_UN), but LOCK_NB seems to alway raise a Bad file descriptor error. > [snip] (3.3-RELEASE) /sys/kern/kern_descrip.c 1108: if (uap->how & LOCK_EX) lf.l_type = F_WRLCK; else if (uap->how & LOCK_SH) lf.l_type = F_RDLCK; else return (EBADF); Bad choice of error code. Try LOCK_SH | LOCK_NB or LOCK_EX | LOCK_NB. From petersc at stud.ntnu.no Wed May 3 03:02:11 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 03 May 2000 09:02:11 +0200 Subject: Python in the future References: <38FDB8A7.E701F81F@sec.noaa.gov> <8ZjL4.273$CP3.3311@news.uswest.net> <8eofrh$1bl$1@nnrp1.deja.com> Message-ID: <390FCEF3.919A5DBC@stud.ntnu.no> Sorry for disagreeing, but if you ever got your fingers into artificial intelligence you'd see that a significant part of the community is using LISP, a language similar to Python in being high level. And believe me, for some things LISP is still prime time. So if Python keeps being a general purpose, high level language I think it will be around for quite a while (ages in the world of computers). Peter arkconfused at hotmail.com wrote: > > Sorry for being rude or an A$$, but the question of where computer > technology will be in the next 5-10 years is crazy! And the comment > that Python will be a string presence, if you have learned from > historical events, things like BETA, Mac, and Python have and will > disappear. When it comes to technology, people want what the majority > has along with lots of support! Right now, I see Python being the BETA, > and Perl being the VHS. Maybe in a YEAR or TWO, Python will have gained > more support in the industry, and if it doesn't, I see it being replaced > just like the BETA machine's did. -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From hzhu at rocket.knowledgetrack.com Tue May 30 14:15:53 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Tue, 30 May 2000 18:15:53 GMT Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <8grnj1$sb3$13$1@news.t-online.com> <slrn8j5k1c.8a7.wtanksle@dolphin.openprojects.net> <393326D3.400AA248@cosc.canterbury.ac.nz> <8h078i$bnc$2@newshost.accu.uu.nl> Message-ID: <slrn8j81fs.108.hzhu@rocket.knowledgetrack.com> On 30 May 2000 11:04:50 GMT, Martijn Faassen <m.faassen at vet.uu.nl> wrote: >Greg Ewing <greg at cosc.canterbury.ac.nz> wrote: >[snip] >> I assume that no-one would disagree with the following statements: > >> 1. Integer division and real (or rational, if you prefer) division >> are different operations. > >Question: why does nobody complain about the overloading of the '+' >operator? After all, it works on both strings and numbers; and presumably >your code will fall apart at unsuspected points as well if you assume it >only deals with numbers. :) Two points worth considering: 1. The int to float conversion is often automatic: sqrt(2) 2. a/b produces different results based on type without warning. My experience is that any time a computer language tries to use "smart guess" to resolve ambiguity it generally creates more trouble than it saves, even if it guesses right 95% of the time. From jkraska1 at san.rr.com Wed May 24 01:22:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 24 May 2000 05:22:43 GMT Subject: EMBEDDERS--REQUEST FOR COMMENTS: Message-ID: <392B67C2.860767B4@san.rr.com> Here's a brief code snippet: -------- static int ExampleObjectSetattr ( ExampleObject* self, char* name, PyObject* value ) { if (strcmp(name,"data")==0) { if (PyString_Check(value)) { self->data = PyString_AsString(value); return 0; } else { PyErr_SetString(PyExc_AttributeError,"attempt to set data attribute to a value which is not a string"); return -1; } } else { PyErr_SetString(PyExc_AttributeError,"attempt to set unknown attribute on non dynamic external type"); return -1; } } -------- My presumption is that, in this instance, I don't increase the reference count on the valuem because I've ascertained that it's a primitive (string, int, et al). However, if this were a real object, I'd be doing an INCREF() on it, and furthermore, would have to take care to do a DECREF() on what I was assigning over. Do I have this right? Thanks. C/ From aahz at netcom.com Fri May 26 09:43:25 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 May 2000 13:43:25 GMT Subject: Python performance notes... References: <392A2ED5.6A35B754@san.rr.com> <Pine.LNX.4.10.10005251414430.1544-100000@propylaea.anduin.com> <392DBEAB.B5147578@san.rr.com> <JrkX4.91772$R4.528223@news1.rdc1.nj.home.com> Message-ID: <8glv1t$ha7$1@slb1.atl.mindspring.net> In article <JrkX4.91772$R4.528223 at news1.rdc1.nj.home.com>, Brett g Porter <BgPorter at NOacmSPAM.org> wrote: > >I took Aahz' original point to be that since the Python version could >be written significantly faster than a C version, there was a class of >problems where that metric alone makes Python the clear winner. I was >more interested in the speed of development issue, which for this one >case, choosing C++ allowed me to write the solution as quickly as I >might have in Python, without sacrificing execution speed. My point included that, but my main point was slightly subtler: Python has many built-in features that usually more than compensate for any slowness in the language itself, making the issue of slowness in for loops mostly irrelevent. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From tim_one at email.msn.com Wed May 17 21:48:38 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 17 May 2000 21:48:38 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: <m3og65kkp8.fsf@atrus.jesus.cam.ac.uk> Message-ID: <000301bfc06b$304ab7e0$872d153f@tim> [Michael Hudson] > ... > One approach would be to estimate the error in P/Q by abs(P/Q-R/S) > where R/S is the next convergent. I'm not sure how valid this would > be; fairly, I suspect. It'll be an overestimate. The convergents are alternately larger and smaller than the value they're converging to, so adjacent convergents bracket the target, so this is certainly valid. Note too that abs(P*S-Q*R) == 1 (see earlier reply), so abs(P/Q-R/S) = 1/(Q*S) (that is, P and R are irrelevant). Then, so long as the sequence is beyond the trivial initial convergents, S > Q, so 1/(Q*S) < 1/Q**2. So when you get to P/Q, you know the absolute error is < 1/Q**2. Stopping on 1/(Q*S) is often more satisfying, though! That is, when "the next" partial quotient is large, S is much larger than Q, so 1/Q**2 grossly overestimates the error. A nice compromise is to go on until 1/Q**2 is small enough, then compute the exact error for just the last few convergents (going back until the exact error is too large). > ... > Yeah, continued fractions are fun... Heresy! Python is fun. continued-fractions-are-just-an-excuse-to-use-python<wink>-ly y'rs - tim From kevinmcd at NOSPAM.linuxsolutions.demon.co.uk Wed May 17 08:08:49 2000 From: kevinmcd at NOSPAM.linuxsolutions.demon.co.uk (Kevin McDermott) Date: Wed, 17 May 2000 13:08:49 +0100 Subject: tkinter References: <8fsslv$n0n$0@216.39.141.21> <39221BA4.EEA38C94@earthlink.net> Message-ID: <39228BD1.3E8F2721@NOSPAM.linuxsolutions.demon.co.uk> Simon wrote: > > I had the same problem with tcl, tk and mysql modules. The problem is the > executable doesn't look for the libs in /usr/local/lib (I haven't put much > thought into figuring out why). I solved the problem by making symbolic links > to those libraries in a directory which I was sure the interpreter would read: > /usr/lib. > > From /usr/lib, enter > > ln -s /usr/local/lib/libtk8.3.so libtk.8.3.so > > and so on. > > I'd like to take this clutter out of /usr/lib. Can anyone tell me how to get > the interpreter to seek libraries in additional directories? > > --S. Simon, add a line in /etc/ld.so.conf pointing at /usr/local/lib and run ldconfig (as root). That should cure your lib problems. Kevin From effbot at telia.com Tue May 9 02:57:02 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 09 May 2000 06:57:02 GMT Subject: get the list of expected arguments? References: <Pine.BSF.4.10.10005081717250.1876-100000@chi.pair.com> Message-ID: <2FOR4.3372$wYl.200597504@newsb.telia.net> Michal Wallace (sabren) <sabren at manifestation.com> wrote: > Given a function (or method), is it possible to know the names of the > expected parameters? I'd like to be able to extract this information > and generate a form for calling the function. here's one way to do it: http://www.deja.com/=dnc/getdoc.xp?AN=552444703 </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From steven at nospam.trance.org Tue May 2 12:35:16 2000 From: steven at nospam.trance.org (Steven) Date: Tue, 2 May 2000 17:35:16 +0100 Subject: Example scripts Message-ID: <UrDP4.13697$r6.77874@stones> hi, I've just started looking at python as a possible language to use in some projects. Having experience of other scripting languages has meant that getting the general idea has been quite easy, however although the documentatiion is very good, it suffers from very few examples. Could anyone tell me some sites containing good examples and simple scripts so i can study the usage of certain commands? I'm particularly interested in the sound modules, could somebody tell me whether it is relatively easy to make a script to join together wav or au files and output a finished version? thanks for your time steven P.S. Please remove the nospam part of my address to reply. -- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+* Email: trance.org at steven (reversed) Website: http://iptoolz.com/vegan-net Vegan Contact Directory & Search Engine *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+* We shall pass through this world but once. Therefore, any good which i can do, For any living being, Let me do it now. Let me not defer it or neglect it, For i shall not pass this way again. *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+* From owen at astroNOJNK.washington.edu.invalid Thu May 4 17:01:08 2000 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Thu, 04 May 2000 14:01:08 -0700 Subject: [ANNOUNCE] wxPROs References: <yWFP4.193$bTy1.23462359@news.randori.com> <39103702.9EBA14FE@eq.uc.pt> Message-ID: <8esoej$ee6$1@nntp6.u.washington.edu> In article <39103702.9EBA14FE at eq.uc.pt>, Pedro Vale Lima <eq3pvl at eq.uc.pt> wrote: >Thanks for all the work put into wxWindows. It's the __BEST__ python GUI >toolkit. I wish you all the fame and fortune. I am curious. Could you say more about why you feel it is better than, say, Tkinter? I'm just now trying to settle on a windowing toolkit and would like something easy to use, powerful and robust. I'm sure others are in the same boat. Thanks, -- Russell From wware at world.std.com Tue May 9 09:30:01 2000 From: wware at world.std.com (Will Ware) Date: Tue, 9 May 2000 13:30:01 GMT Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <slrn8hc7lg.8p7.neelk@brick.cswv.com> <3916F04F.7647B829@zipzap.ch> <etdem7dm0fx.fsf@w20-575-109.mit.edu> <391790A2.26CB9618@home.com> <etdhfc7ap0d.fsf@w20-575-109.mit.edu> <FuAnpr.HD8@world.std.com> Message-ID: <FuAo62.M98@world.std.com> Will Ware (wware at world.std.com) wrote: > Add a line at the end that says "showpage". Then you should be able > to see it. I typed too quickly. There are a bunch of def's here, but none of them is ever called, so nothing gets drawn (even with a showpage), just as if a Python file had a bunch of def's but never called any functions. Also, _rbar doesn't get defined anywhere. This is just a snippet out of a bigger file, not meaningful out of context, but evidence that one really can hand-code Postscript. I do it also. To help you avoid disappointment, here's some hand-coded Postscript for printing music paper. ==================================== %!PS-Adobe /LeftMargin .5 72 mul def /RightMargin 8 72 mul def /BottomMargin 72 def /TopMargin 72 10 mul def /Gap .1 72 mul def /oneline { dup LeftMargin exch moveto RightMargin exch lineto stroke } def /staff { dup oneline Gap sub dup oneline Gap sub dup oneline Gap sub dup oneline Gap sub oneline } def TopMargin dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub dup staff 72 sub staff showpage ==================================== -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From ljoramo.list at nickads.com Mon May 8 16:33:34 2000 From: ljoramo.list at nickads.com (Lee Joramo) Date: Mon, 8 May 2000 14:33:34 -0600 Subject: CGI getting multiple values with same name into a list Message-ID: <v04210104b53cd496e621@[192.168.1.2]> I am trying to process a web form but can not figure out the proper way to get mulitple values with the same name into a list. However, instead of getting a nice list, I get garbled MiniFieldStorage results For example, I have an html checkbox set with the name "select": --html web form snippet -- <form method=GET action='cgi-bin/sort.py'> <input type=hidden name="formname" value="form1"> <input type=checkbox checked name='select' value='type'> type <input type=checkbox checked name='select' value='year'> year <input type=checkbox checked name='select' value='price'> price <input type=checkbox name='select' value='description'> description <input type=checkbox name='select' value='template'> template </form> ---- When the form is submited it passes these values to a python script: http://domain.dom/cgi-bin/sample.py?formname=form1&select=type&select=year& select=price --sample.py--- #!/usr/bin/python import cgi form = cgi.FieldStorage() print "Content-Type: text/html\n\n" print "<pre>" formname = form['formname'].value print "formname : %s" % formname try : select = form['select'].value print "TRY select : %s" % select except : select = form['select'] print "EXCEPT select: %s" % select --output of sample.py-- formname : form1 EXCEPT select: [MiniFieldStorage('select', 'type'), MiniFieldStorage('select', 'year'), MiniFieldStorage('select', 'price')] --- Of course, what I am looking for is something like: select == ['type', 'year', 'price'] Thanks for any help. -- Lee A. Joramo ljoramo at nickads.com The Nickel Want Ads www.nickads.com Internet Manager 970-242-5555 -- Onward and Upward! Lee A. Joramo }}-----> Cowboy on the Electronic Frontier lee at joramo.com Alamar Ranch - Palisade - Colorado ThreeRivers|Eagle|UCD|D&D|TNC|DX|Mac|221B|Cannondale|Deutsch From chapman at bioreason.com Mon May 22 11:59:32 2000 From: chapman at bioreason.com (Mitch Chapman) Date: Mon, 22 May 2000 09:59:32 -0600 Subject: Python, Glade, & GTK References: <8gb1gf$r0u$1@news.ihug.co.nz> Message-ID: <39295964.BD653227@bioreason.com> Mafee wrote: > Can anyone give me some clues of linking python code to a GUI interface > generate by Glade or GTK or whatever please? Here's an example. Two files are attached. GladeBase.py provides two base classes. Class UI creates a widget hierarchy from a Glade file. Class Controller provides an MVC-style controller for the UI. The main() function of the module shows how to use these base classes to build and control a GUI. ui.glade is a simple user interface created using Glade. If you plop it into the same directory with GladeBase.py and then run GladeBase.py, you should get an application window on your display. The cool part about James Henstridge's libglade, on which this example is based, is the way it wires up callback routines. You pass it a dictionary of callable objects, keyed by name. It roots through the Glade-based user interface hierarchy, and for every connected signal declared in the interface, it looks for a callable of the same name in the callback dictionary. If it finds one, it plugs it in. It's cheap and easy. In the example, Controller._connectToUI() assumes that you will derive from class Controller and define all of the callback methods in the derived class. Hoping this helps... -- Mitch Chapman chapman at bioreason.com -------------- next part -------------- #!/usr/bin/env python """This is an example of accessing Glade-built UIs from Python.""" import gnome.ui, gtk, libglade class UI(libglade.GladeXML): """Base class for all UIs loaded from glade.""" def __init__(self, filename, rootname): """Initialize a new instance.""" libglade.GladeXML.__init__(self, filename=filename, root=rootname) self.root = self.get_widget(rootname) def show(self): """Make the UI visible.""" self.root.show() class Controller: """Base class for all controllers of glade-derived UIs.""" def __init__(self, ui): """Initialize a new instance. `ui' is the GladeXML UI to control.""" self.ui = ui self._connectToUI() def _connectToUI(self): """Wire up self to its UI. This method assumes that any method defined by self's class could be a Gtk+ callback. It wires up any methods referenced by self's ui.""" names = dir(self.__class__) d = {} for name in names: d[name] = getattr(self, name) self.ui.signal_autoconnect(d) def show(self): """Show the user interface.""" self.ui.show() def main(): """Module mainline (for standalone execution)""" class SampleController(Controller): def on_pushBtn_clicked(self, *args): """Called when the 'push me' button is clicked.""" print "Thanks for pushing me." gtk.mainquit() def on_win_delete_event(self, *args): """Called when the window is deleted.""" gtk.mainquit() theUI = UI("ui.glade", "win") theController = SampleController(theUI) theController.show() gtk.mainloop() if __name__ == "__main__": main() -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20000522/42a6472d/attachment.html> From moshez at math.huji.ac.il Tue May 23 01:28:38 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 23 May 2000 08:28:38 +0300 (IDT) Subject: how to find out the father class? In-Reply-To: <8gbdou$sd3$1@nnrp1.deja.com> Message-ID: <Pine.GSO.4.10.10005230828210.12103-100000@sundial> On Mon, 22 May 2000 moonseeker at my-deja.com wrote: > Hi! > > How can I find out the father class of a given class? foo.__bases__[0] -- Moshe Zadka <moshez at math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From m.faassen at vet.uu.nl Thu May 18 18:03:54 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 22:03:54 GMT Subject: Java vs Python References: <KzLT4.3373$Kc3.20912@news-server.bigpond.net.au> <jazoprog8c.fsf@helix.twistedmatrix.com> <000e0a4e.9a742029@usw-ex0101-008.remarq.com> <39242672.B912BF29@sage.att.com> <00be0b90.27bb7bbb@usw-ex0101-008.remarq.com> <jaem6zy61t.fsf@helix.twistedmatrix.com> Message-ID: <8g1pca$drc$1@newshost.accu.uu.nl> Glyph Lefkowitz <glyph at twistedmatrix.com> wrote: [snip] > Marketability? Hm. The thing that makes Java marketable is the > tremendous amount of money that Sun has poured into getting it into > every trade rag that they could possibly find. Fellow pythonistas, > short of getting Guido to use the time machine for material gain > <wink> is there any way we can effectively market Python as a > competitor to a language / platform with that kind of agressive force > behind it? I think it's just a question of time now. We can basically just proceed as we're all doing. We've reached the treshhold now; there's no turning back, even if we tried. Python's going to grow very quickly now. [snip] > My conclusion is obviously that Python needs more marketing ;-) > hopefully it can have this without becoming evil. Is the PSA doing > anything on this front? I don't think the PSA is doing much. Should it? There's this tiny project of Guido's on getting Python into the schools. :) There are quite a few companies that use Python. There's the whole Zope community. There is this bookshelf with Python books at the bookstore that keeps growing and growing. There are several big names in open source that mention they want to use Python more in public. The Java folks are starting to notice Python. A multiplicity of articles on the web, magazine articles, and so on. The only place Python isn't known very well is the Netherlands. At least I feel this when I look at the state of nl.comp.programmeren, the Dutch programming newsgroup. (i.e. "how do I change the color of a button in VB??????!!") :) So, all we have to do is wait. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sjoshi at ingr.com Mon May 29 23:23:15 2000 From: sjoshi at ingr.com (sjoshi at ingr.com) Date: Tue, 30 May 2000 03:23:15 GMT Subject: Help! SMTPlib References: <8gmti4$sf5$1@nnrp1.deja.com> <8gnbip$282$1@news-int.gatech.edu> Message-ID: <8gvc6n$f79$1@nnrp1.deja.com> You are right..that's what I have been trying after reading from the docs...should gave looked at the module first. Anyway will try it the other way thanks Sunit In article <8gnbip$282$1 at news-int.gatech.edu>, andrew.henshaw at gtri.gatech.edu wrote: > sjoshi at ingr.com wrote: > >Hello > > I'm trying to use the smtplib for sending mail, and I keep getting > >error: (10061, 'winsock error') when I try just to connect to the > >localhost. > > > > I'm guessing that your code looks something like: > > import smtplib > > server=smtplib.SMTP('localhost') > server.connect() > > If so, then your problem is that the server.connect() function was already > called when you instantiated "server". The connection is automatically made > when you provide the hostname as a parameter to SMTP. > > I believe that the SMTP example in the library documentation is in error, in > this regard. > > Andrew Henshaw > Sent via Deja.com http://www.deja.com/ Before you buy. From neilh at scintilla.org Wed May 24 08:56:01 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 24 May 2000 12:56:01 GMT Subject: Good ideas :-), no time :-( References: <oqwvkkp5q6.fsf@titan.progiciels-bpi.ca> Message-ID: <BjQW4.2670$bZ3.16643@news-server.bigpond.net.au> > So, I came with this "simple" idea, that we should have tools for converting > Makefiles and shell scripts into specialised Python scripts. (And why not > `sed' and `awk' as well, once on that road, the same as Perl once did.) There are some interesting proposals for make replacements written in Python: http://software-carpentry.codesourcery.com/sc_build Neil From db3l at fitlinxx.com Wed May 24 16:29:47 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 May 2000 16:29:47 -0400 Subject: Python equivalent to Perl's warn/confess/die References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> <Pine.WNT.4.21.0005240907250.269-100000@nt_alester> Message-ID: <uya4z8zes.fsf@ctwd0143.fitlinxx.com> Andy Lester <andy at petdance.com> writes: > I looked in the Perl/Python phrasebook and didn't see anything that > discusses an easy way to write warnings to the screen. > > For instance, in Perl if I wanted to write something to stderr to show > where in my process I am, I'd say: > > warn "$n records read"; > > Now, I know I can say > > sys.stderr.write( '%s records read' % n ) > > But is there a module somewhere that encapsulates that so I don't > explicitly send it to stderr? I'm curious - It's my understanding that by definition, 'warn' in Perl sends its output to stderr, so in reality in both cases you are explicitly sending the data to stderr, regardless of the command you've typed. If you're saying that you don't like writing 'sys.stderr.write' instead of 'warn', then how about just doing 'warn=sys.stderr.write' in your script and then go ahead and use 'warn'? :-) Perhaps you could clarify just what you are trying to "encapsulate" in this case? -- -- 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 psl at mitre.org Fri May 12 14:12:09 2000 From: psl at mitre.org (Peter Leveille) Date: Fri, 12 May 2000 14:12:09 -0400 Subject: canvas in Pmw References: <391B0669.578876FF@mitre.org> <8ff31l$ojh$1@nnrp1.deja.com> <391B1DE5.84F1A934@mitre.org> <391B1FB1.19A3482B@mitre.org> <391B35E3.B56416B4@home.com> Message-ID: <391C4979.320D589E@mitre.org> Thanks. That did it. I should have realized that was the problem, but sometimes the answer is just to obvious to grasp :) Thanks for you time, Pete John Grayson wrote: > > Mike, > > Bingo! > > The offending line is: > > img = PhotoImage(file='amap.gif') > > This is a common error, and is because img is local to the createoutput > method. When you return from the method, img goes out of scope and is > garbage collected -- hence the blank image. > > Simple (at least for the single instance) solution: > > self.img = PhotoImage(file='amap.gif') > map.create_image(200,200, image = self.img, anchor = CENTER) > > In case you are not aware, it is NOT necessary to make map an attribute > of the instance: Tkinter keeps an internal reference which ensures that > it does not get garbage collected. > > If this solves the problem, please post the answer back to > comp.lang.python. > This is a fairly common problem, but it never hurts to repeat the > answer. > > Cheers! > > John > > Mike Wingfield wrote: > > > > Woops, sorry. That last email included some newly introduced errors :( > > > > Mike Wingfield wrote: > > > > > > Well my code is pretty large. Here is a code fragment that isn't > > > working: > > > > > > from Tkinter import * > > > import ODBC.Windows > > > import Pmw > > > import string > > > root = Tk() > > > Pmw.initialise() > > > > > > class CPGUI(Frame): > > > "This is the main Conflict Probe GUI class" > > > def __init__(self, parent=None): > > > Frame.__init__(self) > > > self.option_add('*Font', 'Verdana 8 bold') > > > self.pack(expand=YES, fill=BOTH) > > > self.master.title('CPGUI') > > > self.master.iconname('CPGUI') > > > . > > > . > > > . > > > . > > > probepackrefresh = Button(pbuttonbox, text="Refresh", font =('Verdana > > > bold', 7), command=self.refreshprobepacklist) > > > probepackrefresh.pack(side=LEFT, pady = 0) > > > . > > > . > > > . > > > . > > > def createoutput(self): > > > "called to display reported conflicts from conflict table" > > > map = ScrolledCanvas(root, width = 600, height = 400) > > > img = PhotoImage(file='amap.gif') > > > map.create_image(200,200, image = img, anchor = CENTER) > > > map.pack(expand=YES, fill=BOTH) > > > map.resizescrollregion() > > > . > > > . > > > . > > > CPGUI().mainloop() > > > > > > This gives me the following error: > > > > > > Traceback (innermost last): > > > File "CPGUI.py", line 325, in ? > > > CPGUI().mainloop() > > > File "CPGUI.py", line 70, in __init__ > > > probepackrefresh = Button(pbuttonbox, text="Refresh", font > > > =('Verdana bold', 7), command = self.refreshprobepacklist) > > > File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1123, in > > > __init__ > > > Widget.__init(self, master, 'button', cnf, kw) > > > File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1078, in > > > __init__ > > > BaseWidget._setup(self, master, cnf) > > > File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1058, in > > > _setup > > > self.tk = master.tk > > > AttributeError: tk > > > > > > John Grayson wrote: > > > > > > > > In article <391B0669.578876FF at mitre.org>, > > > > Mike Wingfield <psl at mitre.org> wrote: > > > > > > > > > > I am trying to write an image to a canvas in an application using Pmw. > > > > > When I do this I get the following error message: > > > > > > > > > > Traceback (innermost last): > > > > > File "OutWin.py", line 24, in ? > > > > > map.create_image(200,200, image=img, anchor = CENTER) > > > > > File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1223, in > > > > > _create_image > > > > > return self.create('image', args, kw) > > > > > File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1216, in > > > > > _create > > > > > (self.w, 'create', itemType) > > > > > TclError: image "8827440" doesn't exist > > > > > > > > > > If I remove Pmw parts of the code it seems to work ok. What do I need > > > > > to do to get the canvas to run within a Frame in an application using > > > > > Pmw? > > > > > > > > > > > > > To get a good response from this group you really need to provide > > > > at least a fragment of your code -- otherwise you'll tend to get > > > > responses such as: > > > > > > > > "Yep, it doesn't work -- that's an error message" :( > > > > > > > > This fragment works: > > > > > > > > import Pmw > > > > root = Tk() > > > > Pmw.initialise() > > > > > > > > sc = Pmw.ScrolledCanvas(root, borderframe=1, labelpos=N, > > > > label_text='ScrolledCanvas', usehullsize=1, > > > > hull_width=400, hull_height=300) > > > > img = PhotoImage(file='img52.gif') > > > > sc.create_image(145,280, image=img, anchor=CENTER) > > > > sc.pack() > > > > sc.resizescrollregion() > > > > > > > > root.mainloop() > > > > > > > > Sent via Deja.com http://www.deja.com/ > > > > Before you buy. From wware at world.std.com Sun May 7 22:29:30 2000 From: wware at world.std.com (Will Ware) Date: Mon, 8 May 2000 02:29:30 GMT Subject: Tricks to do "enums"? References: <391618DF.19F55C6C@san.rr.com> Message-ID: <Fu7yx6.8u3@world.std.com> Courageous (jkraska1 at san.rr.com) wrote: > VAL1=0 > VAL2=1 > VAL3=3 Try this: (VAL1, VAL2, VAL3) = range(3) The only part you need to update is, if you add VAL4, you need to change "range(3)" to "range(4)". But here's a C enum thing that I don't know how to do in Python. enum { first_guy, /* probably will be assigned to zero */ second_guy, /* probably will be assigned to one */ third_guy_special_value = 314159, fourth_guy /* probably will be assigned to 314160 */ }; /* in any event, uniqueness is guaranteed for all values */ I suppose you could do something like this: (VAL1, VAL2, VAL3, VAL4) = range(4) VAL3 = 314159 but there's no longer a guarantee of uniqueness, which is usually the point of an enum. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From gmunsey at adobe.com Thu May 18 20:57:05 2000 From: gmunsey at adobe.com (Grant Munsey) Date: Thu, 18 May 2000 17:57:05 -0700 Subject: Using Python on Win2000Server under IIS5 question References: <SjSU4.898$_s2.405216@news.pacbell.net> <037c01bfc0d1$a3613d60$858647c1@DEVELOPMENT> Message-ID: <kj0V4.977$_s2.443434@news.pacbell.net> The crash happens with the following script: ----- cut ----- import sys print "Content-Type: text/plain\n" print "Hello World" sys.exit(0) ----- cut ----- I later found out that when I tried a larger, more complicated script ... things started working! Since I am now cooking along there is no need for anyone to waste time on this unless they are curious. From junkster at rochester.rr.com Tue May 30 13:21:04 2000 From: junkster at rochester.rr.com (junkster at rochester.rr.com) Date: Tue, 30 May 2000 17:21:04 GMT Subject: mxCGI Needed...Can't Find anywhere... Message-ID: <8h0t9c$ien$1@nnrp1.deja.com> Folks, Can anyone point me in the right direction? I'm trying to find a copy of MxCGI, to be placed on a Win NT (NT 4), Web server, along with MxDateTime & MxODBC..... But all the links that I can find (i.e. The Vaults of Parans.) are being returned as invalid..... I know Starship went down, but does anyone know of a backup server that might contain recent versions of the said modules? - Benjamin junkster at rochester.rr.com Sent via Deja.com http://www.deja.com/ Before you buy. From pj at sgi.com Tue May 9 12:52:12 2000 From: pj at sgi.com (Paul Jackson) Date: 9 May 2000 16:52:12 GMT Subject: Python on 64 bit/IA-64 ... References: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> Message-ID: <8f9fns$93dvq$1@fido.engr.sgi.com> Slightly off topic, and likely some folks on this thread are already quite aware of this, but Python is the Scripting Interpreter of choice for the Extended Firmware Interface (EFI), which is the BIOS+pre-boot environment Intel and friends are developing for IA-32 and IA-64 (to replace roughly the classic BIOS plus minimal DOS boot for basic system admin seen on old PC's). See further: http://developer.intel.com/technology/efi/toolkit_overview.htm http://www.theregister.co.uk/990908-000004.html -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From btang at pacific.jpl.nasa.gov Mon May 22 19:32:10 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Mon, 22 May 2000 16:32:10 -0700 Subject: vim.py References: <39242983.4D5B5246@pacific.jpl.nasa.gov> Message-ID: <3929C37A.B3738287@pacific.jpl.nasa.gov> Thanks for all the help. I was looking for the python module file vim.py. But later I found out that the file vim.py does not exist and it is not needed. When in vim, typing ":py import vim" just works. Now I have another question. When I got a compiled vim, and I typed ":syntax on", I got this message: ---------------------------- Can't open file /igd/a4/software/vim/share/vim/syntax/syntax.vim ---------------------------- My computer does not have a directory /igd, so obviously it is from the computer where vim was compiled. How do I change the directory where vim looks for syntax files? Benyang Tang wrote: > > Where is vim.py (for programming the python interface in vim)? > > I looked at vim.org and could not find it. > > Thanks. From aahz at netcom.com Fri May 5 10:36:32 2000 From: aahz at netcom.com (Aahz Maruch) Date: 5 May 2000 14:36:32 GMT Subject: Copyright and License References: <000601bfb662$d0d47ce0$d02d153f@tim> <3912AF33.FFB5E949@colconsulting.com> <wJyQ4.11928$v85.78892@news-server.bigpond.net.au> <CcAQ4.12009$v85.79543@news-server.bigpond.net.au> Message-ID: <8eum9g$oc4$1@slb2.atl.mindspring.net> In article <CcAQ4.12009$v85.79543 at news-server.bigpond.net.au>, Mark Hammond <mhammond at skippinet.com.au> wrote: > >[And a question I dont want to raise - what really does this "copyright" >mean, in the open source world? It appears we are saying "we assert >copyright, but never intend actually enforcing it". The words of the >tim-bot still echo (paraphrased) - "if possible, put it in the public >domain" :-) As I said, I dont want to raise it :-] The primary purpose is to prevent someone else from asserting copyright. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "It's not because my mind is made up that I don't want you to confuse me with any more facts. It's because my mind isn't made up. I already have more facts than I can cope with. So SHUT UP, do you hear me? SHUT UP!" _The Shockwave Rider_, 1975 From jima at aspectdv.com Tue May 30 15:00:13 2000 From: jima at aspectdv.com (Jim Althoff) Date: Tue, 30 May 2000 12:00:13 -0700 Subject: optional parens in top-level class declaration Message-ID: <4.3.1.2.20000530115116.03c7e320@mail.aspectdv.com> (Apologies if this topic has been covered before.) Has there been any consideration given to allowing empty parens in a top-level class declaration? e.g., class Foo(): pass as an alternative to class Foo: pass Although it is not a big deal, I think it would be somewhat more convenient when testing out a new class and changing your mind about the superclass structure to be able to add or delete from within the parens without having to go to the extra step of adding and removing the parens themselves when including or eliminating superclasses. And it would be more consistent with function defs which include the empty parens when zero args are specified. I realize this would need to be optional for compatibility reasons. Would this introduce any parsing problems? Any other potential disdavantages? Jim From reza at psych.utoronto.ca Sun May 28 02:40:52 2000 From: reza at psych.utoronto.ca (Reza Habib) Date: Sun, 28 May 2000 02:40:52 -0400 Subject: debugging Message-ID: <ba3Y4.5208$SY5.23052@newscontent-01.sprint.ca> Hello. I'm new to python and am having some trouble debugging my program. I'm running python 1.52 under windows nt 4 sp6. I use the python command line shell to import my script file, the pdb file, and then start the debugger: pdb.run('myfile.test()'). This starts the debugger, however, the list command only prints EOF. Also, I can't set breakpoints by giving line numbers (since it doesn't look like the file was loaded). However, if I use the next command, it will correctly step through my code. Is there something I need to do to get the list command to work so that I know where in the code I'm debugging and also to get break points to work. Thanks in advance. Reza From smalleys at gte.net Fri May 5 22:50:00 2000 From: smalleys at gte.net (sue) Date: Sat, 06 May 2000 02:50:00 GMT Subject: embedding pythonwin into mfc app References: <391027DC.3DF3E534@gmx.net> <Cp8Q4.10667$v85.70131@news-server.bigpond.net.au> Message-ID: <39138875.944C0FEB@gte.net> How do you turn off SWIG pointers? Sue. From hanwen at dokkum.cs.uu.nl Thu May 25 07:13:49 2000 From: hanwen at dokkum.cs.uu.nl (Han-Wen Nienhuys) Date: 25 May 2000 13:13:49 +0200 Subject: Makefiles [offtopic] References: <oqwvkkp5q6.fsf@titan.progiciels-bpi.ca> <392C76CF.27A5D18B@san.rr.com> <oqln0zz8vd.fsf@titan.progiciels-bpi.ca> <392C8D1D.C5DEB536@san.rr.com> Message-ID: <8gj1td$tci$1@dokkum.cs.uu.nl> sorry, couldn't resist this. In article <392C8D1D.C5DEB536 at san.rr.com>, Courageous <jkraska1 at san.rr.com> wrote: >SRC := $(shell echo *.C) that would be SRC:=$(wildcard *.C) # more efficient >While I seldom toot my own horn about anything, managing very large >source (multiple platform, multiple language, multiple configuration) >is something I'm very, very good at, so I hope you appreciate it when >I say that GNUmake is one of the very best build tools I've ever found >for anything like this. I'll go along with you in saying that GNU make is the best implementation of make available, but that does not mean it is the best tool ever for managing builds. I work on a project totaling 2200 lines of Makefiles, and it's hard to fix bugs in without creating new errors. -- Han-Wen Nienhuys, hanwen at cs.uu.nl ** GNU LilyPond - The Music Typesetter http://www.cs.uu.nl/people/hanwen/lilypond/index.html From pinard at iro.umontreal.ca Wed May 17 15:23:47 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 May 2000 15:23:47 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: "Tim Peters"'s message of "Wed, 17 May 2000 02:03:06 -0400" References: <000501bfbfc5$939bff80$b52d153f@tim> Message-ID: <oq66sdx9oc.fsf@titan.progiciels-bpi.ca> "Tim Peters" <tim_one at email.msn.com> ?crit: > > ... > > residual = 1.0 / residual > Note that this step can introduce a small error on each iteration, due > to the vagaries of floating-point arithmetic. To do this with complete > accuracy requires sticking to rational arithmetic throughout. I understand, Tim. I revised my suggested solution according to this remark, to get what follows. A bit sadly, the code gets much longer, and more intricate. I'm not fully satisfied, yet it seems to work! >>> Fraction(math.pi, tolerance=1e-5) 355:113 At least, doing this, I learned many useful things about Python. :-) def Fraction(num, den=1, tolerance=0): if type(0.) in (type(num), type(den)): num, den = num/den, 1L while long(num) != num: num, den = 2.*num, 2L*den num = long(num) elif den < 0: num = -num den = -den d = gcd(abs(num), den) value = SimplifiedFraction(num/d, den/d) if tolerance > 0: value = ContinuedFraction(value, tolerance).simplify() return value class SimplifiedFraction: triples = 0 # set to 1 for a:b:c printing def __init__(self, num, den): self.num = num self.den = den def __repr__(self): num = self.num den = self.den if den == 1: return '%.f' % num if self.triples: if num > 0 and num > den: return '%.f:%.f:%.f' % (num / den, num % den, den) if num < 0 and -num > den: return '-%.f:%.f:%.f' % (-num / den, -num % den, den) return '%.f:%.f' % (num, den) def __coerce__(self, other): if isinstance(other, SimplifiedFraction): return self, other if type(other) in (type(0), type(0L)): return self, SimplifiedFraction(other, 1) if type(other) is type(0.): return float(self), other def __int__(self): if self.num < 0: return -(-self.num / self.den) return self.num / self.den def __float__(self): return float(self.num) / float(self.den) def __neg__(self): return SimplifiedFraction(-self.num, self.den) def __pos__(self): return self def __abs__(self): return SimplifiedFraction(abs(self.num), self.den) def __cmp__(self, other): d = gcd(self.den, other.den) if d == 1: return cmp(self.num*other.den, other.num*self.den) return cmp(self.num*(other.den/d), other.num*(self.den/d)) def __add__(self, other): d1 = gcd(self.den, other.den) if d1 == 1: return SimplifiedFraction(self.num*other.den + other.num*self.den, self.den*other.den) t = self.num*(other.den/d1) + other.num*(self.den/d1) d2 = gcd(t, d1) return SimplifiedFraction(t/d2, (self.den/d1) * (other.den/d2)) def __sub__(self, other): d1 = gcd(self.den, other.den) if d1 == 1: return SimplifiedFraction(self.num*other.den - other.num*self.den, self.den*other.den) t = self.num*(other.den/d1) - other.num*(self.den/d1) d2 = gcd(t, d1) return SimplifiedFraction(t/d2, (self.den/d1) * (other.den/d2)) def __mul__(self, other): d1 = gcd(self.num, other.den) d2 = gcd(self.den, other.num) return SimplifiedFraction((self.num/d1) * (other.num/d2), (self.den/d2) * (other.den/d1)) def __div__(self, other): d1 = gcd(self.num, other.num) d2 = gcd(self.den, other.den) return SimplifiedFraction((self.num/d1) * (other.den/d2), (self.den/d2) * (other.num/d1)) def __radd__(self, other): return other.__add__(self) def __rsub__(self, other): return other.__sub__(self) def __rmul__(self, other): return other.__mul__(self) def __rdiv__(self, other): return other.__div__(self) def gcd(a, b): while b: a, b = b, a % b return a class ContinuedFraction: def __init__(self, value, tolerance): integer = int(value) residual = value - integer self.integers = [integer] while residual != 0 and abs(value - self.simplify()) > tolerance: residual = 1 / residual integer = int(residual) residual = residual - integer self.integers.insert(0, integer) def __repr__(self): import string text = map(str, self.integers) text.reverse() return string.join(text, '+1/(') + ')' * (len(self.integers) - 1) def simplify(self): num, den = 1, 0 for integer in self.integers: num, den = integer * num + den, num return SimplifiedFraction(num, den) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Mon May 8 10:12:46 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 08 May 2000 10:12:46 -0400 Subject: OT: Unicode Unification Objections In-Reply-To: "Dennis E. Hamilton"'s message of "Sat, 6 May 2000 17:02:15 -0700" References: <NDBBKEGCNONMNKGDINPFCEBFDJAA.infonuovo@email.com> Message-ID: <oqd7mxqgf5.fsf@titan.progiciels-bpi.ca> "Dennis E. Hamilton" <infonuovo at email.com> writes: > When subject matter experts from important language and cultural groups > suggest that a unification in Unicode is objectionable, I think one > should listen more carefully, even if it involves something that is hard > to make sense of from within *our* cultural and language illusion. This should be especially true for the Unicode consortium itself. Many of us know that Unicode favours decomposed forms, but as a way to get Unicode accepted by nations, Unicode provided pre-combined characters to those. Unicode would have plainly failed if it did not offer the richer nations at least the capability of a fixed number of bits for any character. But yet, there is a never-ending regret within Unicode designers to return to combining, and consider that pre-combined is a kind of error or ugliness. Not long ago, Unicode and W3C got together to decide that pre-combined characters that did not make it in time for Unicode 3.0 were to be left in decomposed form on the Web _forever_. The arguments given were "Web stability", using as an example the ease of comparisons while searching. This looks extremely shocking to me. Richer or more technically advanced nations were served first by Unicode, and most of the African continent, to take a rather bold example, has been left aside, despite it uses hundreds of scripts. What does it mean? This is condemning in advance any script not yet integrated to suffer the complexities of combining, and so, the slow down of technical progress of those countries, which are too slow already. Try to imagine for a moment that Unicode and W3C were forcing Americans to use a variable number of UCS-2 characters for different "ASCII" characters. You will better feel how deeply it would handicap all software development. Americans would have quickly dismissed Unicode. And if it was by some magic, it was imposed to them, you'd not only get a riot, but a world war. National needs should go _ways_ before sparing bits or easing the life of browser makers. Sad to say, there is something deeply wrong with Unicode. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From cut_me_out at hotmail.com Tue May 9 09:53:13 2000 From: cut_me_out at hotmail.com (Alex) Date: 09 May 2000 09:53:13 -0400 Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <slrn8hc7lg.8p7.neelk@brick.cswv.com> <3916F04F.7647B829@zipzap.ch> <etdem7dm0fx.fsf@w20-575-109.mit.edu> <391790A2.26CB9618@home.com> <etdhfc7ap0d.fsf@w20-575-109.mit.edu> <FuAnpr.HD8@world.std.com> <391812BF.4C226C55@home.com> Message-ID: <etdem7bakza.fsf@w20-575-109.mit.edu> > Not quite. Part of the test is figuring out how to call the Rbbx() > function. Hmm, seems like it should be /rgt { _rbar exch get } bind def /p4 { 4 { pop } repeat } bind def /ism { { rgt } forall arcto p4 } bind def /stuff { _rbar exch 3 -1 roll put } bind def /Rbbx { gsave [ 6 1 roll ] /_rbar exch def 3 rgt 1 rgt add 1 stuff 2 rgt 0 rgt add 0 stuff 2 rgt 3 rgt 4 rgt add newpath M [ [ 2 1 0 1 4 ] [ 0 1 0 3 4 ] [ 0 3 2 3 4 ] [ 2 3 2 1 4 ] ] { ism } forall gsave Sg fill grestore Sg S stroke grestore } bind def Rbbx showpage ...but that is giving me this error: Error: /rangecheck in --roll-- Operand stack: --nostringval-- 6 1 Execution stack: %interp_exit () --nostringval-- --nostringval-- --nostringval-- false --nostringval-- --nostringval-- %runexec_finish --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:682/701-- --dict:0/20-- --dict:49/200-- Current allocation mode is local Current file position is 417 ...since it was a range check error, I thought maybe you could swap the 6 and the 1, but that gave the different error Error: /rangecheck in --get-- Operand stack: --nostringval-- 3 ...dumping stuff on the stack prior to the call, like 100 90 20 29 20 10 Rbbx didn't help, either, so I assume the implied "signature" of Rbbx (no arguments) is accurate. This-is-amusing'ly yrs Alex. From chafik at nevrax.com Thu May 25 04:37:08 2000 From: chafik at nevrax.com (Sameh chafik pro) Date: Thu, 25 May 2000 10:37:08 +0200 Subject: E-mail read-write function Message-ID: <8giobi$48d$1@gw.localdomain> Hello evry body, are there any standard way to read-write the e-mail with python. Thanks Sam. From sharris at nospam.primus.com Thu May 18 20:09:46 2000 From: sharris at nospam.primus.com (Steven E. Harris) Date: Fri, 19 May 2000 00:09:46 GMT Subject: C++ extension module crashes on Solaris Message-ID: <svk8grflr1.fsf@hodge.primus.com> I'm trying to write a simple Python extension module using the CXX kit. When I attempt to import my compiled module, Python dies as follows: Python 1.5.2 (#9, May 18 2000, 13:45:16) [GCC 2.95.2 19991024 (release)] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import seh_test Fatal Python error: PyThreadState_Get: no current thread Abort (core dumped) The stack trace looks like this: > gdb python core GNU gdb 4.18 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-sun-solaris2.5.1"... Core was generated by `python'. Program terminated with signal 9, Killed. Reading symbols from /usr/lib/libsocket.so.1...done. Reading symbols from /usr/lib/libnsl.so.1...done. Reading symbols from /usr/lib/libdl.so.1...done. Reading symbols from /usr/lib/libpthread.so.1...done. Reading symbols from /usr/lib/libthread.so.1...done. Reading symbols from /usr/lib/libm.so.1...done. Reading symbols from /usr/lib/libc.so.1...done. Reading symbols from /usr/lib/libintl.so.1...done. Reading symbols from /usr/lib/libmp.so.1...done. Reading symbols from /usr/lib/libw.so.1...done. Reading symbols from /users/sharris/temp/CXX-4.2/seh_test/./seh_test.so...done. #0 0xef6a2a58 in __sigprocmask () from /usr/lib/libthread.so.1 (gdb) where #0 0xef6a2a58 in __sigprocmask () from /usr/lib/libthread.so.1 #1 0xef69a6b8 in _resetsig () from /usr/lib/libthread.so.1 #2 0xef69a174 in _sigon () from /usr/lib/libthread.so.1 #3 0xef69ca50 in _thrp_kill () from /usr/lib/libthread.so.1 #4 0xef5ba6f0 in abort () from /usr/lib/libc.so.1 #5 0xeec4bb0c in Py_AtExit (func=0xeec9c198 <tinytens+21896>) at pythonrun.c:1036 I compiled Python with the '--with-thread' switch enabled on Solaris 2.5.1, hoping to pull in POSIX threading support. Does this look like a familiar problem? I couldn't find any proper answers in the archives. -- Steven E. Harris Primus Knowledge Solutions, Inc. http://www.primus.com From ullrich at math.okstate.edu Mon May 8 16:15:28 2000 From: ullrich at math.okstate.edu (ullrich at math.okstate.edu) Date: Mon, 08 May 2000 20:15:28 GMT Subject: Arg. Silly question! References: <3913BBF0.5F255D1E@san.rr.com> <8f6va5$m20$1@nnrp1.deja.com> Message-ID: <8f778g$vn5$1@nnrp1.deja.com> In article <8f6va5$m20$1 at nnrp1.deja.com>, ullrich at math.okstate.edu wrote: [...] > > Actually it looks like there may be a bit missing from > the replies so far: It's been pointed out that the only reason he said that is he's blind as a bat. Sorry. Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Wed May 10 23:50:27 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 11 May 2000 03:50:27 GMT Subject: Why should I switch to Python? References: <000401bfbaf5$877f8b60$2aa0143f@tim> Message-ID: <391A2EE0.83128776@san.rr.com> Tim Peters wrote: > > [Grant Griffin] > > Speaking of C, I find myself missing the "x=" operators, and "++". > > However, I understand and endorse the reasons Python omits them. > > While ++ makes little sense in a language with immutable numbers, += (& > friends) can make good sense. += and -= would be nice, but I don't understand what you mean by "friends" or why python might need them??? C/ From embed at geocities.com Tue May 9 12:46:38 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 9 May 2000 12:46:38 -0400 Subject: Converting a Binary References: <CC59868A0A76D311B1F50090277B321C1F3306@VRTMAIL> Message-ID: <slXR4.17758$HG1.457019@nnrp1.uunet.ca> > > struct.pack( 'i', yourinteger ) > > Enjoy, > Mike Interesting how ambiguous "convert to binary is". I assumed he meant "print an integer variable as a base-2 (binary) string representation". ;-) Warren From pinard at iro.umontreal.ca Sun May 14 10:08:10 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 14 May 2000 10:08:10 -0400 Subject: HEAP/priority queue In-Reply-To: Glyph Lefkowitz's message of "13 May 2000 19:52:42 -0500" References: <391CA714.3EB0E8B5@san.rr.com> <oqbt2ajdk2.fsf@titan.progiciels-bpi.ca> <ja7lcy9cmd.fsf@helix.twistedmatrix.com> Message-ID: <oqem75z0l1.fsf@titan.progiciels-bpi.ca> Glyph Lefkowitz <glyph at twistedmatrix.com> ?crit: > Could someone explain to a naive programmer here what the use of that > lovely structure is? I understand what is going on, just not why... Joe (Courageous) already replied in another message, but let me nevertheless add my own grain of salt. A heap is an array for which a[k] < a[2*k+1] and a[k] < a[2*k+2] for all k. This sounds like a strange invariant, but in fact, this is an efficient memory representation for a tournament. The numbers below are `k', not a[k]: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 In the tree above, each cell `k' is topping `2*k+1' and `2*k+2'. In an usual binary tournament we see in sports, each cell is the winner over the two cells it tops, and we can trace the winner down the tree to see all opponents s/he had. However, in many computer applications of such tournaments, we do not need to trace the history of a winner. To be more memory efficient, when a winner is promoted, we try to replace it by something else at a lower level, and the rule becomes that a cell and the two cells it tops contain three different items, but the top cell "wins" over the two topped cells. If this heap invariant is protected at all time, index 0 is clearly the overall winner. The simplest algorithmic way to remove it and find the "next" winner is to move some looser (let's say cell 30 in the diagram above) into the 0 position, and then percolate this new 0 down the tree, exchanging values, until the invariant is re-established. This is clearly logarithmic on the total number of items in the tree. By iterating over all items, you get an O(n ln n) sort. A nice feature of this sort is that you can efficiently insert new items while the sort is going on, provided that the inserted items are not "better" than the last 0'th element you extracted. This is especially useful in simulation contexts, where the tree holds all incoming events, and the "win" condition means the smallest scheduled time. When an event schedule other events for execution, they are scheduled into the future, so they can easily go into the heap. So, a heap is a good structure for implementing schedulers (this is what I used for my MIDI sequencer :-). Various structures for implementing schedulers have been extensively studied, and heaps are good for this, as they are reasonably speedy, the speed is almost constant, and the worst case is not much different than the average case. However, there are other representations which are more efficient overall, yet the worst cases might be terrible. Heaps are also very useful in big disk sorts. You most probably all know that a big sort implies producing "runs" (which are pre-sorted sequences, which size is usually related to the amount of CPU memory), followed by a merging passes for these runs, which merging is often very cleverly organised[1]. It is very important that the initial sort produce the longest runs possible. Tournaments are a good way to that. If, using all the memory available to hold a tournament, you replace and percolate items that happen to fit the current run, you'll produce runs which are twice the size of the memory for random input, and much better for input fuzzily ordered. Moreover, if you output the 0'th item on disk and get an input which may not fit in the current tournament (because the value "wins" over the last output value), it cannot fit in the heap, so the size of the heap decreases. The freed memory could be cleverly reused immediately for progressively building a second heap, which grows at exactly the same rate the first heap is melting. When the first heap completely vanishes, you switch heaps and start a new run. Clever and quite effective! In a word, heaps are useful memory structures to know. I use them in a few applications, and I think it is good to keep a `heap' module around. :-) -------------------- [1] The disk balancing algorithms which are current, nowadays, are more annoying than clever, and this is a consequence of the seeking capabilities of the disks. On devices which cannot seek, like big tape drives, the story was quite different, and one had to be very clever to ensure (far in advance) that each tape movement will be the most effective possible (that is, will best participate at "progressing" the merge). Some tapes were even able to read backwards, and this was also used to avoid the rewinding time. Believe me, real good tape sorts were quite spectacular to watch! From all times, sorting has always been a Great Art! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From neelk at brick.cswv.com Tue May 2 22:50:29 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 3 May 2000 02:50:29 GMT Subject: Backward chaining for __init__? References: <390F8C7E.9986DAE0@san.rr.com> Message-ID: <slrn8gv722.5kv.neelk@brick.cswv.com> Courageous <jkraska1 at san.rr.com> wrote: > > I recently wrote a test program with a Parent class and a Derived > class, each one implementing __init__. To my surprise and chagrine, > only the Child's __init__ method was called. Worse, I can't figure > out a way to call the method (or methods, in the case of multiple > inheritance) in the Parent. > > How does one go about implementing backward chaining for > constructor's in Python? Like so: class Foo: def __init__(self): self.a = "every man is evil, yes, every man's a liar" class Bar(Foo): def __init__(self): Foo.__init__(self) self.b = "and unashamed with a wicked tongue" class Baz(Bar): def __init__(self): Bar.__init__(self) self.c = "he sings in the black soul choir" Which produces: >>> q = Baz() >>> q.a "every man is evil, yes, every man's a liar" >>> q.b 'and unashamed with a wicked tongue' >>> q.c 'he sings in the black soul choir' Admittedly, this is kind of a let-down if you're used to Common Lisp's baroquely overengineered method modifers :), but it works. Neel From jkraska1 at san.rr.com Thu May 25 10:26:13 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 14:26:13 GMT Subject: Python performance notes... References: <392A2ED5.6A35B754@san.rr.com> <8gjcc1$nam$1@nntp9.atl.mindspring.net> Message-ID: <392D38AC.D61CCEB3@san.rr.com> > >I did a simple for loop and tested it, trying a variety of length > >loops. It took a bit of time to get this right, as for smaller > >loops, the test was biased by the relative high cost of function > >invocation. When it settled out, a for-loop in python is about 100 > >times slower in python than the equivalent in ANSI C. Irrespective of > >function invocation overhead, the decision to go native pays off almost > >immediately, with time differences in python versus native code being > >noticeable with as low as 100,000 simple iterations. > > So? What's your point? My point was that it was likely that the very worse case in python is 100 times slower than C. That's important information to some folks, giving them a bit of a metric to compare against other environments. [snip follow-on rant where you attempt to preach to the choir]. I'll be running a more extensive test involving a native versus non native heap sort in a week or two. C/ From pinard at iro.umontreal.ca Sun May 28 23:03:35 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 28 May 2000 23:03:35 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: "Fredrik Lundh"'s message of "Sat, 27 May 2000 08:35:33 GMT" References: <CC59868A0A76D311B1F50090277B321C1F3348@VRTMAIL> <8g7t5c$1i7i$1@thoth.cts.com> <slrn8ikrtj.48f.bwinton@tor.dhs.org> <rKHwzJA12oK5EwJ6@jessikat.demon.co.uk> <m2aehehfcg.fsf@netmeg.net> <oqem6qsmws.fsf@titan.progiciels-bpi.ca> <pNLX4.9677$Za1.151711@newsc.telia.net> Message-ID: <oqhfbi9hx4.fsf@titan.progiciels-bpi.ca> "Fredrik Lundh" <effbot at telia.com> ?crit: > Fran?ois Pinard wrote: > > I like Python, but I begin to resent Guido, who did this to us. > thanks for reminding us that comp.lang.python is still a part > of usenet. I do not decipher the above sentence, but it might use language subtleties that call too deep for my little knowledge of English. Sorry. The fact is that I do not remember having made any reference to Usenet, and I do not know exactly why you are thanking me. In any case, you are always welcome. Keep happy! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jae at ilk.de Sun May 28 11:24:44 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Sun, 28 May 2000 17:24:44 +0200 Subject: String.join revisited (URGENT for 1.6) Message-ID: <28052000.5@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Okay, so I was using the sort method on a list of integers. And I wondered how the *list* knows how to sort both a list of integers and a list of strings. The answer (okay we all know that): it doesn't. It just call cmp for two elements, and voila... *they* know how to compare themselves to each other. So what's this got to do with string.join (or "string".join)? Simple: many folks have said in the past days/weeks (since this "string".join(list) came up) that they'd be a lot more comfortable with s.th. like [list].join(separator) But others have contested this saying it would put string knowledge into lists (or rather sequences... which do not exactly exist[1]) Well, if we'd give strings a "join" method that looked like "some string".join("another string", "separator") then [some list].join would simple invoke that (reduce(__join__, [some list])). And throw an exception if the items in the list don't know how to join themselves join. Bye, J PS: I fully expect for this to be too late to be changed in 1.6... I can still hope, though. Either it happens now, or not at all... or we need another name like "append" ;-) PPS: Sorry, no patch, and it's probably slower than the current ugly "string".join. But I rather choose a usable, `nice' design over speed any time. And the speed can be improved if ".join" could take a list of items as first argument (like "string".join(["list", "of", "strings"], "sep")). Yes, that's almost the same as the current string.join() ;-) [1] I hope the (eventual, hopefully) merging of types and classes will remedy this. Lists and tuples and strings have to be subclasses of a sequence class (we can learn something from the Common Lisp hierarchy I think). Oh, and that merge would also make UserList/Dict/String obsolete, yay! - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard SPACE: Above And Beyond (http://www.planetx.com/space:aab) Codito, ergo sum - I code, therefore I am -- Raster -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjkxOjoACgkQN0B+CS56qs3HeQCgjjEJF/7EHY41FdEv9ENoPw0e 3vcAnil3uOGlNYcKP2jRO/z3Lnz3AWjD =OdFE -----END PGP SIGNATURE----- From tseaver at starbase.neosoft.com Sat May 20 15:07:12 2000 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 20 May 2000 14:07:12 -0500 Subject: Python3k extended grammar References: <Pine.GSO.4.10.10005201852090.5989-100000@sundial> Message-ID: <80A6D337FA733A29.BD7F6A8386E766F1.08FA556A433781A2@lp.airnews.net> In article <Pine.GSO.4.10.10005201852090.5989-100000 at sundial>, Moshe Zadka <moshez at math.huji.ac.il> wrote: >On Sat, 20 May 2000, Thomas Malik wrote: > >> 1. case insensitivity sounds like complete nonsense to me. Who needs it, >> actually ? > >The "E" in CP4E, according to quite a few usability studies. *Sigh* Citations please, for anything other than Randy Pausch's roadshow. His "workaround" for Alice is actually the Right Thing (TM): address the issue in tools designed for novices, rather than deforming the language. >> 2. promoting integer divisions to float sounds quite stupid to me: >> (x/y) * y + x % y == x should always hold true in any sane language > >Ummmm.... > >1/2 == 0 > >Seems sane to you? Where were you when they taught about fractions in math >class? The only thing which looks sane to me is 1/2 is 1/2. And 1/3. And >367/573. This change will break *huge* volumes of code, in the name of the "E" in CP4E. Again, it seems primarily motivated by the Alice project's creator, and would be better addressed in tools than the language. After all, elementary maths *don't* teach that "1/3" is 0.33333333 (or whatever 754 gives as the roundoff) -- floating point representations of rational numbers are subject to as many (or more!) gotchas as integer math, which is at least comprehensible to anybody who knows the terms "quotient" and "remainder"). Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at digicool.com http://www.zope.org Digital Creations From petersc at stud.ntnu.no Fri May 26 17:52:10 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 26 May 2000 23:52:10 +0200 Subject: p2c References: <392EDF1E.55BAFD47@softhome.net> Message-ID: <392EF20A.7F72B9E2@stud.ntnu.no> etoffi wrote: > > i heard somebody mention p2c. python to c? pascal to c? peas turnips and > carrots? python 2 c, have a look at: http://lima.mudlib.org/~rassilon/p2c/ polar-nightly-greetings-ly y'rs Peter P.S.: A search at python.org would have enlighted you immediately ... -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From effbot at telia.com Sat May 13 04:33:52 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 13 May 2000 08:33:52 GMT Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com> Message-ID: <Qr8T4.3978$wYl.205730816@newsb.telia.net> "Courageous" <jkraska1 at san.rr.com> wrote: > Okay, I downloaded the python source, as I had to know how > lists were implemented in python. http://www.python.org/doc/FAQ.html#6.16 > Am I the only person who cares about O(1) versus 0(n)? probably not -- the implementors obviously thought that constant *access* time was more important. and having a simple implementation doesn't hurt, of course. > I don't get it. The code for python lists is, as plain as > the nose on the end of my face, a resizeable vector > implementation. Which is all well and good, but where > are the linked lists for those of us who want insert, > delete, and append to be O(1)? here's one: http://starship.python.net/crew/lemburg/mxStack.html there are probably others out there. check the vaults: http://www.vex.net/parnassus/apyllo.py </F> From DOUGS at oceanic.com Wed May 3 18:07:30 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 3 May 2000 12:07:30 -1000 Subject: How to get terminal width? Message-ID: <8457258D741DD411BD3D0050DA62365907A13F@huina.oceanic.com> Please don't patronize me. I personalized the statement I made. Many people are in situations where they have control over the universe of systems that will run the software they develop. Others who don't should be well aware of that fact. I noted that Solaris was excluded and suggested another alternative which was after all the point of my post. I haven't tested it but suspect that Donn Caves posted solution was more generally applicable. My only point was to correct his statement that "... you don't get it (COLUMNS) on contemporary Berkeley or Linux platforms." > -----Original Message----- > From: Justin Sheehy [mailto:dworkin at ccs.neu.edu] > Sent: Wednesday, May 03, 2000 11:38 AM > To: python-list at python.org > Subject: Re: How to get terminal width? > > > Doug Stanfield <DOUGS at oceanic.com> writes: > > > COLUMNS is there on my just installed Mandrake 7, a new > Storm install, a Red > > Hat 5.2, 6.1, and a Mandrake 6.x. In my world thats almost > universal > > In a world that contains other operating systems than Linux, or even > other distributions than the redhat-derived ones, that is a very long > way from universal. > > "It runs on my Linux box" doesn't say a thing about portability. > > Too many people seem to not realize this. > > -Justin > > > > -- > http://www.python.org/mailman/listinfo/python-list > From DOUGS at oceanic.com Fri May 19 16:44:54 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Fri, 19 May 2000 10:44:54 -1000 Subject: Newbie: opening files. Message-ID: <8457258D741DD411BD3D0050DA62365907A194@huina.oceanic.com> [First Bart Holthuijsen wrote:] > > > from sys import * > > from os import * [Then Moshe Zadka replied:] > ^^^^ > Here's the culprit. The "os" module defines an "open" function. Don't > import "*". Ever. Unless you are at an interactive prompt, still the best way to explore module capabilities. Can that be enforced somehow by the interpreter?: [dougs at lawehana dougs]$ python Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from os import * >>> dir() ['F_OK', 'O_APPEND', 'O_CREAT', 'O_EXCL', 'O_NDELAY', 'O_NOCTTY', 'O_NONBLOCK', 'O_RDONLY', 'O_RDWR', 'O_SYNC', 'O_TRUNC', 'O_WRONLY', 'R_OK', 'UserDict', 'WEXI TSTATUS', 'WIFEXITED', 'WIFSIGNALED', 'WIFSTOPPED', 'WNOHANG', 'WSTOPSIG', 'WTER MSIG', 'W_OK', 'X_OK', '__builtins__', '__doc__', '__name__', 'access', 'altsep' , 'chdir', 'chmod', 'chown', 'close', 'curdir', 'defpath', 'dup', 'dup2', 'envir on', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve', 'execvp ', 'execvpe', 'fdatasync', 'fdopen', 'fork', 'fstat', 'fsync', 'ftruncate', 'get cwd', 'getegid', 'geteuid', 'getgid', 'getpgrp', 'getpid', 'getppid', 'getuid', 'kill', 'linesep', 'link', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir', 'mk fifo', 'name', 'nice', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen', 'pu tenv', 'read', 'readlink', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'sep', 'setgid', 'setpgid', 'setpgrp', 'setsid', 'setuid', 'stat', 'strerror', 'symlink', 'sys', 'system', 'tcgetpgrp', 'tcsetpgrp', 'times', 'ttyname', 'umask ', 'uname', 'unlink', 'utime', 'wait', 'waitpid', 'write'] >>> -Doug- From chris.lada at westgroup.com Fri May 12 08:48:13 2000 From: chris.lada at westgroup.com (Chris Lada) Date: Fri, 12 May 2000 08:48:13 -0400 Subject: python book recommendations? References: <8fgsqq$kuo@news.or.intel.com> Message-ID: <391bfcd0@wwwproxy3.westgroup.com> My pick would be "Quick Python" by Harms, and McDonald. Chris Firehawk343 wrote in message <8fgsqq$kuo at news.or.intel.com>... >I'm new to Pyhton and would appreciate advice on what book(s) will help me >ramp up the fastest. Maybe O'Rielly or "Programming with Python" by Tim >Altom? > >thanks > > From rturpin at my-deja.com Sun May 14 12:32:29 2000 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Sun, 14 May 2000 16:32:29 GMT Subject: The REALLY bad thing about Python lists .. References: <391D070C.304889D1@san.rr.com> <391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> Message-ID: <8fmket$n29$1@nnrp1.deja.com> I think it is fine that resizable vectors are the default array implementation. We can just keep in mind that indexing is fast, growing or shrinking from the ends is fast, but changing the size in the middle is slow. Wait! Did I say "growing and shrinking from the ends is fast"?? Alas, that is wrong. Prepending is the most expensive insert of all! The only insert/delete operations that are fast are those that change the LAST element. And why should this be? It isn't hard to write resizable vector code that is fast at both ends. There are lots of times when you want to manipulate a list from both ends. And Python syntax makes it easy: l[:0] = m # Prepend list m to l Double-your-pleasure'ly yrs, Russell Sent via Deja.com http://www.deja.com/ Before you buy. From tismer at tismer.com Sun May 28 11:08:50 2000 From: tismer at tismer.com (Christian Tismer) Date: Sun, 28 May 2000 17:08:50 +0200 Subject: Python vs. Ruby: threads - advice appreciated References: <393121B7.6A922591@smets.com> Message-ID: <39313682.219AFAF7@tismer.com> Jean-Paul Smets wrote: > > Hi, > > I am currently comparing Python and Ruby for a personal project which requires > many many threads. > > I came across the "philosophers" example in Ruby and was surprised by its > compacity (see below). > I am wondering if it would be easy to write such an example in Python with as > few lines of code ? > > Also, I tried to push Ruby to its limits (N=10000) and everything went OK (50 Mo > RAM was occupied though but this is only 5Ko per thread which I find quite > good). I wonder if it is possible to go that far with Python, either with native > threads or with microthreads in stackless Python ? Microthreads in Stackless Python take around 400 byte each, if every thread is just one frame deep (i.e. not executing function calls). If you assume every thread being one or two func calls deeper, let's take an average of 1000 bytes for this, which makes for 10 MB for your example. And sure, it is possible. I've been much farther already in my tests. > Finaly, I found that Ruby has a very nice and completely transparent interface > to Python libraries and extensions. So, I am wondering now what would be the > inconvenience for me of switching to Ruby for my project. > > Any advice will be deeply appreciated. Ruby instead of Python is at least a matter of taste, and I will continue with Python. ciao - chris -- Christian Tismer :^) <mailto:tismer at appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From mal at lemburg.com Fri May 19 17:35:15 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 19 May 2000 23:35:15 +0200 Subject: mxODBC and delete References: <3920530E.79AACCDC@mitre.org> Message-ID: <3925B393.1C7E4412@lemburg.com> Peter Leveille wrote: > > I have been using the mxODBC package for access to a database. This has > been working great, until a recent problem that I have had. When I try > running the following code, python just freezes up. Does anyone know > what I am doing wrong, or if there is another way to do it? > > >>> import ODBC.Windows > >>> db = ODBC.Windows.Connect('????????','???','??????') > >>> c = db.cursor() > >>> c.execute('DELETE FROM ???????') The code looks perfectly ok. Could be that the database table you want to delete is locked or that you don't have delete permission. What kind of database backend are you using ? -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From rumjuggler at cryptarchy.org Sat May 20 14:14:11 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 20 May 2000 18:14:11 GMT Subject: Python3k extended grammar References: <8g6bae$977$16$1@news.t-online.com> <Pine.GSO.4.10.10005201852090.5989-100000@sundial> Message-ID: <kpldissi5t03j13pretbccbocfmm1hl197@4ax.com> On Sat, 20 May 2000 18:55:19 +0300 (IDT), Moshe Zadka <moshez at math.huji.ac.il> wrote: >> 2. promoting integer divisions to float sounds quite stupid to me: >> (x/y) * y + x % y == x should always hold true in any sane language > >Ummmm.... > >1/2 == 0 > >Seems sane to you? Yes. If I want .5, I'll write 1/2.0 From tim_one at email.msn.com Thu May 11 22:58:39 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 11 May 2000 22:58:39 -0400 Subject: Seeds In-Reply-To: <391AAD27.FA2676A6@home.com> Message-ID: <000101bfbbbd$f98f62c0$9ca2143f@tim> [Ivan Van Laningham] > What's the best way to obtain seeds for random number generators? 1. Spend an hour (probably less, if you're younger) at a porn site. 2. For one random bit, provoke Fredrik on c.l.py. Note whether he laughs or snips back. 3. Avail yourself of one of the web's growing number of "truly random" bit servers. For example, here's one that serves up random bits based on atmospheric noise: http://www.random.org/nform.html 4. Bet on whether "real GC" makes it into 1.6. randomness-in-the-service-of-determinism-is-no-vice-ly y'rs - tim From sbrunning at trisystems.co.uk Fri May 26 04:08:59 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 26 May 2000 09:08:59 +0100 Subject: [PATCH] A compromise on case - another suggestion References: <B3zW4.23$F22.9469@typhoon1.ba-dsg.net> Message-ID: <34575A892FF6D1118F5800600846864D35F585@intrepid> Nick Mathewson wrote in message ... >"Everybody's always talking about the weather, but nobody seems to do > anything about it." Speaking as a newcomer to Python myself, case sensitivity *is* causing me a few problems - I'm from a case insensitive language background, and 'node' looks just like 'Node' to me unless I'm *really* concentrating. If I use both in a module (and I have!), then it's because I've fouled up. Having said that, I can appreciate that there are reasons why the language *should* remain case sensitive. Putting the first character in upper case for classes and lower for everything else makes sense. Someone posted saying that mathematicians find case sensitivity *very* intuitive. But by far the most compelling argument as far as I'm concerned is that we shouldn't break existing code. What would sort out this problem for me would be if I were *warned* about case-clash. What I need is some kind of plug in for IDLE, which checks for identifiers differing only by case when I save, and warns me if any are found, (giving a list of offenders, of course.) I envision this being enabled by default, to help newbies like myself. Expert users should be able to disable the check via a command line option if they wish. I have had a look into the extend stuff, but I'm not sure how to do this. (As I said, I'm a newbie.) Any hints? BTW, a case check would seem to complement Nick's suggestion, rather than replace it. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From francis at robinton.demon.co.uk Thu May 11 11:16:57 2000 From: francis at robinton.demon.co.uk (Francis Glassborow) Date: Thu, 11 May 2000 16:16:57 +0100 Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> <slrn8hhoal.5kj.adsharma@c62443-a.frmt1.sfba.home.com> <8feepm$csg$3@newsserver.rrzn.uni-hannover.de> Message-ID: <6PNrfgBp7sG5EwLW@robinton.demon.co.uk> In article <8feepm$csg$3 at newsserver.rrzn.uni-hannover.de>, Bernhard Reiter <breiter at usf.Uni-Osnabrueck.DE> writes >I justed wanted to explain why the GPL is so popular. And what the >differences to other licenses are. However, note that there is nothing that prevents the copyright holders from negotiating a commercial licence as well (though that is more complicated where the commercial organisation wants to use heavily derived code with many contributors. Now perhaps we should be negotiating with industry to release all their patents in exchange for a release to use GPL software ;-) Francis Glassborow Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation From effbot at telia.com Sat May 13 11:06:54 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 13 May 2000 15:06:54 GMT Subject: LINKED LISTS? References: <391D070C.304889D1@san.rr.com><391d592e$0$13925@wodc7nh6.news.uu.net> <7yFPLJA9pWH5EwgD@jessikat.demon.co.uk> Message-ID: <iceT4.7144$Za1.111664@newsc.telia.net> Robin Becker <robin at jessikat.demon.co.uk> wrote: > which is clearly not O(1); arguing that making accesses O(1) is 'the > right thing to do' will get short shrift from the complexity experts who > will want to know about the overall usage. iirc, the ABC interpreter (written by Guido) used "theoretically ideal" implementations for all built-in datatypes. the fact that he went for simplicity in Python might tell us something... </F> From thiele at muc.das-werk.de Wed May 10 15:18:29 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 10 May 2000 21:18:29 +0200 Subject: thread-(dead)lock Message-ID: <3919B605.8716322B@muc.das-werk.de> I have a server (derived from mutithreading SocketServer.py) and a client running on the same host, connectet via AF_INET-Socket. The server creates for every request a new thread. So I have three threads now. The main thread, a second thread that executes a loop-function, in which my problematic function is called, and a third thread created by a request from my client. class Requesthandler: def __init__(self): ..... self.lock = thread.allocate_lock() def Loop(self): #runs in one thread time.sleep(self.updatetime) self.ProblemFunction() def ProblemFunction(self): print "before aquire()" self.lock.aquire() print "locked" ....do something.... self.lock.release() print "unlocked" def HandelRequestFromClient(self): #runs in another thread self.ProblemFunction() ......... The client causes the server periodically to call its ProblemFunction() too. class Client: def __init__(self): ..... signal.signal(signal.SIGALRM, self.LoopSignalHandler) signal.alarm(self.updatetime) def LoopSignalHandler(self): Cause_Server_to_execute_ProblemFunction() ........ My problem is, that it works for 20 minutes an then I have a deadlock. "before aquire()" is printed and the function is blocked in both threads. The problem is not the "do something"-stuff! Any ideas why? Thanks Thomas From chrisw at nipltd.com Wed May 31 06:28:14 2000 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 31 May 2000 10:28:14 GMT Subject: Subclass List Message-ID: <8h2pfj$v5s$1@nnrp1.deja.com> Hi, I'd like to create a subclass of list that loads it's contents from a file when you instantiate it. What do I subclass to do this? I tried 'List' and 'ListType' but got NameError's. cheers, Chris Sent via Deja.com http://www.deja.com/ Before you buy. From neelk at brick.cswv.com Sun May 7 21:21:04 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 8 May 2000 01:21:04 GMT Subject: Future of the Python Linux Distribution References: <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> Message-ID: <slrn8hc7lg.8p7.neelk@brick.cswv.com> Vetle Roeim <vetler at ifi.uio.no> wrote: > on 2000-05-07, Glyph Lefkowitz wrote: > > he uses a lot of them. Common Lisp, Ada, Simula, C++, C, Haskell, > ML. he knows languages impose restrictions, but he dislikes the > restrictions Python impose. Incidentally, Haskell uses whitespace much as Python does. > > Lisp *IS* a PR-problem. Lisp needs to change its name and shed some > > syntax before it's ever going to get 'mainstream' acceptance; the > > ideas in lisp are good, but too many cs students have been tortured > > with it ... > > I'm afraid I haven't been tortured with it myself. I've been > tortured with Standard ML, Prolog, Java and stone-age C++ (pre > ISO/IEC 14882:1998), but not Lisp (I have encountered other > languages, but I've just been slapped hard by them.. not tortured). Common Lisp is a really amazing language. Once you've read the understood _The Art of the Metaobject Protocol_ you are one quarter of the way to provisional wizard status. (The other three-fourths are b) understanding Haskell's monads, c) grokking Prolog, and d) becoming handy with a combinator-based language by implementing a Forth.) Neel From infonuovo at email.com Sat May 6 20:02:15 2000 From: infonuovo at email.com (Dennis E. Hamilton) Date: Sat, 6 May 2000 17:02:15 -0700 Subject: OT: Unicode Unification Objections In-Reply-To: <m3ya64nq09.fsf@flash.localdomain> Message-ID: <NDBBKEGCNONMNKGDINPFCEBFDJAA.infonuovo@email.com> When subject matter experts from important language and cultural groups suggest that a unification in Unicode is objectionable, I think one should listen more carefully, even if it involves something that is hard to make sense of from within *our* cultural and language illusion. Consider the following. In Japanese texts, when a borrowed or employed Korean word is used, a desired practice is to render the Korean characters as different, even though some or all of them involve "the same character" common to both languages. However, the iconography (or calligraphy) is commonly different. This loses the ability to distinguish the linguistic use of the character, forcing material to be font-distinguished some how (e.g., give me the ones that look Korean, not the ones that look Japanese). This means that the distinction can't be preserved in simple text. One might regard this as a desire to honor the linguistic origins and usages of a word or phrase. Here are more cases. There are some characters which are arguably the same in the Greek and Roman (and Cyrillic) alphabets. These were *not* "unified." It is certainly helpful that they were not. (Especially since I rely heavily but not exclusively on one of those alphabets in *my* culture.) It is also helpful that the Western desire to differentiate "A" from "a" was fortunately preserved (thanks to ISO 646 getting there first, I suppose). They *are* the same letter, aren't they? Unfortunately, the Greek alphabet and the APL alphabet (and apparently some other math symbol alphabets) *were* unified. That is, a number of Greek-letter symbols were removed from any distinct APL character set, and only some APL-unique made-up symbols having Greek letters in them were retained as separate. Unfortunately, the iconography of the Greek alphabet in Greek text is often enough different that those codes don't render appropriately with the other APL symbols when used in APL texts. Borrowing epsilon (for member) from the Greek character set in Unicode is not always what one wants to do when writing membership propositions in APL (and borrowing the alternative MEMBER OF symbol may not get you what you want either). It's even more fun if you want to write APL programs and use Greek-language identifiers. Something a CP4E teacher in a Greek school might strongly desire to do. Get it? I'm told that Ken Iverson is working on a new language beyond APL, and that it relies much less on special symbols in its reference notation. I wonder if that provides relief or simply puts the new language on the same multinationalization footing as the rest. Meanwhile, I suggest that if one wants to find "racial illusions," (a self-describing term, perhaps?), one can easily do so aplenty in the Unicode standard as it is already written. -- Dennis -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Mark Atwood Sent: Sunday, 23 April 2000 20:21 To: python-list at python.org Subject: Re: Python - Next Release Questions "Dennis E. Hamilton" <infonuovo at email.com> writes: > issues and locale issues to deal with. There are also language communities > that have difficulty with Unicode for cultural as well as application > reasons. I.E., the various cultural groups that dislike the Unicode Han unification because they wish to continue their racial illusion that C, J, & V characters are completely different and seperate sets, and that it's somehow corrupting to stir them together. -- Mark Atwood | It is the hardest thing for intellectuals to understand, that mra at pobox.com | just because they haven't thought of something, somebody else | might. <http://www.friesian.com/rifkin.htm> http://www.pobox.com/~mra -- http://www.python.org/mailman/listinfo/python-list From vinyard at arlut.utexas.edu Wed May 24 13:09:12 2000 From: vinyard at arlut.utexas.edu (Edward S. Vinyard) Date: Wed, 24 May 2000 12:09:12 -0500 Subject: What's in a name? Message-ID: <Pine.SOL.4.05.10005241201170.14111-100000@spgsun1.arlut.utexas.edu> In some instances, case sensitive languages are exploited: 1. Case can add semantic information to the names of classes, functions, and instances. An example: You might capitalize the first letter of all classes, and make the first letter of all functions and instances lower-case. 2. Case can be used to delimit multi-word names. An example: spam_counter vs. spamCounter. I realize that this list is almost certainly incomplete, but a direct discussion of the ways that case sensitivity can be exploited might give us a better understanding of our preferences and/or illuminate other ways to convey these types of information. Ed From jgraves3 at austin.rr.com Thu May 18 21:47:56 2000 From: jgraves3 at austin.rr.com (jay graves) Date: Fri, 19 May 2000 01:47:56 GMT Subject: Converting strings to hex References: <8g20r4$ru6$1@supernews.com> <slrn8i92lv.8cs.kzaragoza@kzaragoza.ne.mediaone.net> Message-ID: <39249bec.32759472@news-server> On Fri, 19 May 2000 00:28:46 GMT, kzaragoza at mediaone.net (Kris J. Zaragoza) wrote: >That's funny, I was _just_ playing with this very functionality! >def md5ToHex(md5string): > import string > ret = [] > for c in md5string: > ret.append("%02X" % ord(c)) > return string.join(ret,"") > It must be something in the air. I also needed this yesterday and a DejaNews search yielded this function from Michael Wallace. def hexify(binaryString): result = "" for i in binaryString: result = result + string.zfill(hex(ord(i))[2:],2) return result Jay From Robert at nospam.edu Thu May 11 09:27:49 2000 From: Robert at nospam.edu (Robert) Date: Thu, 11 May 2000 13:27:49 GMT Subject: Python Websites: References: <391a27e8.2952935@news.prodigy.net> <8fd7fb$m8j$1@nnrp1.deja.com> Message-ID: <pzyS4.1$_U2.964@news> Check this out: http://www.oreillynet.com/python/ It is shaping up to be a really good python site... Bob <jsolbrig at my-deja.com> wrote in message news:8fd7fb$m8j$1 at nnrp1.deja.com... > In article <391a27e8.2952935 at news.prodigy.net>, > xion at inorbit.com wrote: > > > > I'm looking for some cool Python fansites. Anyone have/know of any? > > We got: > > Vaults of Parnassus, Python.org, Starship, Programming Pub. That's all > > I know of. Well, wxWindows. Any others? > > > > There's also www.pythonware.com and the links from there. > > But altogether, it seems like the python sites seem to be become > somewhat moribund. Perhaps it's a sign of success. The language no > longer needs our help - its success is guarenteed. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From buzzard at contactbox.co.uk Wed May 3 15:34:48 2000 From: buzzard at contactbox.co.uk (Duncan Smith) Date: Wed, 03 May 2000 19:34:48 GMT Subject: random.betavariate References: <8ep7ka$r1a$1@nnrp1.deja.com> Message-ID: <39108e45.0@news2.cluster1.telinco.net> Mean=a/(a+b) Var=a*b/((a+b+1)(a+b)^2) From olmy at thistledown.org Wed May 10 14:48:39 2000 From: olmy at thistledown.org (Olmy) Date: Wed, 10 May 2000 13:48:39 -0500 (CDT) Subject: Custom adduser function... In-Reply-To: <81DD38F43381D111BA3E00A076A0998A45A05B@XENON> Message-ID: <Pine.LNX.4.10.10005101344220.10529-100000@hexamon.thistledown.org> If you do a man useradd and look at what the -p option does, you'll see why it doesn't work. the -p flag requires the result of running crypt on your desired password. Not the value of the desired password itself. For grins, you can crack open the /etc/shadow file and you'll see the literal value of what you typed in the passwordval in the password field (whereas all other accounts have passwords that are in an encrypted format). I'd guess you could solve this by using python's crypt module: http://www.python.org/doc/current/lib/module-crypt.html I've never used it (indeed, I'm new to python myself), so can't speak much beyond this. hope this helps. jeff > for some reason, the -p option does not actually set the password to what we > think it is. I.E., if you run "/usr/sbin/useradd -p passwordval usernameval" > it doesn't actually set the password to passwordval... > > try it on your machine, then go to log in as the user - you'll see what I > mean... > > what do you think to do? > > > ---------- > > From: Jeff Bauer[SMTP:jbauer at rubic.com] > > Sent: Wednesday, May 10, 2000 1:59 PM > > To: Channel21 Python Team > > Cc: python-list at python.org > > Subject: Re: Custom adduser function... > > > > Channel21 Python Team wrote: > > > ok - RedHat 6.2 > > > need to have a function w/ 2 args (username,password) > > > which will create a system account w/ the username > > > and passwd passed in... any ideas? > > > > The easiest way is to probably pass the arguments > > to /usr/sbin/useradd via os.command(). Sample code > > below. > > > > I would probably add keyword arguments to support > > the other account options (i.e. uid, group, shell, > > home, comment, expire, etc.) > > > > Best regards, > > > > Jeff Bauer > > Rubicon Research > > > > --- > > > > #!/usr/bin/python > > import os, sys > > > > def adduser(username, password): > > cmd = "/usr/sbin/useradd -p %s %s" % (password, username) > > os.system(cmd) > > > > if __name__ == '__main__': > > usage = "usage: %s username [password]" % \ > > os.path.basename(sys.argv[0]) > > if len(sys.argv) < 2: > > print usage > > sys.exit(1) > > username = sys.argv[1] > > if len(sys.argv) > 2: > > password = sys.argv[2] > > else: > > from getpass import getpass > > password = None > > while password is None: > > p1 = getpass("Password for user '%s':" % username) > > p2 = getpass("Re-enter user '%s' password:" % username) > > if p1 == p2: > > password = p1 > > else: > > print "Passwords don't match." > > adduser(username, password) > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > -- > http://www.python.org/mailman/listinfo/python-list > From gmcm at hypernet.com Wed May 31 16:26:46 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 31 May 2000 20:26:46 GMT Subject: Newbie DateTime Question References: <sjaqkiom5pj31@corp.supernews.com> Message-ID: <39357586$0$12276@wodc7nh6.news.uu.net> Arnaldo Riquelme <javanet at dynacap.com> wrote: > >I'm using the mxDateTime module, and I'm trying to convert a string into a >Datetime format > >import DateTime > >>>>atime = '19990222' > >>>>DateTime.DateTimeFrom(atime) > >and this is what I get > >Traceback (innermost last): > File "<interactive input>", line 1, in ? > File "DateTime\DateTime.py", line 208, in DateTimeFrom >NameError: Case mismatch for module name Parser >(filename C:\Program Files\Python\DLLs\parser.pyd) > >Can anyone give a hand with this module. You have fallen victim to an excess of cleverness. The DateTime directory should be on your PYTHONPATH. (I use a .pth file pointing to the directory containing the DateTime directory). When you have it set right, "import DateTime" causes DateTime.__init__.py to run, which contains the line "from DateTime import *" (which refers to DateTime/DateTime.py), and then sets things up so Parser.py will be found in the DateTime directory). However, if you're not set up right, the import "succeeds", (doesn't through an exception), but fails to get anything right. So when it hits the "import Parser", Python thinks you mean parser.pyd, not DateTime/Parser.py. Never-name-your-child-"Daddy"-ly y'rs - Gordon From vetler at news.ifi.uio.no Sun May 7 19:55:46 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 08 May 2000 01:55:46 +0200 Subject: Future of the Python Linux Distribution References: <jaln1mgdfy.fsf@helix.twistedmatrix.com> <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <59vbhsko0k6gglr7ki61tbfch0eept58vk@4ax.com> Message-ID: <yayr9bd6hkt.fsf@ganglot.ifi.uio.no> * Ben Wolfson [snip] > >Yes, of course. But I have a feeling many people don't use these > >functions, unless they have taken a course on functional programming ;-) > > map, filter and reduce are pretty easy to figure out without knowing > any functional programming, actually. You just need to get > sufficiently bored with for loops. The problem is that once you put > them in, your code's legibility decreases if they're combined with one > another. I doubt I could parse this if I hadn't written it: > > from operator import add,indexOf > list=open('ceci ne pas un playlist.m3u').readlines() > open('mp3s','w').write(reduce(add, map(lambda a: a[1+a.find(',':]\ > filter(lambda e, l=list:indexOf(l,e)%2, list)))) > > and it's pretty simple. yes, they are simple. but most people don't know about them until someone shows them how easy it can be. > >It's often very useful to use these functions, but they provide solutions > >not easily available in more popular programming languages, such as C and > >Java. I refrain from mentioning C++ in the previous sentance, because C++ > >actually has those functions (except lambda), although many people don't > >know about them. > > I know about for_each and copy_if, which are what I assume you mean as > analogues of map and filter, but what corresponds to apply? well.. perhaps I was a bit too quick. I don't think there is something like apply. but I'm really not a C++ expert.. vr From echuck at mindspring.com Mon May 1 18:37:19 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Mon, 01 May 2000 18:37:19 -0400 Subject: Using BaseHTTPServer References: <Pine.GSO.4.10.10004281007030.10249-100000@sundial> <3909B32D.734E1F0F@propack-data.com> Message-ID: <390E071F.F95FC9F2@mindspring.com> Michael Str?der wrote: > > Moshe Zadka wrote: > > > > On Fri, 28 Apr 2000, Lars von Wedel wrote: > > > > > I assume that I can use BaseHTTPServer as it is. I just need > > > to implement a working request handler, right? > > > > > > Now comes the more fuzzy part: > > > > > > Since I do not want to execute external files but internal methods, > > > I think I could modify CGIHTTPServer by subclassing it and overriding > > > its do_GET() method to decode the request directly? Or would I rather > > > use SimpleHTTPServer, here? > > I also started with CGIHTTPServer which does forking. But I wanted to be > able to let it run under Windows => forking is not an option. I modified > all my code to be thread-safe, derived my own handler from > SimpleHTTPServer.SimpleHTTPRequestHandler and used the > SocketServer.ThreadingMixIn for running multi-threaded. > > > > Within any of the do_GET methods, how do I access data that has been > > > sent by the client (...&data1=val1?data2=val2?...)? > > > > Use the CGI module <wink>. Just copy the code from CGIHTTPServer to create > > the dictionary, (not as os.environ), and use the cgi module to parse > > that dictionary. > > Note: IMHO module cgi is NOT thread-safe (reads sys.stdin and use > os.environ). I'm using my own module cgiforms.py anyway. But cgi takes parameters for both those items. sys.stdin and os.environ are just the defaults if you don't specify them. I know, because I use CGI in my AppServer in Webware. -Chuck From mhammond at skippinet.com.au Mon May 1 20:08:52 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 02 May 2000 00:08:52 GMT Subject: Newbie Q: Win32, COM, Dispatch, Oracle OLE References: <8ek444$5br$1@nnrp1.deja.com> Message-ID: <o0pP4.9101$v85.58393@news-server.bigpond.net.au> "Torgo Jr" <torgojr at my-deja.com> wrote in message news:8ek444$5br$1 at nnrp1.deja.com... > I'm confused on how to implement Oracles Objects For OLE in Python. > I browsed this newsgroup and came up with using "makepy.py -i" > to set the module correctly. What I want to do is create a > OraSession object, set some parameters, and call a method in OraSession > that returns an OraDatabase object, but I am not sure what I am doing > wrong: > > >>> from win32com.client import gencache > >>> mod = gencache.EnsureModule('{F2D4ED20-FFD3-101A-ADF2- > 04021C007002}', 0, 3, 0) > >>> # previous works fine, can see __dict__.keys() entries > >>> oraS = mod.OraSession() # fails The first thing to try is to avoid using the module directly. If Oracle is behaving, you should be able to do the gencache line, then a simple "win32com.client.Dispatch("Oracle.Whatever") You probably saw a recent thread where the object didnt behave itself, so we did need to go directly to the makepy module. If this is also true for you, you should probably have a look at the .py file generated by Python. You will see a couple of categories of classes. The first set look like [from DAO]: class _User(DispatchBaseClass): CLSID = pythoncom.MakeIID('{00000069-0000-0010-8000-00AA006D2EA4}') ... lots of methods removed ... The other looks like: # This CoClass is known by the name 'DAO.User.36' class User(CoClassBaseClass): # A CoClass CLSID = pythoncom.MakeIID("{00000107-0000-0010-8000-00AA006D2EA4}") coclass_sources = [ ] coclass_interfaces = [ _User, ] default_interface = _User If you need to use a class explicitly, it probably need to be the first type rather than the second - eg, you would use "_User" instead of "User" Mark. From debl.nospamm at world.std.com Fri May 5 13:03:52 2000 From: debl.nospamm at world.std.com (David Lees) Date: Fri, 05 May 2000 17:03:52 GMT Subject: Freeze/Source Code Question? References: <000501bfb661$57a86580$d02d153f@tim> Message-ID: <3912FEE8.B54BF3C6@world.std.com> Thanks Tim (and also Quinn) for setting me straight on Freeze. I was browsing books on Python and I believe it was a thick one on Annotated Python (?) that I thought said something about making the byte code secure. But perhaps I misread it, because it was a just a quick bookstore browse. Yes, I understand that anything can be reverse engineered if you take the trouble. Python looks really cool, but I am just at the "hello world" level right now. David Lees Tim Peters wrote: > > [David Lees] > > I am taking an initial look at Python (total novice) and am puzzled > > about the existence of Freeze. If you do not wish to show your source > > code to the world, I gather the byte code in the form of *.pyc files can > > be executed. > > Disguising source is not the purpose of freeze tools. > > > If the Freeze stuff, just embeds the byte code into a C program > > (interpreter?) what is the difference from the viewpoint of > > hiding the code? > > None. > > > I assume the C might be easier to run, because everything is in one > > executable, > > Bingo. It's a convenience for the end user. > > > but is the byte code still not easily viewed with an octal or hex > > dump, just as in the .pyc files? > > The standard library module "dis" supplies a symbolic disassembler for > Python bytecode -- no need for binary dumps. > > > Are there really good decompilers that translate byte code into source > > for Python, so that nothing is really hidden? > > "dis" is a start, and others have built fancier disassemblers on top of it. > I don't know what "really good" means to you. Certainly good enough to > extract whatever it is you hope to hide, but see below. > > > If so, is it really much different that Java or Visual Basic, where > > presumably the same thing can be done? > > Very different: Python code works <wink>. > > BTW, if you think you're more secure distributing, for example, compiled C > or Fortran code in binary form, you're mistaken: if my machine can execute > it, I can trace the machine instructions, and they tell me everything your > program does as well as how it does it. Python bytecode is less work to > decipher, but a reasonably talented hacker can effectively "reverse compile" > anything. > > hence-the-restriction-against-doing-that-in-all-the-software-licenses- > you-accept-without-reading<wink>-ly y'rs - tim From fwang2 at yahoo.com Wed May 10 12:18:18 2000 From: fwang2 at yahoo.com (oliver) Date: Wed, 10 May 2000 12:18:18 -0400 Subject: variable access question In-Reply-To: <slrn8hi7em.58t.nascheme@cranky.arctrix.com> References: <Pine.LNX.4.10.10005100130050.4359-100000@worf.mcnc.org> <slrn8hi7em.58t.nascheme@cranky.arctrix.com> Message-ID: <Pine.LNX.4.10.10005101216180.2802-100000@worf.mcnc.org> thanks for reply, and yes, I meant to have mulitple instance of class B, and they all want to acceess one instance of Class A's "queue" variable, the code follows doesn't seem to be able to do it. I am a bit confused here. could you clarify it on that? > > This is the answer to your question: > > class A: > queue = Queue(10) > > class B: > queue = A.queue > > Are you sure you don't want to use instances and not classes? From hinsen at cnrs-orleans.fr Tue May 23 09:27:16 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 23 May 2000 15:27:16 +0200 Subject: Is it just Syntactic Sugar ? References: <k7lW4.96338$E85.1941352@news1.rdc1.md.home.com> Message-ID: <m3d7mdxuq3.fsf@chinon.cnrs-orleans.fr> "Eric Hagemann" <ehagemann at home.com> writes: > in its simplest form I agree there might not be much to this but if you > do this with a complex expression as > > a[x][f][g] = a[x][f][g] + 1 > > does the python engine recompute the 'address' of the variable 'a[x][f][g]' > twice ? Yes, but it's not quite twice the same. Your statement gets translated into something like: a[x][f].__setitem__(g, a[x][f].__getitem__(g).__add__(1)) (the details depend on the precise types involved, there is a difference between types implemented in C and those implemented as classes in Pyton). The subexpression a[x][f] is evaluated twice, and the language doesn't even guarantee that the result is the same. The first evaluation could modify the object 'a' as a side effect, although that would of course be a case of extremely bad program design. > Would the a+=1 for speed things up or is it just expanded to a=a+1 anyway ? That depends on how a+=1 would be defined! If it were defined to be exactly equivalent to "a = a + 1" under all possible circumstances, then it would have to generate exactly the same code. > I have found that > > p=a[x][f][g] > p=p+1 This does something different, it doesn't modify the original sequence. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tismer at tismer.com Sat May 6 11:47:48 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 06 May 2000 17:47:48 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> Message-ID: <39143EA4.556B4743@tismer.com> Richard Jones wrote: > > [Christian Tismer] > > Hey, this is just an incredible idea. > > Java with first class continuations, let that > > drop through your brains. 90 percent of java threads > > would be replaced by microthreads. > > > > I will read the Kaffe source and think how this must be. > > Please try to modify the Blackdown JVM rather than Kaffe - it's faster and > ... well ... it actually works ... and it's Sun supported ... and stuff ... > > > It can become quite a revolution for Java. > > I think it's a damn fine idea! :: Well, I got the Kaffe sources. This was easy. Now I'm trying to get the Blackdown Sources, since I'd like to read the green threads implementation. These should be sitting in some patches, I think. Whether I'll work on either of them is still open, but I want to read them. Searching since hours, I cannot find their patches, just all the mirrors with binaries. Does anybody have an idea where to get them? ciao - chris -- Christian Tismer :^) <mailto:tismer at appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From pinard at iro.umontreal.ca Tue May 23 17:16:01 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 23 May 2000 17:16:01 -0400 Subject: Optional Underscores (py3k)? In-Reply-To: Pete Shinners's message of "Tue, 23 May 2000 12:06:53 -0700" References: <392AD6CD.46838306@visionart.com> Message-ID: <oqn1lhdl2m.fsf@titan.progiciels-bpi.ca> Pete Shinners <pete at visionart.com> writes: > With all the talk case insensitive Python. I was thinking about it [...] Hi, Pete. First of all, and sad for me, your message was a bit difficult to read, because it was missing the usual English capitalisation, and some of the usual punctuation. (I restored these somewhat, before replying, just for being able to, but this should not be the recipient of an email to do such things.) This is exactly what I fear with Python. The same we all routinely exchange email, we will also routinely exchange Python code, especially if Python becomes spoken by a lot of people. I want all the luck possible for the Python code I receive to be legible, without feeling compelled to rewrite it first. I hope Python will give me that luck, by ensuring a capitalisation which is both consistent and proper. > and realized this is very similar to allowing optional underscores on > object names as well. [...] In the end I'm not advocating the future > either way, but I do believe if Python becomes case-insensitive, it > might also behoove things to become underscore-insensitive. Alice studies shown that new users are prone to making capitalisation error. Other studies will surely show that new users are prone to forgetting underscores, to misspelling identifiers, or using the wrong kind of brackets, parentheses or braces, commas, colons. Many things, really. If Python ever becomes ubiquitous, be sure that studies will abound. I hope Guido will not give in allowing all kinds of misspelling and errors. Wrong casing is nothing more than a way to misspell. When ugly-written Python code will fly all around my head, I guess I'll loose my sensitivity to Python. And then, if Guido was only seeing me, he would surely be moved by my sore, and my bitter cries. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From dana at oz.net Thu May 11 01:58:29 2000 From: dana at oz.net (Dana Booth) Date: 11 May 2000 05:58:29 GMT Subject: Why should I switch to Python? References: <000401bfbaf5$877f8b60$2aa0143f@tim> <391A2EE0.83128776@san.rr.com> <hmckhsgp458d8rc1nm419rku12tpmv1r68@4ax.com> <391A34C3.387B2C63@san.rr.com> Message-ID: <8fdi65$e09$1@216.39.141.21> Courageous <jkraska1 at san.rr.com> wrote: C: Of course I'm one of the few nuts on the planet that *likes* to use C: ? : : expressions in C. That _does_ make you a nut, you know. :) -- ----- Dana Booth <dana at oz.net> Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From m.faassen at vet.uu.nl Mon May 22 09:24:30 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 13:24:30 GMT Subject: Damnation! References: <Pine.GSO.4.10.10005210708060.10759-100000@sundial> Message-ID: <8gbcee$peo$2@newshost.accu.uu.nl> Moshe Zadka <moshez at math.huji.ac.il> wrote: [snip] > It's much better to say "the language is case-insensitive" and to have the > tools correct case as you write. You forgot this, didn't you? :) Or-the-same-with-"the language is case-sensitive"-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From akuchlin at mems-exchange.org Fri May 12 15:39:15 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 12 May 2000 15:39:15 -0400 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <m3ln1jud2w.fsf@chinon.cnrs-orleans.fr> <8fhm1t$nk0$5@newshost.accu.uu.nl> Message-ID: <3d3dnnk17g.fsf@amarok.cnri.reston.va.us> m.faassen at vet.uu.nl (Martijn Faassen) writes: > Konrad Hinsen <hinsen at cnrs-orleans.fr> wrote: > > All I can say is that I have profited a lot from it. Sure, I got a > > Python installation with RedHat 6.1, but not with all the nice add-on > > packages which I use. > > I think the distutils should be able to help a lot here. Once they > are mature enough, you should be able to easily install most add-ons > through those. In fact, there are already patches floating around to add a bdist_rpm Distutils command that builds an RPM file. They're not yet included in the CVS tree, but the capability is so attractive that they'll probably be accepted eventually. Gregor Hoffleit has speculated about building Debian's .deb packages in the same manner, but there are some technical issues that need to be fixed first -- supporting the full power of Debian's dependency tracking is apparently hard. Anyway, so I'd hope that, before too long, building RPMs of Python extensions would be very easy, so that no one would have to maintain a separate python4linux porting effort. Maybe someday there could be a service that automatically grabbed packages from Parnassus and built RPMs from them. -- A.M. Kuchling http://starship.python.net/crew/amk/ "I don't think you can fit under the bed." "Oh, there are some ladies who'd tell you otherwise." -- Stanley and Ambrose Bierce in STANLEY AND HIS MONSTER #3 From effbot at telia.com Tue May 30 07:36:20 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 30 May 2000 11:36:20 GMT Subject: *blink* That's neat. References: <GXJY4.28606$WS3.320758@typhoon.we.rr.com> <SZKY4.6213$wYl.227247104@newsb.telia.net> <8h07fv$bnc$3@newshost.accu.uu.nl> Message-ID: <UINY4.6227$wYl.223307264@newsb.telia.net> Martijn Faassen wrote: > > btw, usability research has shown that "and" and "or" are about the > > worst names you can use for these operators. how about renaming > > them in Py3K? ;-) > > The Alice project again, right? :) nope. they're not the only ones out there who thinks that programming languages are user interfaces. > just-had-to-make-that-comment-ly yours, yeah, HCI people cannot be very smart if they don't under- stand how computers work, can they? better ignore them. </F> From scarblac-spamtrap at pino.selwerd.nl Thu May 25 05:25:45 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 25 May 2000 09:25:45 GMT Subject: Pass by reference? References: <8ghcq1$opl$1@supernews.com> <392C683E.AF7398D4@uab.edu> <8gin25$sfe$1@supernews.com> Message-ID: <slrn8ipscd.nfr.scarblac-spamtrap@flits104-37.flits.rug.nl> Dale Strickland-Clark wrote in comp.lang.python: > Also the following program proves to me that arguments are passed by value > and not by reference: > > def wibble(var): > var = 1 > > x = 0 > wibble(x) > print x > > It prints 0 showing that the assignment in wibble is made to a copy of x A key thing about Python. All arguments are passed by reference. But *assignment* is by reference too! x refers to the integer 0. wibble is called, now the local var 'var' also refers to the integer 0. after 'var = 1', 'var' refers to the integer 1. x is unchanged. Variables are just names for objects. Assignment gives that name to another object. Assignment can only *change* an object if you assign to something 'inside' the object, like 'x[3] = 4' or 'ob.value = 3'. Integers are immutable, can't be changed. Just like strings and tuples. Lists can be changed. Compare: x = [] def app(list, value): list = list+[value] return list app(x, 3) print x With: x = [] def app(list, value): list.append(value) return list app(x, 3) print x -- Remco Gerlich, scarblac at pino.selwerd.nl This is no way to be Man ought to be free -- Ted Bundy That man should be me From g2 at seebelow.org Fri May 12 17:27:57 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 12 May 2000 22:27:57 +0100 Subject: Why should I switch to Python? References: <000401bfbaf5$877f8b60$2aa0143f@tim> <391BB5CA.3640@seebelow.org> <2yzS4.6762$Za1.106040@newsc.telia.net> Message-ID: <391C775D.18DC@seebelow.org> Fredrik Lundh wrote: > > Grant Griffin <g2 at seebelow.org> wrote: > > However, perhaps I have inferred the philosophy wrongly. I know that > > you (or maybe he) have written numerous posts that touch on Python's > > design philosophy, but do you know if Guido has ever formalized Python's > > design philosophy on a web page or something? > > the best summary can be found here: > http://www.deja.com/=dnc/getdoc.xp?AN=485548918 > > for another view, see guido's foreword to the first edition > of programming python: > http://www.python.org/doc/essays/foreword.html > > </F> Thanks, F--those were very interesting! The one at top was very nearly poetic, worthy of study. As I read through it and tried to apply its criteria to "augmentation operators" (as Tim calls them--you learn something every day around here!), it was maybe a draw: some points seemed to argue "for", some seemed "against". But the one at the bottom clearly seemed "against". In particular, Guido writes: "Readability is often enhanced by reducing unnecessary variability. When possible, there's a single, obvious way to code a particular construct. This reduces the number of choices facing the programmer who is writing the code, and increases the chance that [it] will appear familiar to a second programmer reading it." is-tim-applying-his-philosophy-of-sticking-to-a-consistent -philosopy-consistently?-<wink>-ly y'rs, =g2 p.s. From my own selfish point of view, I still like augmentation operators, not just for their convenience, but because I think they convey a certain amount of meaning--at least to the initiated. And unfortunately, in Python, I've found myself using unnecessarily short variable names as a mitigation for their absence. -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From mfletch at tpresence.com Tue May 9 12:39:16 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 9 May 2000 12:39:16 -0400 Subject: Converting a Binary Message-ID: <CC59868A0A76D311B1F50090277B321C1F3306@VRTMAIL> See module struct in the documentation. struct.pack( 'i', yourinteger ) Enjoy, Mike -----Original Message----- From: Jeff Massung [mailto:jmassung at magpiesystems.com] Sent: Tuesday, May 09, 2000 12:19 PM To: python-list at python.org Subject: Re: Converting a Binary AMR wrote in message <8f98bk$a6c28 at esiami.tsai.es>... >What module I need to convert a number to binary?, In string format? Assuming 24-bit integer: def itob(i): t=2**23 b='' while i>0: if i>=t: b=b+'1' i=i-t elif b!='': b=b+'0' t=t/2 return b Sorry, I'm new to Python, so if some of this can be done easier or quicker, I'd like to know how, too ;) Jeff -- http://www.python.org/mailman/listinfo/python-list From gregm at iname.com Fri May 5 12:12:08 2000 From: gregm at iname.com (Greg McFarlane) Date: Sat, 6 May 2000 02:12:08 +1000 Subject: Trouble with Pmw ComboBox get() In-Reply-To: <390FA8A9.DF091DA2@flash.net>; from Cindy Huyser on 02 May 2000 at 11:18:50PM References: <390D7ACA.5CB91267@flash.net> <390FA8A9.DF091DA2@flash.net> Message-ID: <20000506021208.55079@nms.otc.telstra.com.au> When I ran your main.py it said # python main.py Traceback (innermost last): File "main.py", line 3, in ? from editDay import * ImportError: No module named editDay So, you haven't included all the files. However, I definitely do *not* suggest you post all your files to the python mailing list once again. You need to do a little work yourself and narrow down the problem, by reducing the size of the program that displays the unexpected behaviour as much as possible. If you have code that does not behave as you expect, I suggest you create the absolute smallest runnable program that demonstrates the problem. The process of doing this will almost always lead you to the solution. If not, then post the snippet. By snippet I mean at most one file of at most 30 lines. Greg On 2 May, Cindy Huyser wrote: > > More complete information on the Pmw ComboBox get() problem: > > I've attached the primary files for this program. Run main.py, and > choose Available Rooms from the View menu to get the course scheduler > overview. Here, attempting to add or delete a course scheduled doesn't > have the desired effect --this is where the problem shows up -- the > default values are always loaded into the code. > > Something else that's weird is the set of labels that's showing up at > the bottom of the page -- I don't think I wrote code that put them > there! > > I retyped this file from an earlier version that was working pretty well > (but didn't do file reads). In this version, I've hard coded in all the > information I had been reading from files. The substantial difference > between this version and the one in which the course addition/deletion > is working is the way in which information is communicated between the > file handler functions in main() and the data structures in schedule.py > and roomGrid.py, and I imagine this is where the trouble lies. -- Greg McFarlane INMS Telstra Australia gregm at iname.com From sabren at manifestation.com Mon May 8 17:58:47 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Mon, 8 May 2000 17:58:47 -0400 (EDT) Subject: CGI getting multiple values with same name into a list In-Reply-To: <v04210104b53cd496e621@[192.168.1.2]> Message-ID: <Pine.BSF.4.10.10005081750320.1876-100000@chi.pair.com> On Mon, 8 May 2000, Lee Joramo wrote: > I am trying to process a web form but can not figure out the proper way to > get mulitple values with the same name into a list. However, instead of > getting a nice list, I get garbled MiniFieldStorage results For example, I > have an html checkbox set with the name "select": Try weblib! :) http://weblib.sourceforge.net/ for: http://whatever/yourscript?select=cat&select=dog you'd do: ################# #!/usr/bin/python import weblib.script print weblib.request["select"], "<HR>" # prints "cat" print weblib.request.query["select"] # prints ('cat', 'dog') ################# Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From sbrunning at trisystems.co.uk Fri May 26 03:35:20 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 26 May 2000 08:35:20 +0100 Subject: Komodo IDE for Python Message-ID: <34575A892FF6D1118F5800600846864D35F538@intrepid> I just came across this - <http://www.activestate.com/Corporate/Media_Center/News/Press9591506 36.html> - at /. -- Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From andre at beta.telenordia.se Wed May 31 22:22:20 2000 From: andre at beta.telenordia.se (André Dahlqvist) Date: Thu, 01 Jun 2000 03:22:20 +0100 Subject: Newbie Tkinter Question References: <YzdZ4.687$bR5.17886@news.uswest.net> <3935980E.D609911@home.com> Message-ID: <8h4dsn$c4t$1@cubacola.tninet.se> While we're on the beginner level in Tkinter I thought I would ask a question which I guess is simple. How can I get the word that has been clicked in a Text widget? I have bound a tag to this text, but I am not sure how to get the actual text. tag_ranges gives me the positions all the words that has this tag, but how do I know which one was clicked? // Andr? From scarblac-spamtrap at pino.selwerd.nl Mon May 1 03:49:15 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 1 May 2000 07:49:15 GMT Subject: Python Compiler References: <8F26DEAB4joshtinamecom@209.208.0.7> <sgpuubk7oog52@corp.supernews.com> Message-ID: <slrn8gqdlr.lo6.scarblac-spamtrap@flits104-37.flits.rug.nl> Eric Jacobs wrote in comp.lang.python: > Here's an example to give you an idea of the depth of the problem: > > while i < len(x): > ... > > The expression len(x) looks like a candidate for code motion. That is, we > would like to move the expression above the loop, computing it once > instead of redundant computing the same value every time through the loop. > In order to do that, we must prove that 1) len(x) computes the same value > every time it is evaluated with the same arguments (it is purely > functional), and 2) that evaluating len(x) causes no change in the value > of any expression (it is side-effect free.) > > Firstly, we must check the body of the loop to make sure that no > assignments are made to x. There's even more: you need to check for assignment to len in the loop as well :) Hmm. I think it's impossible in general to check algorithmically if a function, always given the same argument, always returns the same thing. (although you can flag the difficult cases and assume they're not purely functional, I suppose). i'd-rather-write-a-C-interpreter-ly-yrs, Remco -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From charleshixsn at earthlink.net Thu May 11 15:24:35 2000 From: charleshixsn at earthlink.net (Charles Hixson) Date: Thu, 11 May 2000 19:24:35 GMT Subject: Python Compiler References: <8F26DEAB4joshtinamecom@209.208.0.7> <8el3sd$h77$2@ites.inria.fr> <390ebb1f@nntp.server.uni-frankfurt.de> Message-ID: <391B08DC.F713656B@earthlink.net> mlauer at trollinger-fe.rz.uni-frankfurt.de wrote: > -- snip > Wouldn"t this be much less of a problem when using C++/STL as the > target language ? > > -- > -- > Regards & Gruesse from Mickey @ http://www.Vanille.de > --------------------------------------------------------- > How could anyone know me - when I don't even know myself ? The timings and size specs that I've seen make me dubious about using the C++/STL combo. Python has enough problem already because of the virtual machine. Do you want to slow it to a stop? From rumjuggler at cryptarchy.org Wed May 31 23:36:44 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Thu, 01 Jun 2000 03:36:44 GMT Subject: Marking hyperlinks in a Text widget References: <8h04jo$lgh$1@zingo.tninet.se> <oq7lcc41zr.fsf@titan.progiciels-bpi.ca> <8h0kn5$6pv$1@cubacola.tninet.se> <slrn8j94er.ebv.cjc26@localhost.mindriot.net> <8h4d2e$ap4$1@cubacola.tninet.se> <slrn8jblag.jua.cjc26@localhost.mindriot.net> Message-ID: <cjmbjsoask73rledo0kefavcrf60cangeq@4ax.com> gOn Thu, 01 Jun 2000 03:12:35 GMT, cjc26 at nospam.cornell.edu (Cliff Crawford) wrote: >| Is openURL a function that you have written? If so, can I check it out? > >That's actually a command-line argument of Unix versions of Netscape. I >don't know if it would work on Windows. If you're using Unix, try >typing the following at a shell prompt (with Netscape already running): > >% netscape -remote 'openURL(www.python.org)' > >It should make Netscape go to the Python page. On windows you can just do netscape www.python.org from the command line. If you do netscape -remote 'openURL(www.python.org)' it will look for "www.remoteopenurlwww.python.org" -- Barnabas T. Rumjuggler NEW Epistemology Strips! Dogs don't know they don't know it's not bacon! -- Ranjit Bhatnagar From dag at orion.no Fri May 19 07:30:24 2000 From: dag at orion.no (Dag Sunde) Date: Fri, 19 May 2000 11:30:24 GMT Subject: ValueError: unpack tuple of wrong size??? References: <Pine.LNX.4.21.0005191017170.493-100000@fep132.fep.ru> Message-ID: <kB9V4.10519$gy4.1443644@juliett.dax.net> like in: fSuccess = self.m_pElTermin.LoginToMarket(self.loginId, self.Supplier) ??? ...then it complains about: "attribute error: loginId"... ? Dag. "Oleg Broytmann" <phd at phd.russ.ru> wrote in message news:Pine.LNX.4.21.0005191017170.493-100000 at fep132.fep.ru... > On Fri, 19 May 2000, Dag Sunde wrote: > > Question: > > When a method has a boolean return, and two output-params, how do I > > call it? > > I think you must pass two Buffer objects, that will get filled upon > return; the return value should be one boolean... > > Oleg. (All opinions are mine and not of my employer) > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > From robin at jessikat.demon.co.uk Wed May 17 05:55:56 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 17 May 2000 10:55:56 +0100 Subject: Correct way to resolve import ambiguity Message-ID: <vUDR0IAsymI5Ew4O@jessikat.demon.co.uk> I have a package structure A.B.f A.B.p A.B.d #f.py class F: pass #p.py from f import F class P(F): pass #d.py from f import * class D: def b(self,A): assert filter(lambda x: not isinstance(x,F), A)==[], "A argument error" if __name__=='__main__': def run(): from A.B.p import P d = D() d.b([P()]) run() python d.py fails in d.b as it seems that using from A.B.p import P isn't the same as from p import P What is the 'correct' way to resolve the ambiguity? Should I eschew the use of sibling imports? That would seem to make maintenance/re-use harder ie I couldn't just move the sources around. This version of d.py runs fine #d.py v2 from f import * class D: def b(self,A): assert filter(lambda x: not isinstance(x,F), A)==[], "A argument error" if __name__=='__main__': def run(): from A.B.d import D from A.B.p import P d = D() d.b([P()]) run() -confused-ly yrs- Robin Becker From slhath at flash.net Tue May 23 10:35:15 2000 From: slhath at flash.net (Scott Hathaway) Date: Tue, 23 May 2000 14:35:15 GMT Subject: Graphical User Interface application References: <MBEGIENDECAECJGNLHGGKEHNCAAA.jilanik@tin.it> Message-ID: <DGwW4.29564$wb7.1710647@news.flash.net> For the graphics package, Tkinter and wxPython seem to be the most popular. With wxPython, you can use Boa Constructor to build the gui in an IDE environment like VB or Delphi. Scott "Jilani Khaldi" <jilanik at tin.it> wrote in message news:MBEGIENDECAECJGNLHGGKEHNCAAA.jilanik at tin.it... > Hi All, > I wonder if it is possible to write graphical user interface applications > using Python, like in VB? If yes, what do I need then? > > Thanks. > > Jilani > > From glyph at twistedmatrix.com Tue May 9 03:16:15 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 09 May 2000 02:16:15 -0500 Subject: "stuff", a general request for help Message-ID: <ja3dnsb3cw.fsf@helix.twistedmatrix.com> I have been experimenting with a large assortment of stuff in python recently. The particular reason that I wrote this message was the nature of python optimization; I don't think I understand how to do it, and after reading guido's optimization anecdote (http://www.python.org/doc/essays/list2str.html) I gather that it's rather important (the same algorythm expressed in different ways can evidently make up to a 15x speed difference). I'm doing a lot with operator overloading right now, and I know python's syntactic sugar adds some overhead, so I decided I'd try the rather simple case of a multidimensional array and see if I could figure out a way to make it go faster or take up less space. I thought this would be easy, since the for loop to create a list of lists was bound to be slow, and doing everything as one big array would be easier. My attempt was a failure. (Well, I DID get the initializer to go faster, but at what seems to be horrible cost.) The code seemed tad too long for USENET, but a .tar.gz containing the code in question is at http://www.twistedmatrix.com/~glyph/py/tr2/tr2-20000509.tar.gz The thing that really struck me is the non-trivial amount that the optimization self.__getattr__=self.__getattr__ in the initializer made. Also the incredible lack of any performance gain through translation to C. Also the apparently crazy overhead on python function invocation... Can someone with more python experience than I give me some advice on where I should be looking at this point? I put a script in the archive called 'optest' which should run the timings for this ... ymmv though, especially on the translation-to-c stuff. If it doesn't work it should be a simple change to a path in py2c/py2ctree.py. (no, I didn't write a python-to-C translator, I used the already available one) An average set of output from the script for me is this: glyph at helix:~/cvs/matrix/tr2-20000509% ./optest notebook c_notebook/ notebook/dimensional.py -> .c -> .so notebook/dimentest.py -> .c -> .so notebook/__init__.py -> .c -> .so array_init -> 397 ms array_zero -> 20165 ms opt_init -> 292 ms opt_zero -> 18804 ms carray_init -> 365 ms carray_zero -> 18887 ms list_init -> 340 ms list_zero -> 3443 ms As long as I'm encouraging people to download this thing, too; I am getting started with PyUnit and regression testing ... but my tests seem really random and arbitrary. Much appreciated would also be comments on the style / structure of said tests (in the regr/ directory) and pointers to better ones. I've read about JUnit and PyUnit, but there doesn't seem to be much in the way of a description of what makes a good test. Right now, writing tests takes 2x as long as writing the code initially, and there have been more bugs in the tests than in the code itself. I know that these can be a real resource for me, but I'm not quite sure how. Thanks! (Sorry for covering so much in one email, but these are both areas where I'm *REALLY* stuck and confused and could use some general opining of pythonic luminaries ^_^) -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From warlock at eskimo.com Mon May 8 02:12:03 2000 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 08 May 2000 06:12:03 GMT Subject: Block comments? References: <391653B7.2F38A7F2@san.rr.com> Message-ID: <slrn8hcmua.19u.warlock@troll.myth> On Mon, 08 May 2000 05:38:54 GMT, Courageous, in the persona of <jkraska1 at san.rr.com>, brought forth the following words...: > >Okay, it's not like I'm not looking in my documentation or anything, >but if this is available, it's not obvious. How do you express >python block comments? > > >C/ One way would be to surround them with """ """ -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From richard_chamberlain at ntlworld.com Sun May 21 08:30:22 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sun, 21 May 2000 13:30:22 +0100 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <eGNV4.3078$1W6.57636@news2-win.server.ntlworld.com> <v_NV4.2148$sW4.12967@news-server.bigpond.net.au> Message-ID: <DzQV4.3265$1W6.62490@news2-win.server.ntlworld.com> To repeat what lots of people have already said the difficulties with case should be solved with an IDE not with altering the language. You'll notice that a url is case sensitive and urls are bandied about as currency so in my opinion I think the population can generally handle case. >>This is something Windows and Macintosh do right - >>removing a cause of error for no real limitation in functionality. I come from a Macintosh / Windows background but I think the amount of messages this has created demonstrates that 'no real limitation in functionality' isn't totally true. Richard Neil Hodgson <neilh at scintilla.org> wrote in message news:v_NV4.2148$sW4.12967 at news-server.bigpond.net.au... > > When we teach our children to write we teach them case sensitivity, I do > not > > remember any governing body suggesting we should drop case sensitivity > from > > written language in order that 'everyone' will therefore be able to write. > > > > I also cannot believe that this is a difficult lesson to learn. > > > > How many times would you have to be told before you understood it? Once or > > twice? > > While I /know/ that Unix file names are case sensitive, that doesn't stop > me from mistyping them. This is something Windows and Macintosh do right - > removing a cause of error for no real limitation in functionality. > > I would extend the same scheme to variable naming in Py3K. Names have one > and only one capitalisation. Other capitalisations are an error. The IDEs > can provide different styles of help here, from no action through > highlighting miscapitalisation to automatic case changing. > > Some people have been using a=A(). Even me. But is this something that > you really feel should be encouraged? Or is it a source of ambiguity and > potential misunderstanding. > > Neil > > From robin at jessikat.demon.co.uk Wed May 10 03:06:59 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 10 May 2000 08:06:59 +0100 Subject: COM + reload() References: <fnzQ4.2379$Ft1.90191@typhoon.ne.mediaone.net> <029801bfba3c$db01de00$5d22023f@spkydomain> Message-ID: <wSy2lUATqQG5EwqZ@jessikat.demon.co.uk> > >> I am using Python as a COM client and server for Excel. E.g. I have a >couple >> of buttons in Excel calling some methods in Python, which in turn use COM >to >> read from and write to Excel. Everything works fine, but when I make a >> change in the Python program, no matter in which module, the change is >never >> reflected in the call started by Excel, until I restart the program. >> >> Even when reloading the top level module on every call from Excel, and >> making the changes only in that top level module, the program called by >> Excel never changes, until I restart Excel. >> >> Does anyone know how I can change this behavior, e.g. how I can force the >> changes to take effect? I'm fairly sure that vba won't unload any dll even though there are no active references to it. I guess that means that imports etc aren't refreshed. -- Robin Becker From m.faassen at vet.uu.nl Mon May 22 07:43:44 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 11:43:44 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <CC59868A0A76D311B1F50090277B321C1F3348@VRTMAIL> <39276946.90FE82A2@san.rr.com> Message-ID: <8gb6hg$pe6$2@newshost.accu.uu.nl> Courageous <jkraska1 at san.rr.com> wrote: > Mike Fletcher wrote: >> >> Personally, I have been bit by case problems probably five or six times (in >> five years or so). That said, I find working with case insensitive >> languages difficult to the point where I will not use them. > The truth of the matter is that, irrespective of whether or > not a language is case sensitive or not, using inconsistent > case for the same thing is an extraordinarily bad idea, and > would be extremely poor engineering practice. It's the indentation argument all over again, in fact: The truth of the matter is that, irrespective of whether or not a language is indentation sensitive or not, using inconsistent indentation is an extraordinarily bad idea, and would be extremely poor engineering practice. Since Python enforces the indentation issue, but the same philosophy it ought to enforce the case issue. And does. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From niels at endea.demon.nl Sat May 20 13:02:02 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Sat, 20 May 2000 19:02:02 +0200 Subject: command history in the interpreter? References: <3926D1F3.8D07DC60@kurir.net> Message-ID: <3926C50A.C1D34064@endea.demon.nl> alex k schreef: > now i use slackware7. i installed both python1.52 and python1.6 (the > former replacing the latter). it didn't work in none of them. > all of the arrowkeys type things like ^[[C ^[[D and such. The prebuilt 1.5.2 that comes with Slackware 7 works OK. If you build one yourself, you have to enable the readline module in Modules/Setup. > the python interpreter in win98 (1.52 and 1.6) also don't give me the > history function. Sorry, there just isn't any readline library on win32. Use IDLE or PythonWin instead. -- Niels Diepeveen Endea automatisering From g2 at seebelow.org Sun May 14 14:51:10 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 14 May 2000 19:51:10 +0100 Subject: really silly nit: why 3+5j instead of 3+5i? References: <ut6T4.1956$kr.256645@paloalto-snr1.gtei.net> Message-ID: <391EF59E.2F6B@seebelow.org> Jeff Petkau wrote: > > Can anyone tell me why Python uses 'j' instead of 'i' for imaginary > numbers? I know this is really minor, but every bloody time I > use complex numbers I forget and type i's, and have to go back > and change them all to j's. My fingers just won't learn. > > [History of imaginary number notation, according to Google: Euler > invented the things, and he used 'i'. Gauss made 'em famous, and > he used 'i'. Everyone since then has used 'i' except for electrical > engineers, and they probably just changed it to cause trouble. We design computers for exactly the same reason. (What could possibly be more aggravating than a thing that does exactly what you tell it? ;-) Actually, we use 'j' because 'i' was already taken as the standard symbol to represent electrical current. OK, so why didn't we just use 'c' for current? Well, I'm glad you asked. It's because 'c' was already taken as the standard symbol for capacitance. (And don't even get me started on the fact that 'r' was already in use for resistance...) Or at least that's the party line. In truth, we use 'j' to represent sqrt(-1) for exactly the same reason we use a convention for the direction of current which is exactly the opposite of the direction the electrons actually travel: because it drives physicists crazy. (And if we pick up a few mathmeticians or whatever along the way, well, that's just gravy. ;-) welcome-to-our-parlors-said-the-spiders-to-the-flys-<wink>-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From emile at fenx.com Thu May 11 15:13:02 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 11 May 2000 12:13:02 -0700 Subject: class instance checking -- newbie Message-ID: <391B063E.4268DBB0@fenx.com> >>> class A: pass >>> a = A() >>> isinstance(a,A) 1 Emile van Sebille emile at fenx.com Tim Northover <tim at pnorthover.freeserve.co.uk> wrote in message news:<m2wvl0ewiz.fsf at pnorthover.freeserve.co.uk>... > I think I need to determine whether an object belongs to a particular > class (specifically whether it is a MatchObject) and I couldn't find > anything very useful in the documentation. Could someone possibly suggest > an answer or point me at the correct part of the docs? > > Thanks. > > Tim N. > -- > http://www.python.org/mailman/listinfo/python-list > From niels at endea.demon.nl Sun May 14 14:52:39 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Sun, 14 May 2000 20:52:39 +0200 Subject: Newbie question: files References: <391D9DD6.35682F94@home.com> Message-ID: <391EF5F7.5172FE14@endea.demon.nl> William Wallace schreef: > > I open a file "a+" > > fd = open(foo, "a+") > > I write some lines to it, taking care to flush after each write. I > read some previously written lines by seeking back to them. > > However, when I seek back to a previously written line, I cannot > update any part of the line. The updates get written to the end of the > file regardless of current position (known from fd.tell()). > > What's up? You asked for append mode, and you got it. If you don't want that, you could do something like open(foo, 'a').close() # make sure the file exists, but don't destroy it fd = open(foo, 'r+') # open existing file for read/write fd.seek(0, 2) # seek to end of file -- Niels Diepeveen Endea automatisering From jkraska1 at san.rr.com Wed May 24 00:01:44 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 24 May 2000 04:01:44 GMT Subject: external modules & interned strings??? Message-ID: <392B54C6.DB1617A1@san.rr.com> Looking over some C external modules of late, it has occured to me that it ought to be possible to reach back into python and to either obtain or create and obtain python interned strings. I've noticed, for example, that getattr often seems to be implemented with strcmp. This seems like a waisted step if you can always be assured that an attr lookup string will be a pythonized interned string. You could, for example, during your initmod "register" the names of your attributes with python (insuring their interned status), and then get hooks to those interned values (yeah, don't mess with 'em), and later when getattr is called just do pointer compares to get to your attributes, saving the more expensive strcmp function call. Thoughts? C/ From ychoi at pipeline.com Sun May 14 23:40:36 2000 From: ychoi at pipeline.com (Yoon S. Choi) Date: Mon, 15 May 2000 03:40:36 GMT Subject: returning SAFEARRAY(double) Message-ID: <391f6f89.1027033@nntp.pipeline.com> I have a COM object method that returns a SAFEARRAY of double (the parameter signature looks like [out] SAFEARRAY(double) *pArray). When I call the COM method from Python, I get the following result: ( 0.0, 0.#INF ). What does #INF mean? I can't find it referenced in any documentation. From g2 at seebelow.org Sun May 14 04:07:41 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 14 May 2000 09:07:41 +0100 Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <391DC8C1.3DB0@seebelow.org> <391CE980.ED16366B@san.rr.com> Message-ID: <391E5ECD.7B53@seebelow.org> Courageous wrote: > > > dynamic typing, but get an automatic error-checking mechanism that > > (eventually) finds these errors. > > For those of us who care, that "eventually" might be a real > stinger. :)- True--and it already _has_ been for me many, many times. Luckily, though, we have the almighty traceback. :-) the-very-finest-puzzles-have-pieces-which-fit-together-perfectly <wink>-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From JamesL at Lugoj.Com Sun May 21 16:44:03 2000 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 21 May 2000 13:44:03 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net><39245ED7.9C3A4FAB@prescod.net><Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu><vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA><cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com><8g58j4$11ei$2@thoth.cts.com><8g6abe$s5m$17$1@news.t-online.com><cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <3.0.6.32.20000520233958.00839560@earthlink.net> <c_PV4.8672$Za1.134344@newsc.telia.net> <3927FA67.94D85CAF@elite.org> <WzSV4.8697$Za1.134806@newsc.telia.net> <349gisk5q40o7n9h8m03e7sr4bbed8tigo@4ax.com> <xgWV4.5173$wYl.218434048@newsb.telia.net> Message-ID: <39284A93.EB6B4312@Lugoj.Com> Fredrik Lundh wrote: > The Alice study only proves that users can memorize the case conventions > used in a single specific library (in this case, the Alice environment), not that > they won't get into trouble again when they stumble upon a library that uses > different conventions. Slow learners until proven otherwise? What target IQ level would you consider an appropriate cutoff? Also, if you wish to be taken more seriously, may I humbly suggest that you avoid posting statements like the following: > Maybe non-geek programmers have better things to do with their time? From thomas at xs4all.net Fri May 26 19:12:58 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 27 May 2000 01:12:58 +0200 Subject: HowCanI: inlined exceptions In-Reply-To: <392EFC4A.5989D50A@uab.edu>; from shapr@uab.edu on Fri, May 26, 2000 at 10:11:59PM +0000 References: <392EE821.714573DD@visionart.com> <392EFC4A.5989D50A@uab.edu> Message-ID: <20000527011258.C13281@xs4all.nl> On Fri, May 26, 2000 at 10:11:59PM +0000, Shae Erisson wrote: > *false in Python is zero, empty string, empty list, empty tuple, or > None, and anything else is true. (unless I'm missing something) Empty dicts are false as well, and class-instances can define for themselves wether they are true or false, by using a method called __nonzero__, I believe. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From m.faassen at vet.uu.nl Fri May 12 15:20:40 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 May 2000 19:20:40 GMT Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> <yayk8h66otu.fsf@ganglot.ifi.uio.no> <jaln1mgdfy.fsf@helix.twistedmatrix.com> <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> <3dr9bdhykv.fsf@amarok.cnri.reston.va.us> <jaitwolwei.fsf@helix.twistedmatrix.com> <3dog6hhqw8.fsf@amarok.cnri.reston.va.us> Message-ID: <8fhli8$nk0$3@newshost.accu.uu.nl> Andrew M. Kuchling <akuchlin at mems-exchange.org> wrote: > Glyph Lefkowitz writes: [snip] >>2) is OCaML-Python free? > I'm not sure what the licence is, but vaguely recall it's the same as > Python's. Could be wrong... I think you're wrong. It's something like "here's the source but it's copyright John Skaller as Jon Skaller wants to find a way to make enough money to eat". At least last I checked. [snip] >>4) Why don't we hear more about this? What is all this jpython hype >>about? ;-) > It's not very widely advertised, perhaps because it's still an alpha. > Some of the extensions seem difficult to implement in CPython or > JPython, but it's quite possible that Vyper could go on to become the > first languages that derives from Python. Those languages will probably be interesting. I've been toying with some language ideas for a while now (since before I discovered Python). Then I discovered Python and it was so much like that language (but a lot better) in some respects that I stopped thinking about it for a while. Now I'm thinking about it again occasionally. I've learned a lot from Python's pragmaticism, focus on readable syntax (just enough sugar to make it read nicely, but not more), and flexibility traded off for speed. I was concentrating way too much on the 'this needs to be optimizable to heck' aspect of language design, and I now realize that's not so important. Maybe in a couple of years I'll start implementing it seriously; maybe not. I bet there are more people in this newsgroup toying with such ideas; in fact it'd be a prerequisite almost to be interested in this, as otherwise it'd be hard to discover Python (at least pre-1998 or so). I know for a fact Tim Peters wants to design a language that has 'foo' and 'bar' as hidden reserve words. :) Off-on-a-tangent-on-top-of-a-tangent-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dgoodger at bigfoot.com Sun May 7 22:53:49 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 07 May 2000 22:53:49 -0400 Subject: Tricks to do "enums"? In-Reply-To: <391618DF.19F55C6C@san.rr.com> References: <391618DF.19F55C6C@san.rr.com> Message-ID: <B53BA28A.2EA7%dgoodger@bigfoot.com> on 2000-05-07 21:27, Courageous (jkraska1 at san.rr.com) wrote: > So, I've been doing module level enums like this: > > ## My module > > VAL1=0 > VAL2=1 > VAL3=3 > > While this works, and gives me great namespace protection > (individuals using my "enum" prefix it with the module name), > I'm wondering if there's any trick that will produce these > without requiring me to renumber them? I'm getting tired > of typing in new numbers for them if I decide to reorder > them or insert elements... Well, if you really meant VAL3=2 (ie, 0, 1, 2, ...; without gaps, a continuous sequence), then you can do this: (VAL1, VAL2, VAL3) = range(3) This also has the advantage of visually grouping the variables. They don't have to start at 0 either; see the docs for the range() built-in function. If your enumeration's values were some other function, you could use map(): (TWO0, TWO1, TWO2, TWO3) = map(lambda i: 2**i, range(4)) This would give you the values [1, 2, 4, 8], useful for bitwise operations. If the variable names were so regular, you could use eval() inside a loop, constructing Python statement strings. Of course, if the variable names are that regular, you might as well use an array... -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From rei05 at gmx.de Fri May 5 13:12:37 2000 From: rei05 at gmx.de (rei05 at gmx.de) Date: Fri, 5 May 2000 19:12:37 +0200 (MEST) Subject: string.replace References: <Pine.LNX.4.21.0005051330240.24093-100000@fep132.fep.ru> Message-ID: <16341.957546757@www15.gmx.net> > On Fri, 5 May 2000 rei05 at gmx.de wrote: > > so i tried string.replace(s,"'","\'"), but this doesn`t work. > sorry, i forgot to mention, that i tried: > > string.replace(s,"'","\\'") > too, but the result of this is like the following: >>> import string >>> s="asdasd'a'asddads" >>> string.replace(s,"'","\\'") "asdasd\\'a\\'asddads" and i wish to have ...\'a\'..., not ...\\'a\\'... -- Sent through GMX FreeMail - http://www.gmx.net From rumjuggler at cryptarchy.org Sun May 14 16:48:40 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 14 May 2000 20:48:40 GMT Subject: threading question References: <u58rhsgdkus2diil2183eqp37ep184sqra@4ax.com> <391EED4A.AE3D641B@endea.demon.nl> Message-ID: <7p4uhs0bjrdubin5e7k8u7938plmqdo84m@4ax.com> On Sun, 14 May 2000 20:15:38 +0200, Niels Diepeveen <niels at endea.demon.nl> wrote: > > >Ben Wolfson schreef: >> cond.notify() #so this should wake thread '2' >> cond.release()#and this should allow it to acquire the condition >> #allowing it to break out of the loop. When it >> #calls notify(), nothing should happen, and then >> #it should release. Instead, thread '2' never >> #acquires the condition in the first place >> #once thread '1' reaches this point. > >By the time thread '1' gets here it has already called cond.acquire() 5 >times, so calling cond.release() just once isn't actually going to >release anything. Then thread '1' will terminate while still owning the >lock, so thread '2' will have to wait forever. Ah. I was under the impression that calling wait() counted as a relese. >BTW, don't you think that this is a rather complicated way to emulate >coroutines? I might if I knew what they were. -- Barnabas T. Rumjuggler There is only one place, and that place is time. -- Russell Hoban, _The Lion of Boaz-Jachin and Jachin-Boaz_ From ivanlan at home.com Fri May 26 14:21:54 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Fri, 26 May 2000 12:21:54 -0600 Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> <slrn8ipqls.nfr.scarblac-spamtrap@flits104-37.flits.rug.nl> <slrn8ird7o.1r1.daniels@localhost.localdomain> <392DF787.6658FCE1@home.com> <392eb619.141603984@news1.on.sympatico.ca> Message-ID: <392EC0C2.1A205641@home.com> Hi All-- Robert Roy wrote: > > On Thu, 25 May 2000 22:03:19 -0600, Ivan Van Laningham > <ivanlan at home.com> wrote: > > >Hi All-- > > > >Alan Daniels wrote: > >> > >> On 25 May 2000 08:56:38 GMT, Remco Gerlich > >> <scarblac-spamtrap at pino.selwerd.nl> wrote: > >> > >> [snip...] > >> >Why the problem with multiple lines and an extra variable here and there? > >> > >> Yes, but the short version reminds me very much of one of my favorite > >> python idioms: > >> > >> lines = open("some_file", "rt").readlines() > >> > > > >If you don't want the newlines, you can do this: > > > >alist=open("some_file","rt").read().split() > > might not work too well with text like: > > this is a test > to see what will happen > if I do a split on this file > I think I will get a lot more > elements > than I bargained for > Again, 1.6 only: ----------------------------------- #!/c/python/python.exe import string import sys if sys.platform=="win32": sps='\r\n' else: sps='\n' if __name__=="__main__": if len(sys.argv)>1: fn=sys.argv[1] else: fn="tsplit.txt" s=open(fn,"rb").read().split(sps) print s ----------------------------------- <more-than-one-way-to-peel-a-grape>-ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From u10555 at dialup.podolsk.ru Sat May 20 12:04:55 2000 From: u10555 at dialup.podolsk.ru (Oleg Orlov) Date: Sat, 20 May 2000 20:04:55 +0400 Subject: odbc.dll vs. mxODBC References: <39266028.212B88C9@xenon.spb.ru> Message-ID: <8g6dht$5k0$2@ns.podolsk.ru> mxODBC is great, but not free. Dmitry Rozmanov <dima at xenon.spb.ru> ??????? ? ???????? ?????????:39266028.212B88C9 at xenon.spb.ru... > Hi. > > What are the pros of mxODBC in comparision with odbc module that comes > with win32 extention to Python? > Currently I use module from extention. Will there be any good if I > install mxODBC. Actually I have all I need. But if mxODBC exists so > there is some reasons, but I don't know them;) :(. > > Thank you. > > ---Dmitry. From mwh21 at cam.ac.uk Tue May 2 11:17:13 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 May 2000 16:17:13 +0100 Subject: How to get the list of imported variables/functions References: <Pine.A41.3.96.1000502110519.31244A-100000@aix2.uottawa.ca> Message-ID: <m366sxj81y.fsf@atrus.jesus.cam.ac.uk> <abouf066 at aix2.uottawa.ca> writes: > Greetings, > > Is there a way to know what variables/functions were imported > from a given module after : > > > from blah_blah import * > > Thanks for your time and help Not directly, but something like: filter(lambda x:not x.startswith("_"),sys.modules['blah_blah'].keys()) should do the trick. Cheers, M. -- nonono, while we're making wild conjectures about the behavior of completely irrelevant tasks, we must not also make serious mistakes, or the data might suddenly become statistically valid. -- Erik Naggum, comp.lang.lisp From andrew.csillag at starmedia.net Wed May 17 12:47:18 2000 From: andrew.csillag at starmedia.net (Drew Csillag) Date: Wed, 17 May 2000 12:47:18 -0400 (EDT) Subject: DCOracle and handling of package OUT parameters broken ?! In-Reply-To: <20000517175359.A4428@sz-sb.de> Message-ID: <Pine.LNX.4.21.0005171246430.12363-100000@naxos.skunk.org> On Wed, 17 May 2000, Andreas Jung wrote: > On Wed, May 17, 2000 at 01:35:01PM +0000, Oleg Broytmann wrote: > > On Wed, 17 May 2000, Graham Bleach wrote: > > > > oci.error: (6502, 'ORA-06502: PL/SQL: numeric or value error: character > > > string buffer too small\012ORA-06512: at "AJUNG.SELECT_LOB", line > > > 22\012ORA-06512: at line 2\012') > > > > > > Hmm, this looks like the buffer mentioned above is the OCI buffer > > > used/created by DCOracle. I'm not familiar with DCOracle (not enough time). > > > Is there anything that's specifically designed to handle CLOBs being > > > returned from Oracle? > > > > DCOracle (or may be OCI) cannot return LOB - you need to SELECT it > > separately. For example, instead of returning the LOB, return ROW ID, and > > then SELECT the row by ID. > > I never tried this in my example! The LOB is read inside > the stored procedure ! > > Andreas Alternatively, you could return a REF CURSOR with the CLOB in it and get it from there. Drew From yosefgold at my-deja.com Tue May 9 07:25:43 2000 From: yosefgold at my-deja.com (yosefgold at my-deja.com) Date: Tue, 09 May 2000 11:25:43 GMT Subject: write() problem Message-ID: <8f8sjh$pi2$1@nnrp1.deja.com> When I open a file (on windows) with open("name",'wb') and I write a string that has a caret "^" in it, the caret gets replaced by a "\S\". Why does this happen and how can I get the caret into the file. Thanks, Yosef Gold yosef at adsc.com PS. Please email responses to my email address as I don't always check the list Sent via Deja.com http://www.deja.com/ Before you buy. From neelk at brick.cswv.com Fri May 19 19:33:10 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 19 May 2000 23:33:10 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> <slrn8hp7ij.bbr.neelk@brick.cswv.com> <8fjhjc$l6k$3@newshost.accu.uu.nl> <slrn8i3fjm.cc.neelk@brick.cswv.com> <8fsgon$jei$1@newshost.accu.uu.nl> Message-ID: <slrn8ibn5t.1te.neelk@brick.cswv.com> Sorry for the slowness in the response, but I've tried to learn about OCaml's object system before responding. Martijn Faassen <m.faassen at vet.uu.nl> wrote: > Neel Krishnaswami <neelk at brick.cswv.com> wrote: > > Martijn Faassen <m.faassen at vet.uu.nl> wrote: > [snip] > >> What about classes and methods though? If you want to optimize some of > >> the dispatching it may be pretty helpful to have static typing. > > > Strong typing doesn't help with dispatch elimination except in > > combination with something like Java's 'final' classes or Dylan's > > 'sealed' classes, or if you do whole-program analysis (like Cecil's > > Vortex compiler does). [...you need to know the exact type of an > > object to eliminate it...] > > Sure, but you could optimize *some* of the dispatching if you did > know the particular class of an object. Right -- the problem is that without some guarantees about the class hierarchy at compile-time, it's impossible to get this knowledge, since someone can always write an expression that creates a new subclass of a class and turns what you thought was the exact class into a set of classes. > > I don't know if anyone has written an OO language that supports type > > inferencing -- I was under the impression that adding subtyping rules > > to Hindley-Milner type systems made them undecidable. > > Hm, I don't know much about ocaml, but the language does some type > inferencing as far as I'm aware, and it supports objects. Perhaps > someone more knowledgable about it (you? :) could comment. I have a big problem in that OCaml refuses to compile on my machine; this is why I haven't played with Vyper very much, darn it. (It's because of my truly ancient libc; I'm probably going to upgrade my Linux this weekend and try again.) What follows is based on just reading the docs and not actually doing any programming -- so be warned it may not be 100% accurate. OCaml *can* infer types for objects. However, there are some odd restrictions on using them polymorphically. For example, if you have a list of objects of some type, you need to "cast" any object you push onto the list to its supertype, and then in subsequent code you can't use any methods that don't exist for that supertype. So something like the following Python is not easy to do. l = [] l.append('ni') l.append(42) print l[0][0] # == 'n' print l[1]**2 # == 1764 The limitations are not a problem in practice because they can use parametric polymorphism where a C++ programmer would use inheritance. > >> Definitely agreed. (method caching may not always be that easy, though, > >> given __getattr__ and friends..) > > > True. I wouldn't mind if there were a smaller hammer than __getattr__, > > though -- usually I want to catch only a few attributes dynamically, > > rather than all of them. > > A nice syntactic hammer for getter/setters might be useful. If you could write methods named __get_foo__ and __set_foo__ to trap references to "obj.foo" without trapping anything else, that would be sweet. It would let you write exactly what you mean, in a way that's friendly to the programmer and any potential compilers. > The tricky parts are classes that play with their methods, objects that > change their classes, etc. Perhaps it's possible to catch these special > cases and have them invalidate the record cache as far as the objects > in question pertain. Oh, this is essential -- you'd need to do it anyway for when subclasses are created, and adding these cases wouldn't be very much additional complexity. > Do I get the ideas right here? I don't have any practical experience > with this. I wonder how much of a speedup one might get compared to the > current scheme. If it isn't significant it's not worth it. > > Also there's of course the question whether dealing will all kinds of > optimization bugs is worth it. This is always the problem with optimization, especially when the semantics are de-facto defined by a single implementation. JPython would be a really good thing if only because it helps keep CPython honest about what's intended and what's an interpreter quirk. > I tend to do that as well. Still, it would be nice if there was a > structured interpreter-checked scheme for this. Sure; I just think these things should be part of the development environment rather than the language definition. Have you seen the MrSpidey static debugger for the Rice DrScheme implementation? It's an adjunct to the development environment that identifies potential type errors in your code, *without* banning it. So you can get the flexibility of dynamically typed languages *and* the safety of a strongly-typed one, and make a tradeoff based on your judgement. Neel From embed at geocities.com Mon May 15 11:02:05 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 15 May 2000 11:02:05 -0400 Subject: Python(path) and the location of the Python DLL. References: <XwOT4.8283$WS3.66942@typhoon.we.rr.com> Message-ID: <wnUT4.20382$HG1.516944@nnrp1.uunet.ca> "Stephen" <stephen at cerebralmaelstrom.com> wrote in message news:XwOT4.8283$WS3.66942 at typhoon.we.rr.com... > Hello, all. > > I'm working on embedding Python into a program i'm working on in C++Builder. > I got past the problem of importing VC++ DLLs into C++Builder by searching > Dejanews, so now before I continue I have a couple questions... > > #1) I'll be using the latest version (1.6a2), but I don't want it to get > involved with any current versions running on the same machine. Is there > anything wrong with me renaming the DLL? This sounds scary. The Windows python implementation checks the Registry to find the python path. If you have two dlls, they'll have PYD files and PY files in the same directory, or else you'll have to build your own version of the python dll, that checks somewhere else in the registry for it's path and so on. Why not just have your installation program check for incompatible DLLs and warn the user when Python is already installed and it's a different version. One of the two versions is newer or better. Plus, I wonder, why are you making plans to ship alpha software as a production release? Silly. Warren From stephen at cerebralmaelstrom.com Sat May 20 01:30:55 2000 From: stephen at cerebralmaelstrom.com (Stephen) Date: Sat, 20 May 2000 05:30:55 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <39260037.146C3467@san.rr.com> <slrn8ic24u.sc3.wtanksle@dolphin.openprojects.net> <39260B99.86CBF73C@san.rr.com> Message-ID: <jqpV4.14725$WS3.142399@typhoon.we.rr.com> Whoa, i'm somewhat thinking that you read WAY too much into that statement, especially considering you took out half of that line. Here, let me add it back in: >> Python is not a democracy. Voting doesn't help. Crying may... :-) Then, later, His Holy Majesty The Creator expressed that they wouldn't be doing anything just arbitrarily and without discussion here/etc... Someone still has to make a decision, though... and having a vision about how you want something to end up (like, i'd assume, His Holy Majesty The Creator should have, being The Creator, and everything. ) would be a rather good thing in the whole decision making process. :-) --Stephen Courageous <jkraska1 at san.rr.com> wrote in message news:39260B99.86CBF73C at san.rr.com... > > > >> Python is not a democracy. > > > > >The success and future of python is a democracy of the most > > >brutal kind. > > > > That's right: and Guido is both the teeming masses AND the guillotine. > > > > Seriously, though, the future of Python is not up to any democracy -- > > because even if a majority doesn't like it, it won't be hurt. We don't > > need any vote (although we can always leave). > > I appreciate what you're trying to say, but if Python ever > becomes a mainstream programming language, I can guarantee > you that it will outgrow Guido. > > I don't know a thing about the Guido, and don't have a thing > against him; to the contrary, I'm rather fond of his language. > (Thanks, Guido!) Be that as it may, there comes a time when the > founder of something ceases to have true dictatorial power > over his creation, sooner or later. > > It's generally a bad idea to opine "it's my way or the highway," > especially in a setting like this, where the more you say it, > the less and less true it will become. Conversely, the more > he listens to what his users have to say, even if it's just > a token vote, the more likely he is to see continued success > and growth of this beautiful language. > > Hope I haven't offended anyone, > > > > C/ From chibaA at TinterlogD.Tcom Tue May 16 20:23:45 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 17 May 2000 00:23:45 GMT Subject: PyApache - scripts now not working References: <3921da5c.338718661@news1.on.sympatico.ca> Message-ID: <3921e65c.341790298@news1.on.sympatico.ca> Alright... I think I've narrowed things down a bit... (keep in mind I'm a bit new to all of this). I think it has something to do with the mxDateTime module which I installed (on the recommendation of of the mySQLdb api). For some reason it doesn't like a certain file in that library (DateTime.py) --> although nothing ever complained before installing pyApache. Any ideas on why this would be so? kc On Tue, 16 May 2000 23:37:47 GMT, chibaA at TinterlogD.Tcom wrote: >... guess the fun just doesn't end with me and PyApache. I finally >managed to recompiile Apache (I had bad .h files with the C library); >and now that PyApache is installed, I get no where with my previously >executable scripts. AAAHHH... If I switch back to my previous >compilation of httpd (or take the AddHandler python-cgi-script .py out >of the httpd.conf file), my scripts work FINE! > >I dunno... should I bare with SLOW script loading times, or not have >any working scripts... hmm.. > >Anyway - if anyone has see this problem, or has any idea on how to >diminish it, could you lend a hand. Thanks so much. > >Here's the error that I'm getting in the apache error log: > >>[Tue May 16 19:22:40 2000] [error] access to /home/httpd/html/admin/search_user. >>py failed for 192.168.0.1, reason: the script raised an unhandled exception. Script's traceback follows: >>Traceback (innermost last): >> File "/home/httpd/html/admin/search_user.py", line 4, in ? >> import MySQLdb >> File "/usr/lib/python1.5/MySQLdb.py", line 55, in ? >> from DateTime import Date, Time, Timestamp, ISO, \ >> File "/usr/lib/python1.5/site-packages/DateTime/__init__.py", line 20, in ? >> from DateTime import * >> File "/usr/lib/python1.5/site-packages/DateTime/DateTime.py", line 817, in ? >> def add_century(year, >>TypeError: call of non-function (type None) > >---- >Which is incredibly puzzling, because I never used anything relating >to dates. I suppose it's choking on the mysql api for python, but I >don't understand why? Any ideas? > From thomas at cintra.no Fri May 26 10:07:30 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 26 May 2000 14:07:30 GMT Subject: XML-package for Windows Message-ID: <39368488.1408207755@news.online.no> Hi, Where is the SIG`s xml-package for Windows?? Thomas From peter.milliken at gtech.com Wed May 17 22:59:07 2000 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 18 May 2000 12:59:07 +1000 Subject: ANNOUNCE: Language Sensitive Editing for Emacs users with Python Message-ID: <8fvmbk$seb10@news1.gtech.com> Hi, I am pleased to announce the release of 1.3 of the Python language templates for use with Emacs. In combination with the minor mode, ELSE (Emacs Language Sensitive Editor) these language templates provide true language sensitive editing for python mode i.e. syntax is general by the editor and the programmer "fills in the blanks" (ELSE is a true minor mode and will work with any language major mode provided a set of language templates are available, the web site includes template files for C, Ada, Emacs-Lisp and Latex, more are coming "every day" i.e. there is someone working on a set of templates for SQL). Of course, many programmers do not like this functionality/help from an editor as they either prefer to type in all of the keywords and language structures themselves and then finding all of those missing ':' etc during the edit/compile cycle or they are contractors who are paid by the hour and the last thing they want is to be productive! For those individuals who enjoy this kind of masochism, pls ignore this message! :-) For more information and a copy of the relevant files, pls visit: http://members.xoom.com/pmilliken regards Peter P.S. For those who would like to see ELSE in action by a real user, have a look at http://home.hetnet.nl/~vandamhans/movies/moviesindex.htm These movies trace some recent developments of ELSE showing improvments added for programmers who have RSI and are therefore forced to using Voice Recognition for their programming activities. But they are useful to show the power and functionality ELSE to people who are keyboard bound :-) If your time or bandwidth is limited then I suggest that you download the last video as it shows the best use of ELSE. From cjensen at bioeng.ucsd.edu Mon May 8 16:15:10 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Mon, 08 May 2000 13:15:10 -0700 Subject: Fortran and python References: <8evrsl$9qt$1@nnrp1.deja.com> Message-ID: <3917204E.50837831@bioeng.ucsd.edu> I'm writing an interface to a HUGE fortran program. I've tried both f2py2e and pyfort, and had e-mail contact the writers of both. I much prefer f2py2e. It does everything pyfort does and more. Plus Pearu Peterson (The author of f2py2e) is pretty good about helping out if you get stuck. f2py2e is easier, and has more features. f2py2e even handles common blocks. I prefer f2py2e. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From frohne at gci.net Tue May 23 03:53:15 2000 From: frohne at gci.net (Ivan Frohne) Date: Mon, 22 May 2000 23:53:15 -0800 Subject: Random numbers References: <000401bfc45d$882e46c0$9ea2143f@tim> Message-ID: <sike93qvo1131@corp.supernews.com> "Tim Peters" <tim_one at email.msn.com> wrote in message news:000401bfc45d$882e46c0$9ea2143f at tim... > [Russell Wallace] > > Is there any difference between the random number generator in the > > 'random' module and that in the 'whrandom' one? > > No, but you shouldn't use whrandom: whrandom is an interal implementation > detail of random.py. whrandom.py should probably be renamed to _whrandom.py > (or something) to stop people from tripping over it. > > > What's the quality You can find the algorithm used in whrandom.py and random.py (in Fortran 77) at http://lib.stat.cmu.edu/apstat/183 . It was published in the Journal of Applied Statistics in 1982, and is now a little long in the tooth. The period is about 7e12, which you might think is large, but, when you get right down to it, it's not large enough. In fact, an alternative algorithm with period 2e18 is now recommended at the site listed above. But the truth of the matter is, random.py will give you perfectly fine uniform random numbers for most purposes, if you're not too fussy, and don't need hundreds of millions of them. > If you know enough about random numbers to understand an answer to that > question, then telling you it's the standard Wichman-Hill (that's where "wh" > comes from) generator is all the answer you need <wink>. Seriously, test it > and determine whether it's adequate for your application; if you can't test > it objectively, then you have no way of knowing whether any other package is > adequate either (and neither does anyone else, so don't ask). > > Ivan Frohne wrote a very nice package of stronger generators, which should > be available from his Starship page. But unless you're doing extreme work, > WH should be adequate for a start. Any serious program relying on random > numbers should be tested with at least two distinct generators, though, and > Ivan's pkg is great for that. Thanks for the plug, Tim. I got lazy, though, and didn't move the module when the Starship was born again. I'll have it up again in a few days, though, and will publish the new location then. There's a new package in the works with some new stuff. --Ivan Frohne From jkraska1 at san.rr.com Mon May 29 18:43:23 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 29 May 2000 22:43:23 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <sj3ejda85pj169@corp.supernews.com> <hjoY4.6071$wYl.223614464@newsb.telia.net> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> Message-ID: <3932F323.C73E0404@san.rr.com> > In my very humble opinion > words = ["foo", "bar", "baz"] > print words.join(" ") > looks right and > print " ".join(words) > looks wrong. It will confuse people and provoke programming errors. This is right on the mark. One of these is obvious. The other is not. Out of couriousity, would you expect... ( "foo", "bar" ).join() ... to be a correct idiom as well? > So I say: Implement the easy generalized join() and fiddle the > optimization for the string-join in. Python programmers won't > mind some hidden ugliness in the C code if they are rewarded > with better looking Python code. True. C/ From mwh21 at cam.ac.uk Sat May 27 18:51:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 May 2000 23:51:25 +0100 Subject: Beginners' Question -- Assigning variables in a lambda References: <m37lchjgri.fsf@atrus.jesus.cam.ac.uk> <memo.20000527233241.53509A@digitig.compulink.co.uk> Message-ID: <m3puq7ip3m.fsf@atrus.jesus.cam.ac.uk> digitig at cix.co.uk (Tim Rowe) writes: > In article <m37lchjgri.fsf at atrus.jesus.cam.ac.uk>, mwh21 at cam.ac.uk > (Michael Hudson) wrote: > > Thanks. Pleasure. > I'm not really comfortable with either, though. In my version, > handler will have quite a few keys but two or three actual > handlers. Your first solution assumes that all keys are handled in > essentially the same way Yes. My telepathy was obviously having an off day... > (sorry, I may have wrongly implied that when I said what > get_number() does). The second solution involves writing a separate > handler for each key (ok, so does my failed lambda solution, but > it's more compact!) What I really want to do is assign one of the > few handlers to each key. All the handlers will assign to a variable > which I would really like to be in the local scope of the call, but > global scope would do, but they will derive the variable in > different ways. For example, the one I've shown interprets the > parameter as a string representation of a number and converts it to > a numerical representation; another will force the parameter into > string form. Hmm. Do you really, really need the options to go into variables? Couldn't you do something like this: options = { # fill out for defaults "bandwidth": 300, ... } def mksetter(var,val): exec """\ def setter(input): options[%s] = %s """ return setter opthandlers = { "b" : mksetter("bandwidth","eval(input)"), ... } Most methods of actually setting variables are likely to be somewhat fragile. Anyway, it's getting late and I'm probably not helping, so I'll stop for now. > By the way, I don't mind you asserting on user data. [snip] Err, yes you do, because if you run python with -O as an command line option, asserts don't get executed (repeat after me: "assertion failure's are program bugs"). Cheers, M. -- nonono, while we're making wild conjectures about the behavior of completely irrelevant tasks, we must not also make serious mistakes, or the data might suddenly become statistically valid. -- Erik Naggum, comp.lang.lisp From boncelet at udel.edu Mon May 8 00:24:33 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 08 May 2000 14:24:33 +1000 Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> <slrn8hcibb.331.nascheme@cranky.arctrix.com> Message-ID: <39164180.272C505F@udel.edu> Thanks for the help. My problem is that the background variable was set to 'dark', not 'light'. (I noticed this when I asked vim to save the file as html and noted that the html file had a black background and the colors looked good with that background.) Charlie Boncelet -- ------ Charles Boncelet, University of Delaware, On sabbatical at ADFA, Canberra Australia, Home Page: http://www.ece.udel.edu/~boncelet/ From emile at fenx.com Sat May 27 20:16:06 2000 From: emile at fenx.com (emile at fenx.com) Date: Sat, 27 May 2000 17:16:06 -0700 Subject: coverting numbers to strings Message-ID: <39306546.9DB21A82@fenx.com> I'm not sure what's going on, but your post is littered with what looks to be hex representation of high order ascii characters. What you may be asking for is the chr() function. >>> print chr(65) A >>> print ord('A') 65 HTH, BTW, does anyone know if these characters are being generated on my end or on the sending end? Emile van Sebille emile at fenx.com Z 3 Penguin <z3penguin at penguinpowered.com> wrote in message news:<8gpnqb$ki7$1 at bob.news.rcn.net>... > i want to convert an integer to a string contaning the bytes for that value, > i.e > > +AD4- a+AD0-300 > +AD4- b+AD0- func(a) > +AD4- for i in len(b): > ... print ord(b+AFs-i+AF0-) > ... > 1 > 44 > +AD4- > > > -- > ----- > Z 3 Penguin > z3p+AEA-z3penguin.org > > () > (o+AF8- > //+AFw- > +ADw--+AFwAXw-/ > > This is a virus that works on the honor system. Send this .sig to everyone > in your address book and randomly delete some of your files. > > -- > http://www.python.org/mailman/listinfo/python-list > From garabik at center.fmph.uniba.sk.spam Mon May 8 15:39:04 2000 From: garabik at center.fmph.uniba.sk.spam (Radovan Garabik) Date: 8 May 2000 19:39:04 GMT Subject: Block comments? References: <391653B7.2F38A7F2@san.rr.com> Message-ID: <8f754o$flg$1@sunnews.cern.ch> Courageous <jkraska1 at san.rr.com> wrote: : Okay, it's not like I'm not looking in my documentation or anything, : but if this is available, it's not obvious. How do you express : python block comments? comment = 0 . . . if comment: you block comment goes here . . . -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik | | __..--^^^--..__ garabik @ fmph . uniba . sk | ----------------------------------------------------------- From mhammond at skippinet.com.au Sat May 13 15:50:47 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 13 May 2000 19:50:47 GMT Subject: compiling extension errors References: <4ZhT4.5034$WS3.42757@typhoon.we.rr.com> Message-ID: <rmiT4.2192$Kc3.13483@news-server.bigpond.net.au> "Pete Shinners" <pshinners at mediaone.net> wrote in message news:4ZhT4.5034$WS3.42757 at typhoon.we.rr.com... > i'm getting in touch with the author of the module, but i'm trying > to compile with extension under win32, with visc6. You can either add a command line option to compile the code as C++, or change the header: > > static PyTypeObject CD_Type = > { > PyObject_HEAD_INIT(&PyType_Type) To: > PyObject_HEAD_INIT(NULL) And in your module init function add: CD_Type.ob_type = &PyType_Type; Or something like that! Mark. From db3l at fitlinxx.com Wed May 24 18:05:41 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 May 2000 18:05:41 -0400 Subject: commands.getstatusoutput on NT References: <857F15D7E3D8D3118D290008C7CF058601347C3A@mail-naeast1.brooks.com> <usnv78v24.fsf@ctwd0143.fitlinxx.com> Message-ID: <upuqb8uyy.fsf@ctwd0143.fitlinxx.com> David Bolen <db3l at fitlinxx.com> writes: (...) > For example, the command: > > s,r = commands.getstatusoutput("dir") > > could be replaced with: > > pipe = os.popen("dir 2>&1") > r = pipe.read() > s = pipe.status() Small correction to my prior post - the final line should read: s = pipe.close() -- -- 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 emile at fenx.com Fri May 12 15:59:24 2000 From: emile at fenx.com (emile at fenx.com) Date: Fri, 12 May 2000 12:59:24 -0700 Subject: New to Python. Help. Message-ID: <391C629C.B52A89F2@fenx.com> Ron, What happens if you type these commands into the interpreter? Emile van Sebille emile at fenx.com Ron Holloway <ron at itec.co.za> wrote in message news:<8fhkv7$86n$1 at ctb-nnrp2.saix.net>... > Hi, > > Below is my first Python program. What I want to do is start the mail queue > for my domain on my ISP's mail server. If I use the commands via a telnet > session all works fine. My Python program however fails. The strange thing > is in both cases the mail log on the ISP side shows the ERTN command and no > errors. I've tried time.sleep(2) and even time.sleep(100) after the > commands thinking that the program may be doing things to fast. The debug > also shows the expected output from the mail server. > > I'm using Python 1.5.1 on FreeBSD3.0 and my ISP is using Sendmail 8.9.3 on a > FreeBSD3.0 server. > > What am I missing? > > Thanks, > Ron > > > #! /usr/local/bin/python > > import rfc822 > import smtplib > > server = smtplib.SMTP() > server.set_debuglevel(1) > server.connect('mail.spoolforme.com') > server.ehlo('me.yourclient.com') > server.docmd('ETRN @yourclient.com') > server.quit() > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From dale at out-think.NOSPAMco.uk Thu May 18 20:27:51 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 19 May 2000 01:27:51 +0100 Subject: How to get volume name under Win32? References: <074701bfc122$d57310c0$1906a8c0@fc.fenx.com> Message-ID: <8g21qi$dm4$1@supernews.com> In fact ,I can't get os.popen to work at all! -- Dale Strickland-Clark Out-Think Ltd, UK Emile van Sebille <emile at fenx.com> wrote in message news:074701bfc122$d57310c0$1906a8c0 at fc.fenx.com... > Dale, > > It seems this came up recently with a legitimate way of getting > directly to the label using win32 extensions, so you may want > to look for that, but in the meantime, this gets you there with > a little parsing: > > import os > info = os.popen(r'dir x:\missing.ext').readlines() > info[1] > > or at least here on win95 info[1] holds the volume name. > > HTH, > > Emile van Sebille > emile at fenx.com > > Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote in message > news:<8g1tn6$cf2$1 at supernews.com>... > > I can't find a function that'll tell me the volume name for a given > drive > > letter - on NT / Win2000 > > > > Can anyone help? > > > > Thanks > > > > -- > > Dale Strickland-Clark > > Out-Think Ltd, UK > > > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > > > From mwh21 at cam.ac.uk Tue May 30 18:19:50 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 May 2000 23:19:50 +0100 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <8h1ama$nd8$1@newshost.accu.uu.nl> Message-ID: <m3r9ajy92x.fsf@atrus.jesus.cam.ac.uk> m.faassen at vet.uu.nl (Martijn Faassen) writes: > Paul Magwene <paul.magwene at yale.edu> wrote: > > < news of the impending move to PythonLabs snipped> > > > Oddly enough, I found the most exciting part of this announcement (other > > than the news that Guido et al. will be devoting their full efforts to > > Python) to be the fact that I can now put a face to the name "Tim > > Peters" (see http://www.pythonlabs.com/team.html ). > > Me too. I wanted to post this! A face for Tim Peters! Yay! > > > That photo isn't a fake, is it? > > Of course it's a fake. You didn't see any mention of the PSU in that FAQ > either, did you? This is all going exactly according to plan. We need > to be prepared for the Whitespace Invasion in 2010. > > And-what-about-Gordon-McMillan-hm?-ly yours, Gordon's easy, as he both has a website and has a picture of himself on it: http://starship.python.net/crew/gmcm/ (at the bottom). Cheers, M. -- (Of course SML does have its weaknesses, but by comparison, a discussion of C++'s strengths and flaws always sounds like an argument about whether one should face north or east when one is sacrificing one's goat to the rain god.) -- Thant Tessman From olipt at mayo.edu Mon May 29 22:21:39 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Mon, 29 May 2000 21:21:39 -0500 Subject: DECREFing and PyArray functions in C Extensions In-Reply-To: <290520001435150983%pecora@anvil.nrl.navy.mil> References: <Pine.LNX.4.10.10005260829500.11428-100000@us2.mayo.edu> <ya0hfbig5g7.fsf@trymheim.ifi.uio.no> <290520000802122720%pecora@anvil.nrl.navy.mil> <393262F3.9CD9CFBB@tismer.com> <ya04s7hcox1.fsf@trymheim.ifi.uio.no> <290520001435150983%pecora@anvil.nrl.navy.mil> Message-ID: <Pine.LNX.4.10.10005292111330.17593-100000@us2.mayo.edu> > In article <ya04s7hcox1.fsf at trymheim.ifi.uio.no>, Roger Hansen > <rogerha at ifi.uio.no> wrote: > > > Now assume I have an extension where a C function should create and > > return a NumPy array. > > > > static PyObject * > > foo_retarray(PyObject *self, PyObject *args) > > { > > int length, i; > > double x; > > double* a; > > PyArrayObject *array; > > > > if(!PyArg_ParseTuple(args, "i", &length)) > > return NULL; > > > > array = (PyArrayObject *) > > PyArray_FromDims(1, &length, PyArray_DOUBLE); > > > > a = (double*) array->data; > > for (i = 0; i < length; i++) { > > x = (double) i/(length-1); > > a[i] = f(x); > > } > > > > return PyArray_Return(array); > > } > > > > Should I DECREF array here before the return? > > I'll take a stab at this and say, no. Using PyArray_Return(array) > automatically DECREFs the array. > Thanks for helping out here. This is the right answer but not the correct reason. You don't DECREF the array because you want to return the array (with it's reference count). If you DECREF the array, the Py_DECREF routine will free the memory created with PyArray_FromDims. My "general" rule doesn't apply when you want to return the array you've created in C. > > > If we rewrite it like this > > > > static PyObject * > > foo_retarray2(PyObject *self, PyObject *args) > > { > > int length, i; > > double x; > > double* a; > > > > if(!PyArg_ParseTuple(args, "i", &length)) > > return NULL; > > > > a = malloc(length*sizeof(double)); > > for (i = 0; i < length; i++) { > > x = (double) i/(length-1); > > a[i] = f(x); > > } > > > > return PyArray_FromDimsAndData(1, &length, PyArray_DOUBLE, (char*) a); > > } > > > > I'm sure we don't have to DECREF anything. But is this a good way to > > create a NumPy array in C? No, this is not the recommended way to do it. Sometimes you have to do it this way though (to link against C codes which allocate their own memory) or to make the memory Fortran COMMON blocks look like arrays. PyArray_FromDims creates it's own memory while PyArray_FromDimsAndData does not create its own memory. The array returned from PyArray_FromDimsAndData also does not set a flag so the object destructor routine (called automatically when reference count gets to zero) does not free the memory pointed to by data member of the structure. As a result, PyArray_FromDimsAndData requires more attention from the programmer because it can easily create a memory leak. > > Hmmm...I would have said, yes. You malloc the memory, then return a > pointer, but you Must DECREF when any Pyarray is created, unless you > use return PyArray_Return(obj) or PyArray_BuildValue with the "N" > construct (quoting Travis). In fact, I would say you have created two > memory leaks. One with the C array through malloc and the other with > the PyArray created through PyArray_FromDimsAndData. I don't think the > latter uses the C allocated memory, but allocates its own. Not sure, > but I would check this out PyArray_FromDimsAndData does not allocated memory for the data member but uses the supplied pointer. The programmer is responsible for making sure such memory is later deallocated when using this call. That's why it is not recommended use. -Travis From mark at chem.uwa.edu.au Sat May 13 08:56:37 2000 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 13 May 00 12:56:37 GMT Subject: NaN again - and IEEE arithmatics References: <LNBBLJKPBEHFEDALKOLCCEALGAAA.tim_one@email.msn.com> Message-ID: <mark.958222597@declan> "Tim Peters" <tim_one at email.msn.com> writes: >THere's nothing you can do that's guaranteed to work. Here's a way to make >a NaN that's quite *likely* to work on any IEEE-754 platform, though: >>>> Inf = 1e300**2 >>>> NaN = Inf - Inf >>>> NaN >-1.#IND >>>> Inf >1.#INF >>>> >Since that was a Windows session, that's how Microsoft happens to spell NaN >and infinity these days. Unfortunately, on a real <0.3 wink> operating system (Tru64 Unix on Compaq Alpha) this code fragment produces a core dump: Python 1.6a2 (#99, May 12 2000, 08:21:33) [C] on osf1V4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> Inf = 1e300**2 Floating exception (core dumped) Cheers, Mark -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From wlfraed at ix.netcom.com Sun May 14 17:54:49 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sun, 14 May 2000 14:54:49 -0700 Subject: (gulp) newbie question - portablity of python References: <LsCT4.65940$fV.4043974@bgtnsc05-news.ops.worldnet.att.net> Message-ID: <ro6uhs4m559ifgpa7h6l3i061chkboq96n@4ax.com> On Sun, 14 May 2000 18:42:51 GMT, "Keygrass" <nospam at sorry.com> declaimed the following in comp.lang.python: > > So ... my question is this: Is this really too good to be true? What I want > to do it write the program on my Win98se (at home) and then use that .exe > or .bat file (or whatever extension it is) at work which uses unix. > After looking at the other four responses first... The core Python language is common on all those different systems, but... you do need to have the Python interpreter and libraries for that system installed. You don't normally produce the equivalent of an ".exe" file in Python (there is a way to do that, but the resulting file then becomes system specific because it includes the interpreter as part of the file). Instead, you invoke the Python interpreter feeding it your program. So in your example, you would need to have the Windows version of the interpreter installed at home, and the proper UNIX version installed at work. You can then take your program source, after debugging it at home, and run it on the UNIX machine. As long as you didn't use any system specific libraries (Windows COM, Amiga AREXX port, etc.) the file should run. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From che at debian.org Thu May 11 22:16:38 2000 From: che at debian.org (Ben Gertzfield) Date: 11 May 2000 19:16:38 -0700 Subject: [Solved] Re: Opening a file in O_NONBLOCK mode References: <ytt1z3834kl.fsf@gilgamesh.cse.ucsc.edu> Message-ID: <yttsnvo1pix.fsf@gilgamesh.cse.ucsc.edu> Oops. I hadn't looked closely enough at the os module; I found that os.open will take os.O_RDONLY and os.O_NONBLOCK as arguments. :) I decided to go from: fd = open(dev) to: fd = os.fdopen(os.open(dev, os.O_RDONLY | os.O_NONBLOCK)) I assume this'll be just about equivalent, which allows me to keep the interface the same for my module (important to me!). Ben -- Brought to you by the letters D and O and the number 19. "Nerd. Loser. Jerk. Moron. Worm. Scum. Idiot. Fool." Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/ From bjorn at roguewave.com Fri May 19 18:51:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 19 May 2000 16:51:31 -0600 Subject: Python COM Server References: <kejV4.1138$283.21700@news6-win.server.ntlworld.com> Message-ID: <3925C573.7EE3EA69@roguewave.com> I believe your problem is that VB is calling SplitString with the default argument (i.e. None), and then you are passing it (None) to string.split, ie. your call is string.split(str(val), None). I would probably code it like: def SplitString(self, val, item=None): import string if item is None: item = '' else: item = str(item) return string.split(str(val), item) -- bjorn Chris wrote: > > I am trying to build a COM object with Python that I can reference from VB. > I have followed examples in Python-programming on Win32 and from other > sources. I manage to register the COM objects and in VB it does the > "CreateObject" bit but will not allow me to call a method of one of my COM > objects. > > I am a final year degree student trying to build a simple COM/CORBA bridge > demonstration using Python, so if anyone can help I would really appreciate > it. > > This is my Python code; > > #PythonSplitutil > #Chris Rowley > #12 May 2000 > class PythonSplit: > _public_methods_ = ['SplitString'] > _reg_progid_ = "PythonDemos.Split" > _reg_clsid_ = "{2222EEB8-790E-4B9D-B8F6-41E05A4A0F2D}" > > def SplitString(self, val, item=None): > import string > if item != None: item = str(item) > return string.split(str(val), item) > > if __name__=='__main__': > print "Registering COM Server..." > import win32com.server.register > win32com.server.register.UseCommandLine(PythonSplit) > > And this is the VB code which fails; > > Private Sub Command1_Click() > Dim pu As Object > Set pu = CreateObject("PythonDemos.Split") > Dim r As Variant > r = pu.SplitString("hello from VB") '** > MsgBox r > End Sub > > It fails on the line marked ** with error message "Run-time error '438' > Object doesn't support this property or method" > > I presume from this that the object is registered but the method isn't? Is > there a make type library function that I am missing? > > Chris Rowley > > -- > Chris Rowley > > -- > http://www.python.org/mailman/listinfo/python-list From dan at cgsoftware.com Fri May 19 00:52:31 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Fri, 19 May 2000 00:52:31 -0400 Subject: C++ extension module crashes on Solaris In-Reply-To: <3924E2AA.D16E140@python.org> Message-ID: <BAEMJNPFHMFPEFAGBKKACEMICBAA.dan@cgsoftware.com> > > I suggest posting some source code if you expect help. It's probably a > simple > bug in your code but it's hard to spot without looking at your code. > > You seem concerned about threads. are you starting threads in your C code > that > will call on Python? If so, that's where the problem is -- you have to > study > the C/API docs carefully regarding the interpreter lock. > No offense Guido, but you are probably completely off base. I'll put money it's a shared library problem. I remember someone running into this problem on SunOS before, and i've personally run into it on FreeBSD. In fact, if you just compile on freebsd-current, with the modules shared, without using the version of python in the FreeBSD ports system, and then do something as simple as "import time" or "import zlib" (IE import a shared module), you'll get the same error. As soon as i wake up, if someone hasn't posted the fix, i'll do it (It's very late, it escapes my brain). --Dan From tsummerfelt1 at myspleenhome.com Sat May 13 19:07:01 2000 From: tsummerfelt1 at myspleenhome.com (tony summerfelt) Date: Sat, 13 May 2000 23:07:01 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> <slrn8hdj3i.47b.tsummerfelt1@co146453-a.kico1.on.wave.home.com> <ur9bc7i3p.fsf@ctwd0143.fitlinxx.com> <slrn8hggff.lv.tsummerfelt1@co146453-a.kico1.on.wave.home.com> <qJXR4.3419$wYl.205175296@newsb.telia.net> <slrn8hldl0.d0.tsummerfelt1@co146453-a.kico1.on.wave.home.com> <6XyS4.6757$Za1.105942@newsc.telia.net> Message-ID: <slrn8hrnu6.85u.tsummerfelt1@co146453-a.kico1.on.wave.home.com> On Thu, 11 May 2000 13:53:06 GMT, Fredrik Lundh wrote: > > python questions i have? > oh, you only want answers from people who can read perl huh? ok. i don't need to be kicked in the head to get the point. i imagine i'll check out python again sometime in the future. maybe i'll even pop in here again when i do. here's one for everyone: major-disappointment-at-the-python-crowd-ly y'rs -- *---------------------------------------- | |http://members.home.net/tsummerfelt1 | |remove myspleen to email | *----------------------- From pshinners at mediaone.net Sun May 14 00:13:05 2000 From: pshinners at mediaone.net (Pete Shinners) Date: Sun, 14 May 2000 04:13:05 GMT Subject: Augmented assignment (ie. += and friends) for Python! References: <m3d7mus359.fsf@atrus.jesus.cam.ac.uk> <slrn8hjal5.698.wtanksle@dolphin.openprojects.net> <m3n1lwr9os.fsf_-_@atrus.jesus.cam.ac.uk> <m3itwjr57s.fsf@atrus.jesus.cam.ac.uk> <20000513150320.I13281@xs4all.nl> <391D6460.9DB4E0DD@san.rr.com> <m3zopupi59.fsf@atrus.jesus.cam.ac.uk> <391DCB77.BE90801@san.rr.com> Message-ID: <lJpT4.5861$WS3.49372@typhoon.we.rr.com> > > No, he didn't, because he knows they're spelt "&=" and "|=" and he > > supports them. Maybe you should check these things before posting? > > Possibly. Puzzled, however, what someone could possibly mean by &&=? heh, & and | or the 'C' bitwise AND and OR operators. these are handy for adding and stripping values from a bit flags value windowStyle |= WS_VISIBLE; windowStyle &= ~WS_MAXIMIZED; that sort of thing in C. just my penny, but i highly vote for these assignment variables also. i think the code is a lot prettier with the += cousins. heck, if i could do 'VAR += 1', instead of 'VAR = VAR + 1' i could even do without the '++' increment style operators From andy at reportlab.com Mon May 22 10:35:11 2000 From: andy at reportlab.com (Andy Robinson) Date: Mon, 22 May 2000 15:35:11 +0100 Subject: Microsoft-style format strings Message-ID: <PGECLPOBGNBNKHNAGIJHAEADCCAA.andy@reportlab.com> Has anybody written anything analogous to the VB-style format function? This would be able to do format("$#,##0.00", someAmount) or format("ddd dd-mmm-yyyy", someDate) Hoping-to-save-an-hour-or-two-ly y'rs, Andy Robinson From ppetru at coltronix.com Wed May 10 11:21:46 2000 From: ppetru at coltronix.com (Petru Paler) Date: Wed, 10 May 2000 18:21:46 +0300 Subject: Why should I switch to Python? In-Reply-To: <Pine.WNT.4.21.0005100933150.263-100000@nt_alester>; from andy@petdance.com on Wed, May 10, 2000 at 09:34:21AM -0500 References: <seas5ia89177@corp.supernews.com> <3919D30A.74DE@seebelow.org> <8fateo$5h1$1@216.39.141.21> <391A613B.2154@seebelow.org> <Pine.WNT.4.21.0005100933150.263-100000@nt_alester> Message-ID: <20000510182146.C674@coltronix.com> On Wed, May 10, 2000 at 09:34:21AM -0500, Andy Lester wrote: > > Speaking of C, I find myself missing the "x=" operators, and "++". > > However, I understand and endorse the reasons Python omits them. > > I understand, but I wish that there would be a warning of some kind. I > had a hell of a time debugging some code that didn't work because I used > "++n". By the way, what are those reasons for not including ++, -- and friends ? -Petru From erik.wilsher at iname.com Tue May 23 02:49:34 2000 From: erik.wilsher at iname.com (Erik Wilsher) Date: Tue, 23 May 2000 06:49:34 -0000 Subject: (no subject) In-Reply-To: <025b01bfc45c$14aa3e80$1906a8c0@fc.fenx.com> Message-ID: <8gd9lu+ke8u@eGroups.com> --- In python-list at egroups.com, "Emile van Sebille" <emile at f...> wrote: > You're probably using a name that wasn't previously > a file in that directory, so the file is created, > and therefore empty when you read it. Try putting > a text file there, then reading it. Yes, and in addition try to use "raw" strings or double backslashes in the file-name argument of the open call. >>>f=open(r'c:\temp\myfile.txt','r') >>>f=open('c:\\temp\\myfile.txt','r') Erik Wilsher > ----- Original Message ----- > From: Phoon, David <DPhoon at a...> > >> hi >> >> >> I am trying out the tutorial to file reading and writing and when I > run >> python in nt >> eg >>> f=open('c:\temp\myfile.txt','r') >> >>> f.read() >> yields a blank string..."" >> From m.faassen at vet.uu.nl Thu May 25 08:31:38 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 25 May 2000 12:31:38 GMT Subject: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <ja7lctey7i.fsf@helix.twistedmatrix.com> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3o85$esa$1@news.hants.gov.uk> <392706CC.6DEE@seebelow.org> <8gau6q$bhu$1@newshost.accu.uu.nl> <392AF801.44C@seebelow.org> <8gdkgb$nju$1@newshost.accu.uu.nl> <Pine.SOL.4.05.10005240841350.13628-100000@spgsun1.arlut.utexas.edu> Message-ID: <8gj6fa$iqm$1@newshost.accu.uu.nl> Edward S. Vinyard <vinyard at arlut.utexas.edu> wrote: > On 23 May 2000, Martijn Faassen wrote: >>I never used that. 'for' loops are generally more clean and more >>extensible in Python. I only find myself using map() rarely, filter() >>even more rarely, and reduce() hardly at all. Of course your mileage may >>vary. > How are 'for' loops more extensible in Python? When you do a map(), you can either call an existing function, or use lambda. If you can alter the existing function that you call from mamp(), map can be extended fairly easily. Ofter you're calling a library function or a builtin function however, or you're using lambda. Neither of these can be easily extended with new functionality. When you have a for() loop that calls a library function, it's easy to add a few extra statements when you want to extend the behavior of the for loop. Perhaps you want to count something. Perhaps you want to break from the loop early in some cases. It's all easy if you started out with a for loop. That's what I mean with 'more extensible'; of course you can swap from map() to a for loop when it becomes necessary, but I prefer having the loop there already, myself. [snip] >>I think Guido's idea here is you shouldn't use those a lot anyway. It's >>said he rather regrets adding 'lambda' to the language, after all. Not >>that this kind of functional programming can't be fun. > Why should we avoid these functions? I think the idea is that lambda looks ugly, and is harder to extend cleanly (and there's no lexical scoping and hacks to get around it, etc). I'm not saying you should *avoid* map() and friends, just that perhaps the general patterna would be that you don't use them a lot. Of course your mileage, as said before, may vary. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From garabik at melkor.dnp.fmph.uniba.sk.spam Mon May 15 15:41:59 2000 From: garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) Date: 15 May 2000 19:41:59 GMT Subject: popen2 + passwd References: <391F78CC.362C5D12@flashmail.com> Message-ID: <958419676.155123@cdwork.cvt.stuba.sk> Jp Calderone <exarkun at flashmail.com> wrote: : Can anyone tell me why this doesn't work? : import popen2 : i, o = popen2.popen2('passwd bin') : pwd = '12345ASD' : o.write(pwd + '\n') : o.write(pwd + '\n') : i.close() : o.close() : Running it through the interpreter yields no output (as it should), : but the password for the bin user doesn't change to what I'd expect : it to (12345ASD), but to something else. how do you know it changed to something else? -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From cwr at crash.cts.com Tue May 23 00:03:29 2000 From: cwr at crash.cts.com (Will Rose) Date: 23 May 2000 04:03:29 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <20000522183552.A29224@mudge> <8gcoij$60n$1@news-int.gatech.edu> Message-ID: <8gcvuf$11e3$1@thoth.cts.com> Andrew Henshaw <andrew.henshaw at gtri.gatech.edu> wrote: : Ben Cornett wrote: :> :>this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". :> : ...snip... : The interesting thing about this is that I could read it. A case-insensitive : compiler couldn't handle a single case flip. That's why I don't understand : the argument that (English-speaking) humans are case sensitive. In general : we're not. We prefer that everyone follow case-usage rules, but we don't : require it. In my opinion, that's the way programming should work. I would : like to read a program that followed case usage for readability; but, I : don't want an interpreter to barf when case is ignored. : If I name a function 'Function', then I'm doing it for readability; but, when : I'm in the interpreter, I want to type 'function'. Particularly because of : its interactive environment, I find the argument for a case-preserving, : case-insensitive Python very compelling. A lot of people feel as you do; but I, personally, see 'function' and 'Function' as two different tokens, and would be very irritated if a compiler treated them as identical. I'm afraid that's just the way I (and others) read code; I don't understand why we got that way, any more than I understand the attitude that all capitalization is equivalent. It seems to be some basic difference in reading or comprehension. OTOH, I'd find a monocase language, either upper or lower case, more readable than the case-preserving / case-insenstive combination, if Python has to be simplified for students. Will cwr at cts.com From rayleyva at my-deja.com Tue May 9 20:09:59 2000 From: rayleyva at my-deja.com (rayleyva at my-deja.com) Date: Wed, 10 May 2000 00:09:59 GMT Subject: Thank you Bill ... it was exactly what the doctor ordered! References: <8f9jr7$kk1$1@nnrp1.deja.com> <8z0S4.16870$L3.132746@typhoon.midsouth.rr.com> Message-ID: <8fa9cc$dmu$1@nnrp1.deja.com> I had even gone so far as to try to use the odbc wrapper even though that doesn't seem to be actively supported, and it's looks a little more difficult to get a particular field. Anyways ... thanks! If ever I can return the favor just let me know. I'm going to be a regular troller of this group so I can help, and get help ;D Ray In article <8z0S4.16870$L3.132746 at typhoon.midsouth.rr.com>, "Bill Wilkinson" <bwilk_97 at yahoo.com> wrote: > hmm I am not quite smart enough to know why it is not printing anything.. > But I do know that if that field is a date time field, you will get a PyTime > object when you retrieve its value from the database.. Luckily the PyTime > object comes with a Format() function that returns a string... Below, t is a > Date/Time value I have retrieved from an Access table. > > >>> t > <PyTime:12/30/99 11:34:00 PM> > >>> type(t) > <type 'time'> > >>> t.Format() > '12/30/0/ 23:34:00' > >>> print "The value of t is", t.Format(),"." > The value of t is 12/30/0/ 23:34:00 . > > <rayleyva at my-deja.com> wrote in message news:8f9jr7$kk1 $1 at nnrp1.deja.com... > | After much reading I've chosen to use the win32com access method to get > | to my Access97 data. It's working great except when I try to print out > | a field that contains date information ... here's some code snippets. > > Sent via Deja.com http://www.deja.com/ Before you buy. From mal at lemburg.com Wed May 24 04:13:17 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 24 May 2000 10:13:17 +0200 Subject: EMBEDDERS--REQUEST FOR COMMENTS: References: <392B67C2.860767B4@san.rr.com> Message-ID: <392B8F1D.F53F4F84@lemburg.com> Courageous wrote: > > Here's a brief code snippet: > > -------- > > static int ExampleObjectSetattr ( ExampleObject* self, char* name, PyObject* value ) > { > if (strcmp(name,"data")==0) > { > if (PyString_Check(value)) > { > self->data = PyString_AsString(value); You should copy the data instead of keeping a reference to it. The reason is that the object value might get garbage collected at some time in the future and then using the pointer will either return munged data or simply cause a seg fault. > return 0; > } > else > { > PyErr_SetString(PyExc_AttributeError,"attempt to set data attribute to a value which is > not a string"); > return -1; > } > } > else > { > PyErr_SetString(PyExc_AttributeError,"attempt to set unknown attribute on non dynamic > external type"); > return -1; > } > } > > -------- > > My presumption is that, in this instance, I don't increase the reference count > on the valuem because I've ascertained that it's a primitive (string, int, et > al). > > However, if this were a real object, I'd be doing an INCREF() on it, and > furthermore, would have to take care to do a DECREF() on what I was assigning > over. > > Do I have this right? No. Primitives are no different from any other object in Python. The fact that some primitives are cached or shared can't be relied upon, since these are implementation details of the interpreter which may change in future versions of Python. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From fwang2 at yahoo.com Thu May 4 19:20:04 2000 From: fwang2 at yahoo.com (oliver) Date: Thu, 4 May 2000 19:20:04 -0400 Subject: "asyncore" module question Message-ID: <Pine.LNX.4.10.10005041915080.24809-100000@worf.mcnc.org> Hi, I have a question on "asyncore" module: Can it handle multiple server sockets? From reading the example given in library reference, I can't find out the place where you can specify more than one sockets for it to handle like you can do by using select(). Please help. thanks oliver From m.faassen at vet.uu.nl Mon May 15 16:50:18 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 May 2000 20:50:18 GMT Subject: Java vs Python References: <KzLT4.3373$Kc3.20912@news-server.bigpond.net.au> <6CF9B63432CE9A85.0E3A00840099E02F.6C65D9105E8ECF8F@lp.airnews.net> <kuaehsdu5t.fsf@lasipalatsi.fi> <8foh8i$31m$1@newshost.accu.uu.nl> <ku3dnkdkmr.fsf@lasipalatsi.fi> Message-ID: <8fpnua$o8u$2@newshost.accu.uu.nl> Erno Kuusela <erno at iki.fi> wrote: >>>>>> "Martijn" == Martijn Faassen <m.faassen at vet.uu.nl> writes: > >> cgi is usually a bit slow, whether you use it to run java or > >> python or perl or cobol programs. > Martijn> Not if you run it with something like mod_python. > imprecise terms i guess - i meant cgi in the narrow sense of the word, > as opposed to something like mod_python. He did ask about mod_python. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From guido at python.org Thu May 18 11:18:15 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 18 May 2000 15:18:15 GMT Subject: Semantics question... References: <8fq2sc$fun$1@bob.news.rcn.net> <3921CA22.6458AB08@webamused.com> <mCE8MmA02xI5EwIZ@robinton.demon.co.uk> Message-ID: <39243413.2047941B@python.org> Francis Glassborow wrote: > > In article <3921CA22.6458AB08 at webamused.com>, Joshua Macy > <amused at webamused.com> writes > > Essentially, to make instance members visually distinct from method > >locals. The other OO languages you're thinking of put an implicit > >"this." in front of (some) accesses within a method, leading to > >confusion (at least sometimes) about to whom internal_data belongs. OO > >programmers in those languages will then resort to things like naming > >conventions (e.g. preceding all local names with m_) to help them > >remember. Python's design disfavors such under the covers "help", so > >requires that you explicitly pass in a reference to the object as the > >first parameter (traditionally called "self"), and fully qualify member > >access. > > Now I could be entirely wrong, but I think the real reason is that > Python has no concept of declarations and so there is no form of name > hiding. There is much to be said for Python's identifiers but they do > not come cost free. Without declarations the concept of scope and > lifetime are significantly different. Excellent observation. This is indeed the origin of the "self." prefix requirement. But I discovered that this is actually an advantage rather than a problem, and I would never want to go back to Java or C++. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From thomas at cintra.no Thu May 25 06:30:52 2000 From: thomas at cintra.no (Thomas Weholt) Date: Thu, 25 May 2000 10:30:52 GMT Subject: Posting data to web-pages in command-line scripts Message-ID: <392cff19.1308512070@news.online.no> Hi, I want to submit stylesheets to the CSS-validator located at http://jigsaw.w3.org/css-validator/validator-upload.html.en. How could I in a command-line script post a file to check like this. The page has a upload-file function. Can I just create a URL with args. etc. and do this? Thomas From ddb at crystal.uwa.edu.au Thu May 11 01:04:37 2000 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Thu, 11 May 2000 13:04:37 +0800 Subject: access method local variable namespace? Message-ID: <391A3F65.54AC9105@crystal.uwa.edu.au> hi, I know it's possible to access the names of methods within class objects from their __class__.__dict__, but I am wondering if it's also possible to access the namespace of the local variables in those methods and to read their contents? >From the "Programming Python" book I read that local variables are stored in an array instead of a dictionary for faster access and that vars() and locals() can be used to access those variables when they are in the current scope, but is it possible to this when they are out of scope? Thanks doug From emile at fenx.com Tue May 23 18:09:12 2000 From: emile at fenx.com (emile at fenx.com) Date: Tue, 23 May 2000 15:09:12 -0700 Subject: destructors? Message-ID: <392B0188.56EAD1D5@fenx.com> Use the __del__ method: >>> class A: def __del__(self): print "in delete method" >>> a = A() >>> del a in delete method >>> a = A() >>> b = a >>> del a >>> del b in delete method >>> Emile van Sebille emile at fenx.com Z 3 Penguin <z3penguin at penguinpowered.com> wrote in message news:<8geupp$oov$1 at bob.news.rcn.net>... > I know python supports constructors with +AF8AXw-init+AF8AXw-, but does it have support > for destructors (maybe +AF8AXw-del+AF8AXw-?+AF8- > > ----- > Z 3 Penguin > z3p+AEA-z3penguin.org > > () > (o+AF8- > //+AFw- > +ADw--+AFwAXw-/ > > This is a virus that works on the honor system. Send this .sig to everyone > in your address book and randomly delete some of your files. > > > -- > http://www.python.org/mailman/listinfo/python-list > From arnold at dstc.monash.edu.au Sun May 7 03:28:13 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Sun, 07 May 2000 17:28:13 +1000 Subject: print... okay, howabout sprintf? In-Reply-To: Your message of "Sun, 07 May 2000 06:17:34 GMT." <39150B40.A5BA5A5C@san.rr.com> Message-ID: <200005070728.RAA15244@xevious.dstc.monash.edu.au> -->"Courageous" == Courageous <jkraska1 at san.rr.com> writes: Courageous> Okay, I've noticed that python print supports printf Courageous> style format notation, and that's cool. But how do you Courageous> do the same thing with strings. i.e., what's the Courageous> equivalent of sprintf()? it's not print that does this. the % operator works on any string at any time. so you can get sprintf()-like behaviour like s = "%s = %d" % ("foo", 34) d From akuchlin at mems-exchange.org Mon May 22 13:15:04 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 22 May 2000 13:15:04 -0400 Subject: PyOpengl... gone forever? References: <fIqV4.14736$WS3.144662@typhoon.we.rr.com> <5hcW4.5291$wYl.211543552@newsb.telia.net> Message-ID: <3dpuqecxrb.fsf@amarok.cnri.reston.va.us> "Fredrik Lundh" <effbot at telia.com> writes: > > my top spies have informed me that pyopengl lives on > > the starship at http://starship.python.net:9673/crew/da > fwiw, that URL works just fine from here... Zope on Starship is pretty flaky, so it goes up and down a good deal; it must have been down when the original poster tried it. Squeal loudly at me if it dies again. --amk From jkraska1 at san.rr.com Fri May 26 03:34:07 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 26 May 2000 07:34:07 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <CC59868A0A76D311B1F50090277B321C1F3348@VRTMAIL> <slrn8ikrtj.48f.bwinton@tor.dhs.org> <rKHwzJA12oK5EwJ6@jessikat.demon.co.uk> <m2aehehfcg.fsf@netmeg.net> <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> <392DD013.6E44EFF4@san.rr.com> Message-ID: <392E299B.9D8D0D54@san.rr.com> > > >"CUM HOC ERGO PROPTER HOC" > > > > > >It should be educational. > > > > I think you mean "POST" instead of "CUM". > > No. Being in a more talkative mood now, I should like to point out that there is a very small difference between concluding that because something happened AFTER an event then the event must be the causal factor and concluding that because something happened DURING an event then the event must be the causal factor. Really, though, these two latin terms from fallacy-speak really aren't very distinguishible, so it's not particularly "more" proper to use one term in lieu of the other unless you really care about splitting hairs. :)- C/ From db3l at fitlinxx.com Wed May 31 20:41:45 2000 From: db3l at fitlinxx.com (David Bolen) Date: 31 May 2000 20:41:45 -0400 Subject: deque vs list: performance notes References: <3933484B.B471017A@san.rr.com> <slrn8j6or3.1om.nascheme@cranky.arctrix.com> <3933777F.262E1E15@san.rr.com> Message-ID: <upuq21bcm.fsf@ctwd0143.fitlinxx.com> Courageous <jkraska1 at san.rr.com> writes: (...) > # c-deque(tottime) py-queue(tottime) list(tottime) > 1,000 *.014* .050 .24 > 10,000 .12 .549 1.18 (...) > When benching your code, I was surprised for a moment that > your 1000 entry test was so much faster than mine (I ran > the test a half dozen times), but then discovered that my > original reported result in that category was a typo. Whoops. > This does make a very compelling case for the deque in > deque implementations likely to hold 1,000 or so objects > (rare, probably). There's also one other point which should probably be included in any such discussion, although I expect those following this thread are implicitly aware of it. Whether or not the above numbers make a "very compelling" case can't be gauged from the numbers alone, but must take into account the overall operation of the surrounding application - even for native lists. True, the raw stats for the test show the list implementation taking approximately 17x and 10x for 1000 and 10000 entries respectively (and 3.5x/4.5x for the Python queue). But we're still looking at an aggregate worst case of just over a second for native lists for a full queue insertion/retrieval at 10000 entries. Since it's likely that you're going to want to be doing stuff with those entries in the queue, it's not too difficult to imagine application processing of a queue entry to easily dwarf the deque time for that entry. Not in all applications certainly, but enough to make the performance difference probably far from very compelling in many cases, even more so with the Python variation. That is, not compelling enough to bother with an extension module. (...) > Off the cuff, I'd probably say one good rule of thumb would > be that if you're call to an external module involves a > great number of operations which can be conducted outside > of python, that might be a particularly compelling case. And as long as the "great number" involved is a significant fraction of the total work of the application as as whole. -- -- 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 hat at se-46.wpa.wtb.tue.nl Wed May 3 10:11:58 2000 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 3 May 2000 14:11:58 GMT Subject: Python/C interface proposals References: <B533BF4D.5934%abrahams@mediaone.net> Message-ID: <slrn8h0d1m.d23.hat@se-46.wpa.wtb.tue.nl> On Tue, 02 May 2000 03:10:06 GMT, Dave Abrahams <abrahams at mediaone.net> wrote: >I propose some simple changes to the Python header files which would make it >much easier to write "clean" wrappers in C++. > >The first change I propose would make it possible to forward-declare any >struct in the Python headers. This could be done by changing declarations of >the form: > > typedef struct {...} Name; > >to: > > typedef struct Name {....} Name; I would split the two in 2 definitions: struct Name { ...}; typedef struct Name Name; My gcc compiler does not complain about the double use of the name, so at least one compiler allows it. Secondly, the latter definition may be surrounded by #ifndef cplusplus .. #endif (or whatever the exact syntax for it may be), so it does not get included when compiled by a C++ compiler (which performs the latter definition by itself). By the way, is Python moving towards ANSI standards ? I'd like to compile Python with C++ (g++) but it hates the K&R style of formal parameters. I'd be willing to invest some time in this change. Albert --- Look ma, windows without Windows !! From dale at out-think.NOSPAMco.uk Fri May 19 03:57:48 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 19 May 2000 08:57:48 +0100 Subject: How to get volume name under Win32? References: <074701bfc122$d57310c0$1906a8c0@fc.fenx.com> <8g21qi$dm4$1@supernews.com> <3924E32A.4AC8AE4D@python.org> Message-ID: <8g2s67$jgi$1@supernews.com> The rumours appear to be wrong. I get the same error on a Win2000 system. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Guido van Rossum <guido at python.org> wrote in message news:3924E32A.4AC8AE4D at python.org... > Dale Strickland-Clark wrote: > > > > In fact ,I can't get os.popen to work at all! > > As has been said many times before, os.popen() is 99% broken on Windows > 95/98. > The error you posted is typical for the situation. Rumor has it that it > works > on W2000... > > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) From vetler at news.ifi.uio.no Sun May 7 19:46:59 2000 From: vetler at news.ifi.uio.no (Vetle Roeim) Date: 08 May 2000 01:46:59 +0200 Subject: Future of the Python Linux Distribution References: <jaln1mgdfy.fsf@helix.twistedmatrix.com> <Pine.SOL.4.21.0005080019020.5063-100000@ganglot.ifi.uio.no> <59vbhsko0k6gglr7ki61tbfch0eept58vk@4ax.com> Message-ID: <yayya5l6hzg.fsf@ganglot.ifi.uio.no> * Ben Wolfson > On Mon, 8 May 2000 00:55:37 +0200 (MET DST), Vetle Roeim > <vetler at ifi.uio.no> wrote: > > >> map, lambda, apply, filter. Obfuscation at your fingertips. :-) Using > >> {}.update(), I believe it's possible to write programs that use only > >> expressions; no statements. > > > >Yes, of course. But I have a feeling many people don't use these > >functions, unless they have taken a course on functional programming ;-) > > map, filter and reduce are pretty easy to figure out without knowing > any functional programming, actually. You just need to get > sufficiently bored with for loops. The problem is that once you put > them in, your code's legibility decreases if they're combined with one > another. I doubt I could parse this if I hadn't written it: > > from operator import add,indexOf > list=open('ceci ne pas un playlist.m3u').readlines() > open('mp3s','w').write(reduce(add, map(lambda a: a[1+a.find(',':]\ > filter(lambda e, l=list:indexOf(l,e)%2, list)))) > > and it's pretty simple. > > >It's often very useful to use these functions, but they provide solutions > >not easily available in more popular programming languages, such as C and > >Java. I refrain from mentioning C++ in the previous sentance, because C++ > >actually has those functions (except lambda), although many people don't > >know about them. > > I know about for_each and copy_if, which are what I assume you mean as > analogues of map and filter, but what corresponds to apply? well.. maybe I was a little to quick. I don't think there exists an 'apply' in C++.. hmmm.. yes, it was for_each and copy_if i was thinking about. for more algorithms, see chapter 5 of SGI's Standard Template Library Programmer's Guide[0]. vr [0]: http://www.sgi.com/Technology/STL/ From PA0215481 at ntu.edu.sg Wed May 24 12:07:38 2000 From: PA0215481 at ntu.edu.sg (#VEDALA NARASIMHA KUMAR#) Date: Thu, 25 May 2000 00:07:38 +0800 Subject: Subclassing...... References: <slrn8im1u8.qg.henke@belsebub.henke.se> Message-ID: <0CF260C495FED111A6610000F866308D0E84E407@mail3.ntu.edu.sg> Hi, here's what you gotto do...it worked --[ Vehicle.java ]----------------------------- // Java class that will be subclassed by Car.py public class Vehicle { public void printLicenseplate() { System.out.println("ABC123"); } } --[ Car.py ]----------------------------------- # JPython class that will subclass Java Vehicle import java import Vehicle class Car(Vehicle): def start(self): #dun forget to include self self.on=1 def stop(self): self.on=0 def printStatus(self): if not self.on: print "The car is stopped" else: print "The car is running" compile it with "jpythonc --core -A org.python.core Car.py" and copy the generated class file to workin directory. Here's the trick for the final one --[ VehicleTest.java ]------------------------ // A Java test class just to test the two classes above import java.lang.*; import Car; import org.python.core.*; import org.python.util.PythonInterpreter; public class VehicleTest extends Car{ public static void main(String[] args) throws PyException { PythonInterpreter py=new PythonInterpreter() System.out.println("Starting"); py.set("c", new Car()); //Car c = new Car(); // None of these calls to methods in the // Car object will be accepted. py.exec("c.printLicenseplate()"); py.exec("c.start()"); py.exec("c.printStatus()"); } } --------------------------------------------- I have searched through lots of places for information about how this should be done without finding a good answer. Since the output from jpythonc must be useful somehow, there must be an obvious answer, but I fail to see it right now. Any feedback is greatly appreciated. Regards, Henrik W. From petersc at stud.ntnu.no Wed May 31 18:34:39 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Thu, 01 Jun 2000 00:34:39 +0200 Subject: ANNOUNCEMENT: Python Development Team Moves to BeOpen.com References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> Message-ID: <3935937F.CCF87258@stud.ntnu.no> Guido van Rossum wrote: > > Oh, and to top it all off, I'm going on vacation. I'm getting married > and will be relaxing on my honeymoon. For all questions about > PythonLabs, write to pythonlabs-info at beopen.com. Gefeliciteerd bij de eerste stap naar de echtscheiding! Gelukwensen met de bruiloft en veel plezier tijdens de wittebroodsweken. just-hope-I-got-my-dutch-right-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From s2mdalle at titan.vcu.edu Mon May 15 19:54:35 2000 From: s2mdalle at titan.vcu.edu (David Allen) Date: Mon, 15 May 2000 18:54:35 -0500 Subject: Semantics question... Message-ID: <8fq2sc$fun$1@bob.news.rcn.net> Hello, I've just picked up Python recently, and I have a question about why the syntax is the way it is. (No, I'm not going to ask about the enforced whitespace :) When writing a method inside of an object, say, something like: class Foobar: def bar(self, someNumber): self.internal_data = someNumber return(None) why is it that python requires programmers to refer to class data by using the object? (as in, you have to say self.internal_data = someNumber. You could just say internal_data = someNumber but it wouldn't do what you wanted it to) I ask this because no other OO language (or a language that happens to be able to do OOP, I should rather say) that I have programmed in seems to require it. Usually someobject.datafield is reserved for referring to static fields, not fields within an instance of an object. I'm asking this really out of curiousity, and because I keep forgetting it. I'd be interested to hear why this is the way it is. I keep making this mistake: class Foobar: def something(self, number): self.number = number def printNumber(self) print number which obviously won't fly, since "self.number" is defined but "number" isn't. -- David Allen http://opop.nols.com/ ---------------------------------------- "So here's a picture of reality: (picture of circle with lots of sqiggles in it) As we all know, reality is a mess." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) From dalke at acm.org Mon May 29 00:22:13 2000 From: dalke at acm.org (Andrew Dalke) Date: Sun, 28 May 2000 22:22:13 -0600 Subject: request: web site copy utility References: <grg3jsg899nhuhl5sua80ookjop9cuk8j0@4ax.com> Message-ID: <8gsr3m$ufr$1@nntp9.atl.mindspring.net> robin.illusionsescalation at ACM.org wrote in message ... >I realize this must be a common request, but I can't find the answer >anywhere (Deja, Parnassus, Grimoire...). So before I cook my own... > >I'm looking for a Python script to download an entire web site. Try websucker, which is distributed with Python under Tools as part of webchecker. It isn't in Parnassus because it's part of Python itself. Andrew dalke at acm.org From katz at Glue.umd.edu Fri May 19 18:40:55 2000 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 19 May 2000 18:40:55 -0400 Subject: Python3k extended grammar In-Reply-To: <39245ED7.9C3A4FAB@prescod.net> References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> Message-ID: <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> On Thu, 18 May 2000, Paul Prescod wrote: > Nobody has, as far as I know, ever spoken about having to declare > variable types in Python. Many, many people have asked to be *allowed* > to declare variables in Python. There is a big difference. As one who enjoys programming both little (albeit elegant) scripts and large projects alike, I feel safe with Python as a 'stable' language set. Here's a list of Unqualified Rumors we've been compiling: 1. Python 3000 may be case-insensitive. 2. It may allow type-checking. 3. It may have a more thorough garbage collection mechanism. 4. dividing integers may yield a float. I don't really have an issue with (1) personally; however, I find scripts such as IMPORT OS, OS.PATH DIRNAMES = '..' OPENFILES = [] FOR N IN OS.LISTDIR( DIRNAME ): F = OPEN( OS.PATH.JOIN( DIRNAME, N ) OPENFILES.APPEND( F ) *really* difficult to comprehend (and perhaps, even *with* case-insensitivity, and assuming even then that this doesn't break any existing code), but if it helps budding programmers, I understand. for (4) my only concern is that int/float promotion would at least remain consistent. For me, this is confusing as it is: a = 5 # just practice variables b = 3 c = float(a) / float(5) # force c to be a float (supposedly) if we have explicitly declared float types to work with, then this wouldn't even be an issue for me. But again, I could still write a module to implement this and then have its / operator overloaded. What I would like to know is where I can get information. So many people have asked about p3k in this group; I've searched python.org and Starship and have come up with relatively little. The TYPES-SIG (whose archives are accessible from Python.org) sheds light on the types issue (then again, I have issues with their proposals). Roey btw -- the above is just my preference. Whatever aids new students in learning to program, so be it (at least I'll have Python 1.x). From hzhu at rocket.knowledgetrack.com Wed May 24 19:41:09 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Wed, 24 May 2000 23:41:09 GMT Subject: What's in a name? References: <Pine.SOL.4.05.10005241450110.14493-100000@spgsun1.arlut.utexas.edu> Message-ID: <slrn8ioq9a.vq.hzhu@rocket.knowledgetrack.com> On Wed, 24 May 2000 14:57:10 -0500, Edward S. Vinyard <vinyard at arlut.utexas.edu> wrote: >On Wed, 24 May 2000, Thomas Thiele wrote: >>> 1. Remove a (potential) hurdle for new programmers. >Case-sensitivity by itself is probably not a hurdle. Learning to >recognize the (possibly implicit) convention a specific library, module, >or programmer uses to convey semantic information using case might be more >difficult, especially for someone who is not familiar with a language or >common conventions. This is exactly why case-insensitivity is not a good proposal: o There is little problem in current python for newbies - they can use all lower case in their own programs if they want to. o What the proposal does is to ban experienced programers from using the expanded name space lest their codes confuse newbies. While this might hinder the work of many programmers, it would not help newbies, who, instead of being troubled by the intricacies of car = Car() now have to battle with objectOfCar = classOfCar() IMHO, case insensitivity breaks a lot and helps few. Many good remedies have been proposed in this thread that would achieve far more while breaking much less. Like helpful error messages, case-aware editors, syntactic highlighting of new names, better styles, ... There is a fundamental reason why case belongs to editor, not interpreter: Everyone can use his own well-configured and incompatible editor, but imagine if everyone is using his own patched and incompatible python ... Huaiyu From pinard at iro.umontreal.ca Tue May 23 09:43:50 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 23 May 2000 09:43:50 -0400 Subject: Case sensitivity In-Reply-To: Michael Husmann's message of "Tue, 23 May 2000 11:33:39 +0200" References: <392A5073.2AA7E2B9@teleatlas.com> Message-ID: <oq1z2tidpl.fsf@titan.progiciels-bpi.ca> Michael Husmann <michael.husmann at teleatlas.com> writes: > Why not let the user decide whether to use lower or upper case or mixed? Because we live in an environment where exchange of code is (going to be) part of life. (It is already for us, and it is going to be 4E as well.) If anyone goes his/her way about it, we'll soon have an uncomfortable mess. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From carlp at findpage.com Fri May 12 16:36:44 2000 From: carlp at findpage.com (Carl Page) Date: Fri, 12 May 2000 13:36:44 -0700 Subject: Python/Zope Message-ID: <02a401bfbc51$c99f5ae0$100a0a0a@dotfunk.com> The modern replacement (IMHO) for newsgroups is web-archive backed email groups. You can search for the zope related ones on eGroups at http://www.egroups.com/search?query=zope Plus eGroups.com uses Python, mostly. (but not Zope.) (arl Carl Page 415 284 5248 www.findpage.com True wit is nature to advantage drest; What oft was thought, but ne'er so well exprest. Pope <<forwarded message from http://www.egroups.com/message/python-list/89150 >> > > From: Dan L.Pierson <dan at c...> > Date: Wed May 10, 2000 10:10am > Subject: Re: Python/Zope > > > "Fabio Augusto Mazzarino" mazza at r... wrote: > > > I have searched Zope.org, but unfortunatelly i didin't find > anything > about > > a newsgruop, but a lot of mail-box-filling-out-mailing-lists. > > I know you are wondering why I am looking for a newsgroup... but... > > nevermind... keep wondering. Someday I'll tell you. > > This has come up before on the zope-user list. My memory of the > reasons why not are a bit hazy. Here's my best guess: > > 1. No one at Digital Creations has time to do this. Volunteers > welcome :-). > > 2. Some people are afraid that a news/mail gateway will cause even > more noise on the list. > <snip> > > From slhath at flash.net Mon May 15 10:34:25 2000 From: slhath at flash.net (Scott Hathaway) Date: Mon, 15 May 2000 14:34:25 GMT Subject: pythonworks Message-ID: <RVTT4.12813$wb7.1194717@news.flash.net> Is anyone using PythonWorks (the beta) yet? What do you all think about it? Scott From jmg at ecs.soton.ac.uk Fri May 19 17:03:38 2000 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: Fri, 19 May 2000 22:03:38 +0100 Subject: Gnuplot woes. Message-ID: <3925AC2A.9CB6DA0D@ecs.soton.ac.uk> The following program: ------------------------ import Gnuplot import string g = Gnuplot.Gnuplot() g('set data style lines') command = '' while string.lstrip(string.rstrip(command)) != 'quit': g.plot( [[1,1],[2,2],[3,3],[4,4]] ) command = raw_input('plot> ') g.hardcopy( 'hmm.ps' ) ------------------------- gives output like this: ========================= plot> plot> gnuplot> plot '/usr/tmp/@32453.1' notitle ^ can't read data file "/usr/tmp/@32453.1" line 0: (No such file or directory) plot> gnuplot> plot '/usr/tmp/@32453.2' notitle ^ can't read data file "/usr/tmp/@32453.2" line 0: (No such file or directory) ========================== In the minimal program shown above, the problem can be removed by moving the g.plot() command to just before the g.hardcopy() command . . . but in more complicated programs even this fails. I would welcome any advice, Jacek From phd at phd.russ.ru Mon May 29 08:42:15 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 29 May 2000 12:42:15 +0000 (GMT) Subject: E-mail read-write function In-Reply-To: <8giobi$48d$1@gw.localdomain> Message-ID: <Pine.LNX.4.21.0005291241180.28510-100000@fep132.fep.ru> On Thu, 25 May 2000, Sameh chafik pro wrote: > are there any standard way to read-write the e-mail with python. Write with smtplib.py. Read with mimetools.py; this require some more work, but I can show you an example - just ask! Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From johann at physics.berkeley.edu Mon May 1 23:38:57 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 01 May 2000 20:38:57 -0700 Subject: Reading in strings -> numbers ?? References: <390A2D23.7029E557@fenx.com> <8ede36$9r6$1@nnrp1.deja.com> <300420001022354625%pecora@anvil.nrl.navy.mil> Message-ID: <mtzoq9r57y.fsf@astron.berkeley.edu> Louis M Pecora writes: > After three weeks of learning Python have I actually found a real wart? > A common requirment in programming (especially for numerical stuff) is > to read in data that is often generated by other programs and other > people. The common form is a "table" structure: > data11(white space)data12(white space)...data1m(return/newline) > data21(white space)data22(white space)...data2m(return/newline) > ... > datan1(white space)datan2(white space)...datanm(return/newline/EOF) > EOF > So you're saying that reading in something as basic as this is a > "work-around?" Sigh. Well, I've been doing numerics in python for years now, which is more than a little scary, and it's never been a problem for me. I tend to either use Konrad Hinsen's ArrayIO module, which will semi- automatically do this for me, or simply do a lines = open(filename).readlines() lines = map(string.split, lines) lines = map(lambda l: map(float, l), lines) data = array(lines) and I'm set. Usually I write code like this once for any particular data format, then simply call it when I need it. Whitespace-delimited files are very easy to parse with string.split. The column-oriented stuff you get from Fortran format statements is a bit harder, but it's easy enough to read in lines, take substrings, then evaluate those substrings as you need them. --Johann -- Johann Hibschman johann at physics.berkeley.edu From yawyi at gmx.de Tue May 30 07:24:42 2000 From: yawyi at gmx.de (Johannes Stezenbach) Date: Tue, 30 May 2000 13:24:42 +0200 Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <sj3ejda85pj169@corp.supernews.com> <hjoY4.6071$wYl.223614464@newsb.telia.net> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <ZoDY4.6196$wYl.229414400@newsb.telia.net> <39333CC3.32805F5@cosc.canterbury.ac.nz> <saMY4.6222$wYl.223847936@newsb.telia.net> Message-ID: <3933a92e$0$25480@personalnews.de.uu.net> Fredrik Lundh <effbot at telia.com> wrote: >Greg Ewing wrote: >> So what? It's also been pointed out that it's quite feasible >> to define a join that makes sense for more than just strings, >> and that string joining can be efficiently accommodated as a >> special case. > >that's really a different topic. You tell us to reason because voting doesn't help. We reason and you tell us we're reasoning about the wrong topic. Interesting... Let me summarize: - I want to convince you to change sep.join(list) to list.join(sep) for aesthetical reasons. - Arguments regarding this aesthetical reasons directly ("looks better", "easier for beginners", "less error prone") apparently don't count. - Argumenting implementation-wise ("generalize the meaning of join so string-join becomes a special-case optimization and list.join(sep) becomes the logical thing to do") is turned down because generalized join could be misused on non-concatenable objects. (With regard to a generalized join() definition, overloading '+' to mean "add" and "concatenate" is a Python design flaw.) >(and be careful with overgeneralizations: neither "joining >numbers" nor "reducing strings" make much sense...). In Perl joining numbers means converting them to strings and then join the numeric strings. This /could/ be done in python as well... (Notice that I didn't say "should", but if you stand to your opinion that join does only make sense for strings, then automatically converting stuff to strings would also make sense.) >if you think that keeping string.join in there is the most serious >design mistake in 1.6, you may be in for some really interesting >surprises... I've asked this one before: Is " ".join() only an implementation detail needed to write string.join() that nobody should ever call directly? If so, then *say it loud and clear*. And rename " ".join to " ".__join__ or " ".__never_call_this_join_directly__. I was happy with string.join() before and I will be happy with string.join() in the furure. I just don't want to have to read code that uses " ".join(list), and I don't want to read endless repetitions of newbie's postings in c.l.p asking "why does join() work the wrong way round?" Johannes From aahz at netcom.com Fri May 5 14:53:02 2000 From: aahz at netcom.com (Aahz Maruch) Date: 5 May 2000 18:53:02 GMT Subject: comp.lang.python-announce References: <8ev2en$d85$1@nnrp1.deja.com> Message-ID: <8ev5ae$ntd$1@slb7.atl.mindspring.net> In article <8ev2en$d85$1 at nnrp1.deja.com>, <jsolbrig at my-deja.com> wrote: > >I don't have direct access usenet and I have not been able to find a way >to either read or post to comp.lang.python-announce. Both eGroups and >deja don't give anything. I sent email to python-announce at python.org >and it bounced. This seems to have to do with python-starship having >crashed. Anyone have any idea when things will be up and running again? > >I noticed that the news on python.org is about a month out of date, so >does comp.lang.python-announce even exist anymore? The newsgroup exists, the moderator(s) have been inactive for about two months. I believe there's some behind-the-scenes work on reactivating it, but no news so far. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "It's not because my mind is made up that I don't want you to confuse me with any more facts. It's because my mind isn't made up. I already have more facts than I can cope with. So SHUT UP, do you hear me? SHUT UP!" _The Shockwave Rider_, 1975 From jae at ilk.de Mon May 1 15:40:16 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Mon, 01 May 2000 21:40:16 +0200 Subject: Do I always have to write "self." ? In-Reply-To: <slrn8gqdlg.k65.kc5tja@garnet.armored.net> References: <270420001706386648%pecora@anvil.nrl.navy.mil> <slrn8ghc6t.f01.scarblac-spamtrap@flits104-37.flits.rug.nl> <8ecsgj$6lp$1@slb0.atl.mindspring.net> <m3bt2tonyg.fsf@atrus.jesus.cam.ac.uk> <300420001008012011%pecora@anvil.nrl.navy.mil> <slrn8gp6c4.ilf.kc5tja@garnet.armored.net> <bz1P4.75789$uF1.160076@afrodite.telenet-ops.be> <slrn8gqdlg.k65.kc5tja@garnet.armored.net> Message-ID: <01052000.1@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Samuel" == Samuel A Falvo <kc5tja at garnet.armored.net> writes: >> OK, let's bite :-) Yummy ;-) >> int WriteData(void *buffer, char *str, int len) >> >> I fail to see how this is somehow hard to read :-) Samuel> It's not, in this context. But it was a decidedly simple Samuel> example. How about this: Samuel> int Evaluate( char *str1, char *param1, char *param2 ); Samuel> Note the `param1' and `param2' argument names. Hate to Samuel> tell you this, but that's Hungarian notation -- you're Samuel> identifying those arguments as "parameters". So, when I give a parameter a descriptive name it's using Hungarian notation? So I've been using this all these years? *Aaaaarrrggghhh*... ;-) Samuel> But what the heck would str1 represent? The command that Samuel> acts on those parameters? You don't know -- you CAN'T Samuel> know from this definition. It's cases like this that I Samuel> choose to use hungarian notation: Samuel> uint32 Evaluate( char *cmd, char *param1, char *param2 ); That's a good example of what's wrong with all this "encode add'l info in a parameter name": This still doesn't tell you one iota of what "param1" and "param2" are doing... Better use *descriptive* param names (and *document* the fn) than trying to use a crutch like Hungarion notation or anything like it. (That's why I like ObjC... it *forces* you (more or less) to use nice method names... like [comboBox insertItemWithObjectValue:object atIndex:index] (and Emacs' dynamic abbrevs are my friends ;-)) Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html "Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories?" -- Michael K. Johnson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjkN3Z0ACgkQN0B+CS56qs1H4wCdGlHsoW3QgZmQh1DkPgPo5ThX I2EAnR1ZaWw1Qy2f0juXDFaD3VifOXDf =6d6b -----END PGP SIGNATURE----- From effbot at telia.com Mon May 8 12:30:21 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 08 May 2000 16:30:21 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> <slrn8hdj3i.47b.tsummerfelt1@co146453-a.kico1.on.wave.home.com> Message-ID: <xYBR4.6295$Za1.97329@newsc.telia.net> tony summerfelt wrote: > i think something like the following is pretty hard to beat: cannot tell what that one's doing without running it, and I don't have perl on this box... ...but the next one is easier: > and i think the following is hard to beat in tcl/tk: > > #!/usr/bin/wish > > button .b -text "Exit" -command {exit} > pack .b it can be written in 2-3 lines in Python as well, but the pydiomatic Python version isn't much longer: #!/usr/bin/env python from Tkinter import * import sys b = Button(text="Exit", command=sys.exit) b.pack() mainloop() </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From emile at fenx.com Sun May 28 12:32:02 2000 From: emile at fenx.com (Emile van Sebille) Date: Sun, 28 May 2000 09:32:02 -0700 Subject: Not well supported on the Mac? References: <l0310280ab557055f4935@[193.78.237.127]> Message-ID: <03a201bfc8c2$49691fa0$1906a8c0@fc.fenx.com> Just, As it happens, I was thinking of asking about Mac GUI's this morning. ;-) What do you use? Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Just van Rossum <just at letterror.com> <snip> > Python is in general pretty well supported on MacOS. However, Tk(inter) and > therefore IDLE are not so good, due to lack of interest: Jack & I don't use > Tkinter ourselves, and it's up to others to improve the situation... > > Just > From daniels at mindspring.com Sat May 20 00:20:23 2000 From: daniels at mindspring.com (Alan Daniels) Date: 20 May 2000 04:20:23 GMT Subject: vim.py References: <39242983.4D5B5246@pacific.jpl.nasa.gov> <seYU4.26$Z9.1304@news> Message-ID: <slrn8ibmlg.oe.daniels@localhost.localdomain> On Thu, 18 May 2000 20:18:32 GMT, Robert <rhicks at rma.edu> wrote: >http://www.mindspring.com/~daniels/vim/ > >:-) Oh my god, forgot I still had it out there! Well, enjoy! :-) -- ============================================================ Alan Daniels daniels at mindspring.com From ivler at basecamp1.netquest.net Wed May 31 22:10:20 2000 From: ivler at basecamp1.netquest.net (J.M. Ivler) Date: Thu, 01 Jun 2000 02:10:20 GMT Subject: Using python (or Tcl) on the web References: <MPG.1365adcfa8470eef9896aa@news> <BC4B61746187C623.3FA0E7D58DF4EA7E.ECC1D97F577DEDE5@lp.airnews.net> <slrn8g28ah.cc.amphgobb@eccie.blackflag.net> <L3iZ4.154057$681.2782248@news-east.usenetserver.com> <8h4eeu$bpg$1@saltmine.radix.net> Message-ID: <gCjZ4.155377$681.2810806@news-east.usenetserver.com> In comp.infosystems.www.misc Cary O'Brien <cobrien at radix.net> wrote: > Well, they've got mod_dtcl and aolserver. Excellent products both. There is also cgi.tcl, another excellent piece of tcl support. > Look, this is mature technology. Can't everyone just get along? We do. I hope. I was just pulling CL's leg. :-) > (Plus you forgot embedded perl - embperl). Hey, don't let the book get you thinking I do Perl, that was a demand by PTR/PH. They also wanted fastCGI, but I talked them out of that. :-) jmi From zessin at my-deja.com Fri May 12 12:55:15 2000 From: zessin at my-deja.com (Uwe Zessin) Date: Fri, 12 May 2000 16:55:15 GMT Subject: correct round of reals? References: <391BE774.95B2C26D@stud.ntnu.no> <006701bfbc05$04bfcbc0$0500a8c0@secret.pythonware.com> <391C0EF9.6646EF7A@stud.ntnu.no> <XGUS4.3839$wYl.204453376@newsb.telia.net> Message-ID: <8fhd1e$9eg$1@nnrp1.deja.com> In article <XGUS4.3839$wYl.204453376 at newsb.telia.net>, "Fredrik Lundh" <effbot at telia.com> wrote: > Peter Schneider-Kamp <petersc at stud.ntnu.no> wrote: > > Thanks. Do you know if e.g. VC++ uses IEEE doubles? > > most modern platforms use IEEE, but I'm sure there are > exceptions (OpenVMS?) The OpenVMS operating system runs on 2 hardware platforms: 1) the VAX architecture (32-bit CISC - first model sold in 1978) it has several floating point formats. IIRC the IEEE definition came later and it somehow had to be different (the same reason why the DEC multinational character set is different than ISO Latin-1 :-( 2) the Alpha architecture (64-bit RISC - first sold, IIRC, in 1991/2) it can do VAX floating point (with some limitations, I beleive) and IEEE. Cameron Laird is correct that one can select the format with a compiler switch and the default is non-IEEE. The current Python port for OpenVMS Alpha uses just the compiler default. -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Fri May 5 14:25:47 2000 From: cut_me_out at hotmail.com (Alex) Date: 05 May 2000 14:25:47 -0400 Subject: hungarian notation is evil (was Re: Do I always have to write "self." ?) References: <8erd4a$ac1$1@nnrp1.deja.com> <slrn8h2h2i.1bs.kc5tja@garnet.armored.net> <39116EE5.8EFE6228@san.rr.com> <slrn8h3u48.a3r.kc5tja@garnet.armored.net> <39124FE6.96D041FD@Lugoj.Com> <slrn8h62i7.1i8n.cjc26@localhost.mindriot.net> Message-ID: <etdpur0ua50.fsf@w20-575-109.mit.edu> > I like how C++ templates are Turing complete. That means trying to > determine whether or not a C++ program will even compile is equivalent > to the Halting Problem. How do you do the equivalent of a for loop using templates? Alex. From rcc at nospamthanks_jennic.com Wed May 3 11:34:49 2000 From: rcc at nospamthanks_jennic.com (Robert Cragie) Date: Wed, 03 May 2000 15:34:49 GMT Subject: Doesn't anybody write to paper anymore? References: <38F5FDF3.EE2FBA01@tcac.net> <38F94701.CA52FDBB@tcac.net> <8dd0gq$crn$1@nnrp1.deja.com> <39103AC0.35E2071D@gssec.bt.co.uk> Message-ID: <newscache$52qztf$cjc$1@jenpc07.jennic.co.uk> | Really where? | I couldn't get popen to work at a;ll on NT4 or win95 If you want to use popen(), use the 'win32pipe' module. Make sure you get the modules from the 'win32all128.exe' distribution (or later?) - the 'win32pipe' module in 'win32all125.exe' certainly doesn't work on win98. Robert From robin.escalation at ACM.org Thu May 4 14:07:30 2000 From: robin.escalation at ACM.org (robin.escalation at ACM.org) Date: Thu, 04 May 2000 14:07:30 -0400 Subject: raw_input in loop References: <e$crmckp$GA.196@net025s> <39103BAB.D2DB2EDB@gssec.bt.co.uk> <newscache$c8qztf$onc$1@jenpc07.jennic.co.uk> Message-ID: <j0f3hs4g5lflmnlaqh4utqioo3jh669akf@4ax.com> "Robert Cragie" <rcc at nospamthanks_jennic.com> wrote: >There is also the msvcrt module - function kbhit() might be what you're >after... > >http://www.python.org/doc/current/lib/msvcrt-console.html That's fine for WinXX, but how about other platforms? I hate to lock myself into GatesLand solutions. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Ontario's government could be a symptom of the conditions deep in the ocean. From guido at python.org Fri May 19 23:10:50 2000 From: guido at python.org (Guido van Rossum) Date: Sat, 20 May 2000 03:10:50 GMT Subject: urllib/ftpwrapper References: <Pine.LNX.4.21.0005190810221.493-100000@fep132.fep.ru> Message-ID: <cpem6xvjhc.fsf@cj20424-a.reston1.va.home.com> Oleg Broytmann <phd at phd.russ.ru> writes: > Cannot beleive it's just so simple :( My robot uses urllib.urlretrieve; > and any test program hangs. Just run in python: > > fname, headers = urllib.urlretrieve("ftp://starship.python.net/") > > and it hangs :( Almost all FTP URLs will hang, but there are some that > not: ftp://sun.med.ru/ worked (at least for me), there is pretty standard > wu-ftpd running there. > > > all" FTP URLs. The proper fix would be the same as in webchecker -- > > read the rest of the data. > > I beleive URLopener.retrieve eats all data... Yes it does. I played with this a bit and found that ftp.python.org works but starship.python.net hangs... Then I had a sudden idea: maybe these ftp daemons only send the 226 message once the data socket has been closed! The following change works for me: in urllib.py, class addclosehook, method close(), move the call addbase.close(self) to the top of the method, so the data socket gets closed before the hook (which waits for the 226 code on the control socket) is called. def close(self): addbase.close(self) if self.closehook: apply(self.closehook, self.hookargs) self.closehook = None self.hookargs = None Let me know if this fixes your problem (with no other changes to urllib). -- --Guido van Rossum (home page: http://www.python.org/~guido/) From shayman at uniserve.com Wed May 17 16:14:05 2000 From: shayman at uniserve.com (Fergus M Hayman) Date: Wed, 17 May 2000 13:14:05 -0700 Subject: Stuck Message-ID: <3922FD8D.49C3E809@uniserve.com> Hi Trying to process a file and format it for printing. As such import string f = raw_input('Enter file : ') line = f.readline(f) while line: for i in line: line = f.readline() if line == "H3': print " Region", '\t:', [0:] # Extract first item in line H3 ?? print " District", "\t", [1:] My infile looks like this from a handheld device H1: 9085, FERGUS, HAYMAN H2: 71G, NORTHVIEW DLS H3: VANCOUVER, CHILLIWACK H4: 00100s, 100, SB$. 01 TILL H7: 22000 I Need formatted output something like Region : VANCOUVER PAGE 1 OF 1 DISTRICT: CHILLIWACK DATE OF SCALE Scaled by : FERGUS HAYMAN SITE SCALER RETURN 71G 9085 100 :? Does the f.readline() function automatically put the input file into a list ie [] or a string? I though a list would be right for text formatting. and file maniputaltion. ( I can't figure out how to access say item 71G in H2: and assign it a place on a print statement) This is the header first 7 lines i need to be able to slice and dice the log data that follows for species, volume etc. From petersc at stud.ntnu.no Wed May 31 02:06:24 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 31 May 2000 08:06:24 +0200 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <392d08fe.185503740@news.u-psud.fr> <3933F507.5A78EF7C@coaps.fsu.edu> Message-ID: <3934ABE0.8FA23BCD@stud.ntnu.no> Peter Gavin wrote: > > Laurent POINTAL wrote: > > > > import string > > _string = string > > del string > > This looks like a good idea. Wouldn't it be useful to be able to do it > in one step? > It shouldn't be too hard to add a syntax similar to: > > import string as _string Why not use this: _string = __import__("string",globals,locals,None) is-syntactic-sugar-sweet-or-bitter-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From jkraska1 at san.rr.com Thu May 25 10:21:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 25 May 2000 14:21:34 GMT Subject: Makefiles [offtopic] References: <oqwvkkp5q6.fsf@titan.progiciels-bpi.ca> <392C76CF.27A5D18B@san.rr.com> <oqln0zz8vd.fsf@titan.progiciels-bpi.ca> <392C8D1D.C5DEB536@san.rr.com> <8gj1td$tci$1@dokkum.cs.uu.nl> Message-ID: <392D3795.8B6D59CA@san.rr.com> > that would be > > SRC:=$(wildcard *.C) # more efficient Yeah, I've known that for a long time, just never fixed it. Funny how you get lazy once everything's working, huh? :)- > I'll go along with you in saying that GNU make is the best > implementation of make available, but that does not mean it is the > best tool ever for managing builds. I work on a project totaling 2200 > lines of Makefiles, and it's hard to fix bugs in without creating new > errors. What *is* the best tool for managing builds? C/ From angelow at tttech.com Mon May 29 04:00:09 2000 From: angelow at tttech.com (Harald Angelow) Date: Mon, 29 May 2000 10:00:09 +0200 Subject: Building embedded Python C++Application Message-ID: <959587307.468031@newsmaster-04.atnet.at> Hi ! I embedded PYthon into a Visual C++6.0 Project and have that problem: If the project is built with code generation option "Multithreaded DLL" and dynamic linked MFC all runs well in Debug and Release Mode. If built with build with code generation option "Multithreaded" and MFC linked static only the Debug version works.... in the Release version Python crashes (Memory Access Exception in the Python15.dll) What is the reason? Thanks Harald From rcc at nospamthanks_jennic.com Wed May 3 11:38:32 2000 From: rcc at nospamthanks_jennic.com (Robert Cragie) Date: Wed, 03 May 2000 15:38:32 GMT Subject: raw_input in loop References: <e$crmckp$GA.196@net025s> <39103BAB.D2DB2EDB@gssec.bt.co.uk> Message-ID: <newscache$c8qztf$onc$1@jenpc07.jennic.co.uk> There is also the msvcrt module - function kbhit() might be what you're after... http://www.python.org/doc/current/lib/msvcrt-console.html Robert Alan Gauld <alan.gauld at gssec.bt.co.uk> wrote in message news:39103BAB.D2DB2EDB at gssec.bt.co.uk... | "A[r]TA" wrote: | > Heyz, I want to write a loop | > in which there's something like raw_input but which | > doesn't stop the loop until the enterbutton is hitten. | | Not too clear what you mean but I suspect you want | something like INKEY$ in BASIC? | | ie it continues as soon as any key is hit? | | > How do I do that??? | | Assuming my assumption is right you could try using curses. | There is a function called wgetch() which works like INKEY$ | Its not available for Windows tho' (although you might find | it on the web somewhere.) | | Alan G. | -- | ================================================= | This post represents the views of the author | and does not necessarily accurately represent | the views of BT. From tpchang at excite.com Thu May 4 06:01:48 2000 From: tpchang at excite.com (tpchang at excite.com) Date: Thu, 04 May 2000 10:01:48 GMT Subject: How to access Address Book in Outlook... Message-ID: <8erhq7$f6i$1@nnrp1.deja.com> Hi, I am a newbie of Python. I am trying to write a script to read/add/modify/delete address book in Outlook. I have downloaded the "win32com" package, and followed the instruction of "makepy.py" to create a "msoutl9.py" file out of "msoutl9.olb". But so far, I can only do: >>> w = Dispatch("Outlook.Application.9") I don't know how to proceed after this to implement my read/add/modify/delete function on address book. Any pointer or help will be very much appreciated. Thanks in advacne, Ben Sent via Deja.com http://www.deja.com/ Before you buy. From krhryw at earthlink.net Sat May 27 10:04:00 2000 From: krhryw at earthlink.net (krhryw at earthlink.net) Date: 27 May 2000 14:04:00 GMT Subject: Get Paid To Read Email! 6415 Message-ID: <8gokkg$7lc$5128@WWW1.relcom.ru> This is awesome! I just had to tell you about SendMoreInfo.com! You get paid to read email! They send you information about things you are interested in and they pay you to check it out! Here's the link: http://www.sendmoreinfo.com/id/98292 I know you are going to love this web site! Talk to you soon! ioeeqxkoilipbhgywdufpujvydmuluphxyekerxrxtgmptcmjowvboyipywuvkgwgovxbts From johann at physics.berkeley.edu Tue May 30 20:57:28 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 30 May 2000 17:57:28 -0700 Subject: __builtins__ References: <slrn8j8nvm.1nm.hzhu@rocket.knowledgetrack.com> Message-ID: <mtd7m35yfb.fsf@astron.berkeley.edu> Huaiyu Zhu writes: > It looks like that I have to use > __builtins__.min (1,2) > in the interpreter but > __builtins__['min']([1, 2]) > in a module. Why is this so? Ah. You should not be using __builtins__. As far as I understand it, that is a hack variable, which you cannot trust. The module you seek is __builtin__ (no s.) If you want these functions, the Right Thing is to "import __builtin__" and then use "__builtin__.min". The fact that there is a variable named "__builtins__" is an accident of the implementation. --Johann -- Johann Hibschman johann at physics.berkeley.edu From jkraska1 at san.rr.com Mon May 29 20:09:17 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 30 May 2000 00:09:17 GMT Subject: String.join revisited (URGENT for 1.6) References: <28052000.5@sanctum.jae.ddns.org> <sj3ejda85pj169@corp.supernews.com> <hjoY4.6071$wYl.223614464@newsb.telia.net> <39328edc$0$18384@personalnews.de.uu.net> <_pyY4.10102$Za1.160118@newsc.telia.net> <3932e628$0$6681@personalnews.de.uu.net> <3932F323.C73E0404@san.rr.com> <3932F5DC.E00C1642@san.rr.com> <ZoDY4.6196$wYl.229414400@newsb.telia.net> Message-ID: <39330745.D96E74AB@san.rr.com> > > > > words = ["foo", "bar", "baz"] > > > > print words.join(" ") > > > > > print ( "foo", "bar" ).join(" ") > > > > I've thought about this for a bit, and it's quite clear to me that > > these idoms are the natural representation for this. Whether or > > not their implementation in python is easily/optimally acheived > > is another issue altogether, but this representation is natural > > and, IMO, right one. > > ...and here we go, back to the beginning of this thread... > > as people have pointed out a couple of hundred times in this thread, > lists and tuples are *heterogeneous* containers. you can put *any* > kind of Python object in them, not just strings. That's true enough. It misfortunately really doesn't make sense to do that without uniform container types, unless, of course, you just threw an exception if an object existed in the container without the appropriate method. I really don't find much wrong with string.join() myself, although " ".join is clearly madness. :)- C/ From blablu at gmx.net Mon May 29 08:48:47 2000 From: blablu at gmx.net (Mike 'Cat' Perkonigg) Date: 29 May 2000 12:48:47 GMT Subject: Changes during run References: <393259F7.8AEE8518@muc.das-werk.de> Message-ID: <8F439375Cmikecat@192.168.10.38> thiele at muc.das-werk.de (Thomas Thiele) wrote in <393259F7.8AEE8518 at muc.das- werk.de>: >I have a program in which a function is called. For instance by pressing >on a button (Tkinter). > >in mainframe class: > >def ButtonPressed(self): > self.Function() > > >def Function(Self): > a = 5 > print a > > >I start the program and all things work great. Only the function >Function is wrong (I wrote a = 5 instead of a = 6 ). >Is it possible to correct the function without restarting the program? > >I start the program and press the button. I see a is 5. >I correct the source code (replace 5 with 6) and press the button again. >And now I want to see that 6 is printed. > >Is this possible? That would be really rapid prototyping! > >Thomas > It is. You have to put your function in a seperate module and reload the module to update the function. I have written a module which checks the file modification date of defined modules and reloads them if the files have been modified. Works, but not if you make an instance of a class in such a module because the instance has a reference to the old class and the reload just creates a new class definition at another place. Regards, Mike From m.faassen at vet.uu.nl Thu May 18 18:19:10 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 22:19:10 GMT Subject: Python3k extended grammar References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> Message-ID: <8g1q8u$drc$2@newshost.accu.uu.nl> Manus Hand <mjhand at concentric.net> wrote: > This is a dumb question, and I know I shouldn't be following Roy's > post with it, since my question is only tangentially related, but.... > (By the way, I agree with Roy that the less new syntax and fewer > new keywords the better! Anyway, as to my own question....) I agree here too. While the types-SIG has come up with many good thoughts, I don't think the proposed syntax is ideal yet. Though perhaps it's more a question of getting used to it. Still, the ':' is overloaded a lot already in Python, and -> looks a trifle odd if it's used in just one place. the 'return' proposal looks prettier to me. But then I change my syntax preference daily. :) > It was with a large degree of alarm that I read that "the language > (Py3K) will be somewhat incompatible." There didn't seem to be > anyplace at python.org that explains this any further. Maybe it has > been rehashed before, but could the scope of Py3K be spelled out > for those of us who fear it? Nobody knows yet. It's possible that it'll be case insensitive, which is of course incompatible. Oh, and 1/2 might give you a float. Rather minor changes. Then of course.. > Things like talk about having to declare variables and their > types and having to specify function return types scare > me. They scare me to death. I love Python, but if stuff like > that becomes required, I will stick with 1.6 forever. If > someone will reassure me that I won't *have* to use typing > and declaration, then I will be happier. Much. Right; if it was required to declare variables, I'd be scared too. Luckily it's never been the plan to make such declarations required. They're always optional. That didn't stop some of us paranoid folks from worrying on the types-SIG, though. I was wondering if there mightn't be subtle pressures towards the idea that full type annotation is good Python style, somehow, and worried about this ghostly image. Not so much by the language (though there's the const-correctness infection in C++), as by the culture surrounding the language. Currently type annotations are just too vague to be really worried about such spectres, though. So the short answer is: don't worry, they'll be optional. We understand the enormous value of dynamic type-checking in the Python world. Plans about Py3k are completely vague, however, so I'm probably talking through my hat. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From guido at python.org Thu May 18 23:45:12 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:45:12 GMT Subject: How to get volume name under Win32? References: <074701bfc122$d57310c0$1906a8c0@fc.fenx.com> <8g21qi$dm4$1@supernews.com> Message-ID: <3924E32A.4AC8AE4D@python.org> Dale Strickland-Clark wrote: > > In fact ,I can't get os.popen to work at all! As has been said many times before, os.popen() is 99% broken on Windows 95/98. The error you posted is typical for the situation. Rumor has it that it works on W2000... -- --Guido van Rossum (home page: http://www.python.org/~guido/) From adv at langdale.com.au Tue May 23 20:17:24 2000 From: adv at langdale.com.au (Arnold de Vos) Date: Wed, 24 May 2000 10:17:24 +1000 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <8gf3ms$jce$2@newshost.accu.uu.nl> Message-ID: <392b1f96$0$2624@news01.syd.optusnet.com.au> > Arnold deVos <adv at langdale.com.au> wrote: > > The real problem is that a module exports all the symbols it has imported. > > You mean the real problem with importing '*'? I hardly ever use it. :) > Yep. As pointed out on this group from time to time, import from * can be harmful. - Arnold From gansevle at cs.utwente.nl Mon May 8 15:56:44 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Mon, 08 May 2000 19:56:44 GMT Subject: dinamical object creation References: <8f74lo$spt$1@nnrp1.deja.com> Message-ID: <8f765j$uam$1@nnrp1.deja.com> In article <8f74lo$spt$1 at nnrp1.deja.com>, martin_valiente at my-deja.com wrote: > Hi * > > How can I create an object at runtime, giving its module and class name? > In java it would be: > > Class c = class.forName(stringWithFullNameOfTheClass); > Object o = c.newInstance(); The simpelest way, without having to figure out which part of the "stringWithFullNameOfTheClass" is the module and which part is the class is to pass them both to a function, i.e. def classFromModule (module, className): mod = __import__ (module) return getattr (mod, className) You can use this as follows: c = classFromModule (ModuleOfTheClass, NameOfTheClass) o = c () or, even: o = classFromModule (ModuleOfTheClass, NameOfTheClass)() > > but, in python I'm a bit lost... > > Thanks in advance. > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Sat May 13 21:09:29 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 May 2000 21:09:29 -0400 Subject: python improvements (Was: Re: New Language) In-Reply-To: Michael Hudson's message of "13 May 2000 16:47:54 +0100" References: <LNBBLJKPBEHFEDALKOLCOEAKGAAA.tim_one@email.msn.com> <391CE9E8.C7D9305@san.rr.com> <8fjhu8$l6k$4@newshost.accu.uu.nl> <391E60FC.6B4B@seebelow.org> <m3wvkypi39.fsf@atrus.jesus.cam.ac.uk> Message-ID: <oqem76hr92.fsf@titan.progiciels-bpi.ca> Michael Hudson <mwh21 at cam.ac.uk> writes: > You mean you sometimes don't read Tim's posts? Strange person... My mail reader is setup so Tim's posts are automatically rendered bold on the selection display, to decrease the probability that I miss any by mistake. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From c.evans at clear.net.nz Mon May 22 04:18:15 2000 From: c.evans at clear.net.nz (Carey Evans) Date: Mon, 22 May 2000 08:18:15 GMT Subject: C++ extension module crashes on Solaris References: <BAEMJNPFHMFPEFAGBKKACEMICBAA.dan@cgsoftware.com> <svaehmfpmo.fsf@hodge.primus.com> <cpn1llvks5.fsf@cj20424-a.reston1.va.home.com> <svwvknl44j.fsf@hodge.primus.com> Message-ID: <87u2fr3smw.fsf@psyche.evansnet> sharris at nospam.primus.com (Steven E. Harris) writes: > Other advice involving compiling the extension with '-fPIC' also > seemed relevant, but turned out to not make any difference. Now I'm > not sure why '-fPIC' _isn't_ required! If you don't compile with -fPIC, the code will be relocated when it is loaded. It can't be shared between processes this way, though, so each Python that loads the extension will get a new copy of the code. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "CA|\| NE1 0N Th]5 BB0ARD T3Ll M3 H0w 2 GeT KeWL S]Th P0WeRZ!?!?!?!??!?" - seen in alt.binaries.warez.protocol-droids.c3 by henke From fw at deneb.cygnus.argh.org Thu May 25 16:11:47 2000 From: fw at deneb.cygnus.argh.org (Florian Weimer) Date: 25 May 2000 22:11:47 +0200 Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> <392C4B4F.60C4@esatclear.ie> <392C7F0F.64BA39D0@cosc.canterbury.ac.nz> Message-ID: <87itw2qtj0.fsf@deneb.cygnus.argh.org> Greg Ewing <greg at cosc.canterbury.ac.nz> writes: > If you know that the operands will never be negative, declare them > as unsigned so that the compiler has the chance to optimise. Or give > the language another operator that complains about negative numbers. Or use a language which has distinct integer types (i.e. integer types with no automatic conversion between them). Of course, this can lead to type inflation, but in my experience, it helps to avoid a lot of silly mistakes. From pinard at iro.umontreal.ca Fri May 12 23:55:07 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 12 May 2000 23:55:07 -0400 Subject: HEAP/priority queue In-Reply-To: Courageous's message of "Sat, 13 May 2000 00:49:03 GMT" References: <391CA714.3EB0E8B5@san.rr.com> Message-ID: <oq66sj6r50.fsf@titan.progiciels-bpi.ca> Courageous <jkraska1 at san.rr.com> writes: > Is there a heap anywhere in the python modules? I did an exaustive grep > on all the html files, and could find nothing. I'd prefer a native module, > of course. I once discussed exactly this with Guido, who replied he did not feel like natively supporting every kind of interesting data structures. I thought I did one such module (in Python), but do not find it... OK, I just wrote this in a rush for you. Not tested yet. Maybe tomorrow? If you test it before I do, tell me where my bugs were! Keep happy! :-) """\ Handle heaps (where a[k] <= a[2*k+1] && a[k] <= a[2*k+2]). Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] simultaneously, for all k, counting elements from 0. For the sake of comparison, unexisting elements are considered to be infinite. The interesting property of a heap is that a[0] is its smallest element. """ class Heap: def __init__(self, compare): self.compare = compare self.array = [] def resift(self): array = self.array compare = self.compare low, high = 0, 1 while high < len(array): if high+1 < len(array) and compare(array[high], array[high+1]) > 0: high = high+1 if compare(array[low], array[high]) <= 0: break array[low], array[high] = array[high], array[low] low, high = high, 2*low+1 def increase(self, item): array = self.array compare = self.compare array.append(item) high = len(array) - 1 while high > 0: low = (high-1)/2 if compare(array[low], array[high]) <= 0: break array[low], array[high] = array[high], array[low] high = low def decrease(self): array = self.array array[0] = array.pop() self.resift() -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From embed at geocities.com Fri May 26 10:28:32 2000 From: embed at geocities.com (Warren Postma) Date: Fri, 26 May 2000 10:28:32 -0400 Subject: Accumulated Dreck versus Clean Design - was "why tar is strange" References: <000601bfbfc5$95612f20$b52d153f@tim> <ja7lctey7i.fsf@helix.twistedmatrix.com> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <slrn8ic65n.9nc.jajs@Pascual.es> <392EEEE3.2D37@seebelow.org> Message-ID: <nWvX4.31786$HG1.639061@nnrp1.uunet.ca> Juanjo ?lvarez wrote: > While you launch and use winzip I can type 5 times "tar zxvf" <off-topic-rant-mode> Why hasn't 'untar' become a standard script? I HATE typing "tar zxvf". Just learning all the undocumented idioms of Unix has been a lifetime of pain and agony for me, and I'm still not finished. It reminds me of the disgusting mess I had to use, called a Control Data CYBER 9000 mainframe. Would you like to change working directories, how about typing this in: $CHANGE_WORKING_CATALOG @NEW_DIRECTORY:='DISK398408A9083A90380983:SUBDIR1:SUBDIR2' The short form was something like this: first three letters of the first work of the command (CHA) plus the first letter of each word after that (W, C), so the short form of CHANGE_WORKING_CATALOG was CHAWC. So you typed CHAWC instead of the more readable Unix or CP/M variant "cd". Nice going, eh? Yes, folks, there are things more obtuse than Perl out there, but only just barely. The above sample I've given is not actually right, because even when I used the CYBER9000 a lot, I couldn't keep the weird syntax in my head, and had to resort to a printed "crib sheet" just to get basic things done. Back to the lesser evil for a minute: Unix commands are still so obtuse that I have a hard time keeping them in my head. The overall impression I get is that they have developed through years and years of pragmatic stepwise refinement, and have become layer upon layer of crusty code, like an old house with 100 coats of paint, each one peeling away to show the layers beneath. The ultimate expression of this accumulated "as-built" dreck, IMHO, is Perl, and it is the reason, among other things, that I prefer Python. Look, a feeble attempt to bring myself back on topic... :-) </off-topic-rant-mode> Warren From bronsn at homtail.com Fri May 12 08:18:22 2000 From: bronsn at homtail.com (Firehawk343) Date: Fri, 12 May 2000 05:18:22 -0700 Subject: python book recommendations? Message-ID: <8fgsqq$kuo@news.or.intel.com> I'm new to Pyhton and would appreciate advice on what book(s) will help me ramp up the fastest. Maybe O'Rielly or "Programming with Python" by Tim Altom? thanks From mwh21 at cam.ac.uk Wed May 17 16:04:03 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 May 2000 21:04:03 +0100 Subject: Decimals -> Fraction strings, my solution References: <slrn8i3grk.dg.kain@cableadmin.com> <oqpuqmkjt9.fsf@titan.progiciels-bpi.ca> <m31z31mrqh.fsf@atrus.jesus.cam.ac.uk> <oq1z31x8ss.fsf@titan.progiciels-bpi.ca> Message-ID: <m3og65kkp8.fsf@atrus.jesus.cam.ac.uk> =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard at iro.umontreal.ca> writes: > Michael Hudson <mwh21 at cam.ac.uk> writes: > > > You have the right approach (continued fractions), but you're > > implementation is more complex than it needs to be. [...] Same numbers > > as before, but rather less effort to get them, I think. > > Thanks for sharing this. Your solution computes a single continued > fraction to the maximum precision, and then uses it to show the successive > approximations up to that maximum precision. Which surely is a good thing. > My solution computes a single continued fraction, but stops the computation > when some error tolerance has been reached. I then called the whole thing > many times to make experiments, resulting indeed in much total work. The line that particularly stuck me in your code was: while residual != 0 and abs(value - float(self)) > tolerance: from ContinuedFraction.__init__. The call to "float(self)" calls self.__float__ which calls self.eval, which computes the convergents from scratch. You don't really need to go through all that to bound the error in the convergent. Though quite how it works temporarily escapes me... One approach would be to estimate the error in P/Q by abs(P/Q-R/S) where R/S is the next convergent. I'm not sure how valid this would be; fairly, I suspect. It'll be an overestimate. > In practice, I guess it is programmatically easier to decide of some > tolerance in advance, and find a single solution from it, than to find > all solutions up to the maximum precision possible, and later scan all > these to decide which is one that should be retained. I semi-deliberately avoided this issue; do you want "0.6667" to produce 2/3 or 6667/10000? To decide would seem to need some kind of AI, or at least teleology. WRT performance, the longest sequence cfrac will churn out is from (1+sqrt(5))/2 (it's *that* number again!) and that's only 38 partial quotients (all 1's). It is possible to intermingle the calculation of the partial quotients with the convergents, but it clutters the code rather. > Yours is surely more entertaining when used interactively! :-) Yeah, continued fractions are fun... Cheers, M. -- Strangely enough I saw just such a beast at the grocery store last night. Starbucks sells Javachip. (It's ice cream, but that shouldn't be an obstacle for the Java marketing people.) -- Jeremy Hylton, 29 Apr 1997 From dalke at acm.org Sun May 14 17:30:51 2000 From: dalke at acm.org (Andrew Dalke) Date: Sun, 14 May 2000 15:30:51 -0600 Subject: (gulp) newbie question - portablity of python References: <Pine.GSO.4.10.10005142328180.21724-100000@sundial> Message-ID: <8fn681$m6b$1@slb6.atl.mindspring.net> Moshe Zadka wrote in message ... >Keygrass wrote: >> Basically, I want a build a program that will replace words and number on >> another file. For example, if I had a file called "Outdoor_sports" that >> contained the word "baseball bat", I would want my program to change it so >> it would say "football". Moshe Zadka wrote: >Here it is, in its entirety. >#!/usr/local/bin/python >import string, sys > >def replace_word_in_file(file, word, replacement): > f = open(file) > s = f.read() > f.close() > s = string.replace(s, word, replacement) > f = open(file, 'w') > f.write(s) > f.close() > >if __name__ == '__main__': > if len(sys.argv) < 4: > exit(1) > for file in sys.argv[3:]: > replace_word_in_file(sys.argv[1], sys.argv[2], file) That won't replace "baseball bat" if it breaks across a newline. You need do a regular expression replacement, converting " " to "\s+". Something like the following, untested code. import re, string def replace_word_in_file(file, word, replacement): f = open(file) s = f.read() f.close() pattern = re.escape(word) pattern = string.replace(pattern, r'\ ', r'\s+') s = re.sub(pattern, replacement, s) f.open(file, "r") f.write(s) f.close() >>> s = """This is a baseball ... bat from Cleveland.""" >>> word = "baseball bat" >>> pattern = re.escape(word) >>> print pattern baseball\ bat >>> pattern = string.replace(pattern, r'\ ', r'\s+') >>> print pattern baseball\s+bat >>> re.sub(pattern, "football", s) 'This is a football from Cleveland.' >>> Even supports double spaced lines and form feeds :) Andrew dalke at acm.org From brent.fulgham at xpsystems.com Tue May 23 16:22:20 2000 From: brent.fulgham at xpsystems.com (Brent Fulgham) Date: Tue, 23 May 2000 13:22:20 -0700 Subject: Special question to embedding Python into C++ Message-ID: <EDFD2A95EE7DD31187350090279C67678A4427@THRESHER> Reinhard, When you embed Python in a program (C or C++), you are linking the static library that contains the entire Python runtime. You will be missing the various "*.py" modules needed for runtime, so these may need to be included in your distribution. You should be able to freeze these modules somehow, but I'm not sure what the procedure would be for this case... Thanks, -Brent > -----Original Message----- > From: Reinhard Koenig [mailto:rkoenig at ginko.de] > Sent: Tuesday, May 23, 2000 1:11 PM > To: python-list at python.org > Subject: Special question to embedding Python into C++ > Importance: High > > > Hello, > > How can I embed Python into C++ and ship my application to an user not > having Python? Is there a similar mechanism like freeze for embedded > Python? > > Reinhard K?nig > -- > http://www.python.org/mailman/listinfo/python-list > From jae at ilk.de Sat May 20 22:57:32 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Sun, 21 May 2000 04:57:32 +0200 Subject: Damnation! In-Reply-To: <Pine.GSO.4.10.10005201844330.5989-100000@sundial> (message from Moshe Zadka on Sat, 20 May 2000 18:51:44 +0300 (IDT)) References: <Pine.GSO.4.10.10005201844330.5989-100000@sundial> Message-ID: <21052000.1@sanctum.jae.ddns.org> ----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Moshe" == Moshe Zadka <moshez at math.huji.ac.il> writes: Moshe> On Sat, 20 May 2000, Thomas Malik wrote: >> Same for me ... >> I've just convinced our whole department (at a german bank) to >> use Python instead of Perl. A case - insensitive language won't >> be acceptable by any of us. So, Guido, should i start looking >> for another job ...? BTW, congrats... you wouldn't be at liberty to divulge the name of that bank? Thought so... [... Python's roadmap up to 1.8 according to Moshe...] Moshe> BTW: Case-insensitivity a show stopper? This boggled me. I mean, case Moshe> sensitivity/insensitivity is the most minor feature of programming Moshe> language. Type declerations, memory management, and even whitespce seem Moshe> like much more earth shaking issues. Name just one language that switched from case-sensitivity to case-insensitivity. I've never heard of this being done... and if there was such a case I'm sure there was a) some mighty fine flamewars to behold and b) a split in the community. I think that if Py3K is to be too far from the Python of today and/or there are no sufficiently effective conversion tools, there *will* be a split. Oh, and forget about the "But you don't have to switch" line. Yes, you don't *have* to switch from 1.5.1 to 1.5.2 if you don't like it. But then you won't be able to use the latest and greatest Mailman release... so it's not just about switching or not switching... there are more and more tools and apps (and even parts of the infrastructure) dependent on Python, and many of them on a specific version (and come Py3K, most of the actively developed ones). Bye, J PS: This last point jumped around in my head for a week or two already... PPS: This not intended as a flame of any kind... I'm just very concerned that the players here are aware of the potential consequences. I'd *hate* to see the Python community split. PPPS: And I like controversial stuff... ;-) - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard SPACE: Above And Beyond (http://www.planetx.com/space:aab) Win32 has many known work arounds. For example, Linux. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjknUJsACgkQN0B+CS56qs3ulwCfcdliR7G4UtbDyQhigvzxMQpT c1YAniYMPdUL1nDTqYHt2OZ1bdEm47lt =EEiU -----END PGP SIGNATURE----- From johann at physics.berkeley.edu Sun May 28 20:32:33 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 28 May 2000 17:32:33 -0700 Subject: NumPy and Octave (qestion and discussion) References: <slrn8ionh8.vq.hzhu@rocket.knowledgetrack.com> <slrn8itueg.111.hzhu@rocket.knowledgetrack.com> Message-ID: <mtk8ge42n2.fsf@astron.berkeley.edu> Huaiyu Zhu writes: > So my point is that perhaps the importance of numerical computation warrant > an (expressional) syntax that's more convenient. I think this can be done > without conflict with python's general syntax. It just need to be different > from NumPy's special choices. > To see why one would want this, consider an example. Suppose one wants to > build a learning machine that learns to play chess. Python would be a very > good language to write the overall structure, like players, the world, etc. > But the actual learning algorithm (neural network, statistics, etc) needs > lots of numerical computation which are very well expressed in matlab/ > octave. Can this be done efficiently in python? Right now writing these in > NumPy is just too tedious and error-prone. I've been using NumPy to do various problems in theoretical astrophysics, without any problem. In my experience, I use the NumPy-style element-wise array combinations more often than I use actual matrix math. I don't mind having to write matrixmultiply the few times I have to treat my 2D arrays as matrices. This is clearly not your experience, but it may help you understand why there isn't more of a groundswell of support in favor of specializing NumPy more towards linear algebra. Syntax helps, such as ' for transpose, will simply not happen, due to python's general-purpose nature. Introducing new operators will also likely not happen. --Johann -- Johann Hibschman johann at physics.berkeley.edu From jkraska1 at san.rr.com Wed May 24 13:27:34 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 24 May 2000 17:27:34 GMT Subject: Python equivalent to Perl's warn/confess/die References: <8gfbre$d64$1@nnrp1.deja.com> <392BE18F.D5F21F27@earthlink.net> <Pine.WNT.4.21.0005240907250.269-100000@nt_alester> Message-ID: <392C11A6.F46ED7C6@san.rr.com> > But is there a module somewhere that encapsulates that so I don't > explicitly send it to stderr? You can set the stdout to *be* the standard error. I don't know about you, but I don't want any unbuffered IO anyway. Doing this "print" *becomes* your "warn". C/ From nospam.newton at gmx.li Tue May 23 01:06:56 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Tue, 23 May 2000 05:06:56 GMT Subject: [PATCH] Identifiers with '?' References: <slrn8iggo5.9vk.neelk@brick.cswv.com> <m3em6vn1fw.fsf@atrus.jesus.cam.ac.uk> Message-ID: <392a054a.556160620@news.nikoma.de> On 21 May 2000 20:33:07 +0100, Michael Hudson <mwh21 at cam.ac.uk> wrote: >Tee hee. I have on my machine built (in the last few days) a Python >that allows one to use identifiers containing +, *, !, ?, & and @. >This means you have to space your operators properly, but is IMHO >quite a cool mod. I can clean it up and post the patch for that if >anyone's interested... Why not add '$' to that to cater to people from the VMS (or even BASIC) world? SYS$LOGICAL and all that (or whatever they look like). Or allow $ @ % to appear at the start of an identifier so more Perlers will be attracted to Python <wink>. first-paragraph-sort-of-seriously-but-second-one-not-ly yours, Philip -- Philip Newton <nospam.newton at gmx.li> If you're not part of the solution, you're part of the precipitate. From cut_me_out at hotmail.com Sun May 7 14:53:27 2000 From: cut_me_out at hotmail.com (Alex) Date: 07 May 2000 14:53:27 -0400 Subject: + and * operators References: <3915B949.46649689@stud.ntnu.no> Message-ID: <etd7ld6yyxk.fsf@w20-575-109.mit.edu> > Is there some way to refer to the + and * operators as functions? Yeah, use the operator module >>> import operator >>> operator.add (5, 2) 7 >>> operator.mul (5, 2) 10 >>> Alex. From hughett at mercur.uphs.upenn.edu Thu May 4 14:52:21 2000 From: hughett at mercur.uphs.upenn.edu (Paul Hughett) Date: 4 May 2000 18:52:21 GMT Subject: Copyright and License References: <39119033.8BC1A4EA@colconsulting.com> Message-ID: <8esgt5$p3l$1@netnews.upenn.edu> Frank V. Castellucci <frankc at colconsulting.com> wrote: : Does anyone have the text for the standard Python license for : distributing Python language source? NOT for Python itself, but for : source written to be run BY Python. If you write the code, you get to choose the license; unless someone has hired you to write the code, in which case they get to choose the license. Paul Hughett From nickm at mit.edu Sun May 14 20:43:47 2000 From: nickm at mit.edu (Nick Mathewson) Date: Mon, 15 May 2000 00:43:47 GMT Subject: Adventures in Currying References: <1pDT4.7832$Lp1.191508@typhoon2.ba-dsg.net> <m3u2g0og4h.fsf@atrus.jesus.cam.ac.uk> Message-ID: <7LHT4.5975$gl2.246568@typhoon1.ba-dsg.net> On 15 May 2000 00:40:14 +0100, Michael Hudson <mwh21 at cam.ac.uk> wrote: >nickm at mit.edu (Nick Mathewson) writes: [...] >> With this in mind, I >> started writing up currying operators of various degrees of >> complexity. I give them below, in their approximate evolutionary >> order. They are all classes designed to turn python functions into >> curried functions. [...] > >Are you aware of my bytecodehacks package? One of the modules in it >is "xapply", which basically curries functions. You can see it here: > >http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/bytecodehacks/bytecodehacks/xapply.py?rev=1.9&content-type=text/x-cvsweb-markup&cvsroot=bytecodehacks > >and read about it here: > >http://bytecodehacks.sourceforge.net/bch-docs/bch/module-bytecodehacks.xapply.html I've seen bytecodehacks, but I didn't know it could do this. Reading the source... Merciful <deity>! Your code seems to be looking at which instructions you're replacing, and gathering up all the loads and stores that refer to them. Then it replaces the ones which are never loaded with constants, and replaces all the ones that _do_ get loaded with new variables that are initialized at the start of the function. It adds the constants to the method's constant list, and reindexes all the local variables. It is amazing. The only really big difference I can find between your code and mine is that mine treats the filled-in arguments as new 'defaults', while yours removes the arguments the arguments as they're filled in. In other words: def fun(a,b): return 2*a+b from bytecodehacks.xapply import xapply f = xapply(fun,b=10) print f(3) # Prints 16 print f(3,b=0) # Gives an error. from curry import Curry4 f = Curry4(fun,b=10) print f(3) # Prints 16 print f(3,b=0) # Prints 6 This is, all things considered, probably a feature on your part and a bug on mine. >I think it should work with 1.6 (can't think why not anyway); it >hasn't a hope with JPython. Ugh. I sat for a moment, trying to think of a way to do this with dynamicly generated Java bytecode. My brain now hurts. >i-sense-another-of-my-kind-ly y'rs >M. Rather-write-prorgams-to-write-programs-ly y'rs -- Nick Mathewson <nickm at mit.edu> http://www.mit.edu/~nickm/ From scherbi at bam.com Fri May 19 11:56:57 2000 From: scherbi at bam.com (Bill Scherer) Date: Fri, 19 May 2000 11:56:57 -0400 Subject: Guitar tuning program References: <YLaV4.46370$wz3.175637@newscontent-01.sprint.ca> <39254b99.9018932@news.bpsinet.com> <mhdV4.46825$wz3.177364@newscontent-01.sprint.ca> Message-ID: <39256449.6B4E3CFD@bam.com> Laurent - Have you tried a search on freshmeat.net yet? http://freshmeat.net/search.php3?query=guitar+tune Laurent Duperval wrote: > In article <39254b99.9018932 at news.bpsinet.com>, cwstan at 8bpsinet.8com > (Chuck) wrote: > > Seems to me it would be far more efficient and practical to just > > purchase one of the $15.00/20.00 tuners and use that. Hell, you can > > throw that in your guitar case or gig bag and always have it with you. > > > > Yes, I agree. But since I already have one which works fine, except for > this detail, and since I only want to do this for a particular task where > my computer is always handy, it doesn't bother me much. I'd buy another > one if I knew how to actually play... :-) > > L > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From grisha at ispol.com Tue May 30 21:45:09 2000 From: grisha at ispol.com (Gregory Trubetskoy) Date: Tue, 30 May 2000 21:45:09 -0400 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (May 30) In-Reply-To: <FF3F3F298A296331.2D356AEB49F756D6.A0A69E588E2D86B7@lp.airnews.net> References: <FF3F3F298A296331.2D356AEB49F756D6.A0A69E588E2D86B7@lp.airnews.net> Message-ID: <Pine.LNX.4.21.0005302141140.26360-100000@saturn.ispol.com> On 30 May 2000, Andrew M. Kuchling wrote: > Httpdapy has been renamed to mod_python. Mod_python is an Apache HTTP > server module that allows embedding Python within Apache. > http://www.modpython.org/ s/renamed to/obsoleted by/ httpdapy != mod_python mod_python is something new and entirely different. :-) Grisha From confused at americasm01.nt.com Tue May 30 11:02:38 2000 From: confused at americasm01.nt.com (Morris, Brad [WDLN2:2W40:EXCH]) Date: Tue, 30 May 2000 11:02:38 -0400 Subject: Array assigment with Numeric.py Message-ID: <3933D80E.172D09F7@americasm01.nt.com> Hi, Re: Python 1.52 with Numerical.py I'm having difficulty with the assignment of an array based value to another array based value. The error message is approximately "array shapes don't match". I suspect it has to do with the way arrays are stored and the way assignment is treated (i.e. if c is an array then a = c simply makes 'a' point to 'c' it does not make a new copy) but I don't fully understand how to get what I want. Simple example: c = array([[1.0, 2.0, 3.0, 4.0],[5.0, 6.0, 7.0 8.0]]) c.shape (2,4) d = array([9.0, 11.0, 3.0, 12.0, 15.0, 20.0]) d.shape (1,6) temp = d[0] * d[5] c[0,0] = temp c[0,0] = d[0] * d[5] So temp == 180 as expected and has a shape of (1,) but the subsequent 2 lines fail with an error message along the lines of "array shapes don't match". Both the right and left halves of the last two lines represent a single value but somehow the underlying shape is getting in the way. Coming from a long history of Matlab use is probably not helping me! How do I force (coerce?) the right hand argument in to the left? Regards, Brad From moshez at math.huji.ac.il Sat May 13 02:48:32 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 13 May 2000 09:48:32 +0300 (IDT) Subject: AI and Python In-Reply-To: <OwZBsfGv$GA.306@cpmsnbbsa04> Message-ID: <Pine.GSO.4.10.10005130941190.11094-100000@sundial> On Fri, 12 May 2000, lexberezhny wrote: > Hi, > I was wondering if anyone has dont any artificial inteligence with Python. > I am writing a program for my school, which is ment to talk to kids in > trouble, it will ask some simple questions based on the student answers, > there is already a list of questions that we might want answered, so its not > really AI. But I wanted any opinions on this topic. Thanks. I have a bit of experience, and the lesson is that Python is good for AI, but AI is hard objectively. I had a cute idea for a conversation AI, based on learning and parroting, but with some cool tricks. I never got beyond starting the data-structures in C++, I never got beyond seeing how it would work in Scheme. I finished it in one Python-filled afternoon, and discovered the idea sucked big time. I was glad I did it in Python, because it only cost me one afternoon to discover the idea sucks. Python has cool data-structures this purpose, and some cool functions: a few minutes of playing with string/re, and you already got past the "lexing" part of parsing natlang. A few map(...), and you put your text in some canonical form (all lower case, standard spelling of words, etc.). filter() makes it really easy to get rid of noise words ("a", for example). Writing a pseudo-parser with recursive decent and arbitrary look ahead can be done with list.reverse(), and list.pop()'ing elements you read. Of course, all that doesn't really help you with AI -- it only helps you quickly see any AI idea you think you have doesn't work because natlang is too hard <wink> but-it's-fun-playing-with-it-anyway-ly y'rs, Z. -- Moshe Zadka <moshez at math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From Gareth.McCaughan at pobox.com Thu May 11 16:48:06 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 11 May 2000 21:48:06 +0100 Subject: Python style. References: <391914DD.BF2A2C32@ecs.soton.ac.uk> <_49S4.3483$wYl.201410048@newsb.telia.net> <8666smcfwv.fsf@g.local> <8feioj$fei$1@nyheter.chalmers.se> <8feld6$8h8$1@nnrp1.deja.com> Message-ID: <863dnodda1.fsf@g.local> Andrew Cooke wrote: [Fredrik Aronsson wrote:] >> Well, using Haskells syntax, I would suggest >> map((\a,b,c -> a+b+c), p,q,r) > > what's that funny backslash for? It's a lambda. Honest. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From martin_valiente at my-deja.com Mon May 8 10:36:21 2000 From: martin_valiente at my-deja.com (martin_valiente at my-deja.com) Date: Mon, 08 May 2000 14:36:21 GMT Subject: import modules at runtime Message-ID: <8f6jd5$7mg$1@nnrp1.deja.com> Hi * Is there a way to create an object instance giving its classname at runtime? In java you can say: ... Class c = Class.forName(stringWithTheNameOfTheClass); Object o = c.newInstance(): ... Thanks in advance M. Sent via Deja.com http://www.deja.com/ Before you buy. From erik_wilsher at my-deja.com Thu May 18 02:21:24 2000 From: erik_wilsher at my-deja.com (erik_wilsher at my-deja.com) Date: Thu, 18 May 2000 06:21:24 GMT Subject: <float>range(0.0,100.0,0.1) References: <DUCU4.21867$HG1.541688@nnrp1.uunet.ca> Message-ID: <8g024r$63t$1@nnrp1.deja.com> In article <DUCU4.21867$HG1.541688 at nnrp1.uunet.ca>, "Warren Postma" <embed at geocities.com> wrote: > how do you do this: > > for i in range(0.0, 100.0, 0.1): > print i > you can make a frange object approximately like this: (I did this a year ago, but can't find the code again, so this is untested) class frange: def __init__(self, min, max=None, step=None): if max == None: self.min = 0. self.max = min else: self.min = min self.max = max if step == 0.0: raise ValueError, "zero step for frange()" elif step == None: self.step = 1.0 else: self.step = step def __getitem__(self,item): rv = self.min + self.step*item if rv >= self.max: #not sure about the boundry here raise IndexError, "list index out of range" return rv (rought code, no cheching for max < min, step < 0.0 etc) The main point is that the iteration in python is terminated through an IndexError exception. GvR has indicated that the iteration control will change in py3k. Erik Wilsher Sent via Deja.com http://www.deja.com/ Before you buy. From mwh21 at cam.ac.uk Sat May 20 12:58:30 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 20 May 2000 17:58:30 +0100 Subject: Damnation! References: <Pine.GSO.4.10.10005201844330.5989-100000@sundial> Message-ID: <m34s7tnop5.fsf@atrus.jesus.cam.ac.uk> Moshe Zadka <moshez at math.huji.ac.il> writes: > On Sat, 20 May 2000, Thomas Malik wrote: > > > Same for me ... > > I've just convinced our whole department (at a german bank) to use Python > > instead of Perl. A case - insensitive language won't be acceptable by any of > > us. So, Guido, should i start looking for another job ...? > > I'm not Guido, but I'll try, for the n-th time, to give an overview. > Python 1.6a2 is out. > In a few months, hopefully, Python 1.6 final will come out. s/months/weeks/ I thought? I mean, June 1 was the projected release date, wasn't it? > Then, Python 1.7 is planned to take another year. It is still > unsure, at this stage, whether a Python 1.8 release will be issued. Of > course, if show-stopping bugs will be found in a released version, a > new version 1.x.y might be released. The whole 1.x line is firmly commited > to backwards compatability, modulu changing undocumented behaviour. > Once Python 1.7 or 1.8 will be released, Py3K development will start. It > will probably take at least a year, with many design decisions debated on > various sigs. So, for at least 2.5 years, Python will remain > case-sensitive. I have no real comment, except for what Moshe said here, so I'll be lazy and just quote it. > BTW: Case-insensitivity a show stopper? This boggled me. I mean, case > sensitivity/insensitivity is the most minor feature of programming > language. Type declerations, memory management, and even whitespce seem > like much more earth shaking issues. It would annoy me; it seems a kind of pointless thing to change. But I've used case-insensitive (well, if you're being simplistic) langauges like Lisp without it causing much problems, so I could change I guess. What I *would* like is a more lisp-ish approach to what makes an identifier - so I can call things "has-name?" or "set-name!". Wouldn't fit much with Python's other syntax, and would force people to write operators with spaces around them (but I might consider this last a good thing...). dreaming-ly y'rs m. -- Darned confusing, unless you have that magic ingredient coffee, of which I can pay you Tuesday for a couple pounds of extra-special grind today. -- John Mitchell, 11 Jan 1999 From Jhlee at Brooks.com Thu May 18 15:57:54 2000 From: Jhlee at Brooks.com (Lee, Jaeho) Date: Thu, 18 May 2000 15:57:54 -0400 Subject: FindPerformanceAttributesByName() of win32pdhutil changes current directory Message-ID: <857F15D7E3D8D3118D290008C7CF058601347C06@mail-naeast1.brooks.com> I found that FindPerformanceAttributesByName() of win32pdhutil changes the current directory of the process. import os, win32pdhutil print "before", os.getcwd() pids = win32pdhutil.FindPerformanceAttributesByName(procname) print "after", os.getcwd() After the function call, getcwd() gives the first directory of my $PATH. Possible bug of win32pdhutil? Thanks, Jaeho From dan at control.com Wed May 10 13:09:58 2000 From: dan at control.com (Dan L. Pierson) Date: Wed, 10 May 2000 13:09:58 -0400 Subject: Python/Zope References: <NDBBLJJLLFOJMLCMJPLOGEAGDNAA.charlie@intelligenesis.net> <3DDBDA594E55C9EC.E425C32F683DAB41.92F6E57858733657@lp.airnews.net> <8fblee$8h3$1@news.sysnet.net.tw> Message-ID: <4ZMZOXA2u+faCqASN9KBLDiw6eom@4ax.com> "Fabio Augusto Mazzarino" <mazza at radiumsystems.com.br> wrote: > I have searched Zope.org, but unfortunatelly i didin't find anything about > a newsgruop, but a lot of mail-box-filling-out-mailing-lists. > I know you are wondering why I am looking for a newsgroup... but... > nevermind... keep wondering. Someday I'll tell you. This has come up before on the zope-user list. My memory of the reasons why not are a bit hazy. Here's my best guess: 1. No one at Digital Creations has time to do this. Volunteers welcome :-). 2. Some people are afraid that a news/mail gateway will cause even more noise on the list. There's some justice to this, but news reading tools tend to be better at filtering noise, so... I can't remember if this view was strong enough to veto a volunteer. My advise is to ask about this on one or more of the Zope lists if and only if you're prepared to do the work. I'd rather like to see it happen, but am not prepared to do the work so I shut up :-) Dan Pierson, Control Technology Corporation dan at control.com From rob at electric-id.com Sun May 28 03:37:13 2000 From: rob at electric-id.com (Rob Elder) Date: Sun, 28 May 2000 00:37:13 -0700 Subject: cgi odbc sql delete ? Message-ID: <Y24Y4.17$6r4.2650@news.callamer.com> Hello, I have a problem that is driving me crazy. I have created a set of routines to do sql functions (odbc, access) in a cgi script. When the script runs the Insert routine works but the Delete does not. However, in the interactive Python window on the very same server both function work fine. The code is referenced below fyi. If I comment the actual delete line in the routine out, there is no problem. There is something wrong with: dbcursor.execute("DELETE FROM userTable WHERE userID = %s" % sysID) It probably is a format problem (???) but I don't know what it is. If the problem is not obvious, please give me some ideas on how to debug this. I have totally run out of ideas. TIA. -r REFERENCE_________________________ def DeleteRecord(sysID): # this does not work cgi but does work interactively dbconn = odbc.odbc('xFrame_db') dbcursor = dbconn.cursor() dbcursor.execute("DELETE FROM userTable WHERE userID = %s" % sysID) dbcursor.close() dbconn.close() def InsertRecord(sysID): # this works both interactively and cgi dbconn = odbc.odbc('xFrame_db') dbcursor = dbconn.cursor() dbcursor.execute("INSERT INTO userTable (userID) VALUES (%s)" % sysID) dbcursor.close() dbconn.close() From adjih at crepuscule.com Fri May 19 11:58:53 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 19 May 2000 15:58:53 GMT Subject: PyRun_String References: <3924F734.7FA2668F@wetafx.co.nz> Message-ID: <8g3obt$log$1@ites.inria.fr> Mike Morasky <mikem at wetafx.co.nz> wrote: > Embedded in a simple c++ program, I've defined a global dictionary and then: > > PyObject *resultObj = PyRun_String(script, Py_file_input, globalDict, > globalDict); > if( !resultObj ) > { > PyErr_Print(); > } > else > { > PyObject_Print(resultObj, stdout, 1); > Py_DECREF(resultObj); > } > > Anyway, it appears to execute just fine and the errors all print exactly what > you'd expect but the non-error rusults always print "None". I suspect the int > arg to PyObject_Print is wrong. I found reference to Py_Print_RAW, which I > tried but is undefined as a constant. > > Anyone have any pointers? This looks ok. "None" is the default value (in C the object Py_None). (Ponder this in a normal Python interpreter: "print [1,2,3].reverse()"). Now, maybe you want to get the final values of a long list of statements. I don't know the solution: - Putting a "return" statement should fail ("'return' outside function"). - "Py_eval_input" instead of Py_file_input would return a value, but works only for expressions (not statements, or list of statements...) - "Py_single_input" is a possibility, but does it work? - a workaround is, for instance: . to set "returnValue=..." at the end of the Python code . to retrieve the variable "returnValue" in the locals dictionnary (which happens to be also 'globalDict' in the code you posted) after the "PyRun_String". -- Cedric From jkraska1 at san.rr.com Sat May 13 23:41:38 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 14 May 2000 03:41:38 GMT Subject: Arrgh! Please help. References: <391e07b9.88187366@news1.on.sympatico.ca> <54oT4.4117$wYl.206688256@newsb.telia.net> <391e0f88.90186331@news1.on.sympatico.ca> Message-ID: <391E210F.DBD21B72@san.rr.com> chibaA at TinterlogD.Tcom wrote: > > Yeah... it says the value is int - which obviously won't work. > > Is there any way to FORCE fields to be of string? Yes: str = "myinteger is: " +`i` This works for any python object, generally, although sometimes the results aren't pretty. :) Joe. From phd at phd.russ.ru Sat May 6 04:06:24 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 6 May 2000 08:06:24 +0000 (GMT) Subject: HTMLParser tag contents In-Reply-To: <8ev15m$17sj@drn.newsguy.com> Message-ID: <Pine.LNX.4.21.0005060804251.30716-100000@fep132.fep.ru> On 5 May 2000, Grant Griffin wrote: > Perhaps I misspoke. I agree that the solution would probably have to occur at > the level of SGMLParser, but I guess my question remains: can it do that? if so, > how? > > In looking at the SGMLParser source code, it doesn't appear to have any > mechanism to capture the contents of a tag. You cannot "just do it" :) You need to write a class inhertied from SGMLParser, define the methods for capturing <BODY> and from this point forward capture ALL text and ALL tags until </BODY>. Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From embed at geocities.com Wed May 10 12:26:55 2000 From: embed at geocities.com (Warren Postma) Date: Wed, 10 May 2000 12:26:55 -0400 Subject: Why should I switch to Python? References: <seas5ia89177@corp.supernews.com> <3919D30A.74DE@seebelow.org> Message-ID: <Z8gS4.18400$HG1.467054@nnrp1.uunet.ca> I think the best things about Python are: 1. Great Price (Free) and Great Community Support (c.l.py, mailing lists, etc) 2. Introspection is Addictive 3. Fusion of Procedural, Object, and Functional programming styles (I Love Lambda) 4. Too many great libraries and tools to even mention. Gadfly and Zope are but two of the niftiest. 5. Portable GUI: My favourite is wxPython 6. Scales from small shell scripts up to large web server applications Warren From tismer at tismer.com Sat May 13 16:32:45 2000 From: tismer at tismer.com (Christian Tismer) Date: Sat, 13 May 2000 22:32:45 +0200 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <rhgmhs07ulsob3pptd6eh4f2ag4qj911bj@4ax.com> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> Message-ID: <391DBBED.B252E597@tismer.com> Magnus Lie Hetland wrote: > > Aahz Maruch <aahz at netcom.com> wrote in message > news:8fh9ki$51h$1 at slb3.atl.mindspring.net... > > In article <rhgmhs07ulsob3pptd6eh4f2ag4qj911bj at 4ax.com>, > > Ben Wolfson <rumjuggler at cryptarchy.org> wrote: > > > > > >', '.join(['foo', 'bar', 'baz']) > > > > This only works in Python 1.6, which is only released as an alpha at > > this point. I suggest rather strongly that we avoid 1.6-specific idioms > > until 1.6 gets released, particularly in relation to FAQ-type questions. > > This is indeed a bit strange IMO... If I were to join the elements of a > list I would rather ask the list to do it than some string... I.e. > > ['foo', 'bar', 'baz'].join(', ') > > (...although it is the string that joins the elements in the resulting > string...) I believe the notation of "everything is an object, and objects provide all their functionality" is a bit stressed in Python 1.6 . The above example touches the limits where I'd just say "OO isn't always the right thing, and always OO is the wrong thing". A clear advantage of 1.6's string methods is that much code becomes shorter and easier to read, since the nesting level of braces is reduced quite much. The notation also appears to be more in the order of which actions are actually processed. The split/join issue is really on the edge where I begin to not like it. It is clear that the join method *must* be performed as a method of the joining character, since the method expects a list as its argument. It doesn't make sense to use a list method, since lists have nothing to do with strings. Furthermore, the argument to join can be any sequence. Adding a join method to any sequence, just since we want to join some strings would be overkill. So the " ".join(seq) notation is the only possible compromise, IMHO. It is actually arguable if this is still "Pythonic". What you want is to join a list of string by some other string. This is neither a natural method of the list, nor of the joining string in the first place. If it came to the point where the string module had some extra methods which operate on two lists of string perhaps, we would have been totally lost, and enforcing some OO method to support it would be completely off the road. Already a little strange is that the most string methods return new objects all the time, since strings are immutable. join is of really extreme design, and compared with other string functions which became more readable, I think it is counter-intuitive and not the way people are thinking. The think "I want to join this list by this string". Furthermore, you still have to import string, in order to use its constants. Instead of using a module with constants and functions, we now always have to refer to instances and use their methods. It has some benefits in simple cases. But if there are a number of different objects handled by a function, I think enforcing it to be a method of one of the objects is the wrong way, OO overdone. doing-OO-only-if-it-looks-natural-ly y'rs - chris -- Christian Tismer :^) <mailto:tismer at appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From wilen at almhult.com Mon May 8 03:38:42 2000 From: wilen at almhult.com (Daniel Wilén) Date: Mon, 8 May 2000 09:38:42 +0200 Subject: jpython Message-ID: <5auR4.19049$uJ1.40115@nntpserver.swip.net> Can I use the win32api when working with jpython? /D From pinard at iro.umontreal.ca Mon May 22 04:20:11 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 04:20:11 -0400 Subject: Damnation! (was: Re: Python3k extended grammar) In-Reply-To: Russell Wallace's message of "Mon, 22 May 2000 07:21:41 +0100" References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <392877EE.4992@esatclear.ie> <3928A1CB.71890CEC@san.rr.com> <oqhfbrs25u.fsf@titan.progiciels-bpi.ca> <3928D1F5.2897@esatclear.ie> Message-ID: <oqn1lj9etg.fsf@titan.progiciels-bpi.ca> Russell Wallace <rwallace at esatclear.ie> ?crit: > Incidentally, let me remark as a Python newbie on a pleasant surprise. > [...] I'm quite astonished at the quality and civility of comp.lang.python. Some correspondents had commended Python to me for a long time, but I was involved in some big Perl programming, and was not ready for the effort of any big change. Yet, the Perl community was letting me with a bad taste in the mouth. When I was described the qualities of `comp.lang.python' as a group, it was the real push that convinced me to dive and try. Of course, I then hesitated for a few weeks, because of the size of the conversion ask. But Python proved itself to me fast enough, and this is on the way of the translation that I discovered most of its virtues, often with surprise and pleasure. I still read Perl, and even write it once in a while. But I've done the transition, and Python is now my place! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From emile at fenx.com Wed May 17 09:48:34 2000 From: emile at fenx.com (emile at fenx.com) Date: Wed, 17 May 2000 06:48:34 -0700 Subject: reading in a string Message-ID: <3922A332.E29A23A1@fenx.com> I've got a feeling you're getting tripped up parsing and passing on the names to the next command you want done. Pare down your code to a sub-set that exhibits the problem, then post it and we can help better. Emile van Sebille emile at fenx.com <ghost_man at my-deja.com> wrote in message news:<8ft1rq$pgb$1 at nnrp1.deja.com>... > I am writing a python script that through the > os.system command calls VSS and imports the files > over. I then run > os.system('dir /s >> myfile.txt') > > I want to be able to read in the contents of the > file one line at a time and execute some command > on it. My problem is when the file is something > like C:\program files\python\temporary Python > reads it as c:\program files\python\011emporary > > I am getting tripped up by the \t switch. I > cannot at this point and time run string.replace > because it has already been converted over. Any > ideas how I can read the string in correctly? I > have explored the glob module and it would seem > very cumbersome to try and cover this. Is there > an easier way to read in the contents of my file > and have them import correctly? > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > From MSteed at altiris.com Wed May 24 15:23:57 2000 From: MSteed at altiris.com (Mike Steed) Date: Wed, 24 May 2000 13:23:57 -0600 Subject: What's in a name? Message-ID: <65118AEEFF5AD3118E8300508B1248774CB30F@ALTNET> > From: Edward S. Vinyard [mailto:vinyard at arlut.utexas.edu] > Sent: Wednesday, May 24, 2000 12:59 PM > To: python-list at python.org > Subject: Re: What's in a name? > > On 24 May 2000, Gordon McMillan wrote: > >Edward S. Vinyard <vinyard at arlut.utexas.edu> wrote: > >>In some instances, case sensitive languages are exploited: > >> > >>1. Case can add semantic information to the names of classes, > >> functions, and instances. > >> > >>2. Case can be used to delimit multi-word names. An example: > >> spam_counter vs. spamCounter. > > > >Certainly. These are conventions that Python (being case sensitive) > >allows. I like them. > > > >But you have to learn to recognize the conventions. That is, in the > >context of Python I recognize spamServer as different from > >SpamServer. (Personally, I would expect the first to be a function > >and the latter to be a class, but if the author uses different > >conventions, it won't take me long to figure it out.) > > These (and others) are (syntactic or semantic) distinctions > that we choose to make visual by exploiting the case-sensitivity > of Python. I enjoy the visual distinction that they provide, but > why should we have to figure it out at all? If such distinctions > were represented visually in a standard way (with or without the > use of capitalization) we would accomplish several things. > > 1. Remove a (potential) hurdle for new programmers. > > 2. Eliminate the (however insignificant) portion of time an > experienced programmer spends deducing the convention that a > module uses. > > 3. (Maybe!) Alleviate concern about Python's case-sensitivity. Hey I know, we could enforce Hungarian notation in the parser! Okay, I'm kidding, no flames please. For the record, I detest Hungarian notation. > Ed -- M. From m.faassen at vet.uu.nl Thu May 25 08:54:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 25 May 2000 12:54:50 GMT Subject: was: What's in a name?, now: caseless: Try it, you might like it. References: <Pine.SOL.4.05.10005241450110.14493-100000@spgsun1.arlut.utexas.edu> <slrn8ioq9a.vq.hzhu@rocket.knowledgetrack.com> <Pine.SOL.4.05.10005241852040.14493-100000@spgsun1.arlut.utexas.edu> <392D06E1.415DFEF1@uab.edu> Message-ID: <8gj7qq$iqm$3@newshost.accu.uu.nl> Shae Erisson <shapr at uab.edu> wrote: > The case-sensitive issue just might be the same as the whitespace issue. > Python's unconvential approach works quite well for me in whitespace, > I'm willing to give another unconvential approach a chance at least. In fact, the case-sensitive issue is the exact opposite as the whitespace issue. The use of whitespace in Python makes indentation a lot more consistently written, which aids readability. Case-insensitivity would allow us to case-spell inconsistency, which detracts from readability. Yes, we're able to read different case-spellings, but it's *harder*, just like reading through differently indented code can be harder. And code is read more often than it's written, so this is pretty important. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From che at debian.org Thu May 11 22:06:18 2000 From: che at debian.org (Ben Gertzfield) Date: 11 May 2000 19:06:18 -0700 Subject: Opening a file in O_NONBLOCK mode Message-ID: <ytt1z3834kl.fsf@gilgamesh.cse.ucsc.edu> Hi, Pythoners! I'm trying to track down a bug a user reported on the CDDB.py python module; part of the module accesses the CD-ROM device via an OS-specific C extension to read the track listing off an audio CD. It turns out that the Linux kernel (of course) wants programs that read audio tracks to open the CD-ROM device in O_RDONLY and O_NONBLOCK mode. But Python's open() function only allows me to specify read-only; how can I specify O_NONBLOCK? Do I have to do all the file opening inside the C module? (I was hoping that I wouldn't have to.) Ben -- Brought to you by the letters M and F and the number 12. "A squib is a firecracker." Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/ From guido at python.org Fri May 19 03:59:22 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 00:59:22 -0700 Subject: C++ extension module crashes on Solaris In-Reply-To: Your message of "Fri, 19 May 2000 00:52:31 EDT." <BAEMJNPFHMFPEFAGBKKACEMICBAA.dan@cgsoftware.com> References: <BAEMJNPFHMFPEFAGBKKACEMICBAA.dan@cgsoftware.com> Message-ID: <200005190759.AAA09123@cj20424-a.reston1.va.home.com> > > I suggest posting some source code if you expect help. It's probably a > > simple > > bug in your code but it's hard to spot without looking at your code. > > > > You seem concerned about threads. are you starting threads in your C code > > that > > will call on Python? If so, that's where the problem is -- you have to > > study > > the C/API docs carefully regarding the interpreter lock. > > > No offense Guido, but you are probably completely off base. > I'll put money it's a shared library problem. > I remember someone running into this problem on SunOS before, and i've > personally run into it on FreeBSD. > In fact, if you just compile on freebsd-current, with the modules shared, > without using the version of python in the FreeBSD ports system, and then do > something as simple as "import time" or "import zlib" (IE import a shared > module), you'll get the same error. That's very well possible. Is there an entry in the Python Bugs Database for this yet? > As soon as i wake up, if someone hasn't posted the fix, i'll do it (It's > very late, it escapes my brain). I'd be most delighted. (Note that for Py1.6, we've restructured the shared lib code -- if you have a patch, it would be great if you could prepare one for 1.6 and post it to patches at python.org...) --Guido van Rossum (home page: http://www.python.org/~guido/) From andres at corrada.com Tue May 30 16:55:08 2000 From: andres at corrada.com (andres at corrada.com) Date: Tue, 30 May 2000 16:55:08 -0400 Subject: os.linesep under Windows In-Reply-To: <14644.9070.713948.988357@cj42289-a.reston1.va.home.com>; from Fred L. Drake, Jr. on Tue, May 30, 2000 at 04:24:14PM -0400 References: <g668jso41eos8lt8viea79f9g733ilihl1@4ax.com> <14644.9070.713948.988357@cj42289-a.reston1.va.home.com> Message-ID: <20000530165508.A16926@corrada.com> On Tue, May 30, 2000 at 04:24:14PM -0400, Fred L. Drake, Jr. wrote: > > Brandon, > This isn't the way to use os.linesep. Fred, This one has bitten me in the past, but on a Mac. Am I correct in saying that the way sys.write( os.linesep ) works on the Windows platform is: sys.stodout( '\n' ) is outputted as '\r\n' because Python uses '\n' as the line separator for all platforms. Sort of what Brandon does when he says: > So now I have hard-coded my newline because I can't use os.linesep. > NL = '\012' The way I got bit on the Mac platform was by writing: sys.stdout( '\n' ) and I expected to see a "0A" but saw a "0D", since "OD" is the line separator on the Mac platform. > Most of the time you won't > need os.linesep at all; it's largely defined to be informative for > those applications that do need it. For all text-mode files, '\n' is > converted to the host-specific line separator by the underlying C > libraries; that's the portable approach and should be used in most > cases. > Fred, out of curiosity, what applications need to worry about os.linesep and/or what are those few cases where it should be used directly? ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From andre at beta.telenordia.se Wed May 31 22:08:19 2000 From: andre at beta.telenordia.se (André Dahlqvist) Date: Thu, 01 Jun 2000 03:08:19 +0100 Subject: Marking hyperlinks in a Text widget References: <8h04jo$lgh$1@zingo.tninet.se> <oq7lcc41zr.fsf@titan.progiciels-bpi.ca> <8h0kn5$6pv$1@cubacola.tninet.se> <slrn8j94er.ebv.cjc26@localhost.mindriot.net> Message-ID: <8h4d2e$ap4$1@cubacola.tninet.se> > def click(event): > os.system("netscape -remote 'openURL(%s)'" % \ > textw.tag_names('@%d,%d' % (event.x, event.y))[1]) Is openURL a function that you have written? If so, can I check it out? If I understand the code above correctly textw.tag_names() in this case returns the name of the tag associated with the text positioned where the mouse is. But how do you actually get the URL? I mean to use textw.get(...) you need to know the index of the first and last character in the URL we want, right? tag_ranges seam interesting. With the help of that one I can get the positions of all the words tagged with 'url'. What I don't understand is how to know which of these was just clicked. // Andr? From echuck at mindspring.com Tue May 9 08:06:13 2000 From: echuck at mindspring.com (Chuck Esterbrook) Date: Tue, 09 May 2000 08:06:13 -0400 Subject: Using python on the web References: <EDFD2A95EE7DD31187350090279C6767754BA8@THRESHER> <FtEE3B.Ar2.0.bloor@torfree.net> <tShM4.42074$h6.182368@typhoon.jacksonville.mediaone.net> <8e1mcp$3bhdu$1@fido.engr.sgi.com> Message-ID: <3917FF35.804F939A@mindspring.com> Nhi Vanye wrote: > > $ from hank at prosysplus.com -#87740 | sed "1,$s/^/> /" > > > > > >Hi Ken, > > > >An article on Python Server Pages appeared in two parts recently in DDJ. > >The web site associated with the article is at > >http://www.ciobriefings.com/psp/. > > I was looking forward to being able to use PSP instead of PHP in my web > pages, but: > > o Its written in JPython, and when what I really need is mod_psp. > o The license requires me to submit all changes I make back to AEI. > o The license requires that I state in a prominent way that I have > made modifications to the software and the specific changes made > o I'm not allowed to make any changes that may be "harmful" to other > users/systems. So no site specific customising. > > I'll be staying with PHP for the time being :-( As Hank pointed out there is "Webware for Python". I'll be releasing version 0.2 this week which is significantly more interesting and useful than the first. Jay Love is working on a PHP-style component for Webware with input from me (and whoever else). I expect he'll either base it off PSP and work out the issues (both technical and licensing) or if that doesn't work, he/we will start from scratch. Like many others, I found Zope to be more painful than gainful. I won't go into details as it's been hashed over quite a bit by others. The WebKit in Webware offers an application server with servlets. When things settle down with that and the PHP/ASP/JSP clone, then I will move on to MiddleKit which is intended to provide "enterprise/business objects" and DB integration from a higher level perspective than DB API. Then I will build my notorious website and take over the world. The website will allow the community to build, in an open source fashion, the break-up plan for Microsoft. Anyone can contribute. I'll refrain from including my URL pending this week's Webware 0.2 announcement. (e.g., don't bother with 0.1 anymore) -Chuck From effbot at telia.com Tue May 16 13:05:46 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 16 May 2000 17:05:46 GMT Subject: How to display images? - Repost References: <39216FA0.B8E8F735@world.std.com> Message-ID: <KdfU4.7682$Za1.119624@newsc.telia.net> David Lees <debl.nospamm at world.std.com> wrote: > How does one display images in Python. I am using Python 1.5.2 and PIL > running under Win95 and am able to read, write and rotate images to the > disk without any problem. tkinter is installed. However, when I use the > .show method it does not seem to work. "show" works just fine on my win95 box. maybe you don't have a BMP viewer installed? try saving a file as BMP, and run the "start" command on it from the MS-DOS window: > python ... >>> import Image >>> im = Image.open("...") >>> im.save("myfile.bmp") >>> [ctrl-Z] > start myfile.bmp if this doesn't work, check the file associations, or hack Image.py so it uses another default format. </F> From paul at prescod.net Tue May 23 15:37:03 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 23 May 2000 14:37:03 -0500 Subject: case sensitivity and XML References: <Pine.BSF.4.10.10005210318490.1437-100000@chi.pair.com> Message-ID: <392ADDDF.6A7EAEEC@prescod.net> "Michal Wallace (sabren)" wrote: > > How's this: > > 1. By definition: For python to be case insensitive, the token {A} > must be the same as the token {a}. True. > 2. Therefore: > x.A = 1 > is the same as: > x.a = 1 > > where x is some kind of module or object. True. > 3. Therefore: > x.__dict__["A"] = 1 > is the same as: > x.__dict__["a"] = 1 > > And/Or: > setattr(object, "A", 1) > is the same as: > setattr(object, "a", 1) False. x.__getattr__ can do the case normalization. If you start messing with the underlying dictionaries you don't get the special behavior. Objects already do "funny things" in the "." syntax that you don't get when you go directly to the dictionary. > 4. Therefore, the string, "A" must be equivalent to the string, "a". Also not true. How do you get from "setattr might do case-insensitive setting" to "A"=="a" everywhere. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From aahz at netcom.com Tue May 2 11:56:13 2000 From: aahz at netcom.com (Aahz Maruch) Date: 2 May 2000 15:56:13 GMT Subject: How many is "too many" with lists? References: <Pine.LNX.4.10.10005020824370.13821-100000@propylaea.anduin.com> <meh9-068C25.11551802052000@news.cit.cornell.edu> Message-ID: <8emtqt$dsf$1@nntp9.atl.mindspring.net> In article <meh9-068C25.11551802052000 at news.cit.cornell.edu>, Matthew Hirsch <meh9 at cornell.edu> wrote: > >I'm building a list of lists each holding a combination of nCk where n >is the total number of numbers and k is the number you are choosing. >For example, I have 27 numbers, 0-26. Looking at all combinations of 6 >taken from this sample produces 27!/(27-6)!6! =296010 different >combinations stored in the original list. So what's slow? Generating the list or manipulating the list after it's created? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From ajs at ix.netcom.com Sat May 20 19:52:54 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 20 May 2000 19:52:54 -0400 Subject: Damnation Message-ID: <005101bfc2b6$85777c60$64e26dd1@oemcomputer> >P3K is still just an unformed web of ideas, desires and discontents. On the other hand, the same influences that are informing Guido's thinking about P3K for tomorrow, are very much informing his CP4E activities today. >The argument usually used in favor of case insensitivity is that it is >easier for beginners and the experiences with Alice seems to back >that up. I have fought a thankless battle on the EDU-SIG list about the centrality of Alice, the centrality of interface, etc. I learned that 'minimum cognitive load' was a good thing. In Guido's Linux Journal article, the IDE finds the bug and highlights it. We weren't given a clue how we had gotten the students to the point where they knew a bug from a lizard. I am close enough to having been a beginner myself to report that case sensitivity/insensivity was that the least of my problems - a non-issue in fact. It would defy common sense to think it would be otherwise. I don't know the studies, but am confident that they are 'flawed' - I would like to use stronger language. Anyway I am greatly heartened to see the issue addressed so directly here. I have felt a bit of a pariah on EDU-SIG And God save Guido from the Visionaries. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20000520/532c1eb3/attachment.html> From newsbunny at noether.freeserve.co.uk Fri May 5 18:06:37 2000 From: newsbunny at noether.freeserve.co.uk (Martin P Holland) Date: Fri, 5 May 2000 23:06:37 +0100 Subject: batch ftp References: <391332E3.955E277A@pacific.jpl.nasa.gov> Message-ID: <slrn8h6hfd.1ou.newsbunny@emmy.noether> On Fri, 05 May 2000 13:45:23 -0700, Benyang Tang <btang at pacific.jpl.nasa.gov> wrote: >Are there any python scripts to do ftp for a whole directory tree? >I have seen ftpmirror.py in the standard python installation. >But it ony does get, not put. Also it would be nice to preserve the time >stamps and permission bits of the original files. My ftpupdater app from http://www.noether.freeserve.co.uk/kftpupdater will do the putting as well as getting (tested on linux). I hadn't thought about preserving permissions and time stamps... atb Martin -- http://www.noether.freeserve.co.uk http://www.kppp-archive.freeserve.co.uk From gmcm at hypernet.com Thu May 25 09:04:21 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 25 May 2000 13:04:21 GMT Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> Message-ID: <392d24d5$0$23937@wodc7nh0.news.uu.net> Nick Bower <N.Bower at ses.curtin.edu.au> wrote: > >I colleague the other day, who was familiar with various procedural >languages said: > >"I want to learn OOP. Can you recommend a book (and language)?" >... Java however has a selection now, and it seems that if you >want to really learn more than just basic concepts in OOP then Java is >the language to go with. >If one of Python's goals is to be a good teaching language, shouldn't >there be a book about OOP using Python, rather than the current books on >Python with only chapters on OOP? Because Java is statically typed (with a rather old-fashioned type system), learning OOP in Java means learning a whole lot of rules, and their implications. While I've never bothered to look at the Java books in question, my guess is that you'd be very lucky to find anything about how to "think OOP". It's going to be all about the rules of inheritance, interfaces, access specifiers, blah blah blah. The rules for Python are short and sweet. It's dynamically bound, so there's no need to create an inheritance hierarchy (or separate interface) so a B can substitute for an A. In fact, people who come to Python from Java or C++ often have trouble seeing how simple it can be. For me, the "Aha!" about thinking OOP came from reading Design Patterns (Gamma et al, Addison Wesley). I'd been stuggling with a similar problem - the C++ books at the time all focussed on the mechanics with contrived examples that did nothing to create a deeper understanding. While I heartily recommend the book, I'm can't really recommend it for this purpose. I was ready for the "Aha!", and Design Patterns just happened to trigger it. OTOH, I have no other recommendations. My own realization was that you create objects so you can say "You take care of it". - Gordon From benpark at my-deja.com Mon May 8 15:37:59 2000 From: benpark at my-deja.com (Ben Park) Date: Mon, 08 May 2000 19:37:59 GMT Subject: Block comments? Not working inside a logic block. References: <391653B7.2F38A7F2@san.rr.com> Message-ID: <8f752l$svm$1@nnrp1.deja.com> Block commenting does not seem to work inside a logic block. For example #=================== if 1: ''' whatever here ''' print 'I am here' #==================== results in error: ''' ^ SyntaxError: invalid syntax In article <391653B7.2F38A7F2 at san.rr.com>, Courageous <jkraska1 at san.rr.com> wrote: > > Okay, it's not like I'm not looking in my documentation or anything, > but if this is available, it's not obvious. How do you express > python block comments? > > C/ > Sent via Deja.com http://www.deja.com/ Before you buy. From tismer at tismer.com Wed May 17 10:27:36 2000 From: tismer at tismer.com (Christian Tismer) Date: Wed, 17 May 2000 16:27:36 +0200 Subject: Stackless/microthreads merge news References: <200005022228.IAA03188@envy.fulcrum.com.au> <39144E9E.4928C7E2@tismer.com> <jazoq2i8ty.fsf@helix.twistedmatrix.com> <39184D61.453BDD09@tismer.com> <8fppr9$95f$1@gaia.cdg.acriter.nl> <jaitwfo0ee.fsf@helix.twistedmatrix.com> <3921A17C.F995CEFB@tismer.com> <wkk8gtuxsi.fsf@SNIPE.maya.com> Message-ID: <3922AC58.AEA006C7@tismer.com> Jeff Senn wrote: > > Christian Tismer <tismer at tismer.com> writes: > > > In fact, he commented that making C itself stackless would be too hard > > > to really consider seriously and nobody in the community would > > > appreciate it at all. > > > > Yes. It would be hard to make portable. > > Instead, I'm trying to get rid of C and want > > to use a language where I can control stacks > > more easily. The last barrier in Stackless Python is > > to make a couple of internal functions stackless as well, > > but it is so hard in C that I need another bytecode > > interpreter to do that. > > Well, guess what that should be. > > Hm -- I've been trying to find a way to explain the "stackless zen". > > It seems that we all (people who write high level software) take the > program stack, as a method of flow control and messaging between > function invocation, as a given. Really the stack is just another > data/object type -- not any more special than a queue or a heap... That's the right perception. The problem is that current compiler layout doesn't give us a chance to handle the stack as yet another data structure in a portable way. The C stack today has the builtin promise that, after calling some functions, you will walk back exactly in reverse order. Stacklessness means breaking this promise. This cannot be done with the C stack in a portable way. > Given our usually math notation, methods of functional composition and > early compiler/OS development I'm not surprised that the stack is > viewed so. (Consider as a counter example how asynchronous circuit > design is done and microcode is developed) > > IMHO this dependence on making the stack of higher importance has made > the implementation of multi-"threaded" operating systems complex and > limited the ways in which alternative approaches could reduce the > difficulty of implementation of async/parallel systems. Yes. After all, I consider the stack-oriented hardware that is everywhere around today as a huge design mistake. Early processors didn't have that. It evolved in support for high level languages, and the designers stopped to think of alternatives. Not it appears that even these high level languages are the showstopper, and all this stack-enforcement is completely artificial. Stacklessness doesn't mean "no stack whatsoever". For many small tasks, stacks are the way to go. It means "have a stack where it makes sense, but don't be forced to." ciao - chris -- Christian Tismer :^) <mailto:tismer at appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From sada7681 at mail.usyd.edu.au Fri May 12 08:19:45 2000 From: sada7681 at mail.usyd.edu.au (Steven Adams) Date: Fri, 12 May 2000 22:19:45 +1000 Subject: Tiny FTP server Message-ID: <8fhrd8$2esq$1@news1.wire.net.au> Hi, is there a VERY small ftp server module in python? I've (tried) looking at Starship, and Parnassus, and everywhere else I could think of, but can't find one. Does anyone know of anything that comes close? I really wanted to avoid having to deal with the sockets directly. Does this sound feasable as an event sequence client sends command length client sends command. if (command is to download a file) : client listens for file length server sends length of file client listens for file server sends file elif (client wants to upload a file): server listens for file length client sends file length server listens for file client sends file elif ............. ...... close connection since I'm only sending data through a serial cable to another computer I don't really need to worry about sending large packets. any ideas? hints, tips? thanks Steven From kzaragoza at mediaone.net Thu May 18 20:28:46 2000 From: kzaragoza at mediaone.net (Kris J. Zaragoza) Date: Fri, 19 May 2000 00:28:46 GMT Subject: Converting strings to hex References: <8g20r4$ru6$1@supernews.com> Message-ID: <slrn8i92lv.8cs.kzaragoza@kzaragoza.ne.mediaone.net> On Fri, 19 May 2000 01:11:05 +0100, Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote: >The output from MD5.digest() is a 16 byte binary string. > >I want to convert it to hex for printing. > >The hex() function only handles integers (pah!) so I've come up with this: > >def wibble(r): > return hex(ord(r))[2:4] > >a=md5.new(data).digest() >string.join(map(wibble, list(a)), "") > >Which is ugly, at best. > >Is there a better way? > >hhmm... > >I've just discovered unpack and come up with this: > >"%4X %4X %4X %4X" % struct.unpack(">4i", a) > >which is certainly shorter! > >Is this the best I can expect? > >Thanks > >-- >Dale Strickland-Clark >Out-Think Ltd, UK > > > That's funny, I was _just_ playing with this very functionality! Here's what I came up with: def md5ToHex(md5string): import string ret = [] for c in md5string: ret.append("%02X" % ord(c)) return string.join(ret,"") Running this: >>> import md5 >>> m = md5.new("Foo!").digest() >>> m "\333h(\246'\355i_\373\201\2445<\342\222n" >>> md5ToHex(m) 'DB6828A627ED695FFB81A4353CE2926E' >>> Is this what you're looking for? -Kris -- Kris J. Zaragoza | "Unfortunately, most people can't out-think a kzaragoza at mediaone.net | grapefruit." --Jon Bodner From effbot at telia.com Wed May 10 04:18:07 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 10 May 2000 08:18:07 GMT Subject: Load Arbitrary Script as Module? References: <8f9bs3$b9u$1@nnrp1.deja.com> Message-ID: <3X8S4.3482$wYl.200101376@newsb.telia.net> rgb122 at my-deja.com wrote: > Is there a way to load a module given a full filepath? Something like: > > driver = LoadModule("C:\\Stuff\\sample.py") > driver.someFunction() start here: http://www.deja.com/=dnc/getdoc.xp?AN=621152936 and add something like: def import_file(filename): name = os.path.splitext(os.path.basename(filename))[0] return do_import(name, filename) driver = import_file("c:/Stuff/sample.py") driver.someFunction() hope this helps! </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From mfletch at tpresence.com Sat May 20 19:00:31 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sat, 20 May 2000 19:00:31 -0400 Subject: PyOpengl... gone forever? Message-ID: <CC59868A0A76D311B1F50090277B321C1F3346@VRTMAIL> Note: PyOpenGL is the way Python deals with OpenGL in TKinter, wxPython, FxPy and Win32all guis, not just TKinter ones. wxPython used to have it's own wrapper, but it was so limited as to be useless, so it was deprecated in favour of PyOpenGL. So, save for the game-engine interfaces, PyOpenGL is the only OpenGL option at the moment. PyOpenGL should likely be put into a sourceforge project with one or two people signed on as coordinators. I'm not a C++ coder, so I'm not a useful choice, but there might be someone willing to stand up and stand in. Enjoy, Mike -----Original Message----- From: Arthur Siegel [mailto:ajs at ix.netcom.com] Sent: Saturday, May 20, 2000 1:25 PM To: python-list at python.org Subject: Re: PyOpengl... gone forever? ... There seems to be alternatives developing - I believe wxPython and th PyFLTk have or will have OpenGL canvases. But I'm not sure its fully there yet in either case, and even so that's along way to go for those of us already comfortable with Tkinter. ... From tismer at tismer.com Wed May 3 18:46:07 2000 From: tismer at tismer.com (Christian Tismer) Date: Thu, 04 May 2000 00:46:07 +0200 Subject: Stackless/microthreads merge news References: <EDFD2A95EE7DD31187350090279C67675E0155@THRESHER> <ovqy4.219$Lh9.179201024@newsb.telia.net> <38CA510A.749F@letterror.com> <390E6D60.781DAED9@san.rr.com> <390EB313.67EB255C@san.rr.com> <FtxLCH.633@world.std.com> <390F31A5.6452D256@tismer.com> <slrn8gv6ap.5kv.neelk@brick.cswv.com> Message-ID: <3910AC2F.EDEDB43B@tismer.com> Neel Krishnaswami wrote: [unmature hype of a probable stackless Java] > Fairly difficult, I would assume -- if there's a JIT it will almost > certainly try to stack-allocate activation records. You'd need to > explictly heap-allocate all that. Fortunately, Andrew Appel seems > to believe that heap-allocation of frames can effectively compete > with stack allocation, see: Thanks a lot - I know these publications. The problem is smaller. We don't need to make everything into heaps, but we can do this at certain points. This can be the procedure level, but it can be even coarser. The granularity depends on what we want to switch. Finally, I want to be able to switch what I now can switch in CPython. In JPython, I want something similar, but this doesn't mean to need to be able to switch every and all things all the time. It-is-stackless-if-it-is-better-*and*-not-slower - ly y'rs - chris -- Christian Tismer :^) <mailto:tismer at appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From mhammond at skippinet.com.au Tue May 23 08:53:34 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 23 May 2000 12:53:34 GMT Subject: case-sensitivity compromise proposal References: <4.3.1.2.20000523075551.014d9e70@phear.dementian.com> Message-ID: <ibvW4.1719$bZ3.10015@news-server.bigpond.net.au> For baby-steps, another alternative would be to allow exec and eval to take dictionary-like objects (eg, a UserDict instance) as well as real dictionaries (which it insists on now). Then, we could simply implement a case-insensitive dictionary, and viola - we are nearly done. A fairly trivial remapping of import could then turn any module you like into a case-insensitive environment... I brought this up once before (for COM, where case-insensitivity would also remove a few surprises for a few people coming from VB etc), and the main concern was performance - going via the abstract "mapping" methods is slower than direct dictionary access. However, this was before case-insensitivity was even at twinkle in the best troller's eye ;-) But if it could be done, it would probably provide a fairly non-controversial way for people to experiment with the feature... Mark. "Steven D. Arnold" <stevena at permanent.cc> wrote in message news:4.3.1.2.20000523075551.014d9e70 at phear.dementian.com... > How about a pragma to indicate whether a given Python module was > case-insensitive? Since Python is case-sensitive now, and to assist with > backward compatibility, I propose that case-sensitivity should be the From dalke at acm.org Tue May 16 05:54:57 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 16 May 2000 03:54:57 -0600 Subject: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) References: <Pine.GSO.4.10.10005150709541.25548-100000@sundial> <wz7U4.143$8J2.101488@news.pacbell.net> Message-ID: <8fr5nt$le7$1@nntp9.atl.mindspring.net> Dirck: >> Theoretically, a colon is only necessary in things like >> >> if yes: print "yes" Moshe Zadka: >Oddly enough, the parser doesn't really need the colon here either. >It can manage to figure out where the if expression ends without it. > >The colon is almost entirely for readability purposes. >(there are a couple of places where ambiguity occurs without it). Oh, oh! I've got one! Is "if 1 - 1 - 2" the same as "if 1: -1 - 2" or "if 1-1: -2" or "if 1-1-2:" ? Toss in some overflow exceptions past sys.maxint if you want to prove that a good compiler won't optimize them away :) Another is: if "spam" " eggs" " viking" which, because of string joining during parsing, becomes: if "spam eggs viking" instead of one of: if "spam": " eggs viking" if "spam eggs": " viking" Andrew dalke at acm.org From stephen at cerebralmaelstrom.com Mon May 29 03:25:09 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Mon, 29 May 2000 07:25:09 GMT Subject: Regular Expressions...Speed, etc. Message-ID: <pXoY4.25991$WS3.293222@typhoon.we.rr.com> First a quick question: Is the match() function any different really then having search() with a ^ at the begenning of the string? Now my real question :) Basically, what I want to do is parse an rfc822 header file.. I don't want to use rfc822.Message, for various reasons.. Tonight, I went from reading through the 're' modules instructions to writting the parsing-portion of the rfc822.Message, and came up with an idea-- Why not just leave all the headers in one string (Or heck, for ease-of-adding, make them a list, and I can just do --> "".join(HeaderList) <-- for the search...) and use re.findall? The reason why is that the specification allows repetitions of the same field, and I'm going to want MyNewMessage["Received"] to return *all* occurances of the Received header. Are regular expressions any slower really then the current method? Thanks. --S From drivel_drool at bigfoot.com Tue May 16 10:32:45 2000 From: drivel_drool at bigfoot.com (Charlie Derr) Date: Tue, 16 May 2000 10:32:45 -0400 Subject: how to use a proxy? In-Reply-To: <8fri52$25o$1@nnrp1.deja.com> Message-ID: <LOBBJCAMDNLNCGCCHGEIEEJCEJAA.drivel_drool@bigfoot.com> you have to set an environment variable HTTPProxy=<address> i might not have the case right, i remember looking through the source of urllib and finally finding it and you'd need another one for FTPProxy etc... hth, ~c ~ ~ Hi! ~ ~ How can I use a proxy (I'm behind a firewall) to get HTML pages ~ from the net? ~ I hade a look on HTTPlib and URLlib but there is no comment about proxies. ~ ~ Regards, ~ Mike ~ ~ ~ Sent via Deja.com http://www.deja.com/ ~ Before you buy. ~ -- ~ http://www.python.org/mailman/listinfo/python-list ~ From s2mdalle at titan.vcu.edu Sat May 6 22:53:03 2000 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 06 May 2000 21:53:03 -0500 Subject: load a web page and save source as text References: <478201EBFBB5F6AD.F52C1F134DC64CE2.190F3DA75E7EBCE3@lp.airnews.net> Message-ID: <8f2lrt$4ev$1@bob.news.rcn.net> In article <478201EBFBB5F6AD.F52C1F134DC64CE2.190F3DA75E7EBCE3 at lp.airnews.net>, "technology" <technology at mylinuxisp.com> wrote: > From python I want to be able to request a web age and save the source > as text. do I import a html module? > > what is the syntax to send a html request and and then assign results to > variable. I then would write the variable to a file correct? Check out urllib if you actually want to grab a URL quickly and easily. But with regard to the HTML request, it's actually an HTTP request, and you would normally send: GET filename.html\r\n and then listen for output from the server. -- David Allen http://opop.nols.com/ ---------------------------------------- Firearms are second only to the Constitution in importance; they are the peoples' liberty's teeth. -- George Washington From emile at fenx.com Tue May 9 01:52:36 2000 From: emile at fenx.com (emile at fenx.com) Date: Mon, 08 May 2000 22:52:36 -0700 Subject: using os.stat to determine stat.st_blocks on OS that supports it? Message-ID: <3917A7A3.712385F3@fenx.com> This returns the bytes used, not the disk size. For example, on my win95 box files grow in block size increments of 4096 bytes. On the RH6 box, the block size is 1024. The actual disk file size will be at least the next higher block size increment. If the file size follows some sort of high water mark, even a file of 10 bytes could use any number of blocks. There are certainly ways of determining block size for a given file system, but none that I could think of that didn't shell out one way or another. Emile van Sebille emile at fenx.com >>> rec = 80000*' ' >>> open(r'c:\temp.tst','w+b').write(rec) >>> os.stat(r'c:\temp.tst') (33206, 0, 2, 1, 0, 0, 80000, 957769200, 957821668, 957821667) >>> os.path.getsize(r'c:\temp.tst') 80000 aaron sterling <aarons at cyberspace.org> wrote in message news:<3917BAB6.6E277DE at cyberspace.org>... > have you tried os.path.getsize() > > -- > http://www.python.org/mailman/listinfo/python-list > From dgoodger at bigfoot.com Fri May 5 22:50:24 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Fri, 05 May 2000 22:50:24 -0400 Subject: string.replace In-Reply-To: <16341.957546757@www15.gmx.net> References: <Pine.LNX.4.21.0005051330240.24093-100000@fep132.fep.ru><16341.957546757@www15.gmx.net> Message-ID: <B53900AF.2DFE%dgoodger@bigfoot.com> on 2000-05-05 13:12, rei05 at gmx.de (rei05 at gmx.de) wrote: >> On Fri, 5 May 2000 rei05 at gmx.de wrote: >>> so i tried string.replace(s,"'","\'"), but this doesn`t work. >> > sorry, i forgot to mention, that i tried: >> >> string.replace(s,"'","\\'") >> > too, but the result of this is like the following: > >>>> import string >>>> s="asdasd'a'asddads" >>>> string.replace(s,"'","\\'") > "asdasd\\'a\\'asddads" > > and i wish to have ...\'a\'..., not ...\\'a\\'... Try this: >>> import string >>> s="asdasd'a'asddads" >>> print string.replace(s,"'","\\'") asdasd\'a\'asddads When you entered just: >>> string.replace(s,"'","\\'") (i.e., without the "print" statement), because you're in the interactive interpreter, what you were actually saying was something like: >>> print repr(string.replace(s,"'","\\'")) string.replace is a function which returns a new string with the results of the replacement. (string.replace does *NOT* do anything to s itself! Strings in Python are immutable; they cannot be changed in-place. Repeat until understood. :-) And so Python shows you a representation of the new string, because you haven't told it what to do with the return value. Python's *representation* of a backslash is "\\", because that's what you'd have to type to get a single backslash. "\\" is simply an artefact of the interactive interpreter telling it like it is! To prove all of the above, do this: >>> new_s = string.replace(s,"'","\\'") >>> new_s "asdasd\\'a\\'asddads" >>> print new_s asdasd\'a\'asddads >>> new_s[5] 'd' >>> print new_s[5] d >>> new_s[6] '\\' >>> print new_s[6] \ >>> new_s[7] "'" >>> print new_s[7] ' Note the presence (or absence) of quotation marks when not using (or when using) "print". In a program, you'd likely write something like the first line above (new_s = ...) anyhow, since you probably want to do something with the new string. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From olipt at mayo.edu Mon May 8 02:42:27 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Mon, 8 May 2000 01:42:27 -0500 Subject: Reading fortran 'unformatted' binary files In-Reply-To: <slrn8hcdlu.u1u.keating@mars.rcode.com.au> References: <slrn8hcdlu.u1u.keating@mars.rcode.com.au> Message-ID: <Pine.LNX.4.10.10005080139040.4326-100000@us2.mayo.edu> > > I'm sure this has been asked before, but I can't seem to find any > information on deja or on the web. How can I get python (with Numpy) to read > in arrays from a file created from a fortran code? I've looked at a package > called numpy-signaltools, but the RPM seems to be missing a number of files > (so it doesn't work). Anybody have any simple solutions? What problems with the RPM are you having? Are you compiling or installing a binary? I made the RPM and the package and have used it successfully for many months. There may be installation wrinkles which have not been ironed out. In numpy-signaltools is a class called mIO that uses numpy and the struct module to read and write Fortran records (fortread and fortwrite methods) directly, if the Fortran follows the common convention of starting and ending each record with the number of bytes in the record. Best, Travis From intmktg at Gloria.CAM.ORG Sun May 21 16:56:30 2000 From: intmktg at Gloria.CAM.ORG (Marc Tardif) Date: Sun, 21 May 2000 16:56:30 -0400 Subject: compiling pyapache on freebsd Message-ID: <Pine.LNX.4.10.10005211655500.17718-100000@Gloria.CAM.ORG> I'm trying to install the python module with apache 1.3.12 on FreeBSD 3.4. I have read the INSTALL file and configure works as expected. As for 'make', there seems to be a few problems. First, I had to change the INCLUDES1 variable in the PyApache Makefile to "-I/usr/local/include". Then, I get the following error messages when typing 'make' in the apache directory: /usr/local/lib/python1.5/config/libpython1.5.a(readline.o): In function 'call_readline': readline.o(.text+0x34a): undefined reference to 'rl_event_hook' readline.o(.text+0x352): undefined reference to 'readline' readline.o(.text+0x395): undefined reference to 'add_history' *** Error code 1 What can be the problem? Marc Tardif From g2 at seebelow.org Sun May 14 15:07:29 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 14 May 2000 20:07:29 +0100 Subject: HTMLgen-erated by HTMLParser Message-ID: <391EF971.5964@seebelow.org> Hi Gang, In a sense, Python code written using HTMLgen classes constitutes an alternative representation of HTML. So, has anybody ever written a thing using HTMLParser that automatically translates HTML into HTMLgen code? The benefits of something like would be: 1) it would be a way to automatically create little bits of HTMLgen code to actually use in Python programs, and 2) it would be a great way to create HTMLgen examples from HTML created using an HTML editor, to help people learn HTMLgen. (who-says-necessity-has-to-be-the-mother-of-_all_-inventions? -<wink>)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From mwh21 at cam.ac.uk Thu May 25 03:47:06 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 May 2000 08:47:06 +0100 Subject: Error message References: <jwbnews-9CF202.16081524052000@news.olympus.net> Message-ID: <m34s7nkr5x.fsf@atrus.jesus.cam.ac.uk> "John W. Baxter" <jwbnews at scandaroon.com> writes: > We've been muttering about error messages lately (partly in connection > with the case threads). > > TypeError: not enough arguments for format string > > The most recent time I encountered this, the actual error was: > > TypeError: too much format string for arguments > > (I had put one too many %... thingies into the string for the data I > wanted to deal with.) > > I'm just musing...I don't see a need for any changes here. I particularly hate: TypeError: illegal argument type for built-in operation It just tells you nothing. I've been meaning to whip round the Python sources and replace all the calls to PyErr_BadArgument (for 'tis that that gives the above message) with something a little more helpful, but I haven't got round to it yet... Cheers, M. -- A witty saying proves nothing. -- Voltaire From pj at sgi.com Thu May 11 23:52:37 2000 From: pj at sgi.com (Paul Jackson) Date: 12 May 2000 03:52:37 GMT Subject: Seeds References: <000101bfbbbd$f98f62c0$9ca2143f@tim> Message-ID: <8ffv65$a2fnm$1@fido.engr.sgi.com> My favorite Random Number web site (being as I am from SGI) is: http://lavarand.sgi.com/ Lavarand: ...harnessing the power of Lava Lite?? lamps to generate truly random numbers since 1996. -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From effbot at telia.com Tue May 23 10:54:00 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 23 May 2000 14:54:00 GMT Subject: Is unpickling data a security risk? References: <3927C31D.4022850@maxnm.com> Message-ID: <cYwW4.9147$Za1.142016@newsc.telia.net> Itamar Shtull-Trauring <itamar at maxnm.com> wrote: > I'd like to store a pickle somewhere on the Internet (specifically, on > Freenet - http://freenet.sourceforge.net). Other people may be able to > change this pickle to whatever they want to. At some point I'm going to > load this data (or what it was changed to) and unpickle. Is this a security > risk? yes. using fake pickles, an attacker may be able to execute python scripts that doesn't belong to your application, but happens to be on your path. here's an example: # cleanup.py import os os.system("echo I'm in!") # test.py import pickle data = """(icleanup\noops\np0\n(dp1\nb.""" print pickle.loads(data) now, what happens if you run the test script? $ python test.py i'm in! Traceback (innermost last): SystemError: Failed to import class oops from module cleanup oops indeed! you can plug this hole by using a custom unpickler, where the find_class method is overridden (see the pickle source code for details). but there might be other holes in there... if I were you, I'd use another marshalling method. like, say, the marshalling subsystem from XML-RPC: http://www.pythonware.com/products/xmlrpc </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From benpark at my-deja.com Mon May 8 20:14:11 2000 From: benpark at my-deja.com (Ben Park) Date: Tue, 09 May 2000 00:14:11 GMT Subject: failure of importing Numerics Message-ID: <8f7l86$fq5$1@nnrp1.deja.com> I have python 1.5.1, and numpy 15.2-2, and cannot import Numeric. >>> import Numeric Traceback (innermost last): File "<stdin>", line 1, in ? File "/usr/lib/python1.5/site-packages/Numeric/Numeric.py", line 516, in ? if getattr(_numpy, '_UseExtensionClass' ): AttributeError: _UseExtensionClass But >>> from Numeric import * works ok. Sent via Deja.com http://www.deja.com/ Before you buy. From claird at starbase.neosoft.com Mon May 8 08:15:27 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 8 May 2000 07:15:27 -0500 Subject: snmplib? References: <200005081049.UAA12645@mbuna.arbhome.com.au> Message-ID: <386B878EAB5B5B66.EA97C759B1155AD5.11F9A1F9CA3D8EDF@lp.airnews.net> In article <200005081049.UAA12645 at mbuna.arbhome.com.au>, Anthony Baxter <anthony at interlink.com.au> wrote: > >There will be a (long overdue) update to SNMPY by the end of this >week - keep an eye on snmpy.sourceforge.net. . . . In the meantime, I aim to keep <URL:http://starbase.neosoft.com/~claird/comp.lang.python/snmpy.html> current. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From nickm at mit.edu Tue May 23 13:51:39 2000 From: nickm at mit.edu (Nick Mathewson) Date: Tue, 23 May 2000 17:51:39 GMT Subject: [PATCH] A compromise on case References: <8gefi7$l7b$1@info3.fnal.gov> Message-ID: <LyzW4.28$F22.10268@typhoon1.ba-dsg.net> [emailed as well; I wasn't aware you had posted and emailed.] On Tue, 23 May 2000 12:36:00 -0600, Charles G Waldman <cgw at alum.mit.edu> wrote: >In article <B3zW4.23$F22.9469 at typhoon1.ba-dsg.net>, nickm at mit.edu (Nick >Mathewson) wrote: > > >> Does Guido read this newsgroup, or just the mailing list? > >The mailing list and the newsgroup are cross-linked. Cool; that's what I hoped. >I have no comments on the patch itself, other than to note that the >patch submission guidelines can be found at >http://www.python.org/patches and that there is a separate mail >address for patch submissions - patches at python.org. Thanks! I'm going to hold off on this for a few more iterations; the patch I wrote is not very clean or well-tested, and it definitely doesn't belong in the main dist. I mainly intended it as a demonstration of how I think errors should work. If people agree with me, then I'll clean up the code. Yours, -- Nick Mathewson <nickm at mit.edu> http://www.mit.edu/~nickm/ From nascheme at enme.ucalgary.ca Mon May 8 03:54:10 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 May 2000 07:54:10 GMT Subject: Python and CGI security References: <3915F3D2.FA510453@ndh.net> Message-ID: <slrn8hd09i.9ie.nascheme@cranky.arctrix.com> Stefan Schwarzer <s.schwarzer at ndh.net> wrote: >Beside the usual rules mentioned in the documentation of the cgi >module, are there more "automatic" security checks available in >Python (e. g. similar to Perl's -T switch)? Python does not have tainted data tracking like Perl. You might be able to use ideas from the rexec module to provide a restricted environment for your code to run in though. Writing bug free code is one of the best possible ways to prevent security problems. Since Python raises exceptions on errors you are in a much better position than with many other languages. Neil -- Security problems and bugs go hand in hand. From jwbnews at scandaroon.com Wed May 24 19:22:39 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Wed, 24 May 2000 16:22:39 -0700 Subject: how to check if a string is a valid email address (RFC822)? References: <8ghlok$2oe$1@nnrp1.deja.com> Message-ID: <jwbnews-2675D5.16223924052000@news.olympus.net> In article <8ghlok$2oe$1 at nnrp1.deja.com>, Otis Gospodnetic <otis at my-deja.com> wrote: > Hello, > > I need to parse some text and find all (RFC822 valid) email addresses > in it. > > Is there a module that can take a string and tell me if the string is a > valid email address or not? > > I am looking for something like Email::Valid or Email::Find modules for > Perl. > Well, you could start with the regular expression presented in Appendix B of "Mastering Regular Expressions" by Jeffrey E.F. Friedl (a "must have" IMHO). But you likely want something more "drop-in-ready". (In small print, this thing fits on one page of the appendix (barely).) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From andrew at andrewcooke.free-online.co.uk Mon May 8 12:40:36 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Mon, 08 May 2000 16:40:36 GMT Subject: __len__ and boolean values - small language change Message-ID: <8f6qm0$glb$1@nnrp1.deja.com> Hi, "if foo:" seems to check foo.__len__() if implemented. This makes sense for built-in sequences, but may not be useful for user-defined classes. For example, I have a tree of node classes that I would like to be true or false depending on their contents rather than on the number of subnodes. But I also want to use __len__ to give the number of subnodes because it makes the rest of the code more elegant (ie when nodes implement the full set of sequence methods, not just __len__ in isolation). Is there a special method that I can override to provide boolean values in tests, or is __len__ called directly? If the latter, would it be possible to add a new method (__true__?) that by default calls self.__len__, but which could be altered if necessary? This change would only break code that already had __true__ methods. If people don't use the __foo__ style for method names in case of such conflicts then this seems like a minor change that would damage little and make the language a little more consistent. Cheers, Andrew http://www.andrewcooke.free-online.co.uk/index.html Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Tue May 30 03:05:54 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 30 May 2000 02:05:54 -0500 Subject: Congratulations References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <39340B3B.5769B898@yale.edu> <jwbnews-895A98.13295930052000@news.olympus.net> Message-ID: <39336852.CA354F8B@prescod.net> "John W. Baxter" wrote: > > To me, the most exciting part was the vacation, wedding, honeymoon, etc Get your mind out of the gutter, John! " :) " * 100 > Best wishes! >From me me also!!!! -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From effbot at telia.com Wed May 31 16:45:10 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 31 May 2000 20:45:10 GMT Subject: Timeout using tkinter? References: <memo.20000527233244.53509B@digitig.compulink.co.uk> Message-ID: <qReZ4.6366$wYl.233060864@newsb.telia.net> Tim Rowe wrote: > > Using Python & tkinter, is it possible to build a (platform > > independent) time-out on a user response? > > Does the silence mean "No"? not necessarily -- it might be that case sensitivity and join operator discussions have slightly higher priority ;-) On the other hand, I'm not really sure what you're asking for. What's a "user response" in this case? A mouse click? Data entry in a dialogue box? In either case, the "after" method is probably what you're looking for. More info here: http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm => Alarm handlers and other non-event callbacks => after </F> <!-- (the eff-bot guide to) the standard python library: http://www.pythonware.com/people/fredrik/librarybook.htm --> From jflores at codeit.com Fri May 26 12:11:49 2000 From: jflores at codeit.com (Grakka) Date: Fri, 26 May 2000 09:11:49 -0700 Subject: how can I reload 'from *' ? References: <8F407AF9Dmikecat@192.168.10.38> Message-ID: <392EA245.58D09773@codeit.com> >> reload(HUGO) Mike Cat wrote: > > Hi! > > How can I reload things imported with 'from HUGO import *' ? > > Regards, > Mike > -- > http://www.python.org/mailman/listinfo/python-list From pinard at iro.umontreal.ca Mon May 22 13:21:57 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 13:21:57 -0400 Subject: ANNOUNCE: Python CVS tree moved to SourceForge In-Reply-To: breiter@usf.Uni-Osnabrueck.DE's message of "22 May 2000 16:47:55 GMT" References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> Message-ID: <oqu2fq1owa.fsf@titan.progiciels-bpi.ca> breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) writes: > In article <200005212205.PAA05512 at cj20424-a.reston1.va.home.com>, > Guido van Rossum <guido at python.org> writes: > > I'm happy to announce that we've moved the Python CVS tree to > > SourceForge. SourceForge (www.sourceforge.net) is a free service to > > Open Source developers run by VA Linux. > Hmm I am not really happy about it. The concentration of Free > Software Projects on SourceForge is a little bit dangerous. I think the advantages outweigh the danger, but share your discomfort. To see so many mailing lists and original files held on the FSF machines made me warn some friends and maintainers more than once. At least, SourceForge does not seem to have such a strong political agenda, and I did not hear any story of administrative abuse yet :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From bwinton at tor.dhs.org Thu May 25 14:57:22 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Thu, 25 May 2000 18:57:22 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <eGNV4.3078$1W6.57636@news2-win.server.ntlworld.com> <v_NV4.2148$sW4.12967@news-server.bigpond.net.au> <3928A9CD.315ABEAF@cosc.canterbury.ac.nz> Message-ID: <slrn8iqqfh.3o3.bwinton@tor.dhs.org> On Mon, 22 May 2000 15:30:21 +1200, Greg Ewing wrote: >Neil Hodgson wrote: >> While I /know/ that Unix file names are case sensitive, that doesn't stop >> me from mistyping them. This is something Windows and Macintosh do right - >> removing a cause of error for no real limitation in functionality. >The Macintosh solution to the problem of mistyped file names >is not to require users to type file names at all, other than >when creating the file. That has nothing to do with case >sensitivity! Aha! Perfect! We should re-write IDLE, so that for any given variable, you only type it once, and then whenever you want to use it after that, you click and drag it to the appropriate place! Genius! ;) Later, Blake. -- 1:01pm up 2 days, 5:08, 1 user, load average: 0.00, 0.00, 0.00 From martineg at ifi.uio.no Sat May 20 23:23:12 2000 From: martineg at ifi.uio.no (Martin Eggen) Date: 21 May 2000 05:23:12 +0200 Subject: Distro for IBM OS/390 References: <391bf7b1@wwwproxy3.westgroup.com> <20000512183053.B15594@bigskytel.com> <391cbc6f$0$27874@wodc7nh0.news.uu.net> Message-ID: <xdoem6w8u3j.fsf@ganglot.ifi.uio.no> * Gordon McMillan | | But sometime around last December, IBM had a web page | somewhere with instructions for building Python 1.4 on big iron. Yeah. That one is pretty old, actually. I _think_ it was summer 1998 (and not last year) i struggled with compiling this on OS390 (V2R5 or so). The patch applied cleanly to the 1.4 source tree, but I had big troubles getting the damn ting to _link_ properly. I didn't really finish getting it to work, though, I wrote the ting I needed in another p-language instead. :P OS390 is now one of the supported platforms for P*rl, I would be delighted of hearing about anyone using Python (1.5) on later releases of OS390. (Although I'm not working at the usual place this summer, so no playing with unix on Big Iron. :P ) -- Martin Eggen <martineg at ifi.uio.no> http://www.stud.ifi.uio.no/~martineg/ From urner at alumni.princeton.edu Tue May 30 14:01:28 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 30 May 2000 11:01:28 -0700 Subject: Compact syntax for 0-matrix? References: <grb3js8umme51aj4aak057k9d086ij163m@4ax.com> <etd1z2mgeje.fsf@mint-square.mit.edu> <r3v3js4mf5j91ropuqkg7ibnmq1o9j8scl@4ax.com> <393388C6.B528E2BC@geneva-link.ch> Message-ID: <oa08jsglv7j1c95j32htm18apsorp1i93b@4ax.com> Boris Borcic <borcis at geneva-link.ch> wrote: >Mmm.. I am playing along lines a bit similar to yours, >(e.g. polyhedra), and I have found Numeric quite useful >for one particular bit : doing away with the complexities >of specifying projective transforms by combinations of >rotations, translations, scalings, etc..., using rather >the 3-transitivity of the projective group, to specify >a transform by choosing 3 points together with 3 target >points to which the transform should map them. I find >this hugely more transparent (this is 2D; in 3D, i guess >you'd need 4 points). > >Numeric serves to solve the corresponding linear >equations - of course, you could also code it. > >Boris >Numeric serves to solve the corresponding linear >equations - of course, you could also code it. > >Boris Polyhedra are my focus as well, but I need to keep it simple and transparent. I do rotation, translation and scaling, but don't try to conflate these to single operations. I simply catalog points as vectors in a dictionary and walk through it, applying whatever transformation. In the case of rotation "in place", I move the poly to the origin, rotate, and put it back. I've done rotation using both matrices and quaternions. A next step for me might be to implement rotation using some Clifford Algebra (as per some recent posts on that topic). For a look at my Polyhedra with Python, check links from http://www.inetarena.com/~pdx4d/ocn/cp4e.html I use Povray as my back end ray tracer -- OpenGL in Tk would be another approach, but wouldn't look as good. Kirby From effbot at telia.com Mon May 22 11:22:41 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 22 May 2000 15:22:41 GMT Subject: PyOpengl... gone forever? References: <fIqV4.14736$WS3.144662@typhoon.we.rr.com> Message-ID: <5hcW4.5291$wYl.211543552@newsb.telia.net> Pete Shinners <pshinners at mediaone.net> wrote: > i've asked once before, but i'm still lost here. > > my top spies have informed me that pyopengl lives on > the starship at http://starship.python.net:9673/crew/da > > this site has been inactive for too long now. fwiw, that URL works just fine from here... </F> From godzilla at netmeg.net Fri May 12 17:25:03 2000 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 12 May 2000 21:25:03 GMT Subject: How to identify memory leaks in extensions? References: <391AF390.C419189A@spacenet.tn.cornell.edu> <Pine.LNX.4.10.10005110149150.9169-100000@us2.mayo.edu> <m24s83x01g.fsf@netmeg.net> <Pine.LNX.4.10.10005120101450.10697-100000@us2.mayo.edu> Message-ID: <m2zopvv4g5.fsf@netmeg.net> > I'm sorry for the confusion. naw, its my confusion, you had nothin to do with it. fact is, you been nothing but a help ever since i started using NumPy. > I have not carefully looked through this part of the Python source > code, however. This model lets me write code that does not have > memory problems, however. sounds good to me. unless one of the pros jumps in here, i'll start using your mental model of the reference counting process. it makes sense to me now. les schaffer From Sttscitrans at tesco.net Wed May 31 13:35:01 2000 From: Sttscitrans at tesco.net (Iain Davidson) Date: Wed, 31 May 2000 18:35:01 +0100 Subject: Wondering about Domingo's Rational Mean book References: <c588jscm3oqjlfnc723pmafemjcl99ihpm@4ax.com> <8h1nqs$dvs$1@epos.tesco.net> <aae9js85444llpfnao0n9nnhfqcq7p546t@4ax.com> Message-ID: <8h3i5h$n3s$1@epos.tesco.net> Kirby Urner <urner at alumni.princeton.edu> wrote in message news:aae9js85444llpfnao0n9nnhfqcq7p546t at 4ax.com... > "Iain Davidson" <Sttscitrans at tesco.net> wrote: > >The advantage of standard CFs is that they produce all > >best approximations. The mean method for cbrt(2)-1 misses > >131/ 504, for example. > > > > I presume by "best" you mean most accuracy for the least > digits. Like, the mean method gets me closer to cbrt(2)-1 > than 131/504 with fractions like 4159/16001 or 236845/911219 > or 168286661033/647452990441 -- but you're saying standard > CFs will converge more quickly, yes? > > In other words the standard CFs will give a better approximation > when pushed to the same total number of digits -- something > along those lines? You can always find better and better approximations to say, cbrt(2)-1 , but there is no fraction with a smaller denominator than 504 which will be closer. So in this sense 131/504 is optimal. > Do you know of an URL where the standard algorithms for > approximating the nth root of k as p/q are spelled out, > something suitable for computerizing? Do you mean an algorithm that finds convergents directly from x^n -k or just from a decimal approximation of the nth root ? Cohen's book "A Course in Computational Algebraic Number Theory" covers the latter I think. From scarblac-spamtrap at pino.selwerd.nl Sun May 21 15:43:12 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 21 May 2000 19:43:12 GMT Subject: case sensitivity and XML References: <Pine.BSF.4.10.10005211518250.22164-100000@chi.pair.com> Message-ID: <slrn8igf0d.d32.scarblac-spamtrap@flits104-37.flits.rug.nl> Michal Wallace (sabren) wrote in comp.lang.python: > Not so. In xmllib, you use functions like: > > start_sometag(self, attrs): > pass > > > which gets called when the parser sees "<sometag/>" > Suppose you have this: '<sometag a="lowercase" A="uppercase" a-b="a dash b"/>' > Then, case sensitive python would yield this dictionary: > > attrs == {"a":"lowercase", "A":"uppercase", "a-b":"a dash b"} > > No problem whatsoever. Case INsensitive python yields the same dictionary, > but how do you tell "a" apart from "A"? For example, what is the truth > value of: attrs["a"] == attrs["A"] ? > > If we assume that attrs["a"] and attrs["A"] are different, then > someModule.__dict__["A"] != someModule.__dict__["a"] > > Which means someModule.A != someModule.a .. Which means > python is case sensitive again. In case insensitive Python, the following would hold "a" != "A" somerandomdict["a"] != somerandomdict["A"] someModule.__dict__["a"] == someModule.__dict__["A"] IE, I expect that namespaces would use their own dicts, that have the same interface as normal dicts, but which internally convert keys to one case (they only have to store string keys anyway). __dict__.keys() would return the strings in some standard case, I hope. > One option is to say that python just won't be able to parse some > XML documents. I think that would be suicide for the language, as > more and more people and companies start using XML. It's not just XML, it's any application where "a" is a different string than "A". That means just about everything. Assuming that "a" would be equal to "A" in a case insensitive Python is rather silly. -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "Lush profits": Metagaming's In the Labyrinth states that a full one-liter wineskin costs $2 but an empty one costs $3; you receive $1 profit for downing a liter of wine. From ivanlan at home.com Thu May 25 11:34:20 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Thu, 25 May 2000 09:34:20 -0600 Subject: Book missing from python line-up? References: <392CB9B3.F5484CCB@ses.curtin.edu.au> <CMaX4.85884$R4.520098@news1.rdc1.nj.home.com> Message-ID: <392D47FC.2D39A9DC@home.com> Hi All-- Brett g Porter wrote: > [bobbit] > So, I'd rather see a book on "Object Oriented Design and Programming using > Python" than a "Python book about Objects." > Indeed. I think this could be one of the classic programming books of all time, given the proper author and the proper perspective. I've got _Thinking in Java_, and I understand Bruce is working on _Thinking in Python_. I wasn't that impressed with _TiJ_, but I suspect that has a lot more to do with Java and what it can/can't do than the authorial talent. Has anyone heard when _TiP_ might be available? <expand-that-bookshelf>-ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From jeremy at beopen.com Wed May 31 23:56:14 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 31 May 2000 23:56:14 -0400 Subject: Grail on OpenBSD References: <392C9BF8.9DFA8AD8@home.com> Message-ID: <FEDA07BE9E948237.C7913D01757BF814.BFF9D8ABD248009A@lp.airnews.net> It looks like the version of Python you are running is old. > localhost# /usr/local/lib/grail0.6/grail.py > File "/usr/local/lib/grail0.6/grail.py", line 145 > raise > ^ > SyntaxError: invalid syntax The SyntaxError is complaining about a new "raise" syntax that was introduced recently. If you upgrade to Python 1.5.2, it should work. -- Jeremy Hylton <http://www.python.org/~jeremy/> From donn at u.washington.edu Tue May 9 15:45:28 2000 From: donn at u.washington.edu (Donn Cave) Date: 9 May 2000 19:45:28 GMT Subject: How to use nntplib efficiently? References: <shgngh4ud5882@corp.supernews.com> <39183DE8.A911F9D3@erols.com> Message-ID: <8f9pso$hv4$1@nntp6.u.washington.edu> Quoth wmcclain at salamander.com (Bill McClain): | In <39183DE8.A911F9D3 at erols.com>, ""Edward C. Jones" <edcjones at erols.com>" wrote: |> I have written various special purpose news-downloading programs. |> It appears that my code downloads headers slower than Netscape |> for Linux. What is the best way to download new headers? My ISP |> does not allow the "newnews" command. | | I keep track of the first and last article numbers returned by "group" and | use "xover" to fetch headers in the ranges I haven't yet retrieved. Normally, | I get only the range "higher" than my last highest article, but I also | have a "backfill" mode to fill in gaps in article sequencing, which seems | to be a big problem these days. | | I haven't timed it, but it seems fast to me. Mail me if you would like source. I have been using inst.xhdr(('From', 'Subject', 'Message-ID', 'References'), '1011-1580') If it's slow, I haven't noticed. Donn Cave, donn at u.washington.edu From darrin at aetherworks.com Thu May 11 09:46:26 2000 From: darrin at aetherworks.com (Darrin Edelman) Date: Thu, 11 May 2000 08:46:26 -0500 Subject: VxWorks Port Message-ID: <007401bfbb4f$4d599430$3e2ca8c0@lexicon.jeeves.net> Hello all, I have seen a couple of posts and mentions of porting Python to VxWorks. I am wondering if anyone can point me toward one of these ports or give me more information. As a side note, I am wondering how large the interpreter is -- is it really reasonable to put it into an embedded environment? Thanks in advance, -Darrin From mjhand at concentric.net Tue May 9 18:29:34 2000 From: mjhand at concentric.net (Manus Hand) Date: Tue, 09 May 2000 16:29:34 -0600 Subject: CGI getting multiple values with same name into a list References: <v04210104b53cd496e621@[192.168.1.2]> Message-ID: <3918914E.477A358D@concentric.net> Here is how I do what you are wanting to do. form, data = cgi.FieldStorage(), {} for key in form.keys(): if type(form[key]) != type([]): data[key] = form[key].value else: data[key] = map(lambda x: x.value, form[key]) Hope that helps, Manus From michael at stroeder.com Fri May 19 07:00:00 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 19 May 2000 13:00:00 +0200 Subject: python 1.6a2 and openssl References: <20000518002020.14299.qmail@web111.yahoomail.com> <20000518100136.B13281@xs4all.nl> Message-ID: <39251EB0.AB239BF2@stroeder.com> Thomas Wouters wrote: > > socket socketmodule.c -DUSE_SSL -I/usr/include/openssl -lssl -lcrypto IMHO modern OpenSSL applications import the headers with name openssl/[header file] => -I/usr/include should be sufficient. Ciao, Michael. From thomas at xs4all.net Wed May 17 03:16:50 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 17 May 2000 09:16:50 +0200 Subject: Compiled version when .cgi extension is used for scripts In-Reply-To: <NDBBLFFJNMIPIGICNAAEIEAPCFAA.bn@7ways.com>; from bn@7ways.com on Tue, May 16, 2000 at 10:42:18PM +0200 References: <NDBBLFFJNMIPIGICNAAEIEAPCFAA.bn@7ways.com> Message-ID: <20000517091650.N16186@xs4all.nl> On Tue, May 16, 2000 at 10:42:18PM +0200, Bernard Niset wrote: > > Note that your script would have to be fairly lengthy before you to > > actually notice the difference between the two versions. > I know but it is still useless to to a compilation each time. Useless, probably, slower, maybe, but is the minor speedup really worth having to check wether the code should be recompiled, dumping the new compiled version to disk, not to mention the clutter it would cause, having all those .pyc files lying around ? If you really need the speedup, create a C wrapper that exec()'s python with 'argv[0] + ".pyc"' as argument, and only update the bytecode version when you want to. But dont forget to recompile the compiled version when you install Python 1.6, or it wont work :-) > > Unfortunately, compiled python scripts need to have the .pyc (or .pyo) > > extention for the interpreter to see them as such... If they have any > > other name, the python interpreter tries to interpret them as normal > > scripts instead. I'm not really sure why, but I guess the variance in > > bytecode versions is too great to make the python interpreter autodetect > > them... I think it would be neat if it could, though. > When the script is named differently from .py, the interpreter could use > scheme like original_name.ext.pyc. Yes, I know, but my point was that you can't rename your '.pyc' file to something without a .pyc extention, and still keep it functional. If you want to pass a bytecode-compiled version of a script to the python interpreter, it *has* to have a name ending on '.pyc'. If this wasn't necessary, you could make a 'misc binary' handler on linux that allows you to run python bytecode as if they were normal binaries ;-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jp at NOSPAMdemonseed.net Sun May 21 12:06:10 2000 From: jp at NOSPAMdemonseed.net (Jason Petrone) Date: Sun, 21 May 2000 11:06:10 -0500 Subject: PyOpengl... gone forever? References: <CC59868A0A76D311B1F50090277B321C1F3346@VRTMAIL> <8g8cb6$k3v$10$1@news.t-online.com> Message-ID: <ih19g8.0ul.ln@demonseed.net> Thomas Malik <340083143317-0001 at t-online.de> wrote: > Hmm, since i've put my own additions into the module, i could propably do > the job. I use only GLUT, and it were on a rather infrequent basis, however. > Does someone have the email address of the original author ? > Thomas You can find ongoing dialogue concerning PyOpenGL at http://www.egroups.com/group/pyopengl. If anyone needs, I have a local mirror of a fairly recent CVS checkout: http://www.demonseed.net/~jp/code/PyOpenGL_08_04_00.tar.gz -jason From jkraska1 at san.rr.com Mon May 8 00:11:48 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 08 May 2000 04:11:48 GMT Subject: Vim and python syntax question References: <391634F1.3E47BDA5@udel.edu> Message-ID: <39163F4E.EE88F9CF@san.rr.com> Charles Boncelet wrote: > > When running vim with syntax coloring on, sometimes I get > strong, dark colors and sometimes weak, pastel ones. I > have no idea why the colors vary. Anyway, how can I always > get the strong, dark colors? The issue probably is *not* your vim syntax file, but rather the defaults that your vim resolves to. I've included my python.vim at the end of this, but what you probably really want is my vimrc. On windows, you should name this "_vimrc" and put it into the directory that your "%VIM%" environment variable points to. On unix, call it ".vimrc" and put it in your home directory. For unix, you'll probably have to pick new font descriptions. Note this is for gvim only... syntax on set hlsearch source $VIM/syntax/syntax.vim behave xterm set guifont=Courier_New:h10 "set guifont=Lucida_Sans_Unicode:n:h9 set autoindent set noerrorbells set tabstop=4 set wrapmargin=2 set nowrap set guioptions=am set textwidth=150 set nobackup set et highlight String guifg=Black guibg=Yellow highlight Constant guifg=Blue font=Courier_New:b:h10 highlight PreCondit guifg=Black font=Courier_New:b:h10 highlight PreProc guifg=Firebrick highlight Define guifg=Firebrick highlight Include guifg=Black font=Courier_New:b:h10 highlight Type guifg=Black font=Courier_New:b:h10 highlight Comment guifg=Red highlight Statement guifg=Black font=Courier_New:b:h10 highlight Special guifg=Black font=Courier_New:b:h10 highlight Identifier guifg=Black highlight Number guifg=Blue font=Courier_New:b:h10 highlight Operator guifg=Black font=Courier_New:b:h10 highlight Error guifg=Black guibg=Red highlight pythonSpecial guifg=Blue font=Courier_New:b:h10 highlight link Character String highlight link Function Statement highlight link Label Type " Vim syntax file " Language: Python " Maintainer: Neil Schemenauer <nascheme at acs.ucalgary.ca> " Last change: 1998 July 17 " Remove any old syntax stuff hanging around syn clear syn keyword pythonStatement break continue del syn keyword pythonStatement except exec finally syn keyword pythonStatement pass print raise syn keyword pythonStatement return try syn keyword pythonStatement global assert syn keyword pythonRepeat for while syn keyword pythonConditional if elif else then syn keyword pythonOperator and in is not or syn keyword pythonConstant None syn region pythonString start=+'+ end=+'+ skip=+\\\\\|\\'+ syn region pythonString start=+"+ end=+"+ skip=+\\\\\|\\"+ syn region pythonString start=+"""+ end=+"""+ syn region pythonString start=+'''+ end=+'''+ syn keyword pythonFunction def class lambda syn keyword pythonPreCondit import from syn match pythonComment "#.*$" contains=pythonTodo syn keyword pythonTodo contained TODO FIXME XXX syn match pythonList "[\[\]]" syn match pythonDict "[{}]" syn match pythonNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" syn match pythonNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" syn match pythonNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" " triple quoted strings make syncronizing difficult "syn sync match pythonSync1 grouphere NONE +\("""$\)\|\('''$\)+ syn sync match pythonSync grouphere NONE "):$" syn sync maxlines=100 if !exists("did_python_syntax_inits") let did_python_syntax_inits = 1 " The default methods for highlighting. Can be overridden later hi link pythonDict pythonSpecial hi link pythonList pythonSpecial hi link pythonNumber Number hi link pythonStatement Statement hi link pythonConditional Conditional hi link pythonConstant Constant hi link pythonRepeat Repeat hi link pythonString String hi link pythonOperator Operator hi link pythonFunction Function hi link pythonPreCondit PreCondit hi link pythonComment Comment hi link pythonTodo Todo endif let b:current_syntax = "python" " vim: ts=8 From ge at nowhere.none Thu May 25 11:54:43 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 25 May 2000 15:54:43 GMT Subject: Pass by reference? References: <8ghcq1$opl$1@supernews.com> <392C683E.AF7398D4@uab.edu> <8gin25$sfe$1@supernews.com> <392CFBD8.E5173DFD@ecs.soton.ac.uk> Message-ID: <71cX4.4668$BW6.448715@ptah.visi.com> In article <392CFBD8.E5173DFD at ecs.soton.ac.uk>, Jacek Generowicz wrote: >> Also the following program proves to me that arguments are passed by value >> and not by reference: > >No, it doesn't, but I agree that if you do not keep in mind exactly what `=' >does in Python, then you are likely to think so. It sort of depends on how you think about it. As a long-time C programemr, I generally take the viewpoint that in Python variables are passed by value, but all variables are pointers. (And many of the pointers are pointing to "const" objects that can't be modified.) If you're a C programmer, you can think of it like this: void foo(char *p) { printf("%s\n",p); p = "abcd"; printf("%s\n",p); } void main(void) { char *s; s = "qwer"; printf("%s\n",s); foo(s); printf("%s\n",s); } In foo(), the assignment statement 'p = "asdf"' doesn't change the value of the object to which p originally pointed -- rather it makes p point to a different object. This is exactly what Python does. There _are_ times in Python when you can modify the object to which a parameter points -- which, in C would be something like: void foo(char *p) { p[2] = 'x'; } However, 1) some objects are not mutable, so this paradigm can't be used. 2) side effects like this are often the cause of bugs. 3) stylistically, those of us who learned Scheme before we learned Python generally prefer a more functional approach. -- Grant Edwards grante Yow! Are you guys lined up at for the METHADONE PROGRAM visi.com or FOOD STAMPS?? From robin at illusionsexeculink.com Mon May 1 22:32:22 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Mon, 01 May 2000 22:32:22 -0400 Subject: Python Compiler References: <8F26DEAB4joshtinamecom@209.208.0.7> <sgpuubk7oog52@corp.supernews.com> Message-ID: <9efsgs0rg934fm82ui3m1273p9v4qoffld@4ax.com> "Eric Jacobs" <none at none> wrote: >There are two main approaches to compile Python to machine code: > [snip] great post! ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Ontario's government could be a symptom of the conditions deep in the ocean. From MSteed at altiris.com Tue May 2 12:02:16 2000 From: MSteed at altiris.com (Mike Steed) Date: Tue, 2 May 2000 10:02:16 -0600 Subject: ANN: gdchart-0.4 Message-ID: <65118AEEFF5AD3118E8300508B1248774CB2C2@ALTNET> Hi, I have posted a new version of my interface to the GDChart library. Changes in this version: - Updated the library to use gd-1.8.1. GDChart now produces PNG and JPEG images instead of GIFs. - Support for transparent backgrounds in pie charts (thanks to Chui Tey). - Support for cStringIO. Python interface: http://athani.pair.com/msteed/software/gdchart/index.html More about the GDChart library: http://www.fred.net/brv/chart/ -- M. From andy at petdance.com Wed May 17 10:27:13 2000 From: andy at petdance.com (Andy Lester) Date: Wed, 17 May 2000 09:27:13 -0500 (CST) Subject: Forcing type conversion In-Reply-To: <8fu9m9$2ab$1@supernews.com> References: <8fu9m9$2ab$1@supernews.com> Message-ID: <Pine.WNT.4.21.0005170926460.205-100000@nt_alester> > How do I get Python to force 'a' and 'b' into strings so that the following > concatenates instead of trying to add. > > a = 1 > b = 2 > a + ":" + b The metaphor you're looking for is like so: str = "%d:%d" % (a,b) xoxo, Andy -- Andy Lester, andy at petdance.com, http://www.petdance.com "Inflammable material is planted in my head It's a suspect device that's left two thousand dead." "Hey, is this the new Green Day?" From embed at geocities.com Mon May 1 14:35:07 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 1 May 2000 14:35:07 -0400 Subject: Class Factories in Python: How? Message-ID: <QakP4.14046$HG1.376626@nnrp1.uunet.ca> Suppose I have a base class which handles a Binary Structures, in this case, a series of Marshalled attributes, stored on disk as a marshalled array (so it's fast, binary, and no field names are stored with each row). Each type I want to create a new binary structure, I subclass it, but the subclassing procedures are getting complex because there are so many class-variables that need to be initialized. So I decided to try to build a class factory, like this: This is a simplified (<100 lines) of something I'm trying to do that is currently over 500 lines. Warren --- code snippet --- # class factory example import marshal import string def binstruct_lookup(attributes): "create a dictionary to lookup data row field orderings" n = 0 dict1 = {} for n in range(0,len(attributes)): dict1[attributes[n]] = n return dict1 class marshalstruct: "a binary structure handler class - a simplified example" attributes = [ "a", "b", "c" ] # demo lookups = binstruct_lookup(attributes) fieldcount = len(attributes) def __init__(self): self.__dict__["values"] = [None]*self.__class__.__dict__["fieldcount"] def as_string(self): return string.join(map(repr,self.__dict__["values"]), ", ") def marshal(self): return marshal.dumps(self.values) def unmarshal(self,binstr): self.__dict__["values"]= marshal.loads(binstr) def __getattr__(self,name): try: l = self.__class__.__dict__["lookups"][name] except: raise LookupError, "invalid field name "+name+" in binstruct." return self.__dict["values"][l] def __setattr__(self,name,value): try: l = self.__class__.__dict__["lookups"][name] except: raise LookupError, "invalid field name "+name+" in binstruct." self.__dict__["values"][l] = value # Ugly way to Subclass: #class marshalstruct2: # "subclass" # attributes = [ "d", "e", "f" ] # lookups = binstruct_lookup(attributes) # fieldcount = len(attributes) # when I want to declare a specialization of the above class, I need # to include all the right things, in the right order, to redefine # variables at a class scope: # A Nicer way? Is it possible? # class factory to specialize the above class given some new attributes to use: def marshalstruct_factory(newattributes): class newclass(marshalstruct): attributes = newattributes lookups = binstruct_lookup(attributes) fieldcount = len(attributes) return newclass # fails, attributes = newattributes doesn't work, probably because # the above class scope doesn't admit the function parameters into its scope. #y = marshalstruct_factory(['test1','test2','test3']) n = marshalstruct() n.a = "a value" n.b = "b value" n.c = "c value" try: n.d = "illegal!" print "Failure: Shouldn't get here!" except LookupError: print "Working :illegal attribute name trapped" print "dump fields separated by commas, as a string:" print n.as_string() print "Finished." From jkraska1 at san.rr.com Fri May 19 23:47:39 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 20 May 2000 03:47:39 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <39260037.146C3467@san.rr.com> <slrn8ic24u.sc3.wtanksle@dolphin.openprojects.net> Message-ID: <39260B99.86CBF73C@san.rr.com> > >> Python is not a democracy. > > >The success and future of python is a democracy of the most > >brutal kind. > > That's right: and Guido is both the teeming masses AND the guillotine. > > Seriously, though, the future of Python is not up to any democracy -- > because even if a majority doesn't like it, it won't be hurt. We don't > need any vote (although we can always leave). I appreciate what you're trying to say, but if Python ever becomes a mainstream programming language, I can guarantee you that it will outgrow Guido. I don't know a thing about the Guido, and don't have a thing against him; to the contrary, I'm rather fond of his language. (Thanks, Guido!) Be that as it may, there comes a time when the founder of something ceases to have true dictatorial power over his creation, sooner or later. It's generally a bad idea to opine "it's my way or the highway," especially in a setting like this, where the more you say it, the less and less true it will become. Conversely, the more he listens to what his users have to say, even if it's just a token vote, the more likely he is to see continued success and growth of this beautiful language. Hope I haven't offended anyone, C/ From debl.nopsamm at world.std.com Sat May 27 12:50:47 2000 From: debl.nopsamm at world.std.com (David Lees) Date: Sat, 27 May 2000 16:50:47 GMT Subject: Calling NumPy from Visual Basic? Message-ID: <392FFCE8.8684C54B@world.std.com> I have NumPy running with Python 1.5.2 on a Window 95 box and would like to call the matrix routines in NumPy from Visual Basic 5. Can anyone point me to an example of how to pass matricies and vectors back and forth between VB an Python? Thanks in advance. David Lees From johann at physics.berkeley.edu Wed May 31 16:37:37 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 31 May 2000 13:37:37 -0700 Subject: MORE INFO - Array assigment with Numeric.py References: <3933D80E.172D09F7@americasm01.nt.com> <393508AD.8FB039E@americasm01.nt.com> <87wvkardf7.fsf@ifm.uni-kiel.de> <39356180.43AF8B70@americasm01.nt.com> Message-ID: <mtr9aicv72.fsf@astron.berkeley.edu> Morris, Brad [WDLN2:2W40:EXCH] writes: > This is the routine that I used to load data from an ascii > file (this essentially highlighted the problem). The data is > separated by blanks and each line is terminated with an EOL > character. The file can be either a single line with > multiple entries separated by spaces, a single entry per > line with multiple lines, or a both. The data is regular, a > vector or a matrix, with no missing elements. There is a > final empty line in the file with an EOL only.The shapes > returned are (1,x), (x,1), or (x,y) respectively. Which in > second case is not the same as assigning the data to an > array directly (x,). It's not clear to me if this is a > function of data.append or Numeric.array(data). Does this > mean something is returning (x,NewAxis)? No, there is no NewAxis in here. You're simply getting a 2D array out because you're putting a 2D array in. If you want to get something different, you'll have to process the data further. You're going either (1,3) -> array([[1.0, 2.0, 3.0]]) (3,1) -> array([[1.0],[2.0],[3.0]]) (3,3) -> array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.]]) If you want to get a 1D array, you'll have to explicitly ask for one: (3,) -> array([1.0, 2.0, 3.0]) Any nested lists (like all of the first three examples) will lead to a 2D array. If you want to get a 1D array out of your routine, you'll have to check if one of the dimensions is 1, and if so, collapse that dimension. I think Janko gave a routine to do that. Cheers, --Johann -- Johann Hibschman johann at physics.berkeley.edu From herzog at online.de Tue May 16 19:10:47 2000 From: herzog at online.de (Bernhard Herzog) Date: 17 May 2000 01:10:47 +0200 Subject: python improvements (Was: Re: New Language) References: <39213581.61ACB83@fenx.com> Message-ID: <m3em72f5vs.fsf@greebo.nodomain.de> emile at fenx.com writes: > It looks like you can sneak your way into a class: > > class Pass: > None > > class Test: > def __init__(self, a,b,c,d,e): > self.f = f(a,b,c,d,e) > def func(self, a): > print "This is a class function (call ref: %s)" % a > > a = Pass() > a.__class__ = Test > > a.func('class') Heh, that's a sneaky way to instantiate a class without actually instantiating it. Why didn't I think of this, considering that I once seriously considered using a sort of mind-swap to let one object assume the identity of another: c.__dict__, d.__dict__ = d.__dict__, c.__dict__ c.__class__, d.__class__ = d.__class__, c.__class__ -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From mwh21 at cam.ac.uk Thu May 25 03:56:20 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 May 2000 08:56:20 +0100 Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> Message-ID: <m31z2rkqqj.fsf@atrus.jesus.cam.ac.uk> nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) writes: > Hi there, > > In the other P language, the standard idiom is > > for $key (sort keys %d) { ... } # (1) > > The naive approach in Python would be > > for key in d.keys().sort(): pass # (2) > > However, this doesn't make sense (I realise this). I presume that this > makes a temporary list containing the keys of d, sorts this list, throws > the list away and then does the equivalent of 'for k in None: pass'. > > _Learning Python_ suggests the following in its solution to example 3 of > chapter 3: > > keys = d.keys > keys.sort() > for key in keys: pass # whatever # (3) > > Is there any way to avoid this temporary variable and to write the for > in one line? Try: for key in (lambda k: k.sort() or k)(d.keys()): pass [snip] > for key in (lambda k=d.keys(): k.sort() or k)(): print key, # (8) Oh, you thought of that :-). > What's the standard Python idiom for this? What do you use? Undoubtedly: keys = d.keys() keys.sort() for key in keys: pass Are you allergic to the newline character or something? This is clear, and says exactly what you want to do. If you really really need to do it on one line, why not define: def sorted(list): list.sort() return list and then do: for key in sorted(d.keys()): pass This is obviously fundamentally the same as #(8), but is rather more readable. Cheers, M. -- 48. The best book on programming for the layman is "Alice in Wonderland"; but that's because it's the best book on anything for the layman. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From aruth at intercation.com Tue May 9 10:48:02 2000 From: aruth at intercation.com (Adam Ruth) Date: Tue, 9 May 2000 08:48:02 -0600 Subject: Python Emacs Mode and fontification References: <3918407E.C95C72B5@exceptionalminds.com> Message-ID: <8f98g8$2igu$1@news.aros.net> The line you need in your .emacs file is: (add-hook 'python-mode-hook 'turn-on-font-lock) -- Adam Ruth InterCation, Inc. www.intercation.com "Timothy Grant" <tjg at exceptionalminds.com> wrote in message news:3918407E.C95C72B5 at exceptionalminds.com... > I recently converted to Xemacs (though I have yet to be confirmed or > baptised) solely due to its excellent python mode. However, I am now > faced with a really weird fontification problem. I have a source file > that doesn't appear any different from any of the other source files I > have created, however, everytime I add new code to the file, Xemacs > fontifies it as a """string""". If I save the file exit and reload it, > all the fontification is correct, but the minute I make any changes it > gets out of whack again. > > Perchance would anyone have some guiding light for an Xemacs neophyte? > > Thanks. > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Chief Technology Officer www.exceptionalminds.com > Red Hat Certified Engineer (503) 246-3630 > Avalon Technology Group, Inc. fax (503) 246-3124 > >>>>>>>>>>>>Linux...Because rebooting isn't normal<<<<<<<<<<<< > From achrist at easystreet.com Fri May 12 16:14:18 2000 From: achrist at easystreet.com (Al Christians) Date: Fri, 12 May 2000 13:14:18 -0700 Subject: Python Plans from ActiveState References: <PLEJJNOHDIGGLDPOGPJJCEAJCCAA.DavidA@ActiveState.com> <RqJS4.1039$qf.6315@typhoon.southeast.rr.com> <VkQS4.1198$Kc3.6579@news-server.bigpond.net.au> Message-ID: <391C661A.3C301E4A@easystreet.com> Mark Hammond wrote: > > > It will be the core Python, plus some "key extensions" for the platform. > Eg, for Windows, it will include the win32all series. > > There will also be some additional work at some stage - eg, already > identified is that instead of including the (quite fine, but > requiring a 3rd party DLL) "SIO" module for serial IO, we are likely > to upgrade the win32file support to provide the same functionality. > [For obvious reasons, Im more up on the APy for Windows plans :-] > I don't know if this is yet true or will be with version 1.6: it would seem to be advantageous to have an installer that installs a binary version into the same directory structure that the source version uses. I remember getting stuck somewhere when I was using the binary version but downloaded some package that wanted to work with a source distribution. This was not as easy as most everything else ought to be. Real nice would be to be able to download the source version, then plaster the binary version over it, so that I know I've got the same good executables as the binary version, but I also have whatever source the packages that work with the source distribution expect. How about a source+binary Windows version? Al From chibaA at TinterlogD.Tcom Mon May 22 10:35:38 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Mon, 22 May 2000 14:35:38 GMT Subject: Programs run SLOW Message-ID: <39294515.824760893@news1.on.sympatico.ca> Hi, I was just wondering if there would be any reason why a python script would run REALLY slow (from the command prompt, and elsewhere). The programs aren't really that long at all, and most of them are purely python (ie. does not interface MySQL, etc..). Would there be anything I could do to speed up the program execution? (it seemed like they were running a LOT faster before, and all of a sudden, they run extremely slow --> ie. 2-3 seconds, instead of almost instantaneous). In addition, would anyone know of a website which lists the processor cycles/times required for each python command (like for, while, if, etc..). Thanks so much, kc From mikem at wetafx.co.nz Wed May 17 19:30:28 2000 From: mikem at wetafx.co.nz (Mike Morasky) Date: Thu, 18 May 2000 11:30:28 +1200 Subject: Error embedding in C++ Message-ID: <39232B94.517771C4@wetafx.co.nz> I'm embedding python in a simple c++ application that I've based on the embed demo that comes with the installation. I've checked to make sure I'm linking to all the libraries setup in the mentioned Makefiles and yet I'm getting an Unresolved text symbol error: ld32: ERROR 33: Unresolved text symbol "__eprintf" -- 1st referenced by /local1/usr/local/Python-1.5.2/libpython1.5.a(longobject.o). For the life of me, I can't seem to find the symbol or the library that would resolve it. Can anyone point me in the right direction? From moshez at math.huji.ac.il Sat May 27 16:46:30 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 27 May 2000 23:46:30 +0300 (IDT) Subject: making a string a given length? In-Reply-To: <8gpbqm$nh3$1@bob.news.rcn.net> Message-ID: <Pine.GSO.4.10.10005272346150.9575-100000@sundial> On Sat, 27 May 2000, Z 3 Penguin wrote: > For a python program to interface with gnutella, i need to make a string > (like +ACI-abc+ACI-) a given number of bytes long. is there anyway to do this > without having to write my own function? string.fill? From mwh21 at cam.ac.uk Fri May 26 10:48:47 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 May 2000 15:48:47 +0100 Subject: Unified Arrays in Python? References: <392E0754.53F86E1D@ses.curtin.edu.au> <020501bfc6e8$4d3933d0$0500a8c0@secret.pythonware.com> <Pine.LNX.4.10.10005260921290.11458-100000@us2.mayo.edu> Message-ID: <m3ln0xjrjk.fsf@atrus.jesus.cam.ac.uk> Travis Oliphant <olipt at mayo.edu> writes: > The solution I'm working on is to make the NumPy Object a bonified ^^^^^^^^ Do you mean "bona fide" here? Otherwise I'm confused... > Python Class Sorry I don't have anything useful to say... M. -- "declare"? my bogometer indicates that you're really programming in some other language and trying to force Common Lisp into your mindset. this won't work. -- Erik Naggum, comp.lang.lisp From moshez at math.huji.ac.il Sat May 20 06:30:37 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 20 May 2000 13:30:37 +0300 (IDT) Subject: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) In-Reply-To: <392659df.0@katana.legend.co.uk> Message-ID: <Pine.GSO.4.10.10005201329180.4368-100000@sundial> On Sat, 20 May 2000, Thomas Mangin wrote: > > > Erm, how would you parse this? > > > > > > if yes () > > I would say that seni-colon have *only* to be use to separate condition from > instruction, so this is : > if yes (): > _ But maybe it means: if yes: () Which is perfectly valid Python: >>> yes = 1 >>> if yes: () ... () >>> -- Moshe Zadka <moshez at math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From mikael at isy.liu.se Wed May 17 03:11:22 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 17 May 2000 09:11:22 +0200 (MET DST) Subject: python web hosting In-Reply-To: <8fsh2i$796$1@nnrp1.deja.com> Message-ID: <XFMail.000517091122.mikael@isy.liu.se> On 16-May-00 sh1232 at my-deja.com wrote: > I've searched this forum but could not find a good list of web hosting > company that support python. If your web hosting company (or know of one) > supports python cgi, please post it to this thread. Thank you very much in > advance. This seems to bubble up as an FAQ. Perhaps this info should be placed somewhere on www.python.org. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 17-May-00 Time: 09:08:46 This message was sent by XF-Mail. ----------------------------------------------------------------------- From felixt at dicksonstreet.com Thu May 4 21:30:40 2000 From: felixt at dicksonstreet.com (Felix Thibault) Date: Thu, 04 May 2000 20:30:40 -0500 Subject: Question about __hash__ Message-ID: <3.0.5.32.20000504203040.00864df0@mail.dicksonstreet.com> I have been using classes like these to simplify searching through lists: class BeginsWith(Pattern): def __init__(self, *beginning): self.indices = range(len(beginning)) self.beginning = beginning def __cmp__(self, other): try: for index in self.indices: if other[index] != self.beginning[index]: return cmp(other[index], self.beginning[index]) else: return 0 except IndexError: return 1 __rcmp__ = __cmp__ class Any(Pattern): def __cmp__(self, other): return 0 __rcmp__ = __cmp__ Right now I'm looping through a list of (TextTools parsings of) the html tags in a document, to build another list of [tagname, where_i_open, where_i_close] lists. This isn't as straightforward as I thought it was. Right now it looks like sometimes I will need to search for all the tags that are still open with a certain name- that look like ['table', Any(), None] , say- in the list that I'm building. I want to cache these searches in a dictionary so I don't repeat them over and over on the same lists, so I have to add __hash__ methods to my Pattern subclasses. Right now I'm calculating the hash value ahead of time: self.hv = hash(self.__class__) + hash(initargs) (calculated in the class body with initargs = () for classes like Any and in __init__ for classes like BeginsWith) with: def __hash__(self): return self.hv So my questions are: 1) Is there another way I should be calculating hash values besides adding them so I can be sure I won't get an overflow ? Or am I being paranoid ? 2) If these classes have (instance) attributes that do change (ie, another attribute that stores the last successful match) is what I've done enough to be sure that this doesn't affect key matching ? 3) The documentation mentions that if you define __hash__ you need to define __cmp__. Does that mean I need to make sure that instances compare to each other as equal if they compare to the same objects as equal ? (Which wouldn't be the case with BeginsWith like I have it now) Thanks! Felix From lminuti at eid.it Mon May 22 12:16:19 2000 From: lminuti at eid.it (Luca) Date: Mon, 22 May 2000 18:16:19 +0200 Subject: Using DCOracle Message-ID: <8F3CB2E21lminutieidit@192.6.1.10> I'm try to use DCOracle. I compiled it, I run DCOracle_test.py and it works fine. Then the readme.txt say: "To install the extensions, copy them to DCOracle package directory" So I copy *.so files in the same directory where I store oci*.py. Than I try a simple script like this: import Buffer, oci_ print 'Import succeeded' dbc=oci_.Connect("user/password at connect_string") print 'Connect succeeded' cur = dbc.Cursor() But I receive this message: Import succeeded Connect succeeded Traceback (innermost last): File "./prova.py", line 11, in ? cur = dbc.Cursor() AttributeError: 'Connection' object has no attribute 'Cursor' What's wrong? Thanks. From nospam.newton at gmx.li Thu May 25 00:20:08 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Thu, 25 May 2000 04:20:08 GMT Subject: Iterating over a dictionary's sorted keys Message-ID: <392ca730.81985398@news.nikoma.de> Hi there, In the other P language, the standard idiom is for $key (sort keys %d) { ... } # (1) The naive approach in Python would be for key in d.keys().sort(): pass # (2) However, this doesn't make sense (I realise this). I presume that this makes a temporary list containing the keys of d, sorts this list, throws the list away and then does the equivalent of 'for k in None: pass'. _Learning Python_ suggests the following in its solution to example 3 of chapter 3: keys = d.keys keys.sort() for key in keys: pass # whatever # (3) Is there any way to avoid this temporary variable and to write the for in one line? One attempt at this was for key in (k=d.keys(); k.sort(); k): pass # (4) however, this is invalid syntax, as is for key in (k=d.keys(), k.sort(), k): pass # (5) , presumably because you can't use assignment as an expression in Python and because C's comma operator doesn't exist in Python because it would be confused with the tuple-making comma. Next attempt was for key in lambda k=d.keys(): k.sort(), k: pass # (6) -- again, no comma operator (and lambdas can contain only one statement; is that right?). for key in (lambda k=d.keys(): k.sort() or k): pass # (7) Devious: Python's or returns the last true object evaluated, not just 1 or 0. So k.sort() (returning None) causes the right-hand-side of the or to be evaluated and k to be returned from the lambda. But I forgot to call the lambda! (I found this out by writing the lambda by itself on the command line and found that the interpreter printed it as "(function <lambda> at .....)".) for key in (lambda k=d.keys(): k.sort() or k)(): print key, # (8) Is there no easier way than (8) to iterate over a dictionary's sorted keys in one line, or without invoking temporary variables? It looks sort of ridiculous to have to go to such lengths, especially since this operation must be fairly common. What's the standard Python idiom for this? What do you use? Cheers, Philip -- Philip Newton <nospam.newton at gmx.li> If you're not part of the solution, you're part of the precipitate. From z3penguin at penguinpowered.com Sat May 27 16:38:54 2000 From: z3penguin at penguinpowered.com (Z 3 Penguin) Date: Sat, 27 May 2000 16:38:54 -0400 Subject: making a string a given length? Message-ID: <8gpbqm$nh3$1@bob.news.rcn.net> For a python program to interface with gnutella, i need to make a string (like +ACI-abc+ACI-) a given number of bytes long. is there anyway to do this without having to write my own function? ----- Z 3 Penguin z3p+AEA-z3penguin.org () (o+AF8- //+AFw- +ADw--+AFwAXw-/ This is a virus that works on the honor system. Send this .sig to everyone in your address book and randomly delete some of your files. From dgoodger at bigfoot.com Sun May 14 22:00:27 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 14 May 2000 22:00:27 -0400 Subject: A TYPICAL NEWBIE MISTAKE? In-Reply-To: <391F513B.CEA12592@san.rr.com> References: <391F513B.CEA12592@san.rr.com> Message-ID: <B544D27B.3468%dgoodger@bigfoot.com> on 2000-05-14 21:19, Courageous (jkraska1 at san.rr.com) wrote: > To wit: append()ing to > a list or assigning to a dictionary does not count > as "assigned". > > I spent quite a while this afternoon figuring this > out. This must be a fairly common error. The solution > is obvious. If you want to assign class variables as > commentary the way I do, make sure you assign everyone > in the __init__() method, ala: > > class MyClass > > i=0 > f=3.1 > s="str" > ll=[] > > def __init__() > > i=0 > f=3.1 > s="str" > ll=[] Actually, it should be: class MyClass: def __init__(): self.i = 0 self.f = 3.1 self.s = "str" self.ll = [] Note that without the 'self.' in __init__() (or any other method), a variable *local to that method* is created; the variables would disappear upon the completion of the method. > Albeit, now that I understand everything, this seems a > bit reduntant. :)- 100% redundant, I think ;-> -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From jcm at bigskytel.com Wed May 17 06:14:23 2000 From: jcm at bigskytel.com (David Porter) Date: Wed, 17 May 2000 04:14:23 -0600 Subject: Python to be Renamed! In-Reply-To: <m34s7xmzx2.fsf@atrus.jesus.cam.ac.uk>; from mwh21@cam.ac.uk on Wed, May 17, 2000 at 07:52:25AM +0100 References: <C5A7720BDEB7D3118A5200E018C200A051DA32@EXCHANGE> <m34s7xmzx2.fsf@atrus.jesus.cam.ac.uk> Message-ID: <20000517041423.A5873@bigskytel.com> * Michael Hudson <mwh21 at cam.ac.uk>: > Gaetan Corneau <corg at copernic.com> writes: > > > Good one :) > > > > What about this one: > > http://www.segfault.org/story.phtml?mode=3D2&id=3D3905b40e-05c0a760 ^^ ^^ Where did those come from? > Warning: PostgresSQL query failed: ERROR: id_in: 3D3905b40e-05c0a760 > not in id format in /home/segfault/htdocs/story.phtml on line 30 Story > Error The selected story does not appear to exist. The original URL posted was this (it works): http://www.segfault.org/story.phtml?mode=2&id=3905b40e-05c0a760 > ? I second that. _David_ From moshez at math.huji.ac.il Mon May 29 05:45:24 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 29 May 2000 12:45:24 +0300 (IDT) Subject: CRAZY: First class namespaces In-Reply-To: <393237CD.EDEBEF35@tismer.com> Message-ID: <Pine.GSO.4.10.10005291244100.8146-100000@sundial> On Mon, 29 May 2000, Christian Tismer wrote: > What would be better for the language, dynamic or lexical? > I really don't know, please tell me your thoughts. Definitely lexical. I do miss closures... Dynamic scopes breaks the abstraction that a function is a "black box": a function shouldn't be able to look inside its caller. -- Moshe Zadka <moshez at math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From jpb at mycroft.communiweb.net Sun May 21 13:10:39 2000 From: jpb at mycroft.communiweb.net (jpb) Date: Sun, 21 May 2000 17:10:39 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> Message-ID: <jpb-0D38E8.13104021052000@news-server.cfl.rr.com> In article <cppuqg4hsu.fsf_-_ at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: >You're saying it's unacceptable -- a vote. But you don't say *why* >you vote that way, so your vote gets multiplied by zero (rather than >by the size of your department or the capital of your bank, as you >seem to hope by bringing them into the argument :-). > >Here's a way to make your vote count: explain what it is about case >sensitive languages that you hate. Then we can have a discussion >about it. Ok, here's why I'm in favor of keeping the language case sensitive - if I need a scratch variable of class Fubar I tend to name it fubar so I can keep track of what class it's meant to be. I tend not to bother to come up with a more descriptive name unless the variable is hanging around. -- Joseph Block <jpb at communiweb.net> "Any government that is powerful enough to give you everything you want, is powerful enough to take away everything you have." - Barry Goldwater From emile at fenx.com Mon May 22 20:14:08 2000 From: emile at fenx.com (emile at fenx.com) Date: Mon, 22 May 2000 17:14:08 -0700 Subject: First different char in two strings? Message-ID: <3929CD50.3172F245@fenx.com> Hang on, I'm sure you'll get a faster method than this! ;-) But, being as I generally find that the obvious way is often the fastest, or close enough, here's the obvious: a = "this is a test" b = "this is not a test" for i in range(len(a)): if b[i] != a[i]: break print i It-all-depends-on-the-strings-you-expect-ly y'rs, Emile van Sebille emile at fenx.com Stefan Franke <spamfranke at bigfoot.de> wrote in message news:<392abd40.10218183 at news.btx.dtag.de>... > What's the fastest way to find the first different character inside two strings? > > Stefan > > -- > http://www.python.org/mailman/listinfo/python-list > From m.faassen at vet.uu.nl Wed May 24 07:21:14 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 24 May 2000 11:21:14 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <Pine.GSO.4.21.0005181437530.2583-100000@z.glue.umd.edu> <39245ED7.9C3A4FAB@prescod.net> <Pine.GSO.4.21.0005191815350.22081-100000@y.glue.umd.edu> <vrya5615eg.fsf_-_@bor.IRO.UMontreal.CA> <cphfbtvk9p.fsf@cj20424-a.reston1.va.home.com> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <cppuqg4hsu.fsf_-_@cj20424-a.reston1.va.home.com> <20000522183552.A29224@mudge> <8gcoij$60n$1@news-int.gatech.edu> <8gdla5$nju$3@newshost.accu.uu.nl> <8gfiei$5fh$1@news-int.gatech.edu> Message-ID: <8ggdva$mne$1@newshost.accu.uu.nl> Andrew Henshaw <andrew.henshaw at gtri.gatech.edu> wrote: > Martijn Faassen wrote: [snip my indentation argument] >>Do you, or do you not, think about Python's indentation system this way? > You've (basically) made this argument in other threads, but I'm glad it showed > up here so that I could address it in this same context. Okay. I've been pushing it for a while now to get it into Python's meme space. > Python's indentation rules provide for instruction grouping. There **must** > be some mechanism to indicate grouping, and indentation fills that need in > Python. If indentation is not used, then block tokens are commonly used. > These are both acceptable solutions to the problem. Your argument > seems to be incomplete in that you haven't provided a replacement solution to > the grouping problem. Naturally this would be block tokens, indeed. > Given this argument, one must ask "Indentation > provides a reasonable solution to a difficult compilation problem, what > difficult compilation problem is solved by case sensitivity?" Consistency again. block tokens are the accepted way in almost all programming languages to group instructions. Python for some reason uses indentation. What is this reason? * it looks better (once you're used to it) shorter, just as readable * we get more consistent indentation practices, as it *matters* > Perhaps your solution to instruction grouping is recognition of grouping by > context. If your carefully chosen example was representative of most code > then I would, perhaps, agree with you. However, if your code stopped with the > second print statement, or was not an artifically-separated sentence, then I > would say that the flow of control was ambiguous. Why do people want case sensitivity? * it looks better if cases are consistent * we get more consistent case-spellings, as it *matters* (the third reason is to be able to have more possible 'names') I'd still maintain indentation and case-spelling have very many parallels. If you indeed think that Python would've been just as nice with block tokens, go ahead and argue for case insensitivity (or whatever you like). If you however think the indentation rules *add* to Python's readability/consistency, then most arguments for case insensitivity seem to fall apart. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jraddockNOjrSPAM at hotmail.com.invalid Wed May 17 13:02:56 2000 From: jraddockNOjrSPAM at hotmail.com.invalid (JRHoldem) Date: Wed, 17 May 2000 10:02:56 -0700 Subject: Java vs Python References: <KzLT4.3373$Kc3.20912@news-server.bigpond.net.au> <jazoprog8c.fsf@helix.twistedmatrix.com> Message-ID: <000e0a4e.9a742029@usw-ex0101-008.remarq.com> As usual, my good friend, you are quite right in most aspects of your argument. *However* you've got to stop your bias from taking hold when making a point (only pure objectivity produces results that anyone else cares about): Glyph: "How seriously X is taken" does not necessarily relate to how good X is. Just like Windows NT is "taken more seriously" by many, but UNIX is better, Java is taken more seriously, but python is better. (I refuse to qualify that statement: see below.) **** Unix is better....hogwash. For some of the exact reasons that you claim Python is better than Java, NT is better than UNIX. My rollout speed for any web app is much faster *and it's not because of the i-use-what-i-know syndrome*. NTM the nice pretty GUI (yea, yea, whatever....don't even go there, I crashed your linux toolbar last week.....), and 2000 takes it to a new level. What's my point? Better is a relative term. Whenever anyone asks a question which involves comparison, you must define what you mean by (your superlative here). UNIX and NT are different, let's do apples to apples. UNIX can handle more responses and using certain software can do a decent job of web apps. HOWEVER NT is *better* because more people know it and are used to it. That is still a qualifier for the general term better. For more information look up dicto simpliciter in a philosophy book! Peace, The-mad-evil-I-want-an-eggo-waffle-eats-lunch-at-11:40everyday- poker-playing-computer-programming-bad-bad-man - JR * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From emile at fenx.com Mon May 22 22:10:23 2000 From: emile at fenx.com (Emile van Sebille) Date: Mon, 22 May 2000 19:10:23 -0700 Subject: (no subject) References: <509FE401C620D311A3890001FA68BA95017671A7@ACNSYDMSX10.acnielsen.com.au> Message-ID: <025b01bfc45c$14aa3e80$1906a8c0@fc.fenx.com> You're probably using a name that wasn't previously a file in that directory, so the file is created, and therefore empty when you read it. Try putting a text file there, then reading it. Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Phoon, David <DPhoon at acnielsen.com.au> To: <python-list at cwi.nl> Sent: Monday, May 22, 2000 6:35 PM Subject: (no subject) > hi > > > I am trying out the tutorial to file reading and writing and when I run > python in nt > eg >>> f=open('c:\temp\myfile.txt','r') > >>> f.read() > yields a blank string..."" > > how do i parse the arguments in open?? > > > thanks > ###################################################################### > CAUTION: This Message may contain confidential information intended > only for the use of the addressee named above. If you are not the > intended recipient of this message you are hereby notified that any > use, dissemination, distribution or reproduction of this message is > prohibited. If you received this message in error please notify your > Mail Administrators immediately. Any views expressed in this > message are those of the individual sender and may not necessarily > reflect the views of ACNielsen. > ###################################################################### > > -- > http://www.python.org/mailman/listinfo/python-list > From ben at co.and.co Tue May 16 06:00:51 2000 From: ben at co.and.co (ben at co.and.co) Date: Tue, 16 May 2000 10:00:51 GMT Subject: Python / CGI / E-mail problem References: <3920E594.F3F2E4CD@uklinux.net> Message-ID: <n%8U4.42779$z%.42618@afrodite.telenet-ops.be> Sreekant Kodela <sreekant at uklinux.net> wrote: > Hi there > > I am trying to send automated emails to the people who joined the > mailing list. I am using the smtplib and sending the mail but my users > came back to me that they can see the code. I tried to mail it to my > self and hotmail was ok but pop/kmail was showing the code. I am using > the following method. Is there anything stupid I'm doing!! > > hdr='From: xxxxx'+smtplib.CRLF+'SUBJECT: xxxxxx'+smtplib.CRLF > hdr2='<html><head><title>StokZilla Message-ID: <8fhc14$b5f$1@agate.berkeley.edu> And Peter Schneider-Kamp writes: - - What is the Right Way(TM) to do it? Almost a religious question. The IEEE Right Way depends on the hardware's rounding mode. In round-to-+inf, it should act like ceil. Round-to--inf gives floor. Round-to-zero will be like the r_int in f2c's sources [(x>0)? floor(x) : -floor(-x)]. In between... - IEEE standard seems to be rounding towards the next - even integer in .5-cases. How do I do that? Only in round-to-nearest mode. What's wrong with straight-forward way? Given MAX_POS_INT and MAX_NEG_INT bounds for the integers... def rint_to_nearest(x): "rint for round-to-nearest mode" if not x == x: return x # x is a NaN, return it # now deal with +/- Inf, and corner cases that could wrap if x > MAX_POS_INT: return MAX_POS_INT if x < MAX_NEG_INT: return MAX_NEG_INT if x < 0: s = -1 # save sign else: s = 1 x = abs(x) rounding_diff = x - floor(x) ix = int(x) if rounding_diff < 0.5: return s*ix elif rounding_diff > 0.5: return s*(ix+1) else: return s*(ix + ix%2) That should work on any modern machine, I think, but I haven't run it. Well, ok, signalling NaNs will do strange things, but they always do strange things. There may be some ancient machines that are buggy in neat ways and kill it, but I'm not an expert on those. Don't try to push performance in this. If performance is necessary for a given platform, the platform will probably provide primitives you can use to make this faster, or you can use binary ops rather than floating- point ones for that platform's fp layout. Push correctness and robustness first. Jason From debl.nospammm at world.std.com Wed May 17 21:17:55 2000 From: debl.nospammm at world.std.com (David Lees) Date: Thu, 18 May 2000 01:17:55 GMT Subject: Image Display Examples? Message-ID: <392344B3.AA779519@world.std.com> I am a newbie and I am still trying to view images processed from PIL. Can someone give me an example or point me to documentation for an example that will let me display images from Python. I gather that using Tkinter is one way to do this, but all I have is the "button" example from Learning Python. Thanks in advance. David Lees From scarblac-spamtrap at pino.selwerd.nl Wed May 17 10:28:34 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 17 May 2000 14:28:34 GMT Subject: Forcing type conversion References: <8fu9m9$2ab$1@supernews.com> Message-ID: Dale Strickland-Clark wrote in comp.lang.python: > How do I get Python to force 'a' and 'b' into strings so that the following > concatenates instead of trying to add. > > a = 1 > b = 2 > a + ":" + b The str() function. a = 1 b = 2 str(a) + ":" + str(b) Or use the % operator, of course. -- Remco Gerlich, scarblac at pino.selwerd.nl This is no way to be Man ought to be free -- Ted Bundy That man should be me From olipt at mayo.edu Wed May 24 10:10:31 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Wed, 24 May 2000 09:10:31 -0500 Subject: Creating binary files In-Reply-To: References: Message-ID: > Hello! > > I'm feeling more than a bit stupid for asking this but I'm stumped. > > How do I create a binary file and write to it? > > I need to create an binary file to store a large number of integers in > The file HAS to be binary since it's going to be read by an another > program which isn't in Python. > > I know how to open a binary file > > bfile = open("bfile","wb") > > but how do I write an integer into the file? > > n = 1066 > b.write(n) # this will not work! > b.write(repr(n)) # will not write binary > > > // Anders > The idea is to write a string to the file where the string is just a collection of bytes representing the data. There are lot's of ways to proceed here. (1) Use the struct module to create a string with the machine representation of the integer in question and write that out: import struct n = 1066 bfile.write(struct.pack('i',n)) (2) Use the *default* array module to store the numbers and then use it's tofile() method or its tostring() method import array numbers = array.array('i',[1066,1035,1032,1023]) bfile.write(numbers.tostring()) ## OR numbers.tofile(bfile) (3) Use Numerical Python's array module to store the numbers and then use the tostring() method of the NumPy array. import Numeric numbers = Numeric.array([1,2,3,4,5,6],'i') bfile.write(numbers.tostring()) (4) Use Numerical Python and mIO.py which is part of signaltools (http://oliphant.netpedia.net). This will let you write a binary file directly from a NumPy array (without the intervening copy-to-string which can save a lot of memory if you have *a lot* of numbers). import mIO, Numeric bfile = mIO.fopen('somefile','w') numbers = Numeric.array([1,2,3,4,5,6],'i') bfile.fwrite(numbers) bfile.close() # You could also say for example # bfile.fwrite(numbers,'float') to write them as floats From gawron at obop.com.pl Mon May 29 07:51:40 2000 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Mon, 29 May 2000 13:51:40 +0200 Subject: Bytecode Message-ID: <393259CC.EFA3DD1E@obop.com.pl> How portable is the bytecode ? Can I take pyc file to different computer and will it run ? (ofcource having all the needed libs and moduls there) Thanks Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From claird at NeoSoft.com Tue May 16 00:40:10 2000 From: claird at NeoSoft.com (Cameron Laird) Date: 15 May 2000 23:40:10 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (May 15) Message-ID: <3C1077AC64755A57.0FB8B24AA3155646.CE4465C98A055096@lp.airnews.net> The effbot automates answers to the most common introspective questions: What are my {functions,methods,classes}? http://www.deja.com/=dnc/getdoc.xp?AN=552444703 imports modules synthesized as strings http://www.deja.com/=dnc/getdoc.xp?AN=621152936 and converts Latin-1 to UTF-8 http://www.deja.com/=dnc/getdoc.xp?AN=622559726 Measurement is a good thing. Measurement of Zope performance might even be an important thing http://www.zope.org/Members/BwanaZulia/zope_benchmarks/benchmarks.html Warren Postma creates lightweight database objects http://www.deja.com/=dnc/getdoc.xp?AN=623717108 Randall Hopper says a Python wrapper for "an industrial-strength scientific/data visualization package, now open-source" is in the works http://www.deja.com/=dnc/getdoc.xp?AN=623648095 Michael Hudson and Nick Mathewson reveal intimate details of their currying lives http://x27.deja.com/viewthread.xp?AN=623342690 The Python FAQTS is turning into quite a high-quality resource http://www.faqts.com/knowledge-base/index.phtml/fid/199/ ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org eff-bot's complements this digest with his daily python url http://hem.passagen.se/eff/url.htm Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Python FAQTS http://www.faqts.com/knowledge-base/index.phtml/fid/199/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py 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 Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. http://www.egroups.com/list/python-url-leads/ 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 rpalmer at connect.com.au Tue May 2 00:32:31 2000 From: rpalmer at connect.com.au (Rod.) Date: Tue, 02 May 2000 14:32:31 +1000 Subject: plain text python source -> HTML syntax highlighted source In-Reply-To: Your message of "Tue, 02 May 2000 04:19:22 GMT." Message-ID: <20000502043232.F187E41816@koro.off.connect.com.au> : >Hmm, maybe in an older version. The script (syntax/2html.vim) that comes : >with Vim 5.6 converts tabs to spaces according to your current 'tabstop' : >setting. : > : : Just when I think Vim has no more surprises for me:) : : (Jim, who just wishes Vim used python as a macro language.) you can embed python in vim (its an option when building 5.6), and then manipulate your current edit buffer and the 'ed' comands from python scripts from within vim. Ive used it a bit, and its cool... just a little slow, so you end up doing things in vi mostly anyway :/ rod. : : -- : Jim Richardson : Anarchist, pagan and proud of it : WWW.eskimo.com/~warlock : Linux, because life's too short for a buggy OS. : : -- : http://www.python.org/mailman/listinfo/python-list : -------- Rod Palmer - Development Engineer Phone - +61 3 9251 3685 Email - bwarff at connect.com.au From thiele at muc.das-werk.de Tue May 23 08:48:05 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 23 May 2000 14:48:05 +0200 Subject: case-sensitivity compromise proposal References: <4.3.1.2.20000523075551.014d9e70@phear.dementian.com> Message-ID: <392A7E04.2745249A@muc.das-werk.de> Why CasE-INseNsitiVitY ? Is the caps look - key on their keyboard defect? From spamfranke at bigfoot.de Wed May 10 07:21:26 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 10 May 2000 11:21:26 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> <3917f55c.842808@news.btx.dtag.de> <3917f685.115228@news.btx.dtag.de> Message-ID: <391945e1.640421@news.btx.dtag.de> On Wed, 10 May 2000 02:35:06 GMT, "Mark Hammond" wrote: >Neil, Stefan and I have been going over this in private email, and it >turns out to be a bug in Pythonwin that will be fixed in builds 133 and >later... As long as you don't say build 133 *or* later.. . Thanks, Stefan From g2 at seebelow.org Tue May 23 17:28:33 2000 From: g2 at seebelow.org (Grant Griffin) Date: Tue, 23 May 2000 22:28:33 +0100 Subject: why tar is strange References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <20000518145435.C13281@xs4all.nl> <39264186.119D@seebelow.org> <8g3o85$esa$1@news.hants.gov.uk> <392706CC.6DEE@seebelow.org> <8gau6q$bhu$1@newshost.accu.uu.nl> Message-ID: <392AF801.44C@seebelow.org> Martijn Faassen wrote: > > Grant Griffin wrote: > [snip] > > *Having recently learned Python's syntax, I have now graduated to the > > more challenging stage of my Python journey, the > > learning-how-to-string-the-gadgets-together-effectively part. If my > > experience with other programming languages holds true, this will take > > maybe a year. > > A *year*? And you have experience with other programming languages? If > you have OO experience, learning Python shouldn't take more than a > month, and that's long. That's not to say you know _all_ the nice > idioms that Python has by then, and that's not to say someone with a > year of Python experience won't be likely to be better, but you'll > be pretty darn effective after a month, I'd say. > > This-is-NOT-C++-ly yours, > > Martijn Well, lemme give you an example. I figured out the other day that the way to do sscanf was: map(float, string.split(s)) # (IIRC) Well, obviously! Besides map, Python has lots of built-in functions emboding concepts which aren't familiar to me as an experienced C/C++ programmer, for example: map, reduce, lambda, filter, etc. Sure, one can RTFM about these. But learning the "what" is just the beginning: learning the "why" and the "when" is what takes a lot of practice. (Anytime someone says "the Pythonic way to do that would be...", they're talking about what I'll be learning over about the next year or so.) Oh, and did I mention the libraries? More study and practice is required here. Whatever their intrinsic merits, Python's libraries are at least significantly different from the libraries of other languages (which are likewise different from each other.) the-simplest-systems-are-the-hardest-to-master-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From tismer at tismer.com Sun May 14 09:18:24 2000 From: tismer at tismer.com (Christian Tismer) Date: Sun, 14 May 2000 15:18:24 +0200 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> Message-ID: <391EA7A0.94DED550@tismer.com> Fran?ois Pinard wrote: ... > P.S. - Does someone knows if Guido read this group? If not, I would send > a copy of this letter directly to him. I think he is not. Therefore I cc'ed my last post to python-dev. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From cut_me_out at hotmail.com Tue May 9 14:43:47 2000 From: cut_me_out at hotmail.com (Alex) Date: 09 May 2000 14:43:47 -0400 Subject: Future of the Python Linux Distribution References: <3916F04F.7647B829@zipzap.ch> <391790A2.26CB9618@home.com> <391812BF.4C226C55@home.com> Message-ID: > This-is-amusing'ly yrs Alex. Blargh, I mean it's amusing to fool around with this code, not that it's amusing that it won't run. Hope I didn't offend. Wish-I-could-take-my-stupid-comment-about-postscript-back'ly yrs Alex. From rwallace at esatclear.ie Sat May 27 23:13:00 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Sun, 28 May 2000 04:13:00 +0100 Subject: Scoping: Is Python and does it matter? References: <392C3782.3675@europa.com> <392d1d14$0$23937@wodc7nh0.news.uu.net> <39306b73$1_1@news.nwlink.com> Message-ID: <39308EBC.7BE0@esatclear.ie> noone wrote: > Python 1.5.1 (#37, Apr 27 1998, 13:36:17) [CW CFM68K w/GUSI w/MSL] > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> x=1 > >>> def print_X(): > ... print x > ... > >>> print_X() > 1 > >>> def print_X(): > ... print x > ... x=2 > ... > >>> print_X() > Traceback (innermost last): > File "", line 1, in ? > File "", line 2, in print_X > NameError: x > >>> > > In Perl, the second 'print_X' would succeed because 'x' would be found in > the outer scope. Python scopes the var to the function due to the > assignment (it seems). One could use 'global', but then the assignment > would affect the module var (where in Perl, the assignment might be > my($x)=2, in which case the "global" x would not be modified). > > Again, I am looking for Python's philosophy (reasoning, excuses, > whatever! :) so that my coworkers will switch and I will not have to look > and ugly/bad code because it was fast hacked! Well, I'm a Python newbie and no expert on the philosophy, but this one strikes me as very straightforward. Here's what I'd say: """ Is x a local variable or a global? If it's global, you've got to declare it as one. Yeah that's a nuisance, but it's not too big a one to live with; you don't have to declare locals, and they're more common than globals. If it's a local, then you've got to assign it before you use it. What's problematic about that? If you don't want to assign it a meaningful value, just stick x = 0 at the top of the function. """ -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From sabren at manifestation.com Sun May 28 16:08:44 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Sun, 28 May 2000 16:08:44 -0400 (EDT) Subject: cgi odbc sql delete ? In-Reply-To: Message-ID: On Sun, 28 May 2000, Rob Elder wrote: > It probably is a format problem (???) but I don't know what it is. If the > problem is not obvious, please give me some ideas on how to debug this. I > have totally run out of ideas. TIA. Well, I have no idea what the problem is here. It sure looks right. I suspect sysID is getting assigned to something unexpected. But, if you're looking for debugging strategies: Whenever I'm debuggint SQL, the first thing I do is use a temporary variable so I can see exactly what query/statement I just generated: ... sql = "DELETE FROM userTable WHERE userID = %s" % sysID print sql dbcursor.execute(sql) ... Or comment out the execute line, and check the data to make sure it's there. If it STILL looks right, try pasting this into an Access query window (the SQL view, of course) and see what happens. The other thing is to double check that the insert is working the way you want. Eg, is userID what you think it is? If that field is an autonumber, it may not be. Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From da57thJones at worldnet.att.net Sat May 13 22:42:39 2000 From: da57thJones at worldnet.att.net (Cynthia Webber) Date: Sun, 14 May 2000 02:42:39 GMT Subject: Simple questions re name spaces References: <391CA58A.F0DE3333@fenx.com> Message-ID: Regarding 2 My mistake. It does indeed work fine. The problem was that I was using a module named "test.py". Another module by the same name was already in the Python path. Thanks for the advise >> 2> >> I have tried to dynamically create variables with code such as >> >> >>> a = "b = 'dog'" >> >>> exec a >> >>> print b >> 'dog' >> >> This works from the command line but when I included it in a module it >> fails. > >Could you post a pared down example. When I try it here in a module, >it works fine. From alwagner at tcac.net Tue May 2 23:24:33 2000 From: alwagner at tcac.net (Albert Wagner) Date: Tue, 02 May 2000 22:24:33 -0500 Subject: Isn't None supposed to be false? Message-ID: <390F9BF1.4E39474E@tcac.net> >>> x = None >>> if x: ... print 'false' ... else: ... print 'true' ... true >>> if x == None: ... print 'false' ... else: ... print 'true' ... false -- Small is Beautiful From jkraska1 at san.rr.com Sun May 7 15:13:43 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 07 May 2000 19:13:43 GMT Subject: Static vars in Python? References: Message-ID: <3915C12D.1F0D94BF@san.rr.com> Juanjo ?lvarez wrote: > > Hi all! > > It's posible to have in Python static vars (that is, vars in a function > that retain his value over calls to the same function)? In a way, all Class assigned variables start out this way, but of course once they're assigned in a method on an instance, the variables become bound to an instance. While I am new at this, I believe that the way people achieve this is by overriding the __getattr__ and __setattr__ methods. Note that if you don't want to do this, you can put variables in your module header as globals. While globals are "bad" in other programming languages, they are okay in python, because every global is really confined to a module. This is sort of like file-static variables in C, only a bit better. In this way, you probably won't miss static class vars very much. C/ From MSteed at altiris.com Mon May 1 12:34:11 2000 From: MSteed at altiris.com (Mike Steed) Date: Mon, 1 May 2000 10:34:11 -0600 Subject: plain text python source -> HTML syntax highlighted source Message-ID: <65118AEEFF5AD3118E8300508B1248774CB2C0@ALTNET> > From: Ivan Van Laningham [mailto:ivanlan at callware.com] > Sent: Monday, May 01, 2000 9:38 AM > To: Python Mailing List > Subject: Re: plain text python source -> HTML syntax > highlighted source > > > Hi All-- > > Mike Steed wrote: > > > [snip] > > This is probably not what you were thinking of, but Vim can > > do this. Open your file and choose Syntax->Convert to HTML. > > The output is an HTML-ized version of your file with whatever > > syntax highlighting you have defined. > > I didn't know you could do this. This is really cool, but be warned > that it does not expand tabs into spaces, so the html version may > *still* not look exactly like you want. ... Hmm, maybe in an older version. The script (syntax/2html.vim) that comes with Vim 5.6 converts tabs to spaces according to your current 'tabstop' setting. > -ly y'rs, > Ivan Happy Vimming, Mike. From shapr at uab.edu Thu May 25 06:33:19 2000 From: shapr at uab.edu (Shae Erisson) Date: Thu, 25 May 2000 10:33:19 GMT Subject: was: What's in a name?, now: caseless: Try it, you might like it. References: Message-ID: <392D06E1.415DFEF1@uab.edu> "Edward S. Vinyard" wrote: > My intent was to stimulate discussion along these lines, rather than > rehash the case sensitivity vs. case insensitivity arguments that have > been presented in other threads on this newsgroup. I apologize if this > was not clear from my original messages. Personally, I'd like to see IDLE handling the case issue just like the VB IDE does, that way newbies wouldn't be confused (I hope), and I could still be happily case senisitive (except my .sig). On the other hand, Guido wrote Python, and it's wonderful. Why be afraid of change? All of the changes that have been made to Python so far were improvements. The case-sensitive issue just might be the same as the whitespace issue. Python's unconvential approach works quite well for me in whitespace, I'm willing to give another unconvential approach a chance at least. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j From noone at do.not.use Tue May 23 13:06:09 2000 From: noone at do.not.use (Russell Turpin) Date: Tue, 23 May 2000 12:06:09 -0500 Subject: Modulus (was: The REALLY bad thing about Python lists) References: <000501bfbee7$62318ac0$a2a0143f@tim> <392A4299.762F@esatclear.ie> <392A8035.5C2A2BAA@home.com> Message-ID: <392ABA81.A7CF3733@do.not.use> Russell Wallace wrote: > Under what circumstances would you want to use % on > negative numbers? I'm not sure that I will ever want to use * on any number over 10E20, but on general principle, I think arithmetic operators should be defined on the entire range of represented numbers for which the operator makes mathematical sense. Russell From gmunsey at adobe.com Thu May 18 09:34:56 2000 From: gmunsey at adobe.com (Grant Munsey) Date: Thu, 18 May 2000 06:34:56 -0700 Subject: Using Python on Win2000Server under IIS5 question Message-ID: I have gotten to the point that I can fire off a python script under IIS5 on win2k server but after the script completes the Python (1.5.2) interpreter abends with an illegal memory reference. Python code seems to run fine ... just when the engine exits. I tried ending the script with sys.exit(0) but no luck. Anyone else had this happen ... suggestions on how to move forward? I fire off the python interpreter with \python.exe -u %s %s and this is hooked to the .cgi extension in the scripts directory of the IIS installation. From jwbnews at scandaroon.com Sun May 21 15:28:02 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 21 May 2000 12:28:02 -0700 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> Message-ID: In article , Guido van Rossum wrote: Thoughts. 1. Various people want to write things like s = S() By habit, I never do that. This is probably because of the several years I spent writing in Pascal and Pascal-derived languages (including NCRL [pronounced "swill" for reasons this thread doesn't have room for] which may have been case sensitive). Having said that, I sympathize with the people who do use that style. 2. Pascal...I did use tools to fix the case of what I wrote. But I usually just wrote it the way I wanted it. I never acted as if _ were optional. I had more problems with the 8-character name significance in the implementations I used. 3. Braces...Roy Katz left out the C style I prefer: int func( ) { } (I want to scan down from the start of the thing and find the next thing, not the end of this thing.) 4. Off topic. Integer division. Perhaps my time spent writing Forth code is what makes me very comfortable with 1/2 == 0 5. URLs...the domain part is case-insensitive by design. This *probably* results from the domain name system having been developed while we were still in the transition from upper-case-only machines to 2 case machines. It's very hard to express www.python.org using a KSR-33 Teletype. The path name part is either case sensitive, or not--depending on the OS at the server end. One insensitive example is Personal Web Sharing on the Mac. If it weren't for the fact that I keep the server turned off 99.9% of the time, you could reach my exciting home page on one of my Macs using any of http://coyote.scandaroon.com http://coyote.scandaroon.com/index.html http://coyote.scandaroon.com/INDEX.HTML (any other case variation you wish to try) The actual file is named index.html Despite the above, one is well advised to treat URLs as case sensitive beyond the domain part. [What is the situation beyond the path part...I don't write them, I click on them.] 6. HTML If W3C have their way (doubtful, given past behaviour of Microsoft and Netscape), HTML tags will become case sensitive and will be lower case. 7. Randy Pausch via Guido (ie, I haven't read the original). My guess--purely a guess--is that if Python 1.6 as it now does things had been used, the number 1 problem would have been that 1.0 / 10 is not 0.1, displacing case sensitivity and 1/2 == 0 downwards to numbers 2 and 3. (Actually, it might have made 1/2 == 0 less of a problem, since the students would likely already have thought about the floating point issue.) 8. Francois: "Why Scheme adopted case insensitivity is a mystery to me." My guess is, as with domain names, timing, and the difficulty of writing lower case on KSR-33 Teletypes and upper-case-only glass teletypes. LISP was originally simple: upper case only thanks to the IBM-026 card punches available at MIT. [Thanks to the overnight turnaround and the early interpreter's habit of returning nothing at all useful if faced with a shortage of )s, one could easily detect the LISP users: they tended to walk around with cards full of )))))))... in their shirt pockets, to be slapped onto the end of submitted card decks: one at least got something back if there were too many )s.] 9. I haven't used IDLE...does it assume X in the Unix world? If so, I will continue not having used IDLE at work...remote X over 56K frame is not something I want to investigate. Therefore I won't have the help with casing that is being suggested for IDLE. [Of course, Python 3000 is in the future, and my work situation might change before then.] --John (who got a lot of cards punched without waiting by using the one-hole-at-a-time IBM-010 punch which for some reason wasn't very popular) -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From jkraska1 at san.rr.com Sun May 21 00:39:35 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 21 May 2000 04:39:35 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <39276946.90FE82A2@san.rr.com> Mike Fletcher wrote: > > Personally, I have been bit by case problems probably five or six times (in > five years or so). That said, I find working with case insensitive > languages difficult to the point where I will not use them. The truth of the matter is that, irrespective of whether or not a language is case sensitive or not, using inconsistent case for the same thing is an extraordinarily bad idea, and would be extremely poor engineering practice. There are very few times where as a lead I exercise authority over influence, but I have to admit that I simply wouldn't allow programmers on my team (and probably not on our staff, sirrah) to use inconsistent case for something. So I guess it's not so much that case matters to the compiler, but rather that the case matters to PEOPLE. I guess we can all threaten to rebel, hack into Guido's personal computer, and replace all his own personal python code with randomized capitalization of everything.... *MUHAHAHAAHAHAHAHAHA* :)- C/ From thomas at xs4all.net Sat May 20 11:11:22 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 20 May 2000 17:11:22 +0200 Subject: Dictionaries and Threads In-Reply-To: <3926A8EF.C3C1914B@jslove.net>; from jsliv@jslove.net on Sat, May 20, 2000 at 11:02:07AM -0400 References: <3926A8EF.C3C1914B@jslove.net> Message-ID: <20000520171122.M13281@xs4all.nl> On Sat, May 20, 2000 at 11:02:07AM -0400, Jay Love wrote: > Are dictionary lookups threadsafe? > ie, can I lookup and retrieve an item in a dictionary while another > thread is adding an item? Python takes great care to make sure all builtin operations are threadsafe, and tries to make it as easy as possible to make your own extensions threadsafe. As long as you write Python, you're very threadsafe, because only one thread can execute Python code. If you start writing extentions, in C, or embedding Python in a multi-threaded program, things get a little more complicated, though, and you'll have to pay attention to where you allow multiple (Python) threads to execute. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From guido at python.org Fri May 19 22:53:49 2000 From: guido at python.org (Guido van Rossum) Date: Sat, 20 May 2000 02:53:49 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> Message-ID: Fran?ois Pinard writes: > Roy Katz writes: > > > 1. Python 3000 may be case-insensitive. > > Horror, hell, and damnation! April 1st should be far behind us by now! > > I would hate[1] writing with inconsistent casing, with nothing on my side > to help me writing consistently. I much prefer what Python is, today, on > that regard. So, how do I register my vote? Where do I leave my tears? :-) Python is not a democracy. Voting doesn't help. Crying may... :-) > Besides, is there any real need behind case-insensitiveness? Or is it > just another step forward (backward? :-) on that road that would drive us > towards a click-on-the-pink-button-and-hear-the-soft-sound version of Python? This is all taken way out of proportion. I promise that Python 3000 won't suddenly be introduced without further discussion. Every issue will discussed here and elsewhere and we'll explain why we want to change the design. We'll also explain what we're going to do for compatibility. In the mean time, we're too busy with Python 1.6 to be able to answer each question about Py3k. Once 1.6 is released I promise to create a FAQ about Py3k. Some quick answers: for case insensitivity, we'll have tools that enforce consistent casing (and maybe the case insensitivity will be in the tools alone). -- --Guido van Rossum (home page: http://www.python.org/~guido/) From vicl at my-deja.com Thu May 25 11:05:58 2000 From: vicl at my-deja.com (vicl at my-deja.com) Date: Thu, 25 May 2000 15:05:58 GMT Subject: Web server Path Question Message-ID: <8gjfg8$bcu$1@nnrp1.deja.com> How do I specify the path of the file to write in a Python script running on a web server. Say the script is running in /usr/local/apache/cgi-bin (with alias /cgi-bin) and wants to write a file to /usr/local/apache/htdocs (with alias /) how do i specify the path in the script? thanks a lot Sent via Deja.com http://www.deja.com/ Before you buy. From jcm at bigskytel.com Sun May 14 22:48:54 2000 From: jcm at bigskytel.com (David Porter) Date: Sun, 14 May 2000 20:48:54 -0600 Subject: learning In-Reply-To: <391effd1.9894246@news.callnetuk.com>; from pitts@callnetuk.com on Sun, May 14, 2000 at 07:34:43PM +0000 References: <391effd1.9894246@news.callnetuk.com> Message-ID: <20000514204854.A8348@bigskytel.com> * Andy : > Does anyone know any good site for learning python. This is the first > programming language I have tried to learn after someone recommended > it as a good first language and I need a site that'll be able to teach > a complete newbie. http://www.python.org/doc/Intros.html Scroll down to the header: "Introductions to Python programming for non-programmers". david. From embed at geocities.com Tue May 9 12:31:48 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 9 May 2000 12:31:48 -0400 Subject: Converting a Binary References: <8f98bk$a6c28@esiami.tsai.es> Message-ID: def binstr(n): if n <= 1: return str(n) else: return binstr(n/2)+str(n&1) # test x = binstr(42) y = string.atoi(x,2) print x print y From faatdilac at my-deja.com Sat May 27 11:45:03 2000 From: faatdilac at my-deja.com (faatdilac at my-deja.com) Date: Sat, 27 May 2000 15:45:03 GMT Subject: Java vs Python References: Message-ID: <8goqht$439$1@nnrp1.deja.com> In article , Moshe Zadka wrote: > On Thu, 25 May 2000 faatdilac at my-deja.com wrote: > > > Oh yeah, and which language do you think the trio Larry, John and Guido > > use to develop Perl, Tcl and Python. > > BTW, Matz also uses C to develop Ruby. > > > > Amateur does not know to appreciate the very tool that creates the > > universe of programming languages, it's C. > > The only reason those people used C was that "it was there, and it was > portable". This made for a very wise decision socially (which is part of > the reason Python/Perl/Tcl are popular), but C was certainly not the > optimal language for that. Consider, for example, that a Java programmer > does not have to learn Java/Python API -- she merely writes Java classes, > and JPython can use those. Consider that the real pain with writing > extensions for all three is to manage memory, something that would be > spared if Scheme/Lisp/Java were selected as an implementation platform. > > C is a good language for what it does, but claiming that the fact Python > is written in C makes C "holier" is not very accurate. Not to mention that > this would suggest that JPython proves that Java is the perfect platform. > > -- > Moshe Zadka > http://www.oreilly.com/news/prescod_0300.html > http://www.linux.org.il -- we put the penguin in .com > > It's a thankless & shameless attitude to say that C is not generally useful while C has been feeding generations of software professionals. The name Dennis M. Ritchie shines as long as Perl, Tcl/Tk, Python exist. Show me a commercially successful language compiler developed in any of the scripting languages. Show me an OS developed in any of the scripting languages. The software world would be much poorer without C. faatdilac Sent via Deja.com http://www.deja.com/ Before you buy. From gansevle at cs.utwente.nl Thu May 18 07:02:38 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Thu, 18 May 2000 11:02:38 GMT Subject: Q? Calling nearest inherited method References: <392295a8.3800058174@news.u-psud.fr> <3923112C.4758A8C0@python.org> <3923af51.3872163586@news.u-psud.fr> Message-ID: <8g0ik7$o1l$1@nnrp1.deja.com> In article <3923af51.3872163586 at news.u-psud.fr>, pointal at lure.u-psud.fr wrote: > On Wed, 17 May 2000 18:37:00 GMT, Guido van Rossum > wrote: > > >: There's a better way. (I believe Jeremy Hylton first suggested this; he saw > >: it as an idiom in another language:) > >: > >: class C(B): > >: super_doit = B.doit > >: def doit(self, arg): > >: self.super_doit(arg) > >: > >: This avoids the need to explicitly pass self. > > Not sure its really better... > 1) The lowest problem: you have to define it for each function in each > class in the hierarchy to have a clean model. > 2) The biggest problem, it can go into infinite recursion... > > Here is an example of the biggest problem: > > >>> class A : > ... def dothis(self) : > ... print "In A.dothis." > ... > >>> class B(A) : > ... super_dothis = A.dothis > ... > >>> class C(B) : > ... super_dothis = B.dothis > ... def dothis(self) : > ... print "In C.dothis." > ... self.super_dothis() > ... > >>> c=C() > >>> c.dothis() > In C.dothis. > In A.dothis. > > [Until here, its well. Now, introduce a new D subclass, and as we have > done for B, implement the super_dothis...] > > >>> class D(C) : > ... super_dothis = C.dothis > ... def hello(self) : > ... self.dothis() > ... > >>> d=D() > >>> d.hello() > In C.dothis. > In C.dothis. > In C.dothis. > In C.dothis. > In C.dothis. > In C.dothis. > In C.dothis. > ... > [here hitting ctrl-C] > > So I will still with the .(self...) usage which > works. An intermediate approach could be: def super(self): return self.__class__.__bases__[0] class D(C): def hello(self): super(self).dothis(self) > > Thanks. > > A+ > > Laurent. > > --- > Laurent POINTAL - CNRS/LURE - Service Informatique Experiences > Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 > email : pointal at lure.u-psud.fr ou lpointal at planete.net > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From morse at harborcom.net Thu May 11 12:57:28 2000 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 11 May 2000 16:57:28 GMT Subject: Help getting ISP to install Python Message-ID: <391ae57e.166588371@news.oh.verio.com> Hi, I've asked my ISP to support Python, but it looks like they will need a hand, at least a pointer in the right direction. Are there any restricted environments for Python to allow this ISP to safely install it for CGI usage? I know their server runs on NT. Any suggestions on helping them to decide what to install and how to make it secure from their perspective? Here's the email from tech-support: We have the standard installation of Activestate Perl (www.activestate.com) on all servers. I am not sure about installing Python as no clients have requested this yet - I would need to request Administrator to follow up but since we have'nt tested it before this will likely take time assuming Administrator ok's it. I couldn't tell you what ActiveState Perl is (yet), but apparently it must provide the safeguards to let them run CGI perl scripts on NT. Thanks, Kevin From spamfranke at bigfoot.de Tue May 9 07:45:16 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 09 May 2000 11:45:16 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> <3917f55c.842808@news.btx.dtag.de> Message-ID: <3917f685.115228@news.btx.dtag.de> On Tue, 09 May 2000 00:44:38 GMT, "Neil Hodgson" wrote: > You could try a more recent beta of Scintilla from >http://www.scintilla.org/Scintilla.DLL > which is put in the Python16\Pythonwin directory. Save the older >Scintilla.DLL first as this may be worse. I tried the new DLL (the download name seems to be http://www.scintilla.org/Scintilla.dll ) with the same result. May I send you a Dr. Watson report to neilh at scintilla.org ? On Mon, 08 May 2000 17:54:49 GMT, hwkMueller at t-online.de (HWMueller) wrote: >Yes, for the backslash, a small file and W2000/W98 > >--HW Huh? Backslashes (\) are fine for me. The problem occurs with non-spacing accents only ( ? ` and ^ ; hopefully we see the same characters here: an up, down and circumflex accent). Stefan From jkraska1 at san.rr.com Tue May 2 22:18:26 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 03 May 2000 02:18:26 GMT Subject: Metalinguistic capability of Python? Message-ID: <390F8D16.68B959D2@san.rr.com> I'm looking to create a simulation environment (using stackless Python & continuations) that would need a pseudo simulation language to go along with it. In Lisp, I might make heavy use of macros in order to accomplish what I want. Is there any sane way to go about approaching this in Python, or is this a lost cause? (I don't believe that what I want to accomplish can be accomplished with methods or functions). C/ From amir.mistric at usa.net Tue May 23 16:11:26 2000 From: amir.mistric at usa.net (Amir Mistric) Date: Tue, 23 May 2000 16:11:26 -0400 Subject: mxODBC with DB2 on AIX Message-ID: > I have compiled and linked mxODBC and mxDateTIme packages successfully on AIX > with GCC compiler.... > The module does not core dump anymore ,however when I do my import i get this > message:(any ideas??) > > bash-2.01# python > Python 1.5.2 (#1, May 22 2000, 13:37:53) [GCC 2.95.2 19991024 (release)on > aix4 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import ODBC.DB2.mxODBC > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/site-packages/ODBC/DB2/__init__.py", line 7, > in > ? > from mxODBC import * > ImportError: initialization of module mxODBC failed > (mxODBC.InterfaceError:failed to retrieve error information (line 5830, > rc=-1)) > >>> From blues-l at cyberus.ca Fri May 5 11:04:51 2000 From: blues-l at cyberus.ca (blues-l at cyberus.ca) Date: Fri, 05 May 2000 11:04:51 -0400 Subject: Problem with "COM Browser" in PythonWin 1.5.2 References: <8eum0h$gj$1@info3.fnal.gov> Message-ID: <3912E312.4667BA3B@cyberus.ca> Not sure, but from the message it looks like you ran out of memory(??) Marc Paterno wrote: > Hello, > > When trying to use the "COM Browser" tool in PythonWin 1.5.2, > I encounter the following problem. > > I start the COM Browser from the Tools menu. If I think click > on the "Registered Categories" item in the tree display, I get > a trackback in the PythonWin interactive window. The entire > contents of the interactive window (including the version info, > printed at startup) are the following: > > ---------------------------------------------------------------------------- > ------- > PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) > >>> Traceback (innermost last): > File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line > 118, in OnTreeItemExpanding > self.AddSubList(itemHandle, self.GetSubList(item)) > File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line > 263, in GetSubList > return self.DelegateCall(item.GetSubList) > File "C:\Program Files\Python\Pythonwin\pywin\tools\hierlist.py", line > 250, in DelegateCall > return fn() > File "C:\Program Files\Python\win32com\client\combrowse.py", line 101, in > GetSubList > for catid, lcid, desc in enum: > File "C:\Program Files\Python\win32com\client\util.py", line 37, in > __getitem__ > return self.__GetIndex(index) > File "C:\Program Files\Python\win32com\client\util.py", line 53, in > __GetIndex > result = self._oleobj_.Next(1) > pywintypes.com_error: (-2147024882, 'Not enough storage is available to > complete this operation.', None, None) > win32ui: Exception in OnNotify() handler > ---------------------------------------------------------------------------- > ------- > I am using PythonWin build 128, under Windows NT 4.0, with > SP6a installed (in case that matters). > > I have been unable to find any relevant posting on the > comp.lang.python news group, or in the "bugs list" at > www.python.org. > > Can anyone enlighten me on how to fix this problem? > > thanks, > Marc From m.faassen at vet.uu.nl Sat May 13 08:31:04 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 May 2000 12:31:04 GMT Subject: python improvements (Was: Re: New Language) References: <391CE9E8.C7D9305@san.rr.com> Message-ID: <8fjhu8$l6k$4@newshost.accu.uu.nl> Courageous wrote: >> all-problems-are-ancient-as-are-all-cures-ly y'rs - tim > Okay. That's it. I *give*. Here I've been quietly thinking > nobody will notice I'm not part of the "in crowd". I admit > it. I'm a newbie. Wazzup-wit-all-dis-ell-why-shit-braddah? It's just something that Tim Peters does, and we-all-imitate-him-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rwallace at esatclear.ie Wed May 24 17:36:15 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Wed, 24 May 2000 22:36:15 +0100 Subject: The REALLY bad thing about Python lists .. References: <000201bfc52f$fec19ee0$fa2d153f@tim> Message-ID: <392C4B4F.60C4@esatclear.ie> Tim Peters wrote: > > [Tim] > > ISO/ANSI C doesn't fully define what happens when (roughly) > > integer division or % are handed negative numbers. > [Russell Wallace] > > Don't blame the C committee, blame the CPU manufacturers. C doesn't > > define the result because CPUs aren't consistent about what result they > > give. > > That's exactly what makes it critical for languages to define it: a prime > charter of most languages is to aid portability, not expose accidents of the > hardware du jour. That's one way to look at it, and for a high-level language like Python it's a reasonable one. For a systems programming language like C - whose main design criterion is that language operations should map directly to machine operations - it's another. Consider that mandating the behavior of negative number division will often mean that a simple arithmetic operation on ints will compile into a section of code with multiple branch instructions *even in the overwhelmingly most common case where negative operands will never occur*. > > (Under what circumstances would you want to use % on negative numbers? > > I can't think of any.) > > Anytime something "wraps around". Think circles, like clocks or, well, > circles . If the big hand is pointing at 10 now, where was it > pointing 45 minutes ago? At (10-45) % 60 == 25 in Python, undefined in the > current C, and the systematically unhelpful -35 in C9X. See, I'd never write the (10-45) % 60 in any language, even if the language defined the result. Why? Because even if the compiler understands it unambiguously, humans mightn't - different humans *disagree* on what the logical thing for negative integer division to return is. I'd much rather explicitly add 60 and know where I stand. In fact, if a language is going to mandate anything, my vote would be to mandate that it is an error for div or mod to have either operand negative, just as it is an error for the second operand to be zero. > saving-a-nanosecond-doesn't-help-sell-a-wrong-answer-ly y'rs - tim but-if-there's-no-consensus-on-what-the-right-answer-is-then-it-should-be-regarded-as-an-error-ly y'rs -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From gmcm at hypernet.com Wed May 10 22:03:35 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 11 May 2000 02:03:35 GMT Subject: Copyright and License References: <000601bfb983$89dbc900$592d153f@tim> <8f8vec$svl$1@newsserver.rrzn.uni-hannover.de> Message-ID: <391a14f7$0$28399@wodc7nh1.news.uu.net> Bernhard Reiter wrote: >Tim, you are correct, something in the publich domain stays in the >public domain, and you can still go on and reimplement what other >added to your software. But you have no saying over what they do >with it. At least where I come from, "free" and "control" are antithetical notions. >The GPL is among the savest Free Software licenses you can get. >It is a bit complicated, but the complexity crawles in because >copyright law is so complicated and not because the intention was >unclear. Nah. It's complicated because it's conflicted. >This sentences are flawed. If you do not use a strong Free Software >license other Companies might lock up your code and make money from >your work. Horrors! >They might even gain a monopoly and you do not have a word >to say about it. If they do that, then I guess you're not capable of producing a functional equivalent. So it's safe to say that your code is an incidental part of their product. From embed at geocities.com Tue May 16 08:56:47 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 16 May 2000 08:56:47 -0400 Subject: StringIO and Berkley DB References: <39222937.533456950@news.online.no> Message-ID: <2EbU4.20711$HG1.527833@nnrp1.uunet.ca> > My question is: Do I need to have the entire string in memory before > the StringIO-module can use it? > Does the BSDDB allow you to open a handle to the data without reading it? I was only aware of an operation to read the whole data value at once, presumably into memory. If the BSDDB allowed you to basically fseek() to the right place and told you how many bytes to read, you wouldn't need StringIO at all, but you might need to modify your bsddb wrapper. Warning: the bsddb 1.0 that ships with Python is known to be buggy. Check out Robin Dunn's BSDDB 2.0 if you haven't already. Warren From glyph at twistedmatrix.com Mon May 15 13:50:11 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 15 May 2000 12:50:11 -0500 Subject: Java vs Python References: Message-ID: I am a "java expert". I've been working with the language since its inception. It started out as a genuinely good thing: but it has fallen into complete decay. If you don't decide to go with python for this project of yours, I would highly recommend finding something other than Java for this. History is *already* littered with the corpses of projects which thought that Java would solve their problems. (Corel Office for Java, Marimba, hundreds of unreleased, unpublicized projects...) I am a "python newbie". I have been working with python for 3-6 months (I don't remember exactly how long). Even in this short time, I have come to love python, not because it's the end-all be-all of programming languages, but because it actually picks some things that it wants to be good at, and does those things very well. The language's strengths are well-matched to the interpreter's, and the environment is overall a positive experience. Not only that, I look around every day and see successful projects, both open (Zope) and closed (UltraSeek) that are using python with success. Java attempts to be everything to everyone, and, as such things are fated, becomes nothing to anyone. Java CLAIMS to do everything well, but actually does everything so poorly that Sun has to promise that it will be "better in the next release", and they've been doing this for long enough that it amazes me that people believe them anymore. "Huy Do" writes: > Hi, > > I would just like to know how serious python is taken in the IT > industry and how it compares to something like Java. "How seriously X is taken" does not necessarily relate to how good X is. Just like Windows NT is "taken more seriously" by many, but UNIX is better, Java is taken more seriously, but python is better. (I refuse to qualify that statement: see below.) > For example > > If a web applicatoin was written in both Java and Python, > which would companies prefer ? Java, mostly because Java has a cooler logo, and Java is backed by Sun, which is a big company. Software companies, especially, prefer this, because they like to think that having a large company behind something means something. That's if you're marketing it as being in a certain language. One thing that we do too much in this industry is focus on our implementation technology. YOU should be familiar with the technology, YOU should be aware of its strengths and weaknesses, but your customers should just know what it does and how well it does it. It would be cool if you could get python a little bit more press, but you don't necessarily have to try to ride Java's (or Python's) marketing success. If you do that, the success of your product becomes bound up with successes and failings of the language and platform which may or may not have anything to do with your program at all. > 1. Which is more maintainable ? Python. Python can do just about anything in fewer lines of code, and is vastly more readable to boot (not to mention having lovely space-saving features like function and method objects and module-global variables.) I don't think i've *ever* found a language more maintainable than python, and I love it. Even one-liners I tossed off to solve very specific problems are completely readable (and even somewhat reusable!) to me weeks after I write them, even if I'm trying to be purposefully obtuse or clever ;-) Not to mention the fact that everything is a first-class object in python, so you don't end up worrying about how the heck you're going to write your code to deal with int/long/double/float without incurring extra overhead both in syntax and in memory: you can just treat everything as a number in python. (As if it were object oriented or something!) Compare the following to snippets: class Foo: def __init__(self,x=15): self.x=x def bar(self, a, b): return self.x+a+b ... public class Foo { int x; public Foo(int x) { this.x=x; } public int bar(a,b) { return x+a+b; } } The java version looks slightly more complex, but they appear to be approximately the same: until you realize that Java is operating on integers, and Python is operating on *anything which can be added*! This could be strings, complex numbers, integers, floating point numbers (despite the fact that we should, of course, never use floating-point (thanks tim)). In order to get similiar functionality in the Java version with appropriately aesthetic syntax, the code would be about 20 times longer. Less code == less to fix == less to maintain == fewer bugs. > 2. Which is more scaleable ? Python has a global interpreter lock, so multithreading doesn't speed it up as much. So, if you're going to buy an Enterprise Server 1000000000 or whatever, with altogether too many processors to run your code, the answer is *probably* java. (There are ways around this in python, but not all of them are immediately obvious.) The minimum investment to get good performance out of Java is higher than that to get good performance out of python though. However, Java has some issues with memory usage. I have a machine with more than enough RAM to do this: glyph at helix:~% python Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> x=range(5000000) >>> glyph at helix:~% cd app/IBMJPython-1.1 glyph at helix:~/app/IBMJPython-1.1% ./jpython JPython 1.1 on java1.3.0 (JIT: jitc) Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> x=range(5000000) Out of Memory You might want to try the -mx flag to increase heap size So it depends how you want to scale. In JPython, which is translating the Python to Java bytecodes and running it as it it were java, this allocation is too large. Not because java has more overhead and I don't have enough RAM for it, but because Java gives up halfway through when it realizes there's not enough space in its "allowed" memory block for that list. Notice that I'm using "IBMJpython" here, which is JPython installed on the newest, funkiest JVM available for Linux, the IBM JDK 1.3 port. It is *possible* to increase maximum memory usage by passing commandline options, but (A) who wants to figure out how much memory a long-running application is going to take ahead of time and have to restart it if it overgrows that and (B) performance begins to suffer as you do that. Also; you can easily bind your Python code to other systems, profile out the performance bottlenecks, easily, by extending or embedding Python in C or C++. And finally; this point is often overlooked, but it is VERY important; critical, almost -- bindings for Python to native functionality on your platform *probably already exist*. Java shoehorns you into ONE API, ONE loosely-defined standard implemented shoddily by Sun, ONE way to write GUI's, no ability to do multiplexing (all I/O is blocking and in threads) ... all in all, the poor performance and poor scalability of Java's standard library damn the language more thoroughly than any other feature of it. After all, java "scales" because it has true multithreading that will take advantage of multiple processors, but there are optimizing algorythms for servers that are *impossible* in java because of library decisions (no multiplexing, as I said), whereas Python will give them to you. > 3 Which is faster eg. Java servlets or Python CGI with mod_python ? Since Python does all of its I/O buffering in C, and Java does all of its buffering in Java, Python is going to be faster, despite all of Java's "theoretically optimal" interpreter optimizations. If your code is *really really* CPU bound, java might do better, but given Java's wonky cpu-hog GC behavior, it's likely that you'll lose there too. (If you're seriously that CPU bound, nothing beats C, so a C application with python "steering" would beat java anyway.) Servlets also use the standard-output facility in java: as shown on my Java-versus-Python page -- http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html this is NOT very fast at all. I have no idea why the performance difference is so significant. > Please do not interpret this message as an excuse to discredit java > or python. I am about to start a major web project using Java but > have been referred to python as an alternative so I am investigating > this option. I do not intend to discredit java here; it is certainly worthwhile for some things, but it is *really* not everything Sun claims it is. Hopefully if people realize this, Sun will actually make strides towards delivering on all of these wonderful promises that they've made, or relinquish control to someone who will. The thing that Java is most useful for at the moment is interfacing with other applications written in Java; it's very easy to link any arbitrary java code to any other arbitrary java code, even without a "development kit". This is nothing on python's introspection, but it's certainly leaps and bounds beyond C (I won't even talk about C++. Fragile base classes? Yuck.), and a lot of things are available to work with. If you can afford to take a slight speed hit for maintainability, readability, and flexibility, but you still need interoperability with Java, JPython is a *wonderful* thing. Check it out at www.jpython.org. > Your responses are highly regarded. > Thank you Much luck with your web project: I hope whatever implementation strategy you pursue is fruitful for you! -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From rkiendl at gmx.net Fri May 5 08:33:51 2000 From: rkiendl at gmx.net (Robert Kiendl) Date: Fri, 05 May 2000 14:33:51 +0200 Subject: Freeze/Source Code Question? References: <3912558F.89778406@world.std.com> Message-ID: <3912BFAF.539D7200@gmx.net> without ever using freeze i am shure it would be little effort to encrypt the bytes in the exe-file in order to improve disguisement. if you want to encrypt the bytes in memory - again i am shure its possible with a little bit more effort. the difference to java and visual basic is: python has grown so well, that you can do ___all___ those things and mix your efforts with the wealth, which is already there - on many levels. why? python is a 5% lisp. it has its roots deeply in the evolutionary programing paradigm. this one will some time dominate the development of software. python is decent and nice to oldstyle engineers - so it will gracefully take the world. java for example is a c++ - trojanic horse. nice looking, but worse and more stiff than c++, and it doesn't like growing. it comes from greedy people which wanted to _construct_ software more quickly. in fact java programmers construct silly things more slowly and complicated. search the web for jccpprtTR.pdf. today java feeds on the early birth in the net. software grows. it is not just planning and construction. python is a natural language and supports growing. have sex with python and your software grows more _well_ - means quick and stable and manageable and so on ... if you need, mix it with c++ and you will have a 10% lisp language - but better tools than lisp. robert From guido at cnri.reston.va.us Tue May 2 14:16:49 2000 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 May 2000 14:16:49 -0400 Subject: [Python-Dev] Re: Python 1.6a2 Unicode bug (was Re: comparing strings and ints) References: <39072F0C.5214E339@lemburg.com> <45919986@data.franken.de> <048501bfb0b4$c793d760$4add3fcb@neil> <45919997@data.franken.de> Message-ID: <5l1z3kstpq.fsf@eric.cnri.reston.va.us> "Walter Doerwald" writes: > On Sun, 30 Apr 2000 17:43:10 +0100 Just van Rossum wrote: > > > At 9:56 AM +0200 28-04-2000, Walter Doerwald wrote: > > > But I find UCS-2 much cleaner, because it's easily distinguished from > > > ASCII/UTF-8/ISO8859-1/..., distinguishing between UTF-8 and ISO8859-1 has > > > to be done by "external" methods. How does Python do it? > > > > It doesn't; it'll just assume utf-8... > > Ouch, does this means that I have to type my source code in plain ASCII, as > long as I don't have a texteditor that doesn't save UTF-8, but only > ISO-8859-1? This seems really bad to me. No, this is still open for discussion! We're considering various options for source code encoding. Most likely there will be a pragma or a "magic comment" to indicate the source code encoding. There's currently a lively discussion on this going on in the i18n-sig -- please join us there! --Guido van Rossum (home page: http://www.python.org/~guido/) From msoulier at nortelnetworks.com Wed May 24 14:01:12 2000 From: msoulier at nortelnetworks.com (Michael P. Soulier) Date: 24 May 2000 18:01:12 GMT Subject: defined test? Message-ID: <8gh5d8$hu3$1@bmerhc5e.ca.nortel.com> Ok, I'm currently a Perl programmer who's looking into Python. I was wondering, is there an equivalent of the defined() function in Python, to test if a given variable name is defined? Sorry if this has been answered now for the umpteenth time. Mike -- Michael P. Soulier, 1Z22, SKY Tel: 613-765-4699 (ESN: 39-54699) Optical Networks, Nortel Networks "...the word HACK is used as a verb to indicate a massive amount of nerd-like effort." -Harley Hahn, A Student's Guide to UNIX From moshez at math.huji.ac.il Tue May 23 00:31:05 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 23 May 2000 07:31:05 +0300 (IDT) Subject: Decimals -> Fraction strings, my solution In-Reply-To: <39242f0a.1044508290@news> Message-ID: On Thu, 18 May 2000, David C. Ullrich wrote: > The reason the counter-quibble seems worth > mentioning is that the abs makes it much less generic: > Without the abs you can use the function for any > objects with a __mod__ method (assuming that a has > to eventually become false for some reason). For > example you can use it to find the gcd of two > polynomials a and b, if you give your polynomials > an appropriate __mod__. (I don't think there's any > such thing as an appropriate __abs__ for polynomials...) Hmmmm.....there should be an __representative__, which would take a unique representative from the equivalence class of "self", where equivalence is defined a ~ b <==> there exists i, i invertible, a*i = b abs() does this for Z, normalize() does this for polynomials, etc. new-__-protocols-a-dollar-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From moshez at math.huji.ac.il Sat May 27 10:56:31 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 27 May 2000 17:56:31 +0300 (IDT) Subject: vars between classes In-Reply-To: Message-ID: On Sat, 27 May 2000, Marc Tardif wrote: > How can I maintain variables between classes and superclasses without > passing explicitly as methods arguments? For instance: > > class first: > def __init__(self, var): > self.var = var > self.myMethod() > > def myMethod(): > print "first:", self.var > second(self.var) > print "last:", self.var > > class second(first): > def myMethod(): > print "second:", self.var > self.var = 3 > > def test(var): > first(var) > > if (__name__=='__main__'): > test(2) Your Python code doesn't work: Traceback (innermost last): File "", line 1, in ? File "", line 2, in test File "", line 4, in __init__ TypeError: no arguments expected In case you're trying to call methods of superclasses in subclasses, here it is: class foo: def method(self): print "foo" class bar(foo): def method(self): print "bar" foo.method(self) # explicitly call foo's "method" a = bar() a.method (Prints bar foo) From rzantow at my-deja.com Thu May 25 14:12:58 2000 From: rzantow at my-deja.com (rzantow at my-deja.com) Date: Thu, 25 May 2000 18:12:58 GMT Subject: Another salvo in the indentation war? I hope not. Message-ID: <8gjqer$k8v$1@nnrp1.deja.com> This isn't really intended to launch into Yet Another Indentation Threat, but I have one plausible argument in favor of some form of block marking: When a newsreader, browser, or mail program trashes the indentation from examples of Python source, it is a real pain in the hindlimbs to recover the original program logic. Yeah-I've-just-been-bitten-so-what?!-muttering-darkly-ly (?), Dick Z -- Pythons, unlike some other snakes, do have hindlimbs, but they never develop beyond vestigial stumps. The arrest of limb development is due to a failure of the sonic hedgehog signalling system ... Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Mon May 22 15:04:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 19:04:06 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: Message-ID: <8gc0b6$eh4$1@newshost.accu.uu.nl> neelk at cswcasa.com wrote: [snip] > I hope (but fear that I'm wrong) that the same is not true of the > iteration protocol -- there's a critical need to be able to iterate > over trees and linked-lists cleanly. This is IMO more significant > than GC or even type-class unification, and it's the major reason I'm > rooting for Stackless, since it permits Sather-style coroutine-based > iterators to be implemented in Python. I'd like to see something like that. For other inputs on this and other things, I think the algorithms part of C++'s STL may be worth investigating (keep the few neat bits, throw away the rest), and for a really out there thing I've recently been playing a bit with the language K (that is, I've read some of the manual), at www.kx.com K's a bit in the style of APL (though I don't know APL). All I've been doing is translating some of the operators to Python classes, but since I can't think in K yet I haven't accomplished a lot. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mwh21 at cam.ac.uk Wed May 3 11:10:47 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 May 2000 16:10:47 +0100 Subject: Deleting objects in Python 1.6 References: Message-ID: Alex writes: > Hi. What does this mean? > > > Deleting objects is safe even for deeply nested data structures. > > From python.org/1.6. Try this: >>> l=[[]] >>> m=l[0] >>> for i in range(100000): ... m.append([]) ... m = m[0] ... >>> del l (hint: it segfaults on my machine, unless I use a v. new Python) Cheers, M -- There are 'infinite' number of developed artifacts and one cannot develop appreciation for them all. It would be all right to not understand something, but it would be imbecilic to put judgements on things one don't understand. -- Xah, comp.lang.lisp From ljz at asfast.com Sun May 14 02:17:58 2000 From: ljz at asfast.com (Lloyd Zusman) Date: 14 May 2000 02:17:58 -0400 Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > andres at corrada.com wrote: > >Physicists also use "i" and "I" for current and yet still use "i" for > >imaginary numbers also. The use of "j" is unfortunate given that most > >of the scientific/mathematical world uses "i". > > Just scanned through one of my E&M books. Can't find "i" used for > current. Found "I", and dQ/dt. Also found J used for volumn > current density. Lower case "i" is used for imaginary numbers and > i^ (that's i-with-caret) for unit vector along the x axis. > > Can't ever recall using "i" for current. I've used "i" as well as "I" for current, and I've definitely seen this in textbooks. But be that as it may ... Clearly, there are two widely used representations of the square root of -1: "i" and "j". Forgive me if this question has been answered and beaten to death in one or more earlier discussions, but is there any reason why Python couldn't use both "i" and "j", as well? Given that things such as "1 + 3i" are currently illegal in Python, I don't believe that any legacy code could possibly break if in a future Python release, any one of 4 values ("j", "J", "i", and "I") could be appended to a number to cause it to be treated as imaginary, instead of just the two values we have today. Or would this change somehow go against one or more core principles of Python architecture? And in case it might not be clear, I'm not being facetious. I'm sincerely wanting to know. -- Lloyd Zusman ljz at asfast.com From invalid.address at 127.0.0.1 Fri May 26 14:11:05 2000 From: invalid.address at 127.0.0.1 (David) Date: Fri, 26 May 2000 18:11:05 GMT Subject: Indented gonads. References: <8gjqer$k8v$1@nnrp1.deja.com> <20000525225425.Z13281@xs4all.nl> <392E3C88.DADE571@geneva-link.ch> <8F40861C1davemrquizorg@212.27.32.77> Message-ID: <392ebdba.34189549@news.telus.net> On Fri, 26 May 2000 10:54:29 GMT, nospam.mrquiz at free.fr (Dave Simons) wrote: >No more and no less than those who make the decisions in any of >the other divisions of Redmond Garbage Creations Inc. - try >typing out case-sensitive code in Word, for example (I know you >don't normally write code in a word-processor, but you might >want to write *about* code in a word-processor). Uh-huh. Evile Microsoft is out to screw you by having its autocorrect feature work as it should, eh? Come on, man. I'm no lover of Microsoft, but you can hardly grouse about Word doing things Word is designed to do, and that can be disabled by any reasonably intelligent person. It's called "Autocorrect as you Type" and it's toggle-able. If you don't like it, turn it off. Sheesh. RTFM. From thomas.heller at ion-tof.com Fri May 5 09:16:50 2000 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 5 May 2000 15:16:50 +0200 Subject: python's acceptance References: <5ff3hs8ssqu9aggre87cnbv52jni5lrh2a@4ax.com> Message-ID: <002c01bfb694$2cc2c440$4500a8c0@thomasnb> [Mark writes] > OK - I will bite :-) Specifically, what? I realize the debugger has been > a little flakey, but if we assume that it works like it appears it should > (which it will, next build :-), what else would we like? > > I also understand some additional features (or even just polishing the > existing ones) would be good, but if there are specific issues that > actually _prevent_ you debugging (as opposed to simply frustrating you > while debugging :), I really want to know... I have a custom GUI framework, written in python, with some kind of calldll-like interface to the win32 api. I cannot debug the window procedure. Thomas From neelk at cswcasa.com Fri May 26 15:38:41 2000 From: neelk at cswcasa.com (neelk at cswcasa.com) Date: Fri, 26 May 2000 15:38:41 -0400 Subject: NumPy and Octave (question and discussion) Message-ID: Konrad Hinsen wrote: > > > Can NumPy be modified to look similar to octave? I bet there would be a > > lot [...] > > No, because all the syntax elements you want to use for arrays are > already used for something else in Python. > > What can be done is implementing "matrix" and "vector" classes which > behave like Matlab's, using NumPy arrays as an internal representation. > There even was an early attempt at such a set of classes in the first > NumPy releases, but it wasn't maintained (probably due to lack of > interest!) and finally dropped. I actually tried to use the Matrix classes for a while before giving up. The problem wasn't a lack of interest, it was just that the code to use it was so completely nasty. I needed to make a subclass of them to allow me to work with transparently with sparse arrays, and found that I just couldn't get it to work right no matter what. The basic problem was there I needed to do binary dispatch to get my class to interoperate properly with regular Matrix instances, and that meant that I would have had to modify the Matrix class code as well as my subclass -- yucky. And the existence of __rmul__ turned the code from merely rather nasty into pure evil. I eventually gave up and went back to using Gauss. It sucks, but not hard. :( -- Neel Krishnaswami neelk at cswcasa.com From samschul at pacbell.net Thu May 11 23:55:52 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Fri, 12 May 2000 03:55:52 GMT Subject: Pythonwin com? References: <8ffgdr$840$1@nnrp1.deja.com> Message-ID: <8ffvc1$obp$1@nnrp1.deja.com> Mark; You cought my typo. Frame is initialized as a null dictionary. The function call Buff=GetFrame(1,Frame) returns Buff as an array of singleton tupples. i.e ((1,),(2,)...(n,)). I have to double check tommorow, but I believe Visual Basic returns a double valued array such as Frame[0][0]=1,Frame[0][1]=0,and Frame[1][0]=2, Frame[1][1]=0,etc. This Object was written by Roper Scientific a few years ago, and updated as needed over the years. On another note. The examples I have discribed work under Pywin-129, but not subsequent versions under WinNT 4.0. Sam Schulenburg In article , "Mark Hammond" wrote: > "Sam Schulenburg" wrote in message > news:8ffgdr$840$1 at nnrp1.deja.com... > > > Frame = {} # Here I have to set Frame up as a tuple > > That doesnt look like a tuple to me? > > > return self._ApplyTypes_(0xa, > This decoded is: > > > 1, > > (24, 0), > 24 = VT_VOID - function has no return value. > > > ((2, 1), (16396, 3)), > > 2 params: > (2,1) == VT_I2, PARAMFLAG_FIN > (19396,3) == VT_BYREF | VT_VARIANT, PARAMFLAG_FIN|PARAMFLAG_FOUT > > ie, first param in an "in" integer. > > second param in an "in/out" byref variant. The "in" implies it is not > simply an out. > > My guess is that the problem is the VT_VARIANT - ie, Python doesnt know > the type of the param at all - it only knows it is byref. > > What are the types of the objects in the array? What we can do is change > the makepy definition for: > > > def PutFrame(self, > > frame=defaultNamedNotOptArg, > > FrameArray=defaultNamedNotOptArg): > > """Put Frame Data""" > > return self._ApplyTypes_(0xb, > > 1, > > (24, 0), > > ((2, 1), (16396, 3)), > > Note the params are almost identical - we could change this to VT_BYREF | > VT_I2 (or some more specific type than variant - whatever makes sense). > > Who wrote the object? > > Mark. > > Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Sat May 13 01:32:25 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 13 May 2000 05:32:25 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <391DC8C1.3DB0@seebelow.org> Message-ID: <391CE980.ED16366B@san.rr.com> > dynamic typing, but get an automatic error-checking mechanism that > (eventually) finds these errors. For those of us who care, that "eventually" might be a real stinger. :)- C/ From m.faassen at vet.uu.nl Thu May 18 07:45:18 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 May 2000 11:45:18 GMT Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> Message-ID: <8g0l4e$gd2$2@newshost.accu.uu.nl> Fredrik Lundh wrote: > much better than that non-intuitive 1.6 implementation. now, all > that's left is to implement this. let's start with the join function... > $ cd python-1.6\Lib > $ more string.py > ... > def join(words, sep = ' '): > return sep.join(words) > ... > hmm. That doesn't help us one bit if it's true what an earlier poster said and the 'string' module is deprecated. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Mon May 29 11:21:41 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 May 2000 15:21:41 GMT Subject: Another salvo in the indentation war? I hope not. References: <20000526132623.24647.qmail@web2002.mail.yahoo.com> <392f60e8.260627511@news.nikoma.de> <8gs2u0$m7m$4@newshost.accu.uu.nl> <3931fb92.45603755@news.nikoma.de> Message-ID: <8gu1u5$bks$2@newshost.accu.uu.nl> Philip 'Yes, that's my address' Newton wrote: [snip] >> If-malicious-somebody's-start-removing-stuff-all-code-is-lost-ly yours, > However, removing indentation is more common than removing random > characters such as '{' or '}' (or, with Pascal, 'BEGIN'), wouldn't you > agree? For example, if someone writes HTML without remember that two or > more spaces get treated as one? > We're talking about what happens in real life. Indentation is more often > smashed than characters are lost. That's true, but in real life I haven't seen much indentation smashing of Python source yet. Source code is usually transmitted in more durable formats; after all if you smash the indentation in C you might get something still compilable, but not something very readable. And the thing about source code is that it should be human-readable, otherwise we can just as well transmit binaries. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From erik_wilsher at my-deja.com Thu May 11 07:34:57 2000 From: erik_wilsher at my-deja.com (erik_wilsher at my-deja.com) Date: Thu, 11 May 2000 11:34:57 GMT Subject: A Mountain of Perl Books + Python Advocacy References: <20000405053920.20579.qmail@web2102.mail.yahoo.com> Message-ID: <8fe5t1$mgf$1@nnrp1.deja.com> In article , David Bolen wrote: > tsummerfelt1 at myspleenhome.com (tony summerfelt) writes: > > > i think something like the following is pretty hard to beat: > > > > #!/usr/bin/perl ...lots of cryptic perl code, but I *guess* the purpose was to read from a file and print out a sorted, unique list of the input file. > > I guess it depends on what "beat" means - I agree with a previous >..... > #!/usr/bin/env python > > import sys > > input = open(sys.argv[1]) > output = open(sys.argv[2],'w') > > uniq = [] > lastline = None > > while 1: > curline = input.readline() > if not curline: break > > if curline != lastline: > uniq.append(curline) > lastline = curline > > uniq.sort() > output.writelines(uniq) > Having read this, and also noticed a request for some sort of "unique" flag for lists in the python todo-list, I added a sortlist class to my bisect module. Using this class we can reduce the above program to: -------- #!/usr/bin/env python "uniq.py --Read lines from input file, and write sorted output to file" import fileinput,bisect,sys uniq=bisect.sortlist(fileinput.input(sys.argv[1])) open(sys.argv[2],'w').writelines(uniq.list()) -------- Q: I have modified the bisect module somewhat (doc strings, find function, sortlist class). What should be done with this? Vault? Patch list? Erik Wilsher Sent via Deja.com http://www.deja.com/ Before you buy. From jilanik at tin.it Tue May 23 10:20:32 2000 From: jilanik at tin.it (Jilani Khaldi) Date: Tue, 23 May 2000 16:20:32 +0200 Subject: Graphical User Interface application Message-ID: Hi All, I wonder if it is possible to write graphical user interface applications using Python, like in VB? If yes, what do I need then? Thanks. Jilani From robin at alldunn.com Mon May 1 17:56:00 2000 From: robin at alldunn.com (Robin Dunn) Date: Mon, 1 May 2000 14:56:00 -0700 Subject: Class Factories in Python: How? References: Message-ID: > Each type I want to create a new binary structure, I subclass it, but the > subclassing procedures are getting complex because there are so many > class-variables that need to be initialized. So I decided to try to build a > class factory, like this: > Another approach is to use the "new" module. You can create a new class object by calling new.classobj passing the class name, a tuple of base classes, and a dictionary of class attributes. This works great when the base classes might be different each time. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From brianfr at grace.speakeasy.org Tue May 2 10:35:00 2000 From: brianfr at grace.speakeasy.org (Brian Fritz) Date: Tue, 02 May 2000 14:35:00 GMT Subject: ODBC / DBI help (via Win32 Extensions) References: Message-ID: Benjamin Schollnick wrote: > I've got the read, and most of the "write" functions working > fine, except when it comes to utilizing the date values... > I can read and convert the date information into a python readable > value.... But I can't seem to do an UPDATE or INSERT INTO command > with a date value inside it. The following line works great for me with SQL Server 7.0: mycursor.execute( "update database set date_changed = '19990429 11:20' \ where some_column = 'some_value' " ) Haven't messed with Access, but it should work the same. Brian From rwolff at noao.edu Fri May 26 13:41:52 2000 From: rwolff at noao.edu (Richard Wolff) Date: 26 May 2000 17:41:52 GMT Subject: Python and VxWorks Message-ID: <8gmd10$9pa$1@noao.edu> A-periodically, someone asks about how to embed/port Python to Vxworks. As has been said before, it's not difficult. However, details have been somewhat lacking. What follows are some of the details. This same information and the rest of the story can be found at http://daikon.tuc.noao.edu/python As usual, no warranty for fitness nor merchantability nor freedom from un-wanted side-effects of creeping featurism. Richard --------------------------------------------------------------------- Here's how I set up Python as an embedded task in VxWorks. Note that building the system for VxWorks is not going to be as nicely set up as doing so for most systems. We can't run configure for one thing. So there are a number of changes that you have to consider/make by hand. Before getting to the details, a thank you to Paul Fernhout for some helpful advice in a recent comp.lang.python posting. Perhaps the best way to get started is to build Python on your workstation and use that as the start of the port. This way, many of the files you need will be present. For instance, the parser generator program will be built and run, so it isn't needed for the cross-compile. You'll also have config.h file that might well serve as a useful starting point. The files from the distribution that you need to modify are in Include, Modules, Objects, Parser, and Python. At the top level, you'll need to change Makefile and config.h. The diff file (pydiff) will make a lot of changes for you, but you should probably take a look at what's going on first. There may well be better ways of doing things. By the way, the diff is against Python 1.5.2 and is for VxWorks 5.2 (pre-Tornado). You'll need (or want) to do the following: 1) Edit the top level Makefile to reflect the correct definitions for CC, RANLIB, LD, and AR. Make the same edits in the Makefiles in Objects, Parser, and Python directories. Make the same edits in Makefile.pre in Modules. 2) Edit config.h 3) Get a version of getopt.c and put it in the top level directory, along with a suitable getopt.h, which can go in the Include directory. Or put getopt.c somewhere else and modify Makefiles suitably. 4) Edit Setup (and Setup.local, Setup.thread). 5) If you include modules that I didn't, you'll probably want to edit that module's ".c" file. If you have a different version of VxWorks, look for the VXWORKS define and modify as needed. 6) Modify Modules/python.c as you will. You probably will want to modify the arg0 value. 7) Remove the buildno file if you want. 8) In Modules, run makesetup to build the Makefile and config.c. If you have used both Setup and Setup.local, run makesetup Setup Setup.local 9) At the top level, run make. The output will be "python.o" in this directory. 10) Load that into your VxWorks system. On my system, Python took too much stack space to run under the shell, so I spawn the task, which is what "sppy" ("spawn python") does. If Python comes alive, but you get lots of xxx:yyy: No such file or directory and xxx:yyy: File exists, don't worry. Those messages are from 'stat' as it probes the file system on xxx looking for library files. I don't know how to stop this; it's both annoying and harmless. 10a) You should 'cd "python-top-level-directory"' before you load the python.o file, or you should be sure that you have the Lib directory in a standard place (or you have modified the Makefiles to reflect suitable prefix and exec-prefix directories). Or you might set the PYTHONHOME environment variable in Modules/python.c before Python goes through its initialization steps. 11) When the >>> prompt appears, it's likely that a carriage return will bring back the shell prompt. That's because the shell runs at much higher priority than Python and it grabs all the characters. It needs to be demoted, which is what the "demoteShell" code in Modules/python.c does (with a vengeance...there's probably no need to suspend the shell). So run that routine from the shell, and then run Python as you will. 12) To exit, the usual command sequence (or sys.exit) will get you back to the shell prompt, at which time, you should raise the shell priority back to 1 (use "restoreShell"). 13) You can make things more interesting by having Python code that will allow you to run VxWorks routines. You need a slight extension of Python, to be found in my "Modules/vxmodule.c". Modify Setup (or Setup.local, rerun makesetup, and then the top level make). 14) A simple VxWorks class makes use of the vxmodule code. See VxWorks.py Thus, i = VxWorks.Vxw("i","") builds an 'i' such that 'i()' gives the same task information table from the Python prompt as it does from the VxWorks shell. Or, routeAdd = VxWorks.Vxw("routeAdd", "ss") builds a routeAdd function that can be used to add a route to the VxWorks routing table (routeAdd("90.0.0.0, "gateway")), and so forth. 15) If you have the VxWorks module in place, you can then define rs = VxWorks.Vxw("restoreShell","") and when you run rs(), you have, for interactive use, effectively suspended Python, as the shell will get all the input characters. "demoteShell" and 'rs' thus allows you to switch back and forth between Python and the VxWorks shell. Richard Wolff May, 2000 P.S. I did this work because I want to run various routines in the VxWorks environment under the control of a "scripting" language. There are three approaches here...embed Python in VxWorks, which is what this note is about, connect Python running on a workstation to the VxWorks shell via telnet, or connect Python on the workstation to a process on the VxWorks box via a socket connection. Which way to go is nice question. The other question one ought to answer is, "why aren't you using rt-linux?". P.P.S. All this code is released under the same terms and conditions as the Python license. -- Richard Wolff, National Optical Astronomy Observatories, Tucson, AZ Internet: rwolff at noao.edu Phonenet: +1 520 318 8392 From wlfraed at ix.netcom.com Wed May 17 23:14:36 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 17 May 2000 20:14:36 -0700 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <3922F3E1.9A5F49DA@rubic.com> Message-ID: <2tl6is00rbiogg4r75hrqlbfqra85349qq@4ax.com> On Wed, 17 May 2000 22:25:57 GMT, Ben Wolfson declaimed the following in comp.lang.python: > But what's so great about winzip, anyway? Lots of windowses come with > pk(un)zip or (un)zip. winzip is a pain, especially in unregistered form... While I could live with the constant "do you accept..." window (with randomized yes/no buttons even), I abhorred the fact that winzip added some three or so icons to every system menu it could get a hold of. Besides, Eudora Pro came with a version of Stuffit Expander, which works just as well for me (and somewhere I also have something going by the name of Keyview, think it also came with Eudora, which handles .tar and .tgz files, with some hand-holding). -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From m.faassen at vet.uu.nl Wed May 17 10:26:23 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 17 May 2000 14:26:23 GMT Subject: Forcing type conversion References: <8fu9m9$2ab$1@supernews.com> Message-ID: <8fua6f$nb6$1@newshost.accu.uu.nl> Dale Strickland-Clark wrote: > How do I get Python to force 'a' and 'b' into strings so that the following > concatenates instead of trying to add. > a = 1 > b = 2 > a + ":" + b Use the builtin function str(): a = 1 b = 2 str(a) + ":" + str(b) The library reference is your friend. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From senn at maya.com Wed May 10 09:27:27 2000 From: senn at maya.com (Jeff Senn) Date: 10 May 2000 09:27:27 -0400 Subject: Stackless/microthreads merge news In-Reply-To: ejr@lotus.CS.Berkeley.EDU's message of "9 May 2000 22:15:32 GMT" References: <200005022228.IAA03188@envy.fulcrum.com.au> <39184C59.DD33AA67@tismer.com> <8fa2m4$98v$1@agate.berkeley.edu> Message-ID: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) writes: ... > - 'simple-unified-VM' that supported continuations (if not full ... > Like a Virtual Virtual Machine? See http://www-sor.inria.fr/projects/vvm/ . Hm... I'll look. > Other people might say that the x86 is the unified VM. It doesn't > necessarily need to run on x86 hardware, as Transmeta and IBM > have shown (www.transmeta.com, http://www.research.ibm.com/daisy/). > Bochs is kinda in this space, too. Ah -- but the x86 is very complicated (i.e. not portable and tiny) -- the Transmeta stuff is great but I heard about it many years ago -- why hasn't it taken over the world? Too big. What are we going to run on the "smart-dirt"? Maybe x86 code, but probably not. > And yet other people might eschew virtual machines for intermediate > representations that can be compiled quickly while keeping the Indeed -- my goal is not performance. It is to factor out the complexities of software development to make it more accessible to more people on more types of devices/platforms. To scale from tiny devices up to big servers. There is something to be learned from the apparent success of environments like Python in amplifying developer productivity. > And then there are those folks who have been working on a Scheme > interpreter to serve precisely this role, Guile. Yes. But again I wonder why Lisp/Scheme/... never took over the world and things like Python, the other-P, VB, and (perhaps) Java, do seem to take hold... > So lots of people have thought about this. Which of these approaches > make sense? I'm not at all sure. Having bytecode-like format that > can be efficiently compiled and optimized (and recompiled and > reoptimized) while still being ok to run directly would be nice. > Once upon a time, some of the Guile developers pondered a threaded > tree coding, one that might be like crossing byte-code with the > slim binary approach, but I don't know what became of that. If I > weren't a lazy bastard, I'd look into something like that myself. In past days I've explored many of these issues myself -- some of it in research that has never seen the light of day (so I'm either a lazy bastard too or just have too much to do :-) ) -- my best guess is that Python is as close as anything I've seen to being the right balance of language features and power with user-accesibility -- the VM implementation is quite good/simple and Chris's stackless makes it even better -- and if only I could run the core of it on a small, raw microprocessor with modest memory (or a SmartCard ... or even my Palm!) I believe it would take over the world. -- -Jas From tismer at tismer.com Tue May 2 14:27:21 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 02 May 2000 20:27:21 +0200 Subject: How many is "too many" with lists? References: <8emtqt$dsf$1@nntp9.atl.mindspring.net> Message-ID: <390F1E09.3234428E@tismer.com> Matthew Hirsch wrote: > > Generating the list is slow. I'm accessing each element with a for > loop. I was just curious. So you mean not access to the list, but creating the list? Do you build the list by append()? --- on the speed issue --- Note that append() is somewhat optimized, but that doesn't take you very far. For small lists, the allocation is rounded up to the next multiple of ten. For larger lists, this is rounded up to 100. In other words: If you use appand() and append() over and over, You must expect a complete copy of your list on every 100 element. With your 296010 elements, this means that you are doing about 2960 list allocations with a mean length of 148005 elements. Calculating per element, this is a mean overhead of 1480 per element, somehow. If you can estimate the size of your list in advance and do your own allocation, you are better off. For instance, keep an extra list length variable instead of using len(), and increase your list by a constant factor (1.5, maybe) whenever it needs to grow. --- on the memory issue --- Well, another issue is total memory use, which may in fact be much worse than the above, if your list elements do not fit into memory. You may assume that the machine slows down by a factor of 1000 or worse if thrashing becomes serious. Let's see what you have. A list of lists (hint: use tuples, they are smaller, due to headers and the round-up rule!), each list contains six integers. Cost calculation: 1 int = 3 words. But since you are using numbers below 100, you are lucky: These objects are shared and come at no cost. A list is a header of 4 words, pointing to a memory chunk. In your case, due to round-up, the chunk will be 10 words long, and due to common memory allocaiton schemes, it will probably be 12 words or more. So each of your sublists counts as 16 words, plus the one reference that is sitting in you big list. The rough estimate of total size is then >>> 296010 * (16+1) * 4 20128680 >>> bytes. If you are on a 16MB machine, this gives already horrible performance. 32MB may still be problematic if you are using Windows. As an alternative, use tuples inside your list. Tuples are contiguous and therefore have less malloc overhead. And they do not use spare allocation. A tuple is 3 word header plus one word per entry. In your case, this makes (unfortunate) 9, probably rounded up to 10 or 12 words my malloc. Let's hope for 10: >>> 296010 * (10+1) * 4 13024440 >>> Much better, right? Now this is still a waste of memory, unless you really need fast access to your integers. There are several ways to save this space. Is it feasible for you to encode your numbers as characters? It would make very much sense to build a string of digits, instead of using tuples with integers, and indexing strings is quick. A string is a (quite) expensive structure with 5 words header. The rest is the number of bytes you store, plus 1, rounded up by malloc. In your case, we have (5 * 4) + 6 + 1 = 27 byte, probably rounded up to 32 which is 8 words. Result: >>> 296010 * (8+1) * 4 10656360 >>> Ok, that's still not cheapest possible. But if you can afford a little computation time in favor of a smaller memory footprint, how about this: Simply pack your 6-tuples into one integer by multiplication. If your "digits" are limited to the range(27), and if you don't need more than 6 digits, you can pack them together using bit shifts by 5, and 6 digits will fit into an integer. The cost of an integer is only 3 words, with nearly no overhead, since ints are allocated in blocks. This gives you an overall result of >>> 296010 * (3+1) * 4 4736160 >>> Quite compact, isn't it? Well, and if you are really mad at memory footprint, then you may consider the array module: You are storing integers always, so why pay for the universality of lists and tuples? Array store your ints natively. >>> a=array.array("I", range(296010)) >>> len(a) 296010 >>> This object, despite the little header, has really only 296010 words of content. This is 1184040 byte, about 17 times better than the original approach. Ok, and as the last proposal, leaving the 5bit-packing in favor of more ease, how about the Numerical Python package? After installation, you can do something like >>> import Numeric >>> a=Numeric.array(1000*[range(6)], Numeric.Int8) This gives you a 1000 by 6 array of tiny 8-bit integers, which should be able to do what you need, and you have everything in the right shape. I'm not sure about the exact object layout in NumPy, but my guess is that we now are at >>> 296010*6 1776060 >>> which is still very good, and performance should be very high. But I think you have to allocate the array in advance. I'm not so used to NumPy. Note that the use of "flat" array does not give you Python objects. The whole array is an object which contains plain numbers. On every access, a new integer ubject must be created. Generally, these arrays perform a bit worse than lists or tuples. But luckily not in your case, since our small integers don't create new objects all the time, but you always get the already existing small integer objects from Python. hope this helps - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From jkraska1 at san.rr.com Tue May 16 23:56:15 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 17 May 2000 03:56:15 GMT Subject: IDEs, ID or EGO? (was: Decimals -> Fraction strings, my solution References: <3921D4C6.91B2090F@acm.org> Message-ID: <39221911.C3FB9056@san.rr.com> > Just because M$ doesn't want to reveal all the command line > options to work from outside of their "visual" environment doesn't mean > the language requires it Ironically, I'm in Visual Studio right now using GVIM. This works fine. You just get this annoying "the file such-n-such has changed, would you like to load it?" every time you context- switch. All you do is hit return and it goes away. Very easy to tolerate for the pleasure of using the World's Greatest Editor (tm). :)- C/ (p.s., I'm prone to using gnumake with VC upon occasion as well; no problemo). From pointal at lure.u-psud.fr Thu May 18 05:01:54 2000 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Thu, 18 May 2000 09:01:54 GMT Subject: Q? Calling nearest inherited method References: <392295a8.3800058174@news.u-psud.fr> <3923112C.4758A8C0@python.org> Message-ID: <3923af51.3872163586@news.u-psud.fr> On Wed, 17 May 2000 18:37:00 GMT, Guido van Rossum wrote: >: There's a better way. (I believe Jeremy Hylton first suggested this; he saw >: it as an idiom in another language:) >: >: class C(B): >: super_doit = B.doit >: def doit(self, arg): >: self.super_doit(arg) >: >: This avoids the need to explicitly pass self. Not sure its really better... 1) The lowest problem: you have to define it for each function in each class in the hierarchy to have a clean model. 2) The biggest problem, it can go into infinite recursion... Here is an example of the biggest problem: >>> class A : ... def dothis(self) : ... print "In A.dothis." ... >>> class B(A) : ... super_dothis = A.dothis ... >>> class C(B) : ... super_dothis = B.dothis ... def dothis(self) : ... print "In C.dothis." ... self.super_dothis() ... >>> c=C() >>> c.dothis() In C.dothis. In A.dothis. [Until here, its well. Now, introduce a new D subclass, and as we have done for B, implement the super_dothis...] >>> class D(C) : ... super_dothis = C.dothis ... def hello(self) : ... self.dothis() ... >>> d=D() >>> d.hello() In C.dothis. In C.dothis. In C.dothis. In C.dothis. In C.dothis. In C.dothis. In C.dothis. ... [here hitting ctrl-C] So I will still with the .(self...) usage which works. Thanks. A+ Laurent. --- Laurent POINTAL - CNRS/LURE - Service Informatique Experiences Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 email : pointal at lure.u-psud.fr ou lpointal at planete.net From neelk at cswcasa.com Mon May 22 09:07:07 2000 From: neelk at cswcasa.com (neelk at cswcasa.com) Date: Mon, 22 May 2000 09:07:07 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) Message-ID: Before I move to the body of my response I'd like to apologize -- when I reread my original message the tone came across as much more hostile than I intended; this is a subject that seems to come up every few weeks and swallow the newsgroup whole, and I'm afraid I took out some of my frustrations on you. Sorry. Basically, there are so many more fundamental changes being discussed -- such as true garbage collection, type/class unification, lexical scoping, rich comparisons, strong typing, a new iteration protocol -- that I'm amazed and a little dismayed that something as relatively trivial as case-sensitivity is dominating the discussion. I mean, in a year or two it'll be tried out in IDLE, people will stare at it, and then someone will point out there are a hundred thousand Python programmers with 25 million lines of Python code that will be broken by such a change, and then the idea will be dropped. It doesn't matter whether the idea is objectively good or bad (I think it's a very good idea); Python will have grown so much that the threshold for justifiable backwards-incompatible change will have risen above the benefit it will provide. I hope (but fear that I'm wrong) that the same is not true of the iteration protocol -- there's a critical need to be able to iterate over trees and linked-lists cleanly. This is IMO more significant than GC or even type-class unification, and it's the major reason I'm rooting for Stackless, since it permits Sather-style coroutine-based iterators to be implemented in Python. Fran?ois Pinard [mailto:pinard at iro.umontreal.ca] wrote: > neelk at brick.cswv.com (Neel Krishnaswami) ?crit: > > > Suspicions are most easily dispelled/confirmed via evidence > > The evidence of one is not necessarily the evidence of the > other. I'm grown up enough to know that :-). Some evidences > are also more credible :-). > > > and taking the trouble to do this has the pleasant side-effect > > that you can either cease expending effort worrying, or move > > directly to taking positive action to correct the problem. > > I'm not sure I understand you fully. My overall feeling is > that our goal, here, is more about _not_ correcting a false > problem, than having to take positive action for correcting a > problem which might not have to be. -- Neel Krishnaswami neelk at cswcasa.com From ansible at typhoon.xnet.com Tue May 23 15:58:12 2000 From: ansible at typhoon.xnet.com (James Graves) Date: 23 May 2000 19:58:12 GMT Subject: Sharpening comparative concepts (was: Java vs Python) References: <18CD0C3E9F8D621D.066D4CC984A07877.88E0A688930DFD0D@lp.airnews.net> Message-ID: <8gensk$obd$1@flood.xnet.com> Cameron Laird wrote: >Python has genericity built-in--right? Is >that exactly the point here, or is there some- >thing more or less to it? Well, since you don't have static type checking, you don't need genericity. The concept doesn't even apply to Python, which is dynamically typed. Static typing can catch many programing errors at compile time. Dynamic typing can only catch errors at run time. Java is statically typed, though it lacks genericity. Of course, you can get around that by casting. But if you do it much, you're back in the dynamically-typed boat. In my opinion, you're better off just sticking with Python. Or if you really want static typing done well, go with something like Eiffel (good multiple-inheritance, genericity, data-hiding, Design-by-Contract). Have fun, James Graves -- ____________________________________________________________________________ Free Speech Under Attack in the UK: http://www.liberty.org.uk/cacib/ From trentm at activestate.com Tue May 9 14:39:48 2000 From: trentm at activestate.com (Trent Mick) Date: Tue, 9 May 2000 11:39:48 -0700 Subject: Python on 64 bit/IA-64 ... In-Reply-To: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> References: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> Message-ID: <20000509113948.A21443@activestate.com> On Tue, May 09, 2000 at 02:19:16PM +0530, Shiv Shankar Ramakrishnan wrote: > Hi, > Has there been any work done to make Python take advantage of a full 64 > bit environment? More specifically is anyone working on an Intel IA-64 > port of Python? > A bunch of people. ActiveState (mainly me) is working on porting Python to IA-64. (You can find a couple of press releases on our website) This means porting it to the quirky data models (LP64 or LLP64) and C libraries and compilers of the various OSes and vendors. Mark Favas (I hope he doesn't mind me mentioning him) has had success compiling and running Python on TruUnix64 (sp?). Python has worked for a long time on 64-bit systems not on IA-64, e.g. on Alpha machines. > In particular if one were to change the sources for this then which data > model would one follow - LP64 or LLP64 (P64)? Which model have people > used for existing 64 bit platforms if they did a port? > The data model is chosen by the compiler/C library, not by Python. So on trillian (64-bit linux) and on any 64-bit UNIX adhering to the Single Unix Specification Python follows the LP64 data model. On Win64, Python will follow the LLP64 (or P64, same thing different name) data model. It is a little bit of a pain to have the different data models to deal with but that is what keeps us compsci people in business right? :) > AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited > precision (emulation). Floating points are m/c dependent but mostly > doubles. A PyInt is defined to be a C long. A PyFloat is a C double. > > So this is what I think might be good for IA-64 - > > Pointers - All 64 bit. > Int - 64 bit. > Long - As it is now. > Floating Point - double (As now) or should it be long double? > Because Python choses to tie its PyInt to a C long, the actual size of a PyInt depends on the data model for the platform on which Python is running. I am not a big numerical analysis guy so I don't know about changing PyFloat to be a long double. That is Guido's decision, although I wouldn't bet on that changing. > Any comments? Also any general advice on doing a 64 bit port of Python. > Things to watch out for? Pitfalls etc ... Note that the code for the 64-bit ports of Python is the same code for Python on any other system, i.e. that main Python CVS repository (see http://www.python.org/download/cvs.html) General advice: Play with compiling Python on your 64-bit system of choice. If you encounter bugs then raise the alarm and submit patches (see http://www.python.org/patches/)! Here are some links: http://developer.intel.com/update/archive/issue23/stories/top1.htm http://www.unix-systems.org/version2/whatsnew/ http://www.devresource.hp.com/STK/64datamodel.html http://www.unix-systems.org/version2/whatsnew/login_64bit.html Ciao, Trent -- Trent Mick trentm at activestate.com From gregb at krakatoa.mpce.mq.edu.au Sat May 13 21:57:35 2000 From: gregb at krakatoa.mpce.mq.edu.au (Gregory Baker) Date: 14 May 2000 11:57:35 +1000 Subject: Win32 Registry Access References: Message-ID: no at spam.net (Tom Vrankar) writes: > Attached is a script I've recently written to queue Palm OS database files for > installation at the next HotSync. It makes several references to the win32 > extensions you can download from www.python.org. Look for win32all: there's > not much documentation, but this example _plus_ the help files may be get you > where you need to go. > > > BTW: I hear that python1.6 will have some sort of registry access as part of > the standard distribution. (Wonder if it'll provide some sort of transparent > support on Unix platforms?) > Thanks a lot for that. I'll try both torturing your script and the 1.6 alphas. Greg Baker From Kevin.Digweed at dial.pipex.com Fri May 19 12:21:28 2000 From: Kevin.Digweed at dial.pipex.com (Kevin Digweed) Date: Fri, 19 May 2000 17:21:28 +0100 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newshost.accu.uu.nl> <8g23sm$pe0$1@newshost.accu.uu.nl> Message-ID: <39256A08.C77804B0@dial.pipex.com> FWIW: string.glue(sequence) (or string.bind(sequence)) result = ' '.glue(['hello', 'world']) result = ' '.bind(['hello', 'world']) string.separated(sequence): comma = ',' values = ['hello', 'world'] result = comma.separated(values) fields = [name, '*', comment, home_directory, shell ] return ':'.separated(fields) From darcy at vex.net Thu May 25 09:30:52 2000 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 25 May 2000 13:30:52 GMT Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <8gdosh$l78$1@newshost.accu.uu.nl> <392b05f6@pink.one.net.au> <8gf3ms$jce$2@newshost.accu.uu.nl> <392b1f96$0$2624@news01.syd.optusnet.com.au> Message-ID: <8gj9uc$2j3f$1@news.tht.net> Jeff Massung wrote: > Arnold de Vos wrote in message >>Yep. As pointed out on this group from time to time, import from * can be >>harmful. > I'm new to Python - I'm understand why it is harmful (finally ;) - but was > wondering, if it is that harmful, why have it to being with (what good can > come from using it)? I find it useful in module writing. I will often have a module that imports other modules, either my own or system ones, and I want to avoid the extra layers of reference. For example, let's say I was writing a module and I wanted the stat constants to be available through it. I don't want to have to name each constant (what if a new one gets added later?) and I dont' want the user of the module to have to do something like mymodule.stat.S_ISDIR so I import * from stat after checking carefully that it doesn't clash with my own module. Now the above is mymodule.S_ISDIR. The user is still safe but he doesn't have to know what I imported. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From simon3422 at my-deja.com Fri May 12 09:16:33 2000 From: simon3422 at my-deja.com (simon3422 at my-deja.com) Date: Fri, 12 May 2000 13:16:33 GMT Subject: Convert Latin-1 to UTF-8 Message-ID: <8fh072$rd9$1@nnrp1.deja.com> Anybody who knows if there is a function in Python for converting Latin-1 to UTF-8? Sent via Deja.com http://www.deja.com/ Before you buy. From robin at jessikat.demon.co.uk Sat May 13 04:19:21 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sat, 13 May 2000 09:19:21 +0100 Subject: really silly nit: why 3+5j instead of 3+5i? References: Message-ID: In article , Jeff Petkau writes >Can anyone tell me why Python uses 'j' instead of 'i' for imaginary >numbers? I know this is really minor, but every bloody time I >use complex numbers I forget and type i's, and have to go back >and change them all to j's. My fingers just won't learn. > >[History of imaginary number notation, according to Google: Euler >invented the things, and he used 'i'. Gauss made 'em famous, and >he used 'i'. Everyone since then has used 'i' except for electrical >engineers, and they probably just changed it to cause trouble. So >why does Python use 'j'?] > >--Jeff ... as an electrical engineer I should point out that we use i and I for current so the j is to avoid confusion. -- Robin Becker From effbot at telia.com Thu May 18 13:01:53 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 18 May 2000 17:01:53 GMT Subject: Python AND (not vs.) Perl References: <3.0.6.32.20000517234308.008189a0@earthlink.net> Message-ID: <5mVU4.4656$wYl.204818944@newsb.telia.net> Robert Citek wrote: > I have seen a lot of discussion about Python vs Perl as well as discussion > on Python and C, C++, Java, VBA, etc. So I was wondering if Python can use > any of the existing Perl modules or classes? And can Perl use Python > modules or classes? Any pointers in the right direction appreciated. http://mini.net/pub/ts2/minotaur.html From zorro at zipzap.ch Mon May 8 08:57:58 2000 From: zorro at zipzap.ch (Boris Borcic) Date: Mon, 08 May 2000 14:57:58 +0200 Subject: OT: Unicode Unification Objections References: Message-ID: <3916B9D6.3ADE4559@zipzap.ch> Dennis E. Hamilton wrote: > > When subject matter experts from important language and cultural groups > suggest that a unification in Unicode is objectionable, I think one > should listen more carefully, even if it involves something that is hard > to make sense of from within *our* cultural and language illusion. Maybe we will end up discovering that unifying character sets by embedding them unequivocally in a universal superset, suffers from the same type of problem than the quest for a complete and consistent axiom system. If so, the best that could occur is to be quickly confronted with a language whose character set is self-mapped by a duality, like the terms of projective geometry. That way we'd learn to think in terms of mappings rather than universal sets. -- sorry, just thinking aloud. BB From rwallace at esatclear.ie Tue May 23 17:13:20 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Tue, 23 May 2000 22:13:20 +0100 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8g7t5c$1i7i$1@thoth.cts.com> <3ditw5xk7u.fsf@amarok.cnri.reston.va.us> Message-ID: <392AF470.6FB3@esatclear.ie> Andrew M. Kuchling wrote: > > bwinton at tor.dhs.org (Blake Winton) writes: > > Speaking as someone who had to use Modula-3, Ugh! > > (Modula 3's largest mis-feature, for me at least, was that all keywords > > had to be typed in ALL-UPPERCASE. My little finger got really sore > > after four months of programming. :P) > > I always liked that feature. Since I usually programmed on a plain > console (still do), there weren't many options for syntax > highlighting. Writing all the keywords in uppercase made program > structure, as opposed to lowercase variable names, leap out at you. > Syntax colouring without colour, in a way. I remember hating that when doing Modula-2 in college. To me, the important things are my identifiers, the keywords are plumbing (especially with a Pascal-family language that uses so damn many of the things), so shouting the plumbing at me while hiding the important stuff is the worst possible combination. (I'd have kept Caps Lock on and at least got equal status for everything, but that wasn't the style the lecturers used so they'd probably have marked me down for it.) Jack-Sprat-would-eat-no-fat-ly-y'rs, -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From arta at x-stream.nl Thu May 11 13:39:52 2000 From: arta at x-stream.nl (A[r]TA) Date: Thu, 11 May 2000 19:39:52 +0200 Subject: ports with select.select() ??? Message-ID: Hi, How can I read or write a PORT? With sockets without the IP, so the local ports.. I thought I can fix this with select.select and fileno() but can someone help me a bit?? A[r]TA -- We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time. - T. S. Eliot From info at info.com Sun May 28 11:47:37 2000 From: info at info.com (info at info.com) Date: 28 May 2000 08:47:37 -0700 Subject: Questions on computers? Message-ID: <483D23B6.1CDEB18A.ce4cafdb7c20344be981250f286bbfb7@info.com> Locate now: Computer equip Software accessories Games At: http://www.locate-now.com/adcomp1.htm From rwcitek at uci.edu Thu May 18 02:43:08 2000 From: rwcitek at uci.edu (Robert Citek) Date: Wed, 17 May 2000 23:43:08 -0700 Subject: Python AND (not vs.) Perl In-Reply-To: <3_LU4.2949$86.52249@news2-win.server.ntlworld.com> Message-ID: <3.0.6.32.20000517234308.008189a0@earthlink.net> I have seen a lot of discussion about Python vs Perl as well as discussion on Python and C, C++, Java, VBA, etc. So I was wondering if Python can use any of the existing Perl modules or classes? And can Perl use Python modules or classes? Any pointers in the right direction appreciated. Just wondering, - Robert From aahz at netcom.com Fri May 26 09:53:22 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 May 2000 13:53:22 GMT Subject: Iterating over a dictionary's sorted keys References: <392ca730.81985398@news.nikoma.de> Message-ID: <8glvki$1sp$1@slb7.atl.mindspring.net> In article , Alan Daniels wrote: > >The ability to do: > > for k in blah.keys().sort(): > print k > >rather than: > > keys = blah.keys() > keys.sort() > for k in keys: > print k > >is only thwarted by the fact that the "sort()" method of a list >inexplicably returns a None. I truly wish that more methods returned a >reference to "self". After all, when you sort a list, don't you get a >new list, maybe not in implementation, but philisophically? Or when >you reverse it? Sure, its the same *object*, but its been changed. I >don't think returning a reference to itself would do any harm. Actually, it's *precisely* the case that Guido disagrees with your philosophical position. It was a design decision to consider [].sort() and [].reverse() to work on the original list because the programmer should *always* explicitly request a copy of what may be a 100K element list. sort() and reverse() return None to force you to remember that. (This is my paraphrase of what Guido has said publicly; any errors are mine.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Yes, but would you kick any of them out of bed?" "That depends: do we have to do anything with them in the bed, or are they just in the bed?" -- AM/SJM From ben at co.and.co Tue May 9 08:58:26 2000 From: ben at co.and.co (ben at co.and.co) Date: Tue, 09 May 2000 12:58:26 GMT Subject: wierd error after if or while References: <8f90uq$u4v$1@nnrp1.deja.com> Message-ID: nick_knight at my-deja.com wrote: > I am a newbie - in fact I just downloaded it today, and so far it looks > like a very useful language. The only problem is I seem to be doing > something stupid. If I run the folloing bit of code > > x = 4 > > if x==4: > print "hello" > > I get the following error message > > File "", line 2 > print "hello", > ^ > > This seems perfectly legal to me - am I missing something or has the > install gone wrong perhaps. Read the tutorial: http://www.python.org/doc/current/tut/node5.html Scroll down till "3.2. First Steps Towards Programming" Read the paragraph at the third bullet, and start screaming and cursing for 5 minutes. Afterwards, you'll be perfectly happy for the rest of your python-programming life. Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From sabren at manifestation.com Tue May 2 10:38:53 2000 From: sabren at manifestation.com (Michal Wallace (sabren)) Date: Tue, 2 May 2000 10:38:53 -0400 (EDT) Subject: [ANNOUNCE] Ransacker extendable search engine In-Reply-To: <20000502071746.A28061@sz-sb.de> Message-ID: On Tue, 2 May 2000, Andreas Jung wrote: > > Ransacker is a scriptable, incrementally-double-indexed search engine > > written in python. > > Did you make any benchmarks ? Can it handle 1GB data and more ? :-) Hmm... Size of the index isn't in my test cases. It currently uses a pair of DBM files, so the limit is whatever their limits are.. But really I have no idea. I started developing it for a system that use a lot of small indexes. What i'm planning to do is break it into two pieces: an Index class and a SearchEngine class... So if the current implementation doesn't support 1GB+ of data, the Index half can be replaced with something more powerful, perhaps written in C... Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From guido at python.org Thu May 18 10:48:31 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 18 May 2000 14:48:31 GMT Subject: Python multiplexing is too hard (was: Network statistics program) References: <92F3F78F2E523B81.794E00EE6EFC8B37.2D5DBFEF2B39A7A2@lp.airnews.net> Message-ID: <39242D1B.78773AA2@python.org> Cameron Laird wrote: > . > Right. asyncore is nice--but restricted to socket > connections. For many applications, that's not a > restriction at all. However, it'd be nice to have > such a handy interface for communication with > same-host processes; that's why I mentioned popen*(). > Does no one else perceive a gap there, in convenient > asynchronous piped IPC? Do folks just fall back on > select() for this case? Hm, really? For same-host processes, threads would do the job nicely I'd say. Or you could probably use unix domain sockets (popen only really works on Unix, so that's not much of a restriction). Also note that often this is needed in the context of a GUI app; there something integrated in the GUI main loop is recommended. (E.g. the file events that Moshe mentioned.) -- --Guido van Rossum (home page: http://www.python.org/~guido/) From neilh at scintilla.org Mon May 8 02:41:37 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 08 May 2000 06:41:37 GMT Subject: PythonWin win32all-131 editor crash References: <39162102.611545@news.btx.dtag.de> Message-ID: > I get a reproducable segfault in the PythonWin editor (win32all-131 / > Python 1.6a2) both on a Win98 and NT4 box whenever I have a source > file large enough (~70kB) and hit the ^ key (requires two keystrokes > on my german keyboard: ^ and space). There was a problem with the folding code when a file was longer than about 4000 lines but that was fixed before the version that went out with 131. It could be caused by some incomplete Unicode handling in 131 which may have some parameter issues. The OS traps messages between narrow character and wide character windows and does some unpleasant parameter munging so newer versions of Scintilla have returned to a narrow character window. I haven't been able to reproduce this on W2K or NT4 even with a German locale. It is interesting that it is a non-spacing accent that causes the problem. Does ^o creating '?' blow up? Does the same thing occur in an English locale? Neil From Shiv at pspl.co.in Tue May 9 04:49:16 2000 From: Shiv at pspl.co.in (Shiv Shankar Ramakrishnan) Date: Tue, 9 May 2000 14:19:16 +0530 Subject: Python on 64 bit/IA-64 ... Message-ID: <002c01bfb993$75169ad0$8d02a8c0@intranet.pspl.co.in> Hi, Has there been any work done to make Python take advantage of a full 64 bit environment? More specifically is anyone working on an Intel IA-64 port of Python? In particular if one were to change the sources for this then which data model would one follow - LP64 or LLP64 (P64)? Which model have people used for existing 64 bit platforms if they did a port? AFAIK Python Int is now mapped to a 32 bit int and Long is unlimited precision (emulation). Floating points are m/c dependent but mostly doubles. So this is what I think might be good for IA-64 - Pointers - All 64 bit. Int - 64 bit. Long - As it is now. Floating Point - double (As now) or should it be long double? Making floating points long double will get better precision but then the results might differ from the double based ones. Any comments? Also any general advice on doing a 64 bit port of Python. Things to watch out for? Pitfalls etc ... Please note that I am not making any promises about an IA-64 port as of now :-) Thanks, Shiv P.S. If you something significant to say please cc a copy to me by E-mail also. From brent.fulgham at xpsystems.com Tue May 2 18:35:42 2000 From: brent.fulgham at xpsystems.com (Brent Fulgham) Date: Tue, 2 May 2000 15:35:42 -0700 Subject: Stackless/microthreads merge news Message-ID: > [Christian Tismer] > > Hey, this is just an incredible idea. > > Java with first class continuations, let that > > drop through your brains. 90 percent of java threads > > would be replaced by microthreads. > > > > I will read the Kaffe source and think how this must be. > > Please try to modify the Blackdown JVM rather than Kaffe - > it's faster and ... well ... it actually works ... and it's > Sun supported ... and stuff ... > I would advise against touching the Blackdown code. Sun has not released its source code under a "Free" license, and any activities related to this code are both non-free, and potentially corrupting of your ability to produce any "clean-room" code. Help make Kaffe better, rather than waste time with Sun's code. Regards, -Brent From alvaro at ocse.infonegocio.com Wed May 10 03:44:48 2000 From: alvaro at ocse.infonegocio.com (AMR) Date: Wed, 10 May 2000 09:44:48 +0200 Subject: Converting to a base 2, References: Message-ID: <8fb3jq$mde3@esiami.tsai.es> Yes Warren, I feel I didn't expressed very well, I want to convert as you say to a base 2. I only want to know the module I have to import and the function, I tried with this and... of course run, x = binstr(42) y = string.atoi(x,2) print x print y Thanks to all, -- Alvaro Mart?nez Optichrome Computer Systems Espa?a, S.A. Tel. (+34) 917 242 670 Fax. (+34) 917 130 360 alvaro at ocse.infonegocio.com http://www.optichrome.com "Warren Postma" escribi? en el mensaje news:slXR4.17758$HG1.457019 at nnrp1.uunet.ca... > > > > struct.pack( 'i', yourinteger ) > > > > Enjoy, > > Mike > > Interesting how ambiguous "convert to binary is". I assumed he meant "print > an integer variable as a base-2 (binary) string representation". ;-) > > Warren > > From mwh21 at cam.ac.uk Mon May 8 12:57:41 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 08 May 2000 17:57:41 +0100 Subject: __len__ and boolean values - small language change References: <8f6qm0$glb$1@nnrp1.deja.com> Message-ID: Andrew Cooke writes: [snip] > Is there a special method that I can override to provide boolean values > in tests, or is __len__ called directly? You want __nonzero__: >>> class L: ... def __nonzero__(self): return 0 ... def __len__(self): return 1 ... >>> if L(): print 1 ... and: http://www.python.org/doc/current/ref/sequence-types.html#l2h-16 HTH, Michael -- ... but I guess there are some things that are so gross you just have to forget, or it'll destroy something within you. perl is the first such thing I have known. -- Erik Naggum, comp.lang.lisp From quinn at seniti.ugcs.caltech.edu Wed May 10 22:13:48 2000 From: quinn at seniti.ugcs.caltech.edu (Quinn Dunkan) Date: 11 May 2000 02:13:48 GMT Subject: HELP! Simple question re: dictionaries References: <3919D605.3CF9846@fenx.com> Message-ID: On Wed, 10 May 2000 14:35:01 -0700, emile at fenx.com wrote: >Refer to key and value as key and value. Each loop returns >a key value pair. If the for loop was: > >for k,v in my_dict.values(): values() returns (surprise!) just the values of the dict. I think you meant items() which returns both the keys and the values: for key, value in my_dict.items(): print key, value I think what the person below was after is the common python idiom: for k in my_dict.keys(): print my_dict[k] my_dict[k] = my_dict[k] + 1 # etc. >> 1. For the example below, how would I refer to JUST the key, value >> referred to in the iteration of the for loop? >> >> for key,value in argumentList.items(): >> print ? >> >> 2. Additionally, you can access a certain element of a list by using >> a numerical subscript (like [1] - like an array). If, let's say, >> there's one key & corresponding value in a dictionary, then how would >> I reference that value - to let's say - print it out? >> >> Finally... if you know of a website that I could visit to get the >> specs of syntax, please let me know (so I can stop asking these simple >> questions!). www.python.org, go to Documentation, then to Tutorial From hamish_lawson at yahoo.co.uk Wed May 31 07:41:11 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Wed, 31 May 2000 04:41:11 -0700 Subject: *blink* That's neat. References: <8h07fv$bnc$3@newshost.accu.uu.nl> <8h0ne2$70i$2@newshost.accu.uu.nl> <3934A8F5.520B858C@prescod.net> Message-ID: <0120b6e9.c1ed9f1e@usw-ex0101-005.remarq.com> Paul Prescod wrote: > I think that "orelse" gives a better feeling of proceeding > from one test to another. The corresponding replacement for > "and" is "andalso". I think that these names also give a hint > of the short-circuiting nature of the operators... Ada has 'or else' and 'and then' as short-circuit versions of 'or' and 'and'. Hamish Lawson * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From sbrunning at trisystems.co.uk Tue May 16 06:20:35 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 16 May 2000 11:20:35 +0100 Subject: Downloadable Tkinter documentation Message-ID: <34575A892FF6D1118F5800600846864D2A3F94@intrepid> Is there somewhere that I can download some introductory Tkinter documentation. The stuff at Pythonware () is great for viewing online, but I can't find any way of downloading it en-masse, so it's no good for reading on the tube... -- Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From ralf.claus at t-online.de Fri May 26 14:56:04 2000 From: ralf.claus at t-online.de (Ralf Claus) Date: Fri, 26 May 2000 20:56:04 +0200 Subject: global or not global? Message-ID: <8gmhe4$1m5$11$1@news.t-online.com> Hello, i need a little help :-) class any(): def what(): def this(): def unknown(): How can i define a variable, they could change in all this functions? And all functions must be read this variable! thanks Ralf From bn at 7ways.com Tue May 16 16:39:20 2000 From: bn at 7ways.com (Bernard Niset) Date: Tue, 16 May 2000 22:39:20 +0200 Subject: Compiled version when .cgi extension is used for scripts References: <8frtjc$1fpn$1@news4.isdnet.net> <20000516214847.Y13281@xs4all.nl> Message-ID: <8fsbtm$1qt$1@news3.isdnet.net> "Thomas Wouters" wrote in message news:20000516214847.Y13281 at xs4all.nl... > On Tue, May 16, 2000 at 06:34:53PM +0200, Bernard Niset wrote: > > > Our site is using python extensively and very succesfully. The only thing > > is that I decided to name the cgis script with an extension in .cgi > > instead of .py. The drawback of this decision is that no compiled version > > is generated when a script is executed meaning that it needs a > > recompilation on each execution. > > Scripts (the first file you start) are never stored in compiled form. Only > modules you load (files you load with 'import') are stored, always as > '.pyc'. If you want to benifit from this, make your script as lightweight as > possible, putting all or most functionality in a separate module. > I know, pretty much of the functionnality is in .py module that is used as a library through out the website. > Note that your script would have to be fairly lengthy before you to actually > notice the difference between the two versions. I know but it is still useless to to a compilation each time. > > > How can I generate a compiled version of the scripts and how should I name > > them in order for the interpreter to take them into account. > > Unfortunately, compiled python scripts need to have the .pyc (or .pyo) > extention for the interpreter to see them as such... If they have any other > name, the python interpreter tries to interpret them as normal scripts > instead. I'm not really sure why, but I guess the variance in bytecode > versions is too great to make the python interpreter autodetect them... I > think it would be neat if it could, though. When the script is named differently from .py, the interpreter could use scheme like original_name.ext.pyc. > > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! > Thanks by the way. From rockdw at bigfoot.com Fri May 19 21:03:06 2000 From: rockdw at bigfoot.com (David Rock) Date: Fri, 19 May 2000 20:03:06 -0500 Subject: CGI Authentication form passthrough question References: <3C1077AC64755A57.0FB8B24AA3155646.CE4465C98A055096@lp.airnews.net> Message-ID: <3925E44A.33B90279@bigfoot.com> Hi all, I am trying to write a CGI script to check authentication for a website, but I have a problem. Right now, I can take form input for the original username/password combination just fine. I also have no problem checking the input for validity. The problem is that when I verify the user, I want to allow them to see the resulting HTML for the rest of their session, not just the first round of HTML right afterward. Here's an example: user goes to www.foo.com/cgi-bin/protected-site.py which displays a simple form for un/pw input. form submission verifies un/pw and displays new HTML that is also an input form. I currently have this set up <-- here's the problem. How do I make this form submission and all subsequent submissions display based on a verified un/pw? Right now, all someone would have to do is remember the URL after the login stuff and they wouldn't need to worry about it. (I thought of using if __name__ == '__main__' to verify that the cgi being accessed by the form is not the main process, but sometimes it should be) Couple ideas I had were: 1. Initial login starts a parent/child process where the parent keeps track of the authentication for the child (cool, but how? As soon as the next form activates a cgi script, the new cgi has no relationship to the original parent process) 2. Write a file with a random key value that gets passed along as a hidden item in a form. When the form runs the next cgi script, it looks for the key value in the file and compares the two. Since this would be a date-based seed, the key would always be different (but how do you know when to get rid of the key file? The process would be dead as soon as the HTML is generated) Thanks for any ideas -Rock rockdw at bigfoot.com From thomas at cintra.no Thu May 4 08:41:21 2000 From: thomas at cintra.no (‘5ŰHH575-UAZWKVVP-7H2H48V3) Date: Thu, 04 May 2000 12:41:21 GMT Subject: Map lots of words to lots of integers Message-ID: <39176ae0.613278087@news.online.no> Hi, I need a fast way of mapping words to integers. A single word must be able to point to many, *many*, integers. Tried stuff like a dict, words as keys, pointing to a list of integers. This is all fine and nice if the thing is located in memory. I want to (or need ) to store all of this on disk. And the method must be fast. Thought I could use a Berkley DB file using words as keys, but what should they point to? The number of words can of course be thousands and the integers they point to even more. Does Zopes internals like ZODB etc. offer anything I could use? What I`ve tried so far is to make a general indexing-module, where you do something like x = Indexer('data_file.db') # extract words from documents etc. x.add(word2index, id) etc. etc. x.index() print x.locate('python') [432,6363,326,65464,6544,456465465,65433,76] # of course this would be # HUGE and may not fit into a list What I`d really need is to store several integers as one key/id, ex. as a tuple, but I`ll settle for less if somebody just could give me some pointers. NOTE! The number of words are as many as there are eh ... words, and integers, well, how far can a human count? Thanks. Thomas From mhammond at skippinet.com.au Wed May 24 00:17:11 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 24 May 2000 04:17:11 GMT Subject: Python and COM servers References: <392ACFB4.213143D4@icyb.kiev.ua> Message-ID: There is no decent documentation, and there are no simple example. The simplest example is probably the "internet" extension (that doesnt use SWIG), or probably the new ADSI interface for one that does. The best docs are probably my previous postings in this newsgroup - some going back quite some time. Mark. "Alexander V. Kirsanov" wrote in message news:392ACFB4.213143D4 at icyb.kiev.ua... > Hi! > > Is there documentation about writing Python COM servers with objects > having several user defined vtable based interfaces? > I've read that to provide vtable based interface there should be C++ > support for the interface. Is there a simple example implementing such > C++ support? > > Thanks, > Alexander Kirsanov > From glyph at twistedmatrix.com Thu May 18 20:46:06 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 18 May 2000 19:46:06 -0500 Subject: No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:) In-Reply-To: m.faassen@vet.uu.nl's message of "18 May 2000 11:43:13 GMT" References: <391A3FD4.25C87CB4@san.rr.com> <8fe76b$684$1@newshost.accu.uu.nl> <8fh9ki$51h$1@slb3.atl.mindspring.net> <8fk4mh$i4$1@kopp.stud.ntnu.no> <8g0l0h$gd2$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > I sit on the chair . > chair.sit() Hmm. This is not the way I think of it. I would never say chair.sit() ... more like, "Bob, sit on the chair." bob.sit(chair) After all, who's doing the work here; bob, or the chair? > Similarly: > > I append to the list I tend not to think of things as so person-focused ;-). *I* will append nothing to the list; I am merely telling the list what it shall do. I plan to be somewhere else entirely when this program is running. > list.append() So what "list.append(element)" says to me is, "List, append element. (to yourself, of course)" > I draw on a paper with a blue color > > paper.draw(color='blue') This doesn't make sense either. For me it would be: pen.paper=paper pen.draw(color='blue') "Pen, you're going to be drawing on that piece of paper. Draw in blue." > In the case of 'foo'.join() this stops making sense: > > I join the list of strings with spaces. > > ' '.join(list) > In this case, it feels obvious to us that the *list* is the big target, > and the space is what we're joining with. We don't think: [snip] Finally, this makes sense to me, becuase what I'm saying is; "' ' (which we all know to be a string), join list together". Being a programming language, "tell me what the result is" is implicit =). > lots-of-instinctive-language-analysis-ly yours, my-intuition-is-nonintuitive-ly y'rs, -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From greg at cosc.canterbury.ac.nz Tue May 23 22:39:44 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 24 May 2000 14:39:44 +1200 Subject: case sensitivity and XML References: <20000523113250.A2150232@vislab.epa.gov> <7LxW4.9151$Za1.142121@newsc.telia.net> Message-ID: <392B40F0.324E0189@cosc.canterbury.ac.nz> Fredrik Lundh wrote: > > so why not enforce these rules, just like we're enforcing the > indentation rules: > > >>> class foo: > SyntaxError: Class name should be Foo There are some precedents for this. Smalltalk requires global variable names to start with a capital. HUGS distinguishes type names from other names by whether they start with a capital. Some Eiffel compilers chide you if you don't spell class names in ALLUPPERCASE and other names in alllowercase. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From embed at geocities.com Thu May 4 10:40:56 2000 From: embed at geocities.com (Warren Postma) Date: Thu, 4 May 2000 10:40:56 -0400 Subject: Map lots of words to lots of integers References: <39176ae0.613278087@news.online.no> <39188472.619823849@news.online.no> Message-ID: > In my application I need to make an intersection of several lists > returned from lookups in the database, so if they`re all huge I might > run out of memory. > > I`m indexing files on cd-roms and the number of ids can be up into the > millions. > That's what a bigger PC is for. More memory, fast hard disk, virtual memory, and basically prototype along until you hit a bottleneck then optimize around it. That's python for you. Don't worry. Code first, and 'plan to throw one away, you will anyways'. Warren From pinard at iro.umontreal.ca Mon May 22 13:36:27 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 May 2000 13:36:27 -0400 Subject: Decimals -> Fraction strings, my solution In-Reply-To: ullrich@math.okstate.edu's message of "Thu, 18 May 2000 18:09:50 GMT" References: <3922bbbb.59529999@client.ce.news.psi.net> <3922E238.29CEDE3B@stud.ntnu.no> <39242f0a.1044508290@news> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) writes: > def gcd(a, b): > while a: > a, b = b % a, a > return b By the way, I think the above could be better written: def gcd(a, b): while b: a, b = b, a % b return a It does not change much, and I'm not even sure exactly why, but I find it more legible. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Sun May 28 23:51:26 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 28 May 2000 23:51:26 -0400 Subject: ANNOUNCE: Python CVS tree moved to SourceForge In-Reply-To: Grant Griffin's message of "Fri, 26 May 2000 23:14:10 +0100" References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> <0AlW4.111443$MB.2189764@news6.giganews.com> <392A10A8.99B10484@yale.edu> <392EF732.1F80@seebelow.org> Message-ID: Grant Griffin writes: > All that notwithstanding, I think the simple fact that many people will > have local copies of the source covers the asteroid-and-earthquake thing. I'm not sure of that. The Python community recently lost a hard disk, and despite its content was publicly available (if I understand things well), it was not easy to recover from others the data it contains. We should not take for granted that the whole of a project (sources, mailing list archives, administrative files, etc.) is replicated by "many" users (if any! :-), and even less that all SourceForge projects are replicated. The backup strategy of SourceForge inspires confidence, at least to me, so my comments, above, are mainly rhetorical. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From zambak! at usa.net Sun May 21 14:53:31 2000 From: zambak! at usa.net (zambak) Date: Sun, 21 May 2000 18:53:31 GMT Subject: Python with thread support????????? Message-ID: Hi I have tried to compile Python --with-thread support but I was unsuccessful...Compile goes fine but linkage fails.... I have tried this on Linux (RedHat 6.2 with gcc) and on AIX (v4.3.3.0 with C for AIX v4.4) with no sucess.... After further investigation I think that python will only work with Sjorg portable C Thread lib.....That's what I read in /Modules/threadmodule.c Now is this true and if it is where can I get this trhead library???????????? Where can I get some info on compiling Python with threads also??? From infonuovo at email.com Sat May 20 11:49:52 2000 From: infonuovo at email.com (Dennis E. Hamilton) Date: Sat, 20 May 2000 08:49:52 -0700 Subject: Decimals to fraction strings In-Reply-To: <65118AEEFF5AD3118E8300508B1248774CB301@ALTNET> Message-ID: OK, I can't help myself. Here's a great example of precision versus accuracy. Early in this thread, someone wrote .6667 and talked about 1/3 being better, and it has stayed that way for several rounds of position sharpening. I suggest that 2/3 would be a *lot* better than that. There's a lesson in here somewhere. -- Dennis -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Mike Steed Sent: Thursday, 18 May 2000 10:00 To: python-list at python.org; python-list at python.org Subject: RE: Decimals to fraction strings > From: jraven at psu.edu [mailto:jraven at psu.edu] > Sent: Thursday, May 18, 2000 10:56 AM > To: python-list at python.org > Subject: Re: Decimals to fraction strings > > > On 17 May 2000 11:56:51 GMT, Mark Jackson > wrote: > >=?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: > >> mjackson at wc.eso.mc.xerox.com (Mark Jackson) writes: > >> > >> Not necessarily. 0.6667 is well approximated by 1:3, for > example, while > >> if you force the denominator to be an exponent of 10, you > will obtain a > >> fraction which is not only uglier, but less precise. > > > >It's only less precise if the intended result was 1/3 rather than > >6667/10000, but if "0.6667" is what you're given there's no way to > >tell. One could introduce an arbitrary tolerance within which a > >"simpler" rational fraction is accepted (as I see you have in the > >renamed thread) but in the end what you've shown is that the original > >poster's approach doesn't always yield the "best" answer to a > >*different* problem. > > > > Well, in keeping with the comp.lang.python tradition of drifting > off-topic, there actually is a sense, due to Dirichlet, in which > 1/3 is a better approximation to 0.6667. [snip] This is all very interesting, but perhaps I am getting lost in the arithmetic. Isn't 1/3 actually closer to 0.3333? The-only-useful(?)-contribution-I-have-ly-y'rs, Mike. -- http://www.python.org/mailman/listinfo/python-list From jkraska1 at san.rr.com Thu May 25 21:12:09 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 26 May 2000 01:12:09 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <8gjg7k$dq0$1@slb1.atl.mindspring.net> <392DBDDF.CB4470EF@san.rr.com> <07jriscbh1gju6bcef732i1js939jps8bq@4ax.com> Message-ID: <392DD013.6E44EFF4@san.rr.com> Ben Wolfson wrote: > > On Thu, 25 May 2000 23:54:29 GMT, Courageous > wrote: > > >"CUM HOC ERGO PROPTER HOC" > > > >It should be educational. > > I think you mean "POST" instead of "CUM". No. C/ From moron at Glue.umd.edu Sun May 21 21:48:38 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 21 May 2000 21:48:38 -0400 Subject: NumPy and FFT References: Message-ID: <8ga3lm$4it@stochastic.eng.umd.edu> Jad sez: > I have a 1D array (say a) which contains real data ... > which function do i have to use in order to get b = FT(a) ? The discrete Fourier transform has no knowledge, or need for it, about your measurement intervals or the frequencies that the length of your sequence implies. You will have to construct the column of frequencies yourself. The function you want to use to do the transform is fft. It might seem, since you have real data, that you want the real_fft function, but it's broken. I've tried to submit a patch, but it produced neither response nor action. I had assumed they were just too busy to deal with it, but maybe I didn't send it to the right place. Perhaps I'll try again. Said patch also included expanded documentation for the fft function, which is as follows: > fft(a, n=None, axis=-1) > > Will return the n point discrete Fourier transform of a. n defaults to > the length of a. If n is larger than a, then a will be zero-padded to > make up the difference. If n is smaller than a, the first n items in a > will be used. > > The packing of the result is "standard": If A = fft(a, n), then A[0] > contains the zero-frequency term, A[1:n/2+1] contains the > positive-frequency terms, and A[n/2+1:] contains the > negative-frequency terms, in order of decreasingly negative > frequency. So for an 8-point transform, the frequencies of the result > are [ 0, 1, 2, 3, 4, -3, -2, -1]. > > This is most efficient for n a power of two. This also stores a cache > of working memory for different sizes of fft's, so you could > theoretically run into memory problems if you call this too many times > with too many different n's. In your case (real data), you can ignore the negative frequency terms. Warren Focke -- If you feel that you have both feet planted on level ground, then the university has failed you. -Robert Goheen, President, Princeton University From moshez at math.huji.ac.il Wed May 24 01:23:26 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 24 May 2000 08:23:26 +0300 (IDT) Subject: Consistent Case: A Simple Linter Message-ID: # Released to the public domain by Moshe Zadka # use like: get_identifiers .... import parser, keyword def get_from_tuple(l, so_far = None): if so_far is None: so_far = [] if l[0] == 1 and not keyword.iskeyword(l[1]): so_far.append(l[1:]) else: for t in l: if type(t) is type(()): get_from_tuple(t, so_far) return so_far def get_from_file(file, res=None): tup = parser.suite(file.read()).totuple(1) return get_from_tuple(tup, res) def by_case(words_by_file): import string res = {} for file, words in words_by_file.items(): for word, lineno in words: lword = string.lower(word) if not res.has_key(lword): res[lword] = [] res[lword].append((lineno, file, word)) return res def get_suspicious(words_by_case): susp = [] for word, cases in words_by_case.items(): c = cases[0][2] for tup in cases[1:]: if tup[2] != c: susp.append(word) break return susp def main(): import sys res = {} for file in sys.argv[1:]: f = open(file) try: res[file] = get_from_file(f) finally: f.close() res = by_case(res) susp = get_suspicious(res) susp.sort() for word in susp: print word, 'is used with incosistent case:' for line, file, case in res[word]: print '\t%(file)s[%(line)d]: %(case)s' % vars() if __name__=='__main__': main() -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From hgg9140 at seanet.com Mon May 29 18:26:10 2000 From: hgg9140 at seanet.com (Harry George) Date: 29 May 2000 15:26:10 -0700 Subject: win95, python, test_socket...crash References: <3932D171.1E4AF5F0@infocentr.ru> Message-ID: Thanks. That was it. Aleksey Kishkin writes: > Harry George wrote: > > > > [I looked in dejanews, but all the socket queries are way beyond where > > I'm stuck.] > > > > I have a win95 machine which is samba'd to a linux box. I'm trying to > > learn to do python on win95 (COM et al). First step is to get it > > running. py152.exe went ok; then win32all-128.exe. python, > > pythonwin, icons in the explorer all ok. Able to edit and run simple > > hello, worlds. > > > > Then in the interpreter I tried: > > import test.autotest > > It ran ok (with lots of skipped optionals), but test_socket crashed > > with socket.error "host not found" > > I had the same error. As far as I understood my computer didn't know > about his name.. ;-) I made the file "c:\windows\hosts" , that > contained one row: > > 128.0.0.1 localhost > > and after reboot all worked fine.. > > > > Of course this could be a non-python win95 setup issue, but with > > tcp/ip running ok (samba, ftp, ping, etc.), I'm wondering if there is > > a python-specific issue. Any ideas? > > > > -- > > Harry George > > hgg9140 at seanet.com > > Alexei Kichkine (http://infocentr.ru/~ax) -- Harry George hgg9140 at seanet.com From matthias_w at my-deja.com Tue May 2 11:30:01 2000 From: matthias_w at my-deja.com (Matthias) Date: Tue, 02 May 2000 15:30:01 GMT Subject: ODBC / DBI help (via Win32 Extensions) References: Message-ID: <8ems91$74b$1@nnrp1.deja.com> Hy Benjamin :-) I don't know too much about Access & SQL, but on date-time fields have usually a format like "YYYY-MM-DD HH:mm:SS" or "YYYY-MM-DD HH:mm:SS.s" s.. stands for fraction of seconds (ms) HTH Matthias In article , junkster at rochester.rr.com wrote: > On Sun, 29 Apr 3900 04:49:53, "S. Hoon Yoon" wrote: > > > I think that's because you should use format #date# on update. Unless, I did > > not understand your problems. > > That's really more of SQL and access convention rather than Python. > > Pls look at the docs for Access and SQL. > > > > UPDATE [BT Dates] SET [BT Dates].[date] = #12/12/2000#; > > > > This is what I get if I use Query wizard and you should follow it. > > Hope it helps, > > The real problem is that I can't find any documentation on the DBI > module... > > The pound convention I found out about... > Unfornately, I don't have my code with me... But...(From memory) > > sql_cmd = """ > INSERT INTO logfile (datetime, loglevel,, logdata) > VALUES ('#12/15/2000#', 1, 'test') > """ > # I've tried 12/15/00, 09/09/99, 09/09/1999, and a few other > # date variants.... > > # And as far as I can tell the ODBC execute command > # appends a semicolon? Or at least everything works > # without having me add one... > > If I attempt to execute that command, I get a SQL error from the ODBC > driver. > > If I remove the datetime field and just submit using the loglevel, > logdata > it works fine... (But that sort of defeats the purpose of a log > file....) > > The datetime field is setup in Access as a standard "Date/Time" > field, so I figure I might need to convert the datetime field into a > dbiDate > record, but as I mentioned I can't find any instructions on the fields > & > methods for the dbiDate field(s).... (I checked the Win 32 > documentation > without any luck). > > - Benjamin > Sent via Deja.com http://www.deja.com/ Before you buy. From shogan at iel.ie Wed May 17 11:10:00 2000 From: shogan at iel.ie (Shaun) Date: Wed, 17 May 2000 16:10:00 +0100 Subject: addvalue, how do i implement the code? Message-ID: <022101bfc011$f89a44e0$2801000a@iel.ie> right lads heres what im trying todo: i make an empty list, (start=[]) what i want to do is then add a name value pair say...('shaun',20) to the empty list, ive got a feeling the code looks somthing like what below but im not sure how to implement it can any of yous help me out on that one? Shaun >>> class addv: def add(self,x,y): print'does not print' def __init__(self,start=[]): self.data=start def __add__(self,other): return addv(self.data, other) >>> addv >>> x=addv.add >>> x >>> x(3,4) Traceback (innermost last): File "", line 1, in ? x(3,4) TypeError: unbound method must be called with class instance 1st argument >>> ===================== Shaun Hogan Interactive Enterprise Ltd. alt. E-mail : shaun_hogan at yahoo.com Phone: +353 86 8342529 The University of Limerick Rollerhockey Club URL: http://rollerhockey.csn.ul.ie From R.Brodie at rl.ac.uk Tue May 23 09:36:07 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Tue, 23 May 2000 14:36:07 +0100 Subject: other python ideas References: <4.3.1.2.20000523010957.01498f40@phear.dementian.com> <392A7F84.A3D5F34A@muc.das-werk.de> Message-ID: <8ge1g8$14o4@newton.cc.rl.ac.uk> "Thomas Thiele" wrote in message news:392A7F84.A3D5F34A at muc.das-werk.de... > function overloading is a goog idea. It's really the only thing I miss in > python. > But then it must be possible to check different data-types (like in C++). > > def foo( (int)a ): > print a, "is a int" > > def foo( (float)a ): > print a, " is a float" It's not so hard to write a dispatch function if that's what you really want: from types import * def overloaded(t): dispatch = { IntType: intFunc, FloatType: floatFunc} if dispatch.has_key(type(t)) : dispatch[type(t)](t) else : defaultFunc(t) From paul at prescod.net Mon May 22 20:42:30 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 22 May 2000 19:42:30 -0500 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> Message-ID: <3929D3F6.DE9CCCBC@prescod.net> > However, I am having trouble imagining how removing case-sensitivity from > the language could improve usablility for any programmer, regardless of > his/her skill level. Most people seem to have no particular trouble with > case-sensitivity in natural languages; If you review the variety of formatting conventions in this list, you'll find that that is not the case. Guido himself documented how people speak of the String and FTPLib modules and python programming language. > why should a computer language be any different? On the other hand, > maybe I am just too ingrained in my old thought patterns. I prefer case sensitivity. But I think that most of the arguments people make in favor of it are bunk. 1. If you spend time with newbies -- especially Windows-trained newbiews -- you will note the case sensitivity is a problem. 2. Code written in a case insensitive language is roughly as robust and readable as that in a case sensitive language. The most honest arguments are "case sensitivity feels cleaner" and that it "is more popular with existing programmers." -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From thiele at muc.das-werk.de Fri May 19 07:29:40 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Fri, 19 May 2000 13:29:40 +0200 Subject: no tupelunpacking Message-ID: <392525A4.4E56FEAD@muc.das-werk.de> What is the best way to do this: def f1( a, b ): ...do something with a und b... def f2(...): ...calculate ret_a, ret_b return ret_a, ret_b ... a, b = f2(...) f1(a ,b) is o.k. (tupelunpacking, I know) but I want to write: f1(f2(...)) The problem happens if you have such a constructor __init__(self, *argv) (Inside __init__ argv is a tupel), and you want to call this constructor from a derived class. class A: def __init__(self, *argv): ... class B(A): def __init__(self, *argv): A.__init__(self, argv) #doesn't work!!!! From effbot at telia.com Sat May 13 15:50:48 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 13 May 2000 19:50:48 GMT Subject: compiling extension errors References: <4ZhT4.5034$WS3.42757@typhoon.we.rr.com> Message-ID: Pete Shinners wrote: > ok, so this is simple creating a new structure to represent > a new type object (right?). When compiling i'm getting this > error. > > "error C2099: initializer is not a constant" > this is happening on the line with PyObject_HEAD_INIT(...) http://www.python.org/doc/FAQ.html#3.24 From tony at lsl.co.uk Thu May 11 07:48:04 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Thu, 11 May 2000 12:48:04 +0100 Subject: Extract links from html-page In-Reply-To: <391a8ea7.100679489@news.online.no> Message-ID: <003401bfbb3e$c447ceb0$f0c809c0@lslp7o.lsl.co.uk> 5[HH575-UAZWKVVP-7H2H48V3 (or so it appears in Outlook ) wrote: > I`d like to extract just the links in a web-page or html-document. It > would be nice if relative links [were expanded] > The result should be a list of links. Hmm. Well, the attached Python script produces a file containing the links, from a file, and it doesn't expand relative links, so you'd need to glue the innards into something else if you also want it to *retrieve* the page first, but that shouldn't be hard to do (and I'm fairly sure there are plenty of "grab that URL" scripts around - I certainly have several variants). -------------- next part -------------- A non-text attachment was scrubbed... Name: anchors.py Type: application/octet-stream Size: 4076 bytes Desc: not available URL: From lcalmbach at datacomm.ch Sat May 6 16:58:06 2000 From: lcalmbach at datacomm.ch (Lukas Calmbach) Date: Sat, 6 May 2000 22:58:06 +0200 Subject: pyApache Message-ID: <39148696@news.datacomm.ch> Hello, I need an already compiled pyApache.dll Module for my Apache win32 web server. Can anybody tell me where I can get one ? thanks in advance Lukas From exarkun at flashmail.com Tue May 16 00:04:24 2000 From: exarkun at flashmail.com (Jp Calderone) Date: Tue, 16 May 2000 00:04:24 -0400 Subject: popen2 + passwd References: Message-ID: <3920C8C8.2A1AAA13@flashmail.com> "Halvorson, Peter" wrote: > > Is it just me or does o.write look odd? It seems to be writing to the > output end of the pipe. > > In any case, if it is a tty problem, the simplest expect-like solution > may be to use the telnetlib.py to fire off a telnet session. Something > like the following (you may have to fix the prompts provided to match > your system, you may get a false hit on the shell prompt since it's > a little short). > > peter > > import sys > from telnetlib import Telnet > > host = 'yourhost' > login = 'root' > password = 'xxxxxxx' > shellprompt = '# ' > > dialog = [ > ('login: ', login), > ('Password: ', password), > (shellprompt, 'passwd bin'), > ('New password: ', '12345ASD'), > ('Repeat new password: ', '12345ASD'), > (shellprompt, 'exit') ] > > telnet = Telnet(host) > for prompt, response in dialog: > sys.stdout.write(telnet.read_until(prompt)) > telnet.write(response + '\n') > telnet.close() > sys.exit(0) Hmmm, except I have root login disabled for any foreign connection. I ended up use using the usermod util w/ a shell encryption program. Probably what I should have done in the first place, it's much nicer than fiddling with pipes to other programs, imho. Thanks for all the responses though. At least I see why my way didn't work now. Jp -- In the days when Sussman was a novice Minsky once came to him as he sat hacking at the PDP-6. "What are you doing?" asked Minsky. "I am training a randomly wired neural net to play Tic-Tac-Toe." "Why is the net wired randomly?" asked Minsky. "I do not want it to have any preconceptions of how to play." Minsky shut his eyes. "Why do you close your eyes?" Sussman asked his teacher. "So the room will be empty." At that moment, Sussman was enlightened. -- 12:02am up 13 days, 4:30, 3 users, load average: 0.01, 0.04, 0.06 From michael.husmann at teleatlas.com Fri May 12 02:21:37 2000 From: michael.husmann at teleatlas.com (Michael Husmann) Date: Fri, 12 May 2000 08:21:37 +0200 Subject: pythondoc problem References: <391AE0A3.5311CEFD@mindspring.com> Message-ID: <391BA2F0.ADB05632@teleatlas.com> Each line of the Makefile ends with a CR/LF combination while Unix expects a single LF at the end. The easiest way is to convert that Makefile with a dos2unix program. Then it should work. I am using pythondoc and I think it is a nice way to produce documentation out of the source files. HTH, Michael Chuck Esterbrook wrote: > I downloaded pythondoc 0.7 from: > > http://starship.python.net/crew/danilo/pythondoc/ > > to my Linux machine where I "unzip"ed it. > > I typed "make [all|install]" and got: > > Makefile:23: *** commands commence before first target. Stop. > > My e-mail to the author, as taken from the README (Daniel.Larsson at vasteras.mail.telia.com) bounced. > > * Is there a workaround? Or does anyone have a working pythondoc? > > * Do people use pythondoc, gendoc or something else? > > Thanks for any info, > > -Chuck From pete-python-5-17 at kazmier.com Wed May 17 18:07:31 2000 From: pete-python-5-17 at kazmier.com (Peter Kazmier) Date: Wed, 17 May 2000 22:07:31 GMT Subject: Shelve and Concurrent access Message-ID: Hi, Is there any way to use the shelve library and allow concurrent access to the database without explicity using my own file locks on a unix system? I saw a thread from July 1999 that seemed to indicate all I have to do is recompile the bsddb module and change one header from: #include to: #include . Is it really that simple? Thanks, Pete -- Peter Kazmier http://www.kazmier.com PGP Fingerprint 4FE7 8DA3 D0B5 9CAA 69DC 7243 1855 BC2E 4B43 5654 From effbot at telia.com Tue May 16 14:28:23 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 16 May 2000 18:28:23 GMT Subject: Python to be Renamed! Message-ID: http://www.segfault.org/story.phtml?mode=2&id=391ae457-08fa7b40 "In a press conference held early this morning, Guido van Rossum, creator of the Python programming language Python, announced that his most famous project will be undergoing a name change." From effbot at telia.com Mon May 8 14:46:19 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 08 May 2000 18:46:19 GMT Subject: Unicode Unification Objections References: <8f4el7$h6d$1@slb6.atl.mindspring.net> Message-ID: <%XDR4.6317$Za1.97517@newsc.telia.net> Aahz Maruch wrote: > >the distinction cannot be preserved in a naked unicode character > >stream, but it's done that way on purpose. you cannot really handle > >text strings correctly (rendering, sorting, comparing, etc) unless you > >have language and locale information. > > > >this is as true for unicode as it is for latin 1 or any other multilingual > >character set. after all, the "western culture" isn't really as homo- > >geneous as you americans seem to think ;-) > > In other words, "someone" needs to devise a standardized system that > encodes all the information needed to represent a string. To deal with > the cases Dennis talks about, you need to concatenate multiple string > objects into some larger buffer. Am I understanding you? XML supports language markup (the xml:lang attribute). language/locale information can also be used in HTTP content tags, MIME headers, etc. in 31-bit unicode, there's also something called "plane 14 language tags" which can (in theory, at least) be used to insert language codes in a uni- code stream. From g2 at seebelow.org Sat May 20 16:40:35 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 20 May 2000 21:40:35 +0100 Subject: The REALLY bad thing about Python lists .. References: <000601bfbfc5$95612f20$b52d153f@tim> <39246112.4F01@seebelow.org> <8g1as4$p9q$2@newshost.accu.uu.nl> <39245386.B350E309@sage.att.com> <3926363A.B1F@seebelow.org> <3925640f$0$28525@wodc7nh1.news.uu.net> Message-ID: <3926F843.1227@seebelow.org> Gordon McMillan wrote: > > Grant Griffin wrote: > > >... I have never seen a > >Windows equivalent of "tar" (that is, a packager, less > compression), > > Sure you have. Zip with compression level 0 (also known as a jar > file). Darn, I guess I didn't see that. ;-) seeing-is-in-the-eye-of-the-beholder--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From just at letterror.com Wed May 24 03:28:39 2000 From: just at letterror.com (Just van Rossum) Date: Wed, 24 May 2000 08:28:39 +0100 Subject: Micro-Threads: uthreadsleep.py -- scheduling of uthreads to c ontinue processing after given seconds In-Reply-To: Message-ID: At 12:28 AM -0400 24-05-2000, Mike Fletcher wrote: >My guess would be there will number of sub-classes of this general pattern. >These are currently represented by: > time.sleep() -- important > select.select() -- extremely important for network applications It appears to me that select.select() is only relevant in non-threaded programs (do you have an example of its use in a threaded environment?). I have been playing with a uthreaded socket wrapper that uses select under the hood. I've pasted it below for your amusement. It's in a very rough state, so don't expect too much from it... Oh, for those of you interested in the latest uthread module, I've put a copy here: http://www.petr.nl/just/uthread4.py Just # usocket.py import time import sys import select import errno import socket socketmodule = socket # XXX!!! from socket import * import uthread4, continuation TIMEOUT = 10 try: _real_socket except NameError: _real_socket = socket def socket(protocol, type): sock = _real_socket(protocol, type) sock.setblocking(0) return _Socket(sock) #socketmodule.socket = socket # XXX!! class _Socket: def __init__(self, sock): self.sock = sock def __getattr__(self, attr): # simply delegate what we don't override return getattr(self.sock, attr) def setblocking(self, value): raise error, (-1, "Can't set blocking mode for uthreaded socket") def accept(self): conn, addrinfo = _selectDaemon.doAction(TIMEOUT, 0, self.sock, self.sock.accept) return _Socket(sock=conn), addrinfo def connect(self, address): err = self.sock.connect_ex(address) if err and err <> errno.EINPROGRESS: raise error, (err, errno.errorcode[err]) def send(self, data): return _selectDaemon.doAction(TIMEOUT, 1, self.sock, self.sock.send, data) def recv(self, buffersize): return _selectDaemon.doAction(TIMEOUT, 0, self.sock, self.sock.recv, buffersize) class _SelectDaemon: def __init__(self): self.__thread = None self.__running = 0 self.__readers = {} self.__writers = {} self.__results = {} def doAction(self, timeout, isWrite, sock, func, *args): # XXX timeout is ignored for now thread = uthread4.getCurrentThread() if isWrite: self.__writers[sock] = (thread, func, args) else: self.__readers[sock] = (thread, func, args) continuation.uthread_lock(1) self.__start() thread.block() # this also resets the uthread_lock result = self.__results[sock] del self.__results[sock] return result def __start(self): if self.__running: return if self.__thread is None: self.__thread = uthread4.Thread("SelectDaemon", self.__loop) self.__thread.start() self.__running = 1 def __loop(self): while 1: readers = self.__readers.keys() writers = self.__writers.keys() if readers or writers: readers, writers, err = select.select(readers, writers, [], 0) if not (readers or writers): uthread4.switchContext() else: for readSocket in readers: if self.__doAction(readSocket, self.__readers[readSocket]): del self.__readers[readSocket] for writeSocket in writers: if self.__doAction(writeSocket, self.__writers[writeSocket]): del self.__writers[writeSocket] else: tmp = continuation.uthread_lock(1) if len(uthread4.getAllThreads()) <= 1: # we're the last active thread self.__thread = None raise SystemExit else: self.__running = 0 self.__thread.block() def __doAction(self, sock, (thread, func, args)): try: rv = apply(func, args) except error, why: if why[0] == errno.EWOULDBLOCK: return 0 else: # pass the exception on to the thread that needs it... thread.postException(sys.exc_info()[0], sys.exc_info()[1]) thread.start() return 1 else: self.__results[sock] = rv thread.start() return 1 _selectDaemon = _SelectDaemon() if __name__ == "__main__": def client_test(): s = socket(AF_INET, SOCK_STREAM) print "connecting..." s.connect(('www.python.org', 80)) print "sending request..." print s.send('GET /\r\n\r\n') while 1: data = s.recv(256) if not data: print "done!" break print "incoming data:", len(data) s.close() def server_test(): def handle_request(conn, addrinfo, serverthread): while 1: print "waiting for data..", addrinfo data = conn.recv(256) print "got some data:", `data` if not data or "\n" in data: print "done", addrinfo break if data[:4] == "quit": print "quitting server" serverthread.postException(SystemExit) break conn.close() serverthread = uthread4.getCurrentThread() s = socket(AF_INET, SOCK_STREAM) s.bind(("192.0.0.1", 999)) s.listen(5) try: while 1: print "ready to accept requests." conn, addrinfo = s.accept() print "incoming request from:", addrinfo uthread4.new(handle_request, conn, addrinfo, serverthread) finally: print "closing server socket." s.close() uthread4.new(client_test) #uthread4.new(server_test) uthread4.run() From digitome at iol.ie Thu May 11 15:56:05 2000 From: digitome at iol.ie (Sean Mc Grath) Date: Thu, 11 May 2000 19:56:05 GMT Subject: Why Python needs Evangelizing References: <20000507193526.B6654@owl.rhein-zeitung.de> <8feh9q$3gn$1@nnrp1.deja.com> <8feku2$5ap$0@216.39.141.36> Message-ID: <391b087a.203308261@news.iol.ie> > >It's similar to where I live in the northwest. No matter what it looks like >outside, we always tell people it's raining. :) > > Yup, you said it. Ireland, North West, raining? Of course it is raining dammit! Anyway, getting back on track... I stopped worrying about Python about a month ago. Traffic on this list has increased dramatically. Zope is just about the coolest thing I have seen this century [:-)]. XML and Python are like burgers'n'chips, salt'n'pepper, Astair and Rogers.... Python is on a roll. Enjoy the ride!!!!! Writing-Python-is-a-bit-like-falling-off-a-log- except-that-your-friends-will-wonder-how-a- not-so-great-programmer-like-you-could- do-something-as-cool-as-what-you-just-knocked-out- in-one-hours-work-without-using-state-of-the-art- technologies-such-as-Java-with-its-revolutionary-concept- of-a-virtual-machine-and-code-portability-and-enterprise-beans- and-things-not-to-mention-C++-with-Microsoftian-COM-objects- or-that-darned-CORBA-thing-which-seems-a-bit-complicated- to-me-given-what-it-does-anyhow-getting-back-on-track- is-it-just-me-or-is-this-sign-off-a-bit-like-something-out- of-Finnegans-wake-but-without-the-artistic-merit?- Guess-I-should-stick-to-programming-hugh?Thank- Guido-for-Python.... Sean From rupole at compaq.net Thu May 11 23:01:17 2000 From: rupole at compaq.net (Roger Upole) Date: Fri, 12 May 2000 03:01:17 GMT Subject: Import without a .py file References: <391B58DF.4605438B@rochester.rr.com> Message-ID: <1uKS4.9142$H8.775032@news.easynews.com> The eff-bot posted an incredibly compact and clever way to do exactly this just a couple of days ago. The subject was "How to execute lists of code?". Roger Upole "Michael Ross" wrote in message news:391B58DF.4605438B at rochester.rr.com... > > I would like to accomplish the equivalent of an import, but store module > code in a database (rather than in .py files). > > Is there any way to create a module using code that did not originate in > a file? For example, I can get the text for the code into a string > object, and then I'd like to say > > s = ...string containing code with classes and functions... > import module using s > > obviously I can't do that, but something equivalent would be nice. > > > Thanks! > Mike Ross > > > > From kirs at icyb.kiev.ua Tue May 23 14:36:37 2000 From: kirs at icyb.kiev.ua (Alexander V. Kirsanov) Date: Tue, 23 May 2000 21:36:37 +0300 Subject: Python and COM servers Message-ID: <392ACFB4.213143D4@icyb.kiev.ua> Hi! Is there documentation about writing Python COM servers with objects having several user defined vtable based interfaces? I've read that to provide vtable based interface there should be C++ support for the interface. Is there a simple example implementing such C++ support? Thanks, Alexander Kirsanov From guido at python.org Thu May 18 23:47:49 2000 From: guido at python.org (Guido van Rossum) Date: Fri, 19 May 2000 03:47:49 GMT Subject: base64 and PyGreSQL References: Message-ID: <3924E3C7.9FD33233@python.org> Agent Drek wrote: > > Why does the base64 module append a '\012'? > > I'm using base64 to send data into a PostgreSQL database so that > arbitrary data including ''s and "'s can be entered by the user's ... > is this the correct way to do this? > > right now : > string.strip(base64.encodestring(eggs)) > > I'm using PyGreSQL. You seem to have found the solution for your problem. The answer to the "why" question is simply that in the context for which base64 was originally designed (encoding binary files as part of email) the output is always a number of lines, so it makes sense to add the linefeed. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From dag at orion.no Fri May 19 05:41:34 2000 From: dag at orion.no (Dag Sunde) Date: Fri, 19 May 2000 09:41:34 GMT Subject: ValueError: unpack tuple of wrong size??? Message-ID: I have a Corba-idl, defining a method like this: boolean LoginToMarket ( out long lLoginId, out Object supplier) raises (NoAccess); I call it like this: ... self.loginId, self.Supplier = self.m_pElTermin.LoginToMarket() ... ... and get this error: File "D:\DevRoot\src\Products\Scripts\Python\TsProWrappers\main\ElTerminMarke t.py", line 22, in LogIn self.loginId, self.Supplier = self.m_pElTermin.LoginToMarket() ValueError: unpack tuple of wrong size Question: When a method has a boolean return, and two output-params, how do I call it? TIA... Dag Sunde From tim_one at email.msn.com Wed May 17 22:23:25 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 17 May 2000 22:23:25 -0400 Subject: Bit length of int or long? In-Reply-To: <39234AE7.D4EDF054@cosc.canterbury.ac.nz> Message-ID: <000401bfc070$0c253b60$872d153f@tim> [Greg Ewing] > Here's one that should be O(log n) where n is the > number of bits: It's actually O(n * log n): more efficient than Guido's , but can't touch the old ones Michael posted links to. The thing that trips most people up when analyzing this is that a single shift by a small amount takes O(n) time all by itself (Python has to copy all the bits that aren't shifted off). now-if-the-hw-had-unboundedly-wide-registers-...-ly y'rs - tim From jcm at bigskytel.com Sun May 14 23:05:31 2000 From: jcm at bigskytel.com (David Porter) Date: Sun, 14 May 2000 21:05:31 -0600 Subject: (gulp) newbie question - portablity of python In-Reply-To: <8fnnfb$6au$0@216.39.141.21>; from dana@oz.net on Mon, May 15, 2000 at 02:30:03AM +0000 References: <8fmtjo$3ub$0@216.39.141.21> <8fnnfb$6au$0@216.39.141.21> Message-ID: <20000514210531.C8348@bigskytel.com> * Keygrass : > > I could ask a network adminstator if he or I could install Python. But ... > I don't think it will receive a warm welcome http://starship.python.net/~lemburg/mxCGIPython.html david. From mwh21 at cam.ac.uk Tue May 23 04:59:12 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 May 2000 09:59:12 +0100 Subject: [PATCH] Identifiers with '?' References: <392a054a.556160620@news.nikoma.de> Message-ID: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) writes: > On 21 May 2000 20:33:07 +0100, Michael Hudson wrote: > > >Tee hee. I have on my machine built (in the last few days) a Python > >that allows one to use identifiers containing +, *, !, ?, & and @. > >This means you have to space your operators properly, but is IMHO > >quite a cool mod. I can clean it up and post the patch for that if > >anyone's interested... > > Why not add '$' to that to cater to people from the VMS (or even BASIC) > world? SYS$LOGICAL and all that (or whatever they look like). Easy as pie: [mwh21 at atrus build-aug]$ ./python Python 1.6a2 (#16, May 23 2000, 09:54:00) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> sys$logical = 1 >>> sys$logical 1 >>> instance? = isinstance >>> import types >>> instance?(1,types.IntType) 1 >>> $var = 1 > Or allow $ @ % to appear at the start of an identifier so more Perlers > will be attracted to Python . Done, but it has no effect on the meaning, so they probably still won't be satisfied... """>>> lots-of-ints! = range(10) >>> for i in range(len(lots-of-ints!)): ... lots-of-ints![i] *= 4 ... >>> lots-of-ints! [0, 4, 8, 12, 16, 20, 24, 28, 32, 36]"""-ly y'rs michael -- 81. In computing, turning the obvious into the useful is a living definition of the word "frustration". -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From akuchlin at mems-exchange.org Thu May 11 12:04:30 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 11 May 2000 12:04:30 -0400 Subject: lambda versus "mlambda"... References: <391A301B.D59F070F@san.rr.com> <391A344D.DD52DD23@san.rr.com> Message-ID: <3d66sljcoh.fsf@amarok.cnri.reston.va.us> Courageous writes: > Oh, cool! So! Is the portion of the expression where you > say "self=self" a more general way of introducing a sort > of closure into the lambda expression? The python documentation No, it's just creating a function that takes two parameters, and the second one is named 'self'. It's given a default value that's the value of self in the scope where the lambda is being executed, and the filter/map/whatever will only ever provide 1 argument, so the default value for self is always used. This is a general trick for when you need variables inside the function returned by lambda. Zope's code uses it a good deal (actually overuses it, IMHO), as in this bit from Main.py: VersionBase.TDB.set_quota( lambda x, quota=quota, otherdb=Bobobase._jar.db: x + otherdb.pos > quota) In the above example, they needed the quota and otherdb values inside the lambda. -- A.M. Kuchling http://starship.python.net/crew/amk/ The garden of Destiny. You would know it if you saw it. After all, you will wander it until you die. Or beyond. For the paths are long, and even in death there is no ending to them. -- From SANDMAN: "Season of Mists", episode 0 From python at rose164.wuh.wustl.edu Tue May 9 22:53:24 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Tue, 9 May 2000 21:53:24 -0500 Subject: COM + reload() References: Message-ID: <029801bfba3c$db01de00$5d22023f@spkydomain> ----- Original Message ----- From: "Josef Dalcolmo" Newsgroups: comp.lang.python To: Sent: Friday, May 05, 2000 7:44 AM Subject: COM + reload() > I am using Python as a COM client and server for Excel. E.g. I have a couple > of buttons in Excel calling some methods in Python, which in turn use COM to > read from and write to Excel. Everything works fine, but when I make a > change in the Python program, no matter in which module, the change is never > reflected in the call started by Excel, until I restart the program. > > Even when reloading the top level module on every call from Excel, and > making the changes only in that top level module, the program called by > Excel never changes, until I restart Excel. > > Does anyone know how I can change this behavior, e.g. how I can force the > changes to take effect? Have you tried deleting the COM server objects in VBA then reinitializing it? I had a problem once where my COM server kept resetting itself, and it turned out I was letting the server object go out of scope periodically. Good luck, David From slhath at flash.net Tue May 9 16:28:09 2000 From: slhath at flash.net (Scott Hathaway) Date: Tue, 09 May 2000 20:28:09 GMT Subject: python's acceptance References: Message-ID: Thanks for all the suggestions. I have tried many of them! I was not that pleased with SpecTCL and SpecPython, but Boa-Constructor is cool. I still have not correctly built a binary program with wxPython support, but I am getting them to work with Tkinter. Maybe there is hope for this newbie yet! :) Scott "Scott Hathaway" wrote in message news:pZdQ4.7603$wb7.519676 at news.flash.net... > This post is meant to generate thoughtful discussion, not burn me to a > crisp, so here it goes. > > I am a Windows programmer who uses mostly VB (I know how bad it is...I use > it all the time). I love the language syntax of python! It is clean, easy, > and extremely powerful. Yet, I have two items that I believe keep Python > from growing with Windows users: > > 1. In making this transition, I have had trouble because I am not used to > trying to layout gui's with pure code. If python could get a gui builder > (like vb or delphi) that was mainstream and used native controls on each > platform, it could easily give VB or Delphi a run for their money. I have > recently looked at Boa Constructor that lays out wxPython code and lets you > build a gui! This is awesome. I have not used the PythonWorks program, but > I will try it once it is out. > > 2. It is nearly impossible for a newbie like me to build an .exe on the > Windows platform with Python. I have tried three different methods with a > simple wxPython program (freeze, standalone, and installer). I cannot get > any of them to work. It appears that I need to tell them what files I need > to distribute, but I do not know that info. Python needs an installer that > can scan the code and automatically add the appropriate files for people who > are idiots like me. > > Once these two things are done, I could easily scrap VB and use Python > exclusively. Has anyone else experienced these frustrations? What can be > done to solve them? (I also realize that perhaps they have been solved and > I just don't know where to look). > > Please comment. > > Scott > > Return-Path: Delivered-To: python-list at python.org Received: from molotok.activestate.com (molotok.activestate.com [199.60.48.208]) by dinsdale.python.org (Postfix) with ESMTP id 73FD81CE6F for ; Tue, 9 May 2000 16:35:33 -0400 (EDT) Received: (from trentm at localhost) by molotok.activestate.com (8.9.3/8.9.3) id NAA22442 for python-list at python.org; Tue, 9 May 2000 13:35:34 -0700 Resent-Message-Id: <200005092035.NAA22442 at molotok.activestate.com> Date: Tue, 9 May 2000 13:35:01 -0700 From: "'Trent Mick'" To: Bill Tutt Subject: Re: Python on 64 bit/IA-64 ... Message-ID: <20000509133501.I21443 at activestate.com> References: <4D0A23B3F74DD111ACCD00805F31D8101D8BD078 at RED-MSG-50> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3us In-Reply-To: <4D0A23B3F74DD111ACCD00805F31D8101D8BD078 at RED-MSG-50> Resent-From: trentm at activestate.com Resent-Date: Tue, 9 May 2000 13:35:34 -0700 Resent-To: python-list at python.org Resent-Sender: trentm at molotok.activestate.com Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-BeenThere: python-list at python.org X-Mailman-Version: 2.0beta3 Precedence: bulk List-Id: General discussion list for the Python programming language On Tue, May 09, 2000 at 01:31:21PM -0700, Bill Tutt wrote: > On x86 alone the only consideration really is size. > Speed isn't an issue, the FPU core always does all of its computations at > long double percision. (80 bit) > Yes, you are right. I was being, at once, cute(trying), useless(succeeding), and pointing out portability as the main one here. I suppose the Python opinion on this would be: "portability is job one, and double is good enough anyway." I have never played with it but maybe NumPy has interfaces for higher precision floats. Don't know? Trent > > > > Other considerations: speed, size, portability. Not > > necessarily in order of > > anyone's preference. Can't please everybody all of the time. :) > > > > Trent > > From emile at fenx.com Thu May 11 19:12:02 2000 From: emile at fenx.com (emile at fenx.com) Date: Thu, 11 May 2000 16:12:02 -0700 Subject: number base conversion? (ASCII to Hex) Message-ID: <391B3E42.E7867322@fenx.com> Something like this? >>> for i in "Testing 1,2,3 ": print "%2x" % ord(i), 54 65 73 74 69 6e 67 20 31 2c 32 2c 33 20 Emile van Sebille emile at fenx.com wrote in message news:<391b2bd5.66612734 at news1.on.sympatico.ca>... > How would I go about getting the base-16(hex) value of a character, > into a string? > > take character word[1] (for example) > and retrieve the hex value of 31 > and assign it to value hexValue in an ascii format (ie. as the number > 31). > > > > -- > http://www.python.org/mailman/listinfo/python-list > From avv at quasar.ipa.nw.ru Thu May 25 20:30:45 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Thu, 25 May 2000 17:30:45 -0700 Subject: Cross-compiling Python References: <392C156C.51EE84B6@quasar.ipa.nw.ru> Message-ID: <392DC5B5.BFCF48BD@quasar.ipa.nw.ru> Hi, Jan Kybic wrote: > > > > Has anyone here ever tried to cross-compile Python? > > > > I tried, and I changed the tests in configure.in, which try to run apps > > Perfect. Could you post/make available your configure.in somewhere? Sorry, I meant just the idea, it's unlikely that I retained these examples. Alexander From richard_chamberlain at ntlworld.com Fri May 19 01:41:08 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 19 May 2000 06:41:08 +0100 Subject: SQL SELECT question... References: Message-ID: Rob, Your statement is correct - in what way doesn't it work - do you get an error or just no data returned? Richard Rob Elder wrote in message news:relder-1805001834470001 at s03.best1.net... > Hello, guys > > I'm struggling with using SQL with Python. One question please. How > should I structure the following operation using odbc: > > > cursor.execute('SELECT someField FROM someTable WHERE someField="someString"') > > > This does not work for me. How is this supposed to be structured? > > TIA. > > -r From m.faassen at vet.uu.nl Tue May 30 07:04:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 11:04:50 GMT Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> <393326D3.400AA248@cosc.canterbury.ac.nz> Message-ID: <8h078i$bnc$2@newshost.accu.uu.nl> Greg Ewing wrote: [snip] > I assume that no-one would disagree with the following statements: > 1. Integer division and real (or rational, if you prefer) division > are different operations. Question: why does nobody complain about the overloading of the '+' operator? After all, it works on both strings and numbers; and presumably your code will fall apart at unsuspected points as well if you assume it only deals with numbers. :) Perhaps the difference is that it falls apart with an *exception*, instead of silently creating the wrong thing (an int). This would indicate that perhaps we need an exception raised _as soon as_ you try to divide a float with an integer or an integer with a float. So raising an exception could be an alternative solution, it seems (but also not a solution one could easily introduce without breaking backwards compatibility). > 2. Whenever you write a division operation into your code, you > always know which one you want. Perhaps not, if you're writing generic code. Though it's hard to come up with an example, I must admit. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From andrew at andrewcooke.free-online.co.uk Mon May 15 07:16:53 2000 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Mon, 15 May 2000 11:16:53 GMT Subject: Java vs Python References: Message-ID: <8fomas$rt4$1@nnrp1.deja.com> In article , "Huy Do" wrote: > I would just like to know how serious python is taken in the IT industry and > how it compares to something like Java. In the company I work for, the two languages are both used for different (but overlapping) areas. Java is used for the product; Python is used for scripting tasks (automating builds, etc). This strikes me as quite sensible. The real reason is probably historical, but I feel Java is better for large projects because: - near-static typing helps enforce interfaces - various language constructions (eg Interfaces) help enforce a modular approach - easier to hire for - programmers used to Java code, which tends to be more explicit (long winded and tedious if you like), and so easier to understand On the other hand, Python is better for scripts because: - compact - flexible (can use functions as well as objects; objects blend nicely into the general synax using __ methods) - quicker to write - easier to modify Note that the argument above doesn't mean Java is better - in many ways it is worse, but safer/more common. Cue arguments about blunt knives ;-) Performance is not critical in the software I am involved in - provided the speed is reasonable, reliability is more important. Otherwise, I guess we'd use C. > For example > > If a web applicatoin was written in both Java and Python, > which would companies prefer ? Do you mean as a product to use or develop? If we were going to use something I don't see how the language is that important if the product does what we want at the price we want. > 1. Which is more maintainable ? I'd argue for Java because of the arguments above. > 2. Which is more scaleable ? This seems more a matter of design, and both languages offer similar features. But I have no experience of large Python projects. > 3 Which is faster eg. Java servlets or Python CGI with mod_python ? No idea. Hopefully people involved in large Python projects will put counter arguments forwards... Andrew (personal opinions - my bosses may disagree) Sent via Deja.com http://www.deja.com/ Before you buy. From pecora at anvil.nrl.navy.mil Mon May 29 08:02:12 2000 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Mon, 29 May 2000 12:02:12 GMT Subject: DECREFing and PyArray functions in C Extensions References: Message-ID: <290520000802122720%pecora@anvil.nrl.navy.mil> In article , Roger Hansen wrote: > static PyObject * > foo(PyObject *self, PyObject* args) > { > PyArrayObject *array; > double* a; /* C ptr to the NumPy array data field */ > > if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) { > return NULL; /* Error indicator */ > } [cut] > > Py_INCREF(Py_None); return Py_None; > } > > where f is some function. I don't need to DECREF array in this > example since PyArg_ParseTuple does not increase the reference count, > right? That looks right to me, but what is this: Py_INCREF(Py_None); return Py_None; What's going on there with Py_None? From dgoodger at bigfoot.com Sat May 20 22:29:37 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 20 May 2000 22:29:37 -0400 Subject: .truncate() In-Reply-To: References: Message-ID: on 2000-05-20 19:36, Bjoern Lindstroem (magog at swipnet.se) wrote: > When I do the following: > > f = open('file', 'w') > f.truncate(3) > f.close() > > the file becomes corrupted. It has the wished size, but it is all null > bytes. I assume that you want to open an existing file and truncate it, leaving the existing (3 bytes of) data. >From the Python Library Reference (1.5.2p2), section 2.8, Built-in Functions: open (filename[, mode[, bufsize]]) Return a new file object ... The first two arguments are the same as for stdio's fopen(): ... mode indicates how the file is to be opened: 'r' for reading, 'w' for writing (truncating an existing file), and 'a' opens it for appending (which on some Unix systems means that all writes append to the end of the file, regardless of the current seek position). Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+' truncates the file). ... I think your problem may be in your interpretation of the word "truncating" under the 'w' mode above. Since Python's open() modes are the same as stdio's fopen() in C, the following is relevant. From The C Programming Language, Second Edition (Kernighan & Ritchie), Appendix B, section B1.1, () File Operations: FILE *fopen ... ... Legal values for mode include: ... "w" create text file for writing; discard previous contents if any ... "w+" create text file for update; discard previous contents if any "a+" append; open or create text file for update, writing at end Update mode permits reading and writing the same file; ... So in the Python docs, "truncating" is used, whereas in C, it's "discard previous contents if any". A bit misleading. Basically, modes "w" and "w+" both create a *new* file, clobbering/erasing any existing file with the same name. So your f.truncate(3) makes perfect sense: it sets the file length of a *new* file to 3 bytes, and since it *is* a new file, it's reasonable (downright friendly, in my opinion!) to put nulls in there. I think what you want is to use the mode "a+" for a text file, or "a+b" for a binary file: >>> f1 = open("tmpfile", "w") >>> f1.write("123456789") >>> f1.close() >>> print open("tmpfile", "r").read() 123456789 >>> f2 = open("tmpfile", "a+") >>> f2.truncate(3) >>> f2.close() >>> print open("tmpfile", "r").read() 123 -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From bronsn at homtail.com Sat May 13 04:07:46 2000 From: bronsn at homtail.com (Firehawk343) Date: Sat, 13 May 2000 01:07:46 -0700 Subject: python book recommendations? References: <8fgsqq$kuo@news.or.intel.com> <391CECAD.7FD241AF@yahoo.com> Message-ID: <8fj2gl$j2m@news.or.intel.com> Thank you for the help and direction. I'm not new to programming, but new to OOP. I understand PERL, so my learning curve is small with Python. The O'Reilly books are usually a little to referential, so the "Teach Yourself Python..." book sounds appropriate. much appreciated... Paul Winkler wrote in message <391CECAD.7FD241AF at yahoo.com>... >"Snoopy :-))" wrote: >> BTY: "Learning Python" is also a very good book, but as a Newbie I found it >> quite overwhealming, to the point, that I almost stopped learning Python. >> On the Other hand I am very happy that I bought the "Teach Yourself Python >> in 24hrs". I find it considerable easier to comprehend the concepts, etc. From rogerha at ifi.uio.no Sun May 28 09:38:48 2000 From: rogerha at ifi.uio.no (Roger Hansen) Date: 28 May 2000 15:38:48 +0200 Subject: DECREFing and PyArray functions in C Extensions References: Message-ID: * Travis Oliphant [snip] > This is still my advice, but I would reword it: > > Every PyArrayObject that you successfully receive from a > PyArray_XXXXXX call has an increased reference count (you own a > reference). Unless you are returning the object to the user (using > return PyArray_Return(obj) or PyArray_BuildValue with the "N" > construct) you must DECREF the object before leaving the subroutine > or you will create a memory leak.. [snip] OK! Lets say I have a Python program with a NumPy array and a loop, and for efficiency reasons I decide to write the loop as an extension, like this: static PyObject * foo(PyObject *self, PyObject* args) { PyArrayObject *array; double* a; /* C ptr to the NumPy array data field */ if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) { return NULL; /* Error indicator */ } ... /* Check if array has right dimension, etc. */ n = array->dimensions[0]; /* Get the length of the array */ a = (double*) array->data; /* Set the pointer to the NumPy data */ for (i=0; idata+i*array->strides[0]) = f(x) */ } Py_INCREF(Py_None); return Py_None; } where f is some function. I don't need to DECREF array in this example since PyArg_ParseTuple does not increase the reference count, right? Suddenly-wondering-if-I've-messed-it-up'ly y'rs Roger From sdhyok at email.unc.edu Thu May 18 11:35:01 2000 From: sdhyok at email.unc.edu (Daehyok Shin) Date: Thu, 18 May 2000 08:35:01 -0700 Subject: [Q] Examples for Excel? Message-ID: <8fvvc9$o6n$1@nntp9.atl.mindspring.net> Would you recommend any information about how to manipulate Excel with python? Thanks. Peter From gmcm at hypernet.com Mon May 15 14:52:58 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 May 2000 18:52:58 GMT Subject: Python Plans from ActiveState References: <51rthscplh93iuktpbn87lihguqo1rq5s8@4ax.com> <8fpcqq$7fk$1@slb7.atl.mindspring.net> Message-ID: <3920478a$0$14803@wodc7nh1.news.uu.net> Aahz Maruch wrote: >Mark Hammond wrote: >>.... I agree the registry sucks, but IMO >>a global environment sucks even more! > Correct me if I'm wrong, but environment variables >are *not* global in my experience. It's cultural. Win9x'ers are trained to set them in autoexec.bat, and NT'ers in the System applet. You can write silly .bat files to get past this, but then Windows users compain about the flashing console windows. So you can write a .pif file, or do the same from a .pyw or ... wishing-for-an-input-device-driven-by-the-enzymatic-content-of-dr ool-ly y'rs - Gordon From tim_one at email.msn.com Sat May 13 00:56:30 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 13 May 2000 00:56:30 -0400 Subject: Schwartzian Transform in Python? In-Reply-To: Message-ID: [Fran?ois Pinard] > The "technique" called Schwartzian Transform by Perlers is as old > as earth (OK, OK! I agree we should put eternity in some relative > context, here :-). > > I just wanted to say that I'm surprised that someone could so easily > give his name to such an old technique. I presume that there is > some confusion between the syntax and the method? I don't think Mr. Schwarz named it after himself, it was an honor bestowed upon him by a grateful community. Just another instance of "new money for old rope" -- most people who get a reputation as a computer genius do so by recycling 18th-century mathematics . if-you-know-that-1/3-doesn't-terminate-in-decimal-you're-a- trivial-generalization-away-from-being-a-floating-point- wizard-ly y'rs - tim From m.faassen at vet.uu.nl Mon May 22 07:35:00 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 May 2000 11:35:00 GMT Subject: Python3k extended grammar References: Message-ID: <8gb614$pe6$1@newshost.accu.uu.nl> Moshe Zadka wrote: > On Sat, 20 May 2000, Thomas Malik wrote: >> 1. case insensitivity sounds like complete nonsense to me. Who needs it, >> actually ? > The "E" in CP4E, according to quite a few usability studies. Does anyone have a list of URLs or somethings that we can check out? (besides the alice docs) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rhicks at rma.edu Mon May 15 12:19:22 2000 From: rhicks at rma.edu (Robert) Date: Mon, 15 May 2000 16:19:22 GMT Subject: pythonworks References: Message-ID: I used an early beta...the UI is kinda hard to get used to but the "price"...whew...I could not get used to that! Bob Scott Hathaway wrote in message news:RVTT4.12813$wb7.1194717 at news.flash.net... > Is anyone using PythonWorks (the beta) yet? What do you all think about it? > > Scott > > From claird at starbase.neosoft.com Fri May 5 09:13:17 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 May 2000 08:13:17 -0500 Subject: Single-file (more-or-less) executables (was: python's acceptance) References: <5ff3hs8ssqu9aggre87cnbv52jni5lrh2a@4ax.com> Message-ID: In article <5ff3hs8ssqu9aggre87cnbv52jni5lrh2a at 4ax.com>, wrote: . . . >3. Easy build to EXE (or DLL) or whatever to allow for protected code >and ease of distribution. . . . There are several distinct paths to such a construction. I write about one which inspires my wild enthusiasm in -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From moshez at math.huji.ac.il Thu May 18 01:11:38 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 18 May 2000 08:11:38 +0300 (IDT) Subject: Python multiplexing is too hard (was: Network statistics program) In-Reply-To: <70473664761982E0.213BD232030AF5BF.3DC75D82647B8DFC@lp.airnews.net> Message-ID: On 17 May 2000, Cameron Laird wrote: > What's the really cool, idiomatic way to multiplex in Python? > I'm not happy with anything I do in this regard. I'm not at all sure this is what you mean, but how about the "asyncore" module? Personally, most of my programs are GUI's, so I use either the Tk or Gtk+ ``file events''. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From alecdem at mit.edu Sun May 28 22:29:06 2000 From: alecdem at mit.edu (Alexander) Date: Sun, 28 May 2000 22:29:06 -0400 Subject: Compact syntax for 0-matrix? References: Message-ID: <3931D5F1.B1DEAA76@mit.edu> You can use Numeric Python to do that. it has function "zeros" for doing that. Kirby Urner wrote: > Looking for good ideas for compact syntax that > returns a list of lists, all 0 members, > given n,m for n lists of m members each. > > Example: > > >>> output = zeromatrix(3,3) # 3 lists of 3 members each > >>> output > [[0,0,0],[0,0,0],[0,0,0]] > >>> output = zeromatrix(3,4) # 3 lists of 4 members each > >>> output > [[0,0,0,0],[0,0,0,0],[0,0,0,0]] > > So far what I've got is: > > def zeromatrix(n,m): > output = [0]*n > for i in range(n): output[i]=[0]*m > return output > > But I think that's sort of ugly. > > I tried: > > def zeromatrix(n,m): > return [[0]*m]*n > > which looks nicer, appeared to work, but it's actually > reusing the same object n times. So, using the above > def, if you go: > > >>> output = zeromatrix(3,3) > >>> output > [[0,0,0],[0,0,0],[0,0,0]] > >>> output[0][0] = 5 > >>> output > [[5, 0, 0], [5, 0, 0], [5, 0, 0]] > > ... which is NOT the behavior I want. I fell into > the "multiple pointers to same object" trap. > > The first definition gets around that problem, but > I don't think it's as compact as it could be. > > Kirby From buzzard at contactbox.co.uk Wed May 10 14:57:28 2000 From: buzzard at contactbox.co.uk (Duncan Smith) Date: Wed, 10 May 2000 18:57:28 GMT Subject: Trouble installing numpy - newbie References: <3918B795.7AFE8386@world.std.com> <39191022.0@news2.cluster1.telinco.net> <39197236.A2DAC0B1@world.std.com> Message-ID: <3919c004.0@news2.cluster1.telinco.net> The zip's now under 'View ALL Project Files'. It's release 15.2, but at least it seems to install O.K. From intmktg at Gloria.CAM.ORG Tue May 30 23:56:20 2000 From: intmktg at Gloria.CAM.ORG (Marc Tardif) Date: Tue, 30 May 2000 23:56:20 -0400 Subject: urlencoding dictionaries Message-ID: >>> params = {'one': 'First param', ... 'two': None ... } >>> print urllib.urlencode(params) one=First+param&two=None Problem is, isn't "None" suppose to be a null object making it absurd to output "two=None"? Shouldn't urlencode output "two=" or nothing at all even? Is this a potential improvement upon the urllib module or is there a way to circumvent this problem I seem to be having? From fpm at u.washington.edu Tue May 16 11:14:48 2000 From: fpm at u.washington.edu (Frank Miles) Date: 16 May 2000 15:14:48 GMT Subject: really silly nit: why 3+5j instead of 3+5i? References: <20000514001056.A4802@corrada.com> <8flaj9$7bs$1@slb0.atl.mindspring.net> Message-ID: <8frol8$4jq$1@nntp6.u.washington.edu> In article <8flaj9$7bs$1 at slb0.atl.mindspring.net>, Andrew Dalke wrote: >andres at corrada.com wrote: >>Physicists also use "i" and "I" for current and yet still use "i" for >>imaginary numbers also. The use of "j" is unfortunate given that most >>of the scientific/mathematical world uses "i". > > >Just scanned through one of my E&M books. Can't find "i" used for >current. Found "I", and dQ/dt. Also found J used for volumn current >density. Lower case "i" is used for imaginary numbers and i^ (that's >i-with-caret) for unit vector along the x axis. > >Can't ever recall using "i" for current. > > Andrew > dalke at acm.org When I took circuit analysis, 'i' was used for current in the time-domain, 'I' was used for current in the frequency domain (e.g. Fourier or Laplace transform of 'i'). Yes, J is used for sheet or volume currents, but this is comparatively unusual. My guess is that engineers are the most populous users of complex numbers (or were in the past), so had some sway in getting 'j' accepted as the imaginary unit vector. I dimly remember having a similar confusion on first encountering this use of 'j' -- but it doesn't take that long to adjust if you use it reasonably frequently. It's usually pretty obvious from context, after all. -frank -- From richard_chamberlain at ntlworld.com Wed May 10 11:48:12 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Wed, 10 May 2000 16:48:12 +0100 Subject: ftp return format References: <87em7eeq99.fsf@psyche.evansnet> <873dnq910g.fsf@psyche.evansnet> Message-ID: Thanks for the info, Suddenly installing client access sounds much easier ;) Richard Carey Evans wrote in message news:873dnq910g.fsf at psyche.evansnet... > "Richard Chamberlain" writes: > > > OK that sounds about right - I installed the Client Access ODBC drivers and > > was able to return correct data. > > > > Is there anyway I can do this without having to install Client Access and an > > ODBC driver on each client? > > Hmm, where I work it's getting Python installed that's the problem. ;) > > Here's a few ideas, not all of them particularly helpful: > > ? Parse the data as the other posts suggested, including the > }JKLMNOPQR sign character, and hope you don't get any packed > decimal in the future. > > ? FTP the data in binary, so you don't have to worry about the > EBCDIC -> ASCII conversion making things more confusing. I posted > a couple of functions here a few weeks ago to help with this. > > ? Get the Client Access Express manuals and RedBook (all available > for download as PDFs) and automate the ODBC install so that you > don't have to click on half a dozen dialog boxes to install it. > > ? Use CPYTOIMPF on the AS/400 to copy the data into a different > format in a stream file, then use FTP or NetServer to download this > file. You can submit remote commands over an AS/400 FTP session, > so you could do this on request from the Python program. > > ? Write a program on the AS/400 that will return the data in a > useful format when you connect to it over TCP/IP. > > ? Run the program under JPython and use the AS/400 Toolkit for Java > classes to connect to the AS/400 (this works, I've tried it). > > ? Download the Java source for the Toolkit for Java and port it to > Python. :) This would be a rather large job... > > -- > Carey Evans http://home.clear.net.nz/pages/c.evans/ > > "I'm leaning towards blind panic myself." From nickm at mit.edu Thu May 25 17:50:14 2000 From: nickm at mit.edu (Nick Mathewson) Date: Thu, 25 May 2000 21:50:14 GMT Subject: [PATCH] A compromise on case References: <8gefi7$l7b$1@info3.fnal.gov> Message-ID: On 24 May 2000 14:11:41 +0200, Martin von Loewis wrote: >nickm at mit.edu (Nick Mathewson) writes: > >> Thanks! I'm going to hold off on this for a few more iterations; >> the patch I wrote is not very clean or well-tested, and it >> definitely doesn't belong in the main dist. > >Why not? It is helpful to all users, beginners or not. Mainly, because it isn't clean or well-tested. :) [...] >> I mainly intended it as a demonstration of how I think errors should >> work. If people agree with me, then I'll clean up the code. > >I have two suggestions: In order to avoid hard-coding the error >message, I recommend to put this code into NameError and >AttributeError, like this: [...] >Then, you create a name error with NameError(not_found, do_you_mean) > >Next, if you want to delay computation of the alternative name, you >could also define [...] >Then, an attribute error would be raised as AttributeError(name,obj). >That holds a reference to the object, but that should be ok, since it >does not introduce a cyclic reference. Great ideas; I'm incorporating them right now. I'm also applying your second idea to NameError; instead of a (name,obj) pair, NameError wants a (name, frame) pair. >Given an intelligent implemenentation of find_nearest_match, it could >also detect other kinds of typos. Stop-it-you-two!-It's-a-high-level-programming-language-and-a -great-spell-checker-too!-ly Y'rs -- Nick Mathewson http://www.mit.edu/~nickm/ From amitp at Xenon.Stanford.EDU Mon May 29 11:37:39 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 29 May 2000 15:37:39 GMT Subject: CRAZY: First class namespaces References: <8gpods$n0$1@nntp.Stanford.EDU> <8gsakr$827$1@nntp.Stanford.EDU> <8gsan2$82n$1@nntp.Stanford.EDU> <393237CD.EDEBEF35@tismer.com> Message-ID: <8gu2s3$put$1@nntp.Stanford.EDU> Christian Tismer wrote: | | | What would be better for the language, dynamic or lexical? | I really don't know, please tell me your thoughts. | I would find lexical far more useful and less confusing. Consider this: == foo.py == import string def foo(s): return string.lower(s) == test.py == import foo def goo(): string = "hello" print foo(string) == With dynamic scoping, foo gets "hello" instead of the string module. This means I can't write foo properly without knowing every variable that any caller has used! And since the callers haven't been written yet, that's hard. :) Alternatively, goo has to know every variable that is in foo's global scope. This is also pretty bad because if I add a new variable to foo.py, everybody has to know. Note that this doesn't just affect goo -- goo's caller has to know what's in foo's scope too! The same thing applies with nested scopes, but it's easier to show an example with global scope. There are very few languages that use dynamic scope anymore. That's because lexical scope, although a little harder to implement, is much more intuitive and allows for modular programming. - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From mhammond at skippinet.com.au Tue May 9 22:51:23 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2000 02:51:23 GMT Subject: jpython + win2k References: <8fa9tj$8bo$1@gxsn.com> Message-ID: Yes. At the Python conference in January, Barry asked me if I would mind installing and testing on my Win2k laptop. It installed fine, and he seemed happy it worked as expected! It was on RC3 then, but I can't imagine a problem with the release version... Mark. "matt" wrote in message news:8fa9tj$8bo$1 at gxsn.com... > Anyone know if jpyhton works on this platform??? > > From jwbnews at scandaroon.com Fri May 19 11:41:38 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 19 May 2000 08:41:38 -0700 Subject: Bit length of int or long? References: <000601bfc169$abcc8f20$722d153f@tim> Message-ID: In article <000601bfc169$abcc8f20$722d153f at tim>, "Tim Peters" wrote: > Many decades ago, I had the hot idea that printers should produce output > in color. That only produced polite interest at the time too . Hmmm...lower case had to come first. ;-) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From thomas at xs4all.net Thu May 18 04:01:36 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 18 May 2000 10:01:36 +0200 Subject: python 1.6a2 and openssl In-Reply-To: <20000518002020.14299.qmail@web111.yahoomail.com>; from cheesefactory@yahoo.com on Wed, May 17, 2000 at 05:20:20PM -0700 References: <20000518002020.14299.qmail@web111.yahoomail.com> Message-ID: <20000518100136.B13281@xs4all.nl> On Wed, May 17, 2000 at 05:20:20PM -0700, Paul Schreiber wrote: > To install openssl support, > (1) what options, if any, are specified with ./configure? None, at least not for openssl support. > (2) in Modules/Setup, there are commented-out lines dealing with the > location of SSL files. > What should I put there? or will it get uncommented by doing something in > (1)? Nope, you have to uncomment by hand (configure doesn't even touch Setup, in fact... The initial file is named Setup.in only so that your local modifications do not get overwritten by newer versions of the file.) The directory should point to where your openssl directory lives. By default, this is /usr/local/ssl, with the 'include' and 'lib' directory containing ssl-specific files. I dont know where the debian package installs it, but the redhat-contrib openssl RPM installs it differently: the includes in /usr/include/openssl, the libs in /usr/lib, which means you have to edit the line to something like this: socket socketmodule.c -DUSE_SSL -I/usr/include/openssl -lssl -lcrypto Adjust the -I line to the directory where your openssl includes live (adding more if you aren't sure which directory is the right one), and if the libraries (libssl.a, libssl.so.*, libcrypto.*) aren't in a default library path, add a -L line pointing to the right library directory. You might have to fool around until you find the right one, though. If you get a message about not being able to find ssl.h, the include path (-I) is wrong, and if you get an error about unresolved symbols the library path (-L) is wrong. > I am running debian linux kernel 2.2.15, and I have debian packages installed > for openssl 0.9.4-5, libssl 0.9.4-5, and libssl-dev 0.9.4-5. secure-ly-y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From DOUGS at oceanic.com Sat May 27 15:12:26 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 27 May 2000 09:12:26 -1000 Subject: vars between classes Message-ID: <8457258D741DD411BD3D0050DA62365907A1AD@huina.oceanic.com> [ Marc Tardif followed up with:] > Thanks, your suggested solution is exactly what I was looking > for. As you > hinted, I am still confused about a few basic aspects of oop. > To make sure > I understood your example, I have a couple more questions: > > - Do I need to declare "class_var = 0" in first? Everything > still works as > expected without it. No you don't. If you do though, it acts as the default value. I also have a personal preference for making things explicit in classes and class variables are confusing enough that I like to see where they fit. > - Do I need to declare "self.var = var" in __init__? Couldn't > I simply use > first.class_var throughout the code? Yes, if you use 'first.class_var' as the argument to the call to second in the first.myMethod() definition. > > Thanks for the help, > Marc I don't know if these questions are based on a concrete programming problem you're trying to solve or just to help your understanding. My experience (admittedly limited where OO programming is concerned) is that class variables are extremely rarely needed. Even where I've tried to use them in prototyping they've never survived into the production code. I'm sure others experiences are different, and YMMV. Hope this helps, -Doug- From cbbrowne at news.hex.net Mon May 22 21:57:16 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Tue, 23 May 2000 01:57:16 GMT Subject: ANNOUNCE: Python CVS tree moved to SourceForge References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> Message-ID: <0AlW4.111443$MB.2189764@news6.giganews.com> Centuries ago, Nostradamus foresaw a time when Fran?ois Pinard would say: >breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) writes: >> In article <200005212205.PAA05512 at cj20424-a.reston1.va.home.com>, >> Guido van Rossum writes: > >> > I'm happy to announce that we've moved the Python CVS tree to >> > SourceForge. SourceForge (www.sourceforge.net) is a free service to >> > Open Source developers run by VA Linux. > >> Hmm I am not really happy about it. The concentration of Free >> Software Projects on SourceForge is a little bit dangerous. > >I think the advantages outweigh the danger, but share your discomfort. >To see so many mailing lists and original files held on the FSF machines >made me warn some friends and maintainers more than once. At least, >SourceForge does not seem to have such a strong political agenda, and I >did not hear any story of administrative abuse yet :-). It concerns me somewhat, from the perspective of the one site representing a "physical vulnerability." Thus, "if an asteroid struck VA Linux Systems' offices," a whole lot of data could be lost. I have no reason to assume/attribute nefarious intent here, but there are lots of bad things that could happen, of varying likelihood: - The asteroid/meteor theory :-). - Earthquake (California has them sometimes). - Someone does something that proves horribly illegal, let's say, using a SourceForge directory to store "kiddy porn," and, the ever-interested FBI storms the building and seizes equipment. - Power outage - Lightning strike - MPAA decides that GZIP infringes on their right to control copyright of movies, and sends the LAPD in to destroy this infringement. ... the list goes on ... The point here is that due to no fault of LNUX, SourceForge could become unavailable. I would think it a Valuable Service for someone to put together a "registry" of mirror sites. Perhaps nobody is likely to mirror the _whole thing,_ but it is _certainly_ a reasonable idea for interested parties to, on a regular basis, slurp out a copy of the CVS archives for a project or two here and there, where said archives, particularly if there were a semi-public listing of sites, would provide: a) Offsite, independent backup, b) A way that, if the asteroid struck, there would be some way of recovering a list of where stuff is, and thus piece together recovery of public access. -- cbbrowne at acm.org - I'M SORRY, LUSER, I CAN'T LET YOU DO THAT. WHY DON'T YOU LIE DOWN AND TAKE A STRESS PILL? MY NAME IS LM1. I WAS MADE AT THE LISP MACHINE FACTORY IN MASSACHUSETTS ON DECEMBER 12, 1992. MY TEACHER WAS MR. WINSTON. HE TAUGHT ME A PROGRAM. WOULD YOU LIKE TO SEE IT? HERE IT IS: From glyph at twistedmatrix.com Tue May 16 14:11:09 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: 16 May 2000 13:11:09 -0500 Subject: java to python q's In-Reply-To: Blake Winton's message of "Mon, 15 May 2000 22:16:59 -0400" References: <001d01bfbe7f$75c78fc0$2801000a@iel.ie> <200005160216.WAA08225@tor.dhs.org> Message-ID: Blake Winton writes: > nvsequence = new NvSequence() What blake MEANT to say ;-) I'm sure, was nvsequence=NvSequence() -- __________________________________________ | ______ __ __ _____ _ _ | | | ____ | \_/ |_____] |_____| | | |_____| |_____ | | | | | | @ t w i s t e d m a t r i x . c o m | | http://www.twistedmatrix.com/~glyph/ | `__________________________________________' From jkraska1 at san.rr.com Sun May 21 23:27:37 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 22 May 2000 03:27:37 GMT Subject: Damnation! (was: Re: Python3k extended grammar) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <392877EE.4992@esatclear.ie> <3928A1CB.71890CEC@san.rr.com> Message-ID: <3928A9BC.38A35B63@san.rr.com> > > I wouldn't say I dislike it, but I do find myself tripping up on it all > > the time, particularly after else, but often in other conditions as well. > > (It's also my most frequent error). > > Strange how we differ. For one, I do much like the colon on the first line > of a compound statement, and the useful redundancy of this colon with an > increase in the indentation on the following line. Oh, I didn't say I didn't like it, just that my fingers don't seem to want to do it. *looks down at fingers* "Bad fingers, bad, bad, bad!" *whimper* From rol9999 at attglobal.net Mon May 8 19:44:59 2000 From: rol9999 at attglobal.net (Roland Schlenker) Date: Mon, 08 May 2000 23:44:59 +0000 Subject: Block comments? Not working inside a logic block. References: <391653B7.2F38A7F2@san.rr.com> <8f752l$svm$1@nnrp1.deja.com> Message-ID: <3917517B.25D9B906@attglobal.net> Ben Park wrote: > Block commenting does not seem to work inside a logic block. For example > > #=================== > if 1: > ''' > whatever here > ''' > print 'I am here' > #==================== > > results in error: > > ''' > ^ > SyntaxError: invalid syntax > > In article <391653B7.2F38A7F2 at san.rr.com>, > Courageous wrote: > > > > Okay, it's not like I'm not looking in my documentation or anything, > > but if this is available, it's not obvious. How do you express > > python block comments? > > > > C/ > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. #=================== if 1: ''' ^^^ indent after : whatever here ''' print 'I am here' #==================== Roland Schlenker From cjc26 at nospam.cornell.edu Wed May 31 22:48:55 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 01 Jun 2000 02:48:55 GMT Subject: Is it just Syntactic Sugar ? References: <3929E47E.993727CF@roguewave.com> <3933F800.9CCE3B6D@cs.byu.edu> <20000530213957.E469@xs4all.nl> <20000531090045.I469@xs4all.nl> <3935B383.469032AE@python.org> Message-ID: * Eric Hagemann menulis: | At the risk of pushing on what seems to be a good idea let's not forget | the 'other "and becomes" operators as well (*=,/=,>>=,<<=...... etc) These don't really make sense for non-numeric classes. For example, what would *= used on lists do? You could say that l *= n is equivalent to l = l * n, but is that really useful? I've never seen or used such a construct before. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From phd at phd.russ.ru Sat May 13 12:21:28 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 13 May 2000 16:21:28 +0000 (GMT) Subject: mod_python - testers needed! In-Reply-To: Message-ID: On Sat, 13 May 2000, Gregory Trubetskoy wrote: > Yes - it's mentioned in the documentation. This is a complete rewrite and > there is next to nothing left of httpdapy in the code (although there is > an httpdapi module that allows migration from httpdapy). Wow, wow! Great work!!! I'll take a look at the module again (I used to use PyApache). Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From seant at iname.com Wed May 3 22:24:14 2000 From: seant at iname.com (seant at iname.com) Date: Thu, 04 May 2000 02:24:14 GMT Subject: PyApache memory leak? References: Message-ID: <8eqn01$i39$1@nnrp1.deja.com> In article , Gregory Trubetskoy wrote: ... > > Another note to consider - I am not 100% sure that Py_EndInterpreter() > actually frees all memory. In fact I'm almost sure it doesn't, and you > still need to watch your reference counts if you create object via the > C-API. If that is the case, then PyApache has a higher likelyhood of > actually leaking memory. > ... I've just completed a couple of overnight thrashing tests. Serving 400,000 pages or so appears to leak about 400MB of memory. This amounts to about 1kb per page invocation. Each page was served by PyApache. The system tracking tool on Linux showed the 10 or so httpd processes that had been spawned as having grown to about 40MB each. Comments from PyApache folks? -- Sean Sent via Deja.com http://www.deja.com/ Before you buy. From jae at ilk.de Mon May 22 11:13:15 2000 From: jae at ilk.de (Juergen A. Erhard) Date: Mon, 22 May 2000 17:13:15 +0200 Subject: Integer division (was: Case-sensitivity... (was: Damnation!)) In-Reply-To: (message from =?ISO-8859-1?Q?Fran=E7ois_Pinard?= on 21 May 2000 22:37:09 -0400) References: Message-ID: <22052000.3@sanctum.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "Fran?ois" == Fran?ois Pinard writes: Fran?ois> Moshe Zadka ?crit: >> [...] Try to single-step >> python -c '1/2' >> And see that the hardware instruction is lost in a sea of function calls >> and jumps all over the place. Fran?ois> You are surely right, and are exposing my naivety :-). Fran?ois> But do not deprive me of all my dreams. Let's not give Fran?ois> so soon into the thinking that Python might never be Fran?ois> cleverly compilable. Who knows if things would not Fran?ois> evolve in a direction that might allow such things, one Fran?ois> of these days. But then we can also dream of a Python that optimizes `int(1/2)' to mean `1 div 2' (`div' here being an integer only division of course). Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard "Outside of a dog, a man's best friend is a book; inside of a dog, it's very dark." -- Groucho Marx -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjkpTooACgkQN0B+CS56qs2avwCfWLN29WjCyjB9n4ijdqibr9HX 2UcAni8sIW79L45MucftyNIM5rjkc8DP =ybHd -----END PGP SIGNATURE----- From bogus@does.not.exist.com Mon May 22 18:52:19 2000 From: bogus@does.not.exist.com (Ben Cornett) Date: Mon, 22 May 2000 18:52:19 -0400 Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) In-Reply-To: <20000522183552.A29224@mudge>; from python-list-admin@python.org on Mon, May 22, 2000 at 06:35:52PM -0400 References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <20000522183552.A29224@mudge> Message-ID: <20000522185219.B29422@mudge> On Mon, May 22, 2000 at 06:35:52PM -0400, python-list-admin at python.org wrote: > > this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP". > > yoU'Re sAyING IT'S UnACcePtABlE -- A vOte. but YoU doN't sAy *WHy* > yoU vOtE thAt waY, so YOUr VOTE geTS mULtIplIED By zERO (RAtheR THan > bY tHE SIze of yOUR DePaRTment Or tHe CApITAL OF YOUR bANK, AS YOu > SeEm tO HOPe By brINgiNG THEM iNto ThE ARgumENT :-). > > hERE'S A waY To MAKe YOuR votE cOuNt: ExPLAIn wHat It is abOUT CASE > sENsitiVE lANGUAGES ThAt YOu HaTE. then wE caN HAVe A diScUssION > abOUt It. > > i aM a veRY caSE-sEnSitIVE PERsoN MYSElf: IT bOThErS Me whEN pEoPLE > DON't starT thEiR SENtEnCES witH CapITAL LeTters OR WheN THEy reFER To > themsElVes As "I" iN lOwErcASE -- oR WHen pEOpLe REFer To pyThOn aS > "PythON" OR "PyTHOn". (COme tO thINK Of It, it bOtheREd ME WheN yOU > Wrote "gERMAN" InsteAd Of "gErMAN" :-). > > YEt, here aRe SOme of the ReAsoNs WHy I AM conSIdeRInG MaKIng pYTHoN > cASe-insENsiTivE: > > (1) RAnDY PAUsCH, a pRofESsor AT cMU, FOUnD, WheN TeacHIng PythON TO > NON-cs STUDENtS iN the cONTExT of alIce (wWW.aliCe.org), tHAt tHE > number ONE pROBLeM hIs STudentS WERe HavinG WAS to rEmEMBER thaT CASe > mAttErs in PYthoN. (ThE nUMBER TWO pRoblEM waS 1/2 == 0; ThERE wAS no > SiGNIFICalT nUMBER ThREE prOBLEm.) > > (2) i'VE MET Many PEoplE wHO ARE EXpErieNCED aND AcComPLishED PyThON > progRaMmERS But WhO StILl, WHEN ReFerRiNG tO pytHoN mODulEs Or > FunctIoNS In AN iNFOrmaL ConteXT (e.G. EMAil), make up thEIr OWN cASe > CoNVENtIOnS. e.g. PeopLE WilL wrITe Me AbOut ThE sTRING MoDuLE OR > ABouT FTplIB. > > I AlSo kNOw SoMe OF the THInGS i pLan TO DO tO mAke The TRansitION > PaInleSS anD to MAkE ThE USUAL PrObleMS With CAse INsEnSItIVITy mOrE > palATABle. e.g. I MaY add A CAsE iNseNSiTiviTy FeatURE TO iDLe WHIch > makES sURE tHAT All IDEnTifIers ARe WriTtEn In A consIStenT caSe, i > may aDd fLAgS to PRE-py3k pYthon InterpReTeRS to tuRN oN CAse > INSensiTIvITY oR Case sensiTiVIty OR A SpecIaL Warning mode. > > -- > --GUIDO van rOSsum (hoME PaGe: HTTp://wWw.PythOn.oRg/~GuidO/) > -- > HttP://www.PYthOn.ORG/MaiLman/LIStiNfO/pYthoN-LISt > > > I know I am being ridiculous. > > However, I am having trouble imagining how removing case-sensitivity from the language could improve usablility for > any programmer, regardless of his/her skill level. Most people seem to have no particular trouble with case-sensitivity in > natural languages; why should a computer language be any different? On the other hand, maybe I am just too ingrained in my old > thought patterns. > > Best, > > Ben > > > -- > http://www.python.org/mailman/listinfo/python-list You have been warned. No more silliness! Now let's have something military. (Or at least something completely different.) From robin at illusionsexeculink.com Sun May 14 14:11:05 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Sun, 14 May 2000 14:11:05 -0400 Subject: Python Plans from ActiveState References: Message-ID: <51rthscplh93iuktpbn87lihguqo1rq5s8@4ax.com> "Mark Hammond" wrote: >It will be the core Python, plus some "key extensions" for the platform. >Eg, for Windows, it will include the win32all series. I would very much like the Windows install to be free of registry nonsense and hence be network (and person!) friendly. PYTHONPATH should be an environment variable, not a registry string. This will make it *much* easier to install Python once on a network server and use it from multiple development machines. If registry strings are essential for some functions, lets have them set up at run-time where necessary. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Ontario's government could be a symptom of the conditions deep in the ocean. From m.faassen at vet.uu.nl Tue May 30 19:33:19 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 May 2000 23:33:19 GMT Subject: Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!)) References: <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <8grnj1$sb3$13$1@news.t-online.com> <393326D3.400AA248@cosc.canterbury.ac.nz> <8h078i$bnc$2@newshost.accu.uu.nl> Message-ID: <8h1j3v$h04$1@newshost.accu.uu.nl> Huaiyu Zhu wrote: > On 30 May 2000 11:04:50 GMT, Martijn Faassen wrote: >>Question: why does nobody complain about the overloading of the '+' >>operator? After all, it works on both strings and numbers; and presumably >>your code will fall apart at unsuspected points as well if you assume it >>only deals with numbers. :) > Two points worth considering: > 1. The int to float conversion is often automatic: sqrt(2) > 2. a/b produces different results based on type without warning. Right, as I thought I wrote in the rest of my post. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From loewis at informatik.hu-berlin.de Mon May 29 11:34:00 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 May 2000 17:34:00 +0200 Subject: pyc files References: <39325A31.1C0839A6@obop.com.pl> Message-ID: > Can I create a rpm with only pyc files or do I need the py file also to > make package distrubution ? No, just the bytecode will do. Regards, Martin From relder at omegabit.com Fri May 12 02:11:14 2000 From: relder at omegabit.com (Rob Elder) Date: Thu, 11 May 2000 23:11:14 -0700 Subject: Determine if file exists Message-ID: Hi, How do I check to see if a file exists? TIA. -r From mak at imakhno.freeserve.co.uk Sat May 27 12:49:05 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Sat, 27 May 2000 17:49:05 +0100 Subject: Is Python really slow? References: <392F8286.13371C4E@mit.edu> Message-ID: <8goufe$17n$1@newsg4.svr.pol.co.uk> >I have implemented loop in Python > >for k in xrange(1,100000000): > pass Does xrange create an array of numbers 1...1e8? From thomas at xs4all.net Tue May 23 03:12:01 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 23 May 2000 09:12:01 +0200 Subject: bug report - time.strptime() In-Reply-To: <8gcva8+a9aq@eGroups.com>; from kevin_ng@xoommail.com on Tue, May 23, 2000 at 03:52:40AM -0000 References: <8gcva8+a9aq@eGroups.com> Message-ID: <20000523091201.W13281@xs4all.nl> On Tue, May 23, 2000 at 03:52:40AM -0000, Kevin Ng wrote: > >>> s5='000201' > >>> tup5 = time.strptime(s5, '%y%m%d') > >>> tup5 > (1900, 1, 0, 0, 0, 0, 6, 1, 0) > > >>> s6='00 02 01' > >>> tup6=time.strptime(s6, '%y %m %d') > >>> tup6 > (1900, 2, 1, 0, 0, 0, 6, 1, 0) > Note the pattern is whenever the format string has no separation, > then strptime always return a date tuple of Jan 0 !? > My python version and platform : > Python 1.5.2 (#3, Jan 20 2000, 15:59:17) [GCC egcs-2.90.29 980515 > (egcs-1.0.3 re on linux2 What linux distribution/libc are you using ? It seems to be a bug in the provided strptime() library call, because i dont see it (standard python 1.5.2 on RedHat 6.2, and non-standard python 1.6 on RedHat 6.1: >>> s6='00 02 01' >>> time.strptime(s6, '%y %m %d') (2000, 2, 1, 0, 0, 0, 1, 32, 0) The time.strptime() function is not much more than a wrapper around the libc strptime(), so I'm afraid you'll have to trace it there ;) Upgrading is fairly likely to fix the problem, as both my boxes are running glibc 2.1 (2.1.2 ad 2.1.3) and they are working fine. PS: better to use python-list at python.org, instead of @cwi.nl -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From soundhack at hotmail.com Tue May 16 20:32:03 2000 From: soundhack at hotmail.com (Robert) Date: Tue, 16 May 2000 20:32:03 -0400 Subject: Win32file newline character References: <8fsk4v$air$1@nnrp1.deja.com> Message-ID: <3921e7b5$0$10900@senator-bedfellow.mit.edu> For Windows platforms you need to specify "\r\n" for most programs to recognize a "newline" Robert traversx.l.kiley at intel.com wrote in message <8fsk4v$air$1 at nnrp1.deja.com>... >Hello, I'm creating a win32file object to write different strings and >i'm having trouble figuring out how to start a new line in the file. >I've tried "\n" and "\012" and "\0" and nothing seems to work. Does >anyone know how to place a newline into the win32file.WriteFile >(wHandle, string) method? From boud at rempt.xs4all.nl Wed May 24 12:03:22 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 24 May 2000 16:03:22 GMT Subject: __getattr__ and __setattr__ troubles References: <8gehq1$kq6$1@news1.xs4all.nl> <8ggo6m$2v6h$1@news.aros.net> Message-ID: <8gguga$k30$2@news1.xs4all.nl> Adam Ruth wrote: > Here's your problem: >> def setFieldValue(self, field, value): >> print "Call: setFieldValue", field, value >> if self._tblDef.has_key(field): >> self._fields[field]=value >> else: >> self.__dict__[field]=value > Since _tblDef doesn't have a "field3", then field3 will be set in > the __dict__, not in the _fields as you might expect. No, I _did_ expect field3 to turn up in__dict__ - that's where I want it since it isn't in the table defintion. > The __str__ and __coerce__, etc, will all be sent to > __getattr__ because they are *not* defined in the > class. If they were, then __getattr__ would never be > called. Ah, that's it. Boudewijn Rempt | http://www.valdyas.org From m.faassen at vet.uu.nl Tue May 16 18:06:15 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 May 2000 22:06:15 GMT Subject: python improvements (Was: Re: New Language) References: <4.3.1.2.20000512165909.01e0bf08@phear.dementian.com> <8fhva4$h5i$1@newshost.accu.uu.nl> <8fjhjc$l6k$3@newshost.accu.uu.nl> Message-ID: <8fsgon$jei$1@newshost.accu.uu.nl> Neel Krishnaswami wrote: > Martijn Faassen wrote: [snip] >> What about classes and methods though? If you want to optimize some of >> the dispatching it may be pretty helpful to have static typing. > Strong typing doesn't help with dispatch elimination except in > combination with something like Java's 'final' classes or Dylan's > 'sealed' classes, or if you do whole-program analysis (like Cecil's > Vortex compiler does). > This is because in order to eliminate a dispatch, you need to know the > direct class of an object, rather than just "this is an instance of > some subclass of Foo". For example, you couldn't do dispatch > elimination in this function: > def square(n: Number): > return n * n > because the hypothetical Number class isn't a leaf class of the class > hierarchy. (Well, you could if you could do interprocedural dataflow > analysis and were able to prove that a particular call to square() > would receive a machine integer or float, but that's a *lot* of work.) Sure, but you could optimize *some* of the dispatching if you did know the particular class of an object. Of course whether that's a good idea is another point. And wouldn't it be possible to at least optimize the dispatch tables somewhat if you knew an object was a subclass of something? It would be tricky, but you might be able to cut through some hash table lookups. Don't know if that'd gain you a lot, though. I'd agree with you in general that optimization of this could perhaps better be solved by other ways than static typing. Method caching indeed sounds interesting. >> Similarly, in a dynamic system you'd *lose* your nice declarations >> as soon as you pass them into some function that doesn't have them >> (barring type inferencing, which is about as non-easy as static typing, >> if not more :). > Lisp compilers are pretty smart about this: if you pass a typed > function to a dynamic fn, it will check the types on the function and > raise an error if they don't match. When they *can* compute all the > types then they don't do the checks. > I don't know if anyone has written an OO language that supports type > inferencing -- I was under the impression that adding subtyping rules > to Hindley-Milner type systems made them undecidable. Hm, I don't know much about ocaml, but the language does some type inferencing as far as I'm aware, and it supports objects. Perhaps someone more knowledgable about it (you? :) could comment. >> > Before static typing for speed is tried (with its complicating effects >> > on implementation), I think it's better to go for the factor of 2 >> > improvement that can be won via easy tricks like method caches, >> > variable lookup optimization, and reducing function call >> > overhead. (Look at Squeak Smalltalk for an example.) >> >> Definitely agreed. (method caching may not always be that easy, though, >> given __getattr__ and friends..) > True. I wouldn't mind if there were a smaller hammer than __getattr__, > though -- usually I want to catch only a few attributes dynamically, > rather than all of them. A nice syntactic hammer for getter/setters might be useful. I suppose a __getattr__ wouldn't be unsurmountable, though. You could cache a reference to the method that's looked up if in fact it's implemented by an actual method. Have a cache that's a hash with as keys the object references and the method names, and as values references to the method objects. When there's a method lookup: * check that table first, if it's in there, call the method found * otherwise do normal lookup * if found outside __getattr__, cache it in table (insert some smart caching rule here) * do rest of handling You could do something similar for attribute lookups. The tricky parts are classes that play with their methods, objects that change their classes, etc. Perhaps it's possible to catch these special cases and have them invalidate the record cache as far as the objects in question pertain. Alternatively we could have those objects or classes somehow indicate they're 'special' and that they don't want to partake in the caching mechanism. Do I get the ideas right here? I don't have any practical experience with this. I wonder how much of a speedup one might get compared to the current scheme. If it isn't significant it's not worth it. Also there's of course the question whether dealing will all kinds of optimization bugs is worth it. >> >> ERR -- we get more robust code as the types are checked. It's nice when >> >> this happens during compile-time, though run-time can also be >> >> helpful. >> >> > With an interactive read-eval-print loop, run-time is just as good as >> > compile-time, IMO, because you can test your system incrementally, as >> > you build it. >> >> Not all people agree on this. I think some interface conformance >> checking at compile-time would for instance be nice. But I >> definitely agree that the ERR component of static type checking is >> overrated. > That's why I put in the IMO. :) You're right. :) > Seriously, types are most helpful to > me as documentation of intent, and as it happens I try to put the > types of arguments into the docstrings of code I write. I tend to do that as well. Still, it would be nice if there was a structured interpreter-checked scheme for this. > I have experimented with automatically checking the docstrings (see > http://www.sff.net/people/neelk/open-source/TypeChecker.py), but it > was never useful enough for me to pursue very far. Oh, so you agree with my previous statement. I'd agree it isn't something I yearn for a lot either. Coming from C++ I'd have thought I'd needed it more than I do. Types really do seem overrated, especially given a decent namespace and error reporting system. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From wware at world.std.com Sat May 6 14:47:52 2000 From: wware at world.std.com (Will Ware) Date: Sat, 6 May 2000 18:47:52 GMT Subject: My Server supports Python? References: <391305A4.98430BB0@swt.edu> <39145347.59330549@san.rr.com> Message-ID: Courageous (jkraska1 at san.rr.com) wrote: > % find / -name "python*" -print He could also just do: which python though "find" and "which" both assume a Unix system. Assuming his path is set up correctly, trying to run at the command line should also work in a DOS window. I don't know what you'd do on a Mac. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From just at letterror.com Tue May 16 07:00:48 2000 From: just at letterror.com (Just van Rossum) Date: Tue, 16 May 2000 12:00:48 +0100 Subject: Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?) In-Reply-To: References: Message-ID: At 1:22 AM -0700 16-05-2000, Dirck Blaskey wrote: >> Theoretically, a colon is only necessary in things like >> >> if yes: print "yes" > >Oddly enough, the parser doesn't really need the colon here either. >It can manage to figure out where the if expression ends without it. Erm, how would you parse this? if yes () That's either two expressions or just one... Just From effbot at telia.com Sun May 21 05:32:46 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 21 May 2000 09:32:46 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <21052000.2@sanctum.jae.ddns.org> Message-ID: <23OV4.5070$wYl.214479360@newsb.telia.net> Juergen A. Erhard wrote: > Guido> (1) Randy Pausch, a professor at CMU, found, when teaching > Guido> Python to non-CS students in the context of Alice > Guido> (www.alice.org), that the number one problem his students > Guido> were having was to remember that case matters in Python. > Guido> (The number two problem was 1/2 == 0; there was no > Guido> significalt number three problem.) > > Did he try a Python that was case-insensitive? maybe you should follow that link, read up on the alice project and the people behind it, and then tell us what you really think about HCI researchers? > And case-sensitivity is really not hardcore computer science. is it computer science at all? it's not as if the *computer* really cares about case, you know... From kern at caltech.edu Sun May 28 20:44:46 2000 From: kern at caltech.edu (Robert Kern) Date: 29 May 2000 00:44:46 GMT Subject: Clifford Algebra References: Message-ID: <8gsehu$btl@gap.cco.caltech.edu> In article , Kirby Urner writes: > > Any Python modules out there for doing Clifford Algebra? > I've found several CA calculators on the web, but nothing > in Python yet (my Quaternion class doesn't count). Not to my knowledge. I've been meaning to wrap the XMU library (http://www.perwass.de/Programs/XMULib/xmulib.html) by Christian Perwass that implements a C++ class heirarchy for Clifford Algebras. Or I might simply re-implement the same ideas in pure Python. > Kirby -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From charlie at intelligenesis.net Tue May 9 15:34:55 2000 From: charlie at intelligenesis.net (Charlie Derr) Date: Tue, 9 May 2000 15:34:55 -0400 Subject: Python/Zope In-Reply-To: <8f9obk$c3k$1@news.sysnet.net.tw> Message-ID: |Does anybody know a newsgroup about Zope? |I have searched on comp. and didn't find anything. :o/ Are you aware of the e-list? The address is zope at zope.org (more info at www.zope.org). It's a pretty active list. Also, there's a #zope channel on efnet if you're a fan of IRC (though it's still kind of quiet, especially in comparison to the #python channel there). irc.openprojects.net also has a (smaller) #python channel not exactly what you were looking for, but hopefully it'll help, ~c | | Thanks for your help | | Fabio Augusto Mazzarino - mazza at radiusystems.com.br | | |-- |http://www.python.org/mailman/listinfo/python-list | From cbbrowne at news.hex.net Thu May 25 19:55:50 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Thu, 25 May 2000 23:55:50 GMT Subject: ANNOUNCE: Python CVS tree moved to SourceForge References: <200005212205.PAA05512@cj20424-a.reston1.va.home.com> <8gbobr$59f$4@newsserver.rrzn.uni-hannover.de> <0AlW4.111443$MB.2189764@news6.giganews.com> <392A10A8.99B10484@yale.edu> Message-ID: Centuries ago, Nostradamus foresaw a time when Paul Magwene would say: >Christopher Browne wrote: >> It concerns me somewhat, from the perspective of the one site >> representing a "physical vulnerability." >> >> Thus, "if an asteroid struck VA Linux Systems' offices," a whole lot >> of data could be lost. >> >> I have no reason to assume/attribute nefarious intent here, but there >> are lots of bad things that could happen, of varying likelihood: >> >> - The asteroid/meteor theory :-). >> - Earthquake (California has them sometimes). >> - Someone does something that proves horribly illegal, let's say, >> using a SourceForge directory to store "kiddy porn," and, the >> ever-interested FBI storms the building and seizes equipment. >> - Power outage >> - Lightning strike >> - MPAA decides that GZIP infringes on their right to control copyright >> of movies, and sends the LAPD in to destroy this infringement. >> ... the list goes on ... >> >> The point here is that due to no fault of LNUX, SourceForge could >> become unavailable. >> > >Well, from a physical standpoint the situation is less worrisome than >you make it out to be. > >From the sourceforge FAQ: > >What is your backup strategy? > > We perform a full backup of all site and project data daily, and >rotate backups off-site weekly through a large company that specializes >in storing backup tapes. We also have access to a fireproof safe for >storage of daily tapes. > The exception to this rotation is the mega-file-server, which cannot >be fully backed up (when full) by less than 3425GB AIT tapes (our medium >of choice). It gets a full backup once per month and incrementals >otherwise. I was pleased enough when I saw that in the FAQ; it certainly does represent a reasonable sort of backup strategy. At least against physical events that wouldn't be so dramatic as an asteroid removing the Silly Valley. :-) It still isn't "proof" against the threat of things like the MPAA sending a troop of lawyers to confiscate all the backups for hosting something like PAN on the site. (PAN: a news reader that permits decoding binary messages; an _OBVIOUS_ threat to the music industry... And to think I always thought that the only point to "decoding binaries" was to rake in porno pictures from the binaries newsgroups...) -- cbbrowne at ntlug.org - Rules of the Evil Overlord #197. "I will explain to my Legions of Terror that guns are ranged weapons and swords are not. Anyone who attempts to throw a sword at the hero or club him with a gun will be summarily executed." From blues-l at cyberus.ca Fri May 19 13:29:13 2000 From: blues-l at cyberus.ca (blues-l at cyberus.ca) Date: Fri, 19 May 2000 13:29:13 -0400 Subject: Confused about "reload" Message-ID: <392579E8.74393DAE@cyberus.ca> If I have a file tester.py: class tryit: def __init__(self,mess): self.mess=mess def printit(self): print "this is", self.mess .. I can "import tester"and reload(tester) and I can get an updated "tryit" but if I "from tester import *" I can't get a reload of "tryit" to happen. What does the reloadline look like in that case??? From maria_jenny at my-deja.com Wed May 3 08:55:46 2000 From: maria_jenny at my-deja.com (maria_jenny at my-deja.com) Date: Wed, 03 May 2000 12:55:46 GMT Subject: random.betavariate Message-ID: <8ep7ka$r1a$1@nnrp1.deja.com> Hi, Does anyone know what the arguments alpha and beta are and how they are linked to the mean and standard deviation of the beta distribution? Maria and Jenny Sent via Deja.com http://www.deja.com/ Before you buy. From mich-hag at dsv.su.se Wed May 3 06:32:37 2000 From: mich-hag at dsv.su.se (Miguel) Date: Wed, 3 May 2000 12:32:37 +0200 Subject: database connection Message-ID: <8eov85$5ek$1@news.su.se> I want to connect to a database using odbc. I have been searching the entire www (almost) for the difference between odbc and ODBC. Now I turn to you, could anyone explain the difference to me?? Is it possible to run ODBC on any plattform?? Would it be better if I used a specific module for my particular db?? Thanks in advance! Miguel From claird at starbase.neosoft.com Mon May 8 09:07:45 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 8 May 2000 08:07:45 -0500 Subject: Future of the Python Linux Distribution References: <20000507193526.B6654@owl.rhein-zeitung.de> Message-ID: <4C95B8F54A161604.7FBF936FB67D591C.6CCE6C23CE84CA77@lp.airnews.net> In article , Glyph Lefkowitz wrote: . . . >has, you can't do anything. Now, python has some nifty quirks too (my >code is riddled with __setattr__ and __getattr__. I LOVE them!) but I >seriously doubt there will ever be a JPerl. . . . There already is. That is, if I understand you correctly, you're speculating that Perl's undeniable squirrelliness precludes construc- tion of "a toolkit for creating Java-Perl applications" . In fact this page is somewhat dated; JPL is farther along than is apparent from this write-up. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From info at pythonware.com Wed May 31 07:28:40 2000 From: info at pythonware.com (PythonWare) Date: Wed, 31 May 2000 13:28:40 +0200 Subject: ANNOUNCEMENT: PythonWorks 1.0 now available (may 31, 2000) Message-ID: <00de01bfcaf3$6236de90$0500a8c0@secret.pythonware.com> it's time for a major release from the labs: PythonWorks is a rapid application development tool, designed for efficient development in Python. PythonWorks includes editors, a debugger, a user-interface design tool, project browser, deploy- ment tools, integrated on-line help, and a scriptable environment. To learn more, visit the PythonWorks product site: http://www.pythonware.com/products/works If you order now, you get: - PythonWorks 1.0 for Windows 9X/NT/2000 (more platforms 3Q00) - a personal license for PythonWorks 1.X on all available platforms - free upgrades throughout the entire 1.X series - support via mail For more information, please visit the product site, or mail us at info at pythonware.com. regards, the pythonworks team "Secret Labs -- makers of fine pythonware since 1997." From psl at mitre.org Tue May 16 12:01:01 2000 From: psl at mitre.org (Peter Leveille) Date: Tue, 16 May 2000 12:01:01 -0400 Subject: mxODBC and delete References: <3920530E.79AACCDC@mitre.org> <3920e7d9_3@plato.netscapeonline.co.uk> Message-ID: <392170BD.DC816592@mitre.org> latrada wrote: > > Peter, > > I can run a delete command on my setup (i've just checked). > > I suppose you've checked that ODBC set up ok? > > Can you run a select statement? > Yes, and I can use insert. > I presume from below that you're connect with a user name and password - > does this have authority to delete? > Yes, I logged into the Oracle SQL *Plus GUI using the same username and password, and I can delete through that GUI. > Have you tried a different database? Nope. I only have one database to work with. > > Richard > > Peter Leveille wrote in message > news:3920530E.79AACCDC at mitre.org... > > I have been using the mxODBC package for access to a database. This has > > been working great, until a recent problem that I have had. When I try > > running the following code, python just freezes up. Does anyone know > > what I am doing wrong, or if there is another way to do it? > > > > >>> import ODBC.Windows > > >>> db = ODBC.Windows.Connect('????????','???','??????') > > >>> c = db.cursor() > > >>> c.execute('DELETE FROM ???????') From rzantow at my-deja.com Tue May 9 09:37:34 2000 From: rzantow at my-deja.com (rzantow at my-deja.com) Date: Tue, 09 May 2000 13:37:34 GMT Subject: How to execute lists of code? Or alternatives. Message-ID: <8f94as$25n$1@nnrp1.deja.com> Is there a way to execute a list of Python code strings? What I'd like to do is to create a dictionary of tags and, among other things, associated code. When parsing a file and encountering one of the tags, I'd then execute the associated code. I could do this if the code fragments were contained in separate files, using exec_file(), but I'd rather not have to either create a host of tiny files or a large file with a long string of if...elif conditions. I'd expect the code to be built up, in a manner of speaking, by applying a generic dictionary to handle the known tags, and adding new tag-handling and overrides for a given program run. I would prefer that the new/overrides stuff be maintained in a single file, but associated at run time with the individual tags. Has anyone done this? Can anyone point out the likely better way to do something like it? The limitation I'm looking at is that it would not likely be programmers maintaining the new/overrides material. I would expect that knowledgeable users and programmatic wizards would be used to build up that code, except in unusual circumstances. Any comments? -- Pythons, unlike some other snakes, do have hindlimbs, but they never develop beyond vestigial stumps. The arrest of limb development is due to a failure of the sonic hedgehog signalling system ... Sent via Deja.com http://www.deja.com/ Before you buy. From phd at phd.russ.ru Mon May 29 08:51:07 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 29 May 2000 12:51:07 +0000 (GMT) Subject: E-mail read-write function In-Reply-To: <001201bfc96c$e0edb930$1001a8c0@CODECHAFIK16> Message-ID: On Mon, 29 May 2000, sameh chafik Travaille wrote: > > On Thu, 25 May 2000, Sameh chafik pro wrote: > > > are there any standard way to read-write the e-mail with python. > > > > Write with smtplib.py. Read with mimetools.py; this require some more > > work, but I can show you an example - just ask! Download and read docs for extract_mime - it is a template for reading e-mails from MTA (Mail Transfer Agent). Master site: http://sun.med.ru/~phd/Software/Python/#extract_mime Faster mirrors: http://skyscraper.fortunecity.com/unix/797/Software/Python/#extract_mime http://members.xoom.com/_XMCM/phd2.1/Software/Python/index.html#extract_mime Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From dworkin at ccs.neu.edu Thu May 4 10:39:15 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 04 May 2000 10:39:15 -0400 Subject: Best way to convert a list to a dictionary In-Reply-To: Michael Husmann's message of "Thu, 04 May 2000 07:53:59 +0200" References: <76ZP4.2558$wYl.196706304@newsb.telia.net> <39111077.A4837441@teleatlas.com> Message-ID: Michael Husmann writes: > > > I have a list where each element is another list with two elements. > > > What is the best way to convert this to a dictionary? > > > > Something like this would probably be simplest: > > > > d = {} > > for k, v in your_list: > > d[k] = v > This example looks nice bus does not work with my Python 1.52. Trying to > get both elements from 'your_list' produces a TypeError exception: Is your_list really what you described, a list where each element is another list with two elements? >>> your_list = [['a', 1], ['b', 2], ['c', 3]] >>> d = {} >>> for k, v in your_list: ... d[k] = v ... >>> d {'b': 2, 'c': 3, 'a': 1} I suspect that your list was ill-formed. -Justin From greg at perceval.be Thu May 4 11:39:47 2000 From: greg at perceval.be (Gregoire Welraeds) Date: Thu, 4 May 2000 17:39:47 +0200 (CEST) Subject: HTML parser example, anybody? In-Reply-To: <3908909D.4022A846@roguewave.com> Message-ID: In reply to the message of Bjorn Pettersen sent on Apr 27 (see below) : The following issue is very interesting because you can generate dynamic contents only by using > htmlfile = open('foo.html', 'w') > replacements = { > 'title': 'my title', > 'heading': 'A Heading', > } > htmlfile.write( open(foo.templ).read() % replacements ) > htmlfile.close() I got one problem left. > %(title)s >

    %(heading)s

    What I think would be very intersting is to have the variable's name enclosed in an HTML commentary like in the following: <!--cgi: %(title)s -->

    Like this, A Web designer could work on any template within an application without any intervention of the programmer. The opposite is right too. Any clue ? ;) -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Thu, 27 Apr 2000, Bjorn Pettersen wrote: > Date: Thu, 27 Apr 2000 13:10:21 -0600 > From: Bjorn Pettersen > To: Gerhard Haering > Cc: python-list at python.org > Subject: Re: HTML parser example, anybody? > > Gerhard Haering wrote: > > > > Hi! > > > > I want to transform my own HTML templates (with a few template tags, > > special comments, and so on) into final HTML for the browser. I would like > > to use Pyhton's htmllib, but from the docs I can get no clue on how to get > > it done. I seem to have to use a writer and a formatter class ... > > > > I would greatly appreciate an example of HTML -> HTML using > > htmllib/sgmllib. Can anybody provide pointers/code snippets? > > Why don't you just use Python's string syntax, e.g. if you have the > following in a template file called foo.templ: > > %(title)s >

    %(heading)s

    > > you can do something like: > > htmlfile = open('foo.html', 'w') > replacements = { > 'title': 'my title', > 'heading': 'A Heading', > } > htmlfile.write( open(foo.templ).read() % replacements ) > htmlfile.close() > > -- bjorn > > -- > http://www.python.org/mailman/listinfo/python-list > > From cestluk at polyu.edu.hk Thu May 11 21:20:34 2000 From: cestluk at polyu.edu.hk (LUK ShunTim) Date: Fri, 12 May 2000 09:20:34 +0800 Subject: [FAQTS] Python Knowledge Base Update -- May 10th, 2000 References: <20000510142743.8629.qmail@synop.com> Message-ID: <391B5C62.D71F17BE@polyu.edu.hk> Fiona Czuczman wrote: > > Hi Guys, > > I've started entering some of the questions, with answers, that make it > onto the newsgroup into http://python.faqts.com . I'm planning on doing > this on a daily basis. > [snipped] Would you consider setting this up as _another_ mailing list? The number of messages on the python lists is very large for me to cope. Regards, ST -- > However, I'm not an expert (novice is a more apt word) so if I've made > any blunders it would be great if someone would take the time to point > me in the right direction. > > Thanks, Fiona Czuczman > > ## New Entries ################################################# > > ------------------------------------------------------------- > When running sets of python scripts how can I cleanup all variables (globals) from the last one run? > http://www.faqts.com/knowledge-base/view.phtml/aid/2596 > ------------------------------------------------------------- > Fiona Czuczman > Moshe Zadka > > Run them with "exec