Re: Pycon disappointment
Tom Moertel organized a Perl conference with an interesting sponsorship policy, that may be worth considering. He posted about it on the reddit thread about this clp thread: http://reddit.com/info/6c9l6/comments/c03gli2 . (Disclaimer: I have no idea if that would work for pycon at all or in part, I'm just posting it because I found it thought-provoking.) -Bill Mill http://billmill.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Klik2 Project, Python apps on linux
Jason, Can you give a little more detail on the problem? What's the directory structure of a Klik package that's failing look like? What program is trying to import what module from where that's failing? -Bill Mill On Jan 27, 2008 1:49 AM, Jason Taylor [EMAIL PROTECTED] wrote: Hi We've been working on klik2, http://code.google.com/p/klikclient/, which implements OSX like application files on linux (with applications working on all distros), In which every user desktop application is 1 file We've run into a bit of a problem with python apps, so while we can run a complicated application like openoffice.org on ubuntu, fedora and suse from a single file we cant run any python applications such as jokosher gnome-specimen angrydd gausssum pathological quodlibet webboard istanbul exaile ccsm bittornado pessulus labyrinth wammu accerciser We'd like to fix this in a clean way with out resorting to nasty hacks involving $PYTHON_PATH. If any one has any suggestions please email me or drop by #klik on freenode Issue http://code.google.com/p/klikclient/issues/detail?id=144 Cheers Jason Taylor -- Why isn't my life like a situation comedy? Why don't I have a bunch of friends with nothing better to do but drop by and instigate wacky adventures? Why aren't my conversations peppered with spontaneous witticisms? Why don't my friends demonstrate heartfelt concern for my well being when I have problems? ...I gotta get my life some writers. - Calven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler-AST-Walk-Visitor: Any Examples or Documentation?
On Mar 23, 1:10 pm, Efrat Regev [EMAIL PROTECTED] wrote: Hello, I'm trying to write something that will translate Python code to pseudo-code (for teaching purposes). Googling around indicated that the compiler module is pertinent, especially creating a visitor to walk the generated AST:http://docs.python.org/lib/module-compiler.html I can build the AST, but I can't figure out how to write the visitor. The package documentation didn't help me out that much, and I couldn't find any examples. In fact, google only came up with this unanswered related question:http://mail.python.org/pipermail/python-list/2006-July/392716.html Any help is appreciated. Thanks and Bye, Efrat Maybe some of the files in google codesearch that import compiler and walk would be helpful? http://www.google.com/codesearch?q=compiler+walk+lang%3Apythonhl=enbtnG=Search+Code It seems from a superficial look that some of those files would be helpful as examples. -Bill Mill bill.mill at gmail.com http://billmill.org -- http://mail.python.org/mailman/listinfo/python-list
Re: windows blinds
On Mar 14, 4:58 pm, lled [EMAIL PROTECTED] wrote: i am new to python and wanted to know could i use it to write a programme so when i double click on a windoz window it collapses (like in linux)? You probably could, but you would basically be writing C, because you're going to need to use the Win32 API. As for how to use the win32 API, you could try asking on comp.os.ms- windows.programmer.win32 ( http://groups.google.com/group/comp.os.ms-windows.programmer.win32/topics?lnk=srg ), because that's some fiendish stuff. -Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex Question
Gabriel Genellina wrote: At Tuesday 16/1/2007 16:36, Bill Mill wrote: py import re py rgx = re.compile('1?') py rgx.search('a1').groups() (None,) py rgx = re.compile('(1)+') py rgx.search('a1').groups() But shouldn't the ? be greedy, and thus prefer the one match to the zero? This is my sticking point - I've seen that plus works, and this just confuses me more. Perhaps you have misunderstood what search does. search( pattern, string[, flags]) Scan through string looking for a location where the regular expression pattern produces a match '1?' means 0 or 1 times '1', i.e., nothing or a single '1'. At the start of the target string, 'a1', we have nothing, so the re matches, and returns that occurrence. It doesnt matter that a few characters later there is *another* match, even if it is longer; once a match is found, the scan is done. If you want the longest match of all possible matches along the string, you should use findall() instead of search(). That is exactly what I misunderstood. Thank you very much. -Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex Question
James Stroud wrote: Bill Mill wrote: Hello all, I've got a test script: start python code = tests2 = [item1: alpha; item2: beta. item3 - gamma--, item1: alpha; item3 - gamma--] def test_re(regex): r = re.compile(regex, re.MULTILINE) for test in tests2: res = r.search(test) if res: print res.groups() else: print Failed end python code And a simple question: Why does the first regex that follows successfully grab beta, while the second one doesn't? In [131]: test_re(r(?:item2: (.*?)\.)) ('beta',) Failed In [132]: test_re(r(?:item2: (.*?)\.)?) (None,) (None,) Shouldn't the '?' greedily grab the group match? Thanks Bill Mill bill.mill at gmail.com The question-mark matches at zero or one. The first match will be a group with nothing in it, which satisfies the zero condition. Perhaps you mean +? e.g. py import re py rgx = re.compile('1?') py rgx.search('a1').groups() (None,) py rgx = re.compile('(1)+') py rgx.search('a1').groups() But shouldn't the ? be greedy, and thus prefer the one match to the zero? This is my sticking point - I've seen that plus works, and this just confuses me more. -Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Regex Question
Hello all, I've got a test script: start python code = tests2 = [item1: alpha; item2: beta. item3 - gamma--, item1: alpha; item3 - gamma--] def test_re(regex): r = re.compile(regex, re.MULTILINE) for test in tests2: res = r.search(test) if res: print res.groups() else: print Failed end python code And a simple question: Why does the first regex that follows successfully grab beta, while the second one doesn't? In [131]: test_re(r(?:item2: (.*?)\.)) ('beta',) Failed In [132]: test_re(r(?:item2: (.*?)\.)?) (None,) (None,) Shouldn't the '?' greedily grab the group match? Thanks Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
iTunes Search Algorithm/Data Structure?
Hello all, What data structure would you use to implement something analogous to the iTunes search? I imagine that it must be a tree of some sort, but I can't figure out an easy structure for it. Requirements (in case you haven't used it): You are given 4 rows in a list view: [[alpha, beta], [delta, gamma], [foo, bar], [etc, etc]] and a search text box. Typing a in the list box leaves rows 0, 1 and 2 in the list box, because some element in each of those rows has an a in it. Typing am leaves only row 1, since gamma has the substring am in it. The key here is that this works instantaneously as you type, even with very large lists with many elements per row. I'd like the employee list in my current application to be similarly filtered, but I don't quite see how. Thoughts? -Bill Mill bill.mill at gmail.com billmill.org -- http://mail.python.org/mailman/listinfo/python-list
Re: python website
On 12/16/05, carmel stanley [EMAIL PROTECTED] wrote: I am interested in doing a web site in python can any body direct me to a site that was created in python. thanks nige python.org cherrypy.org zope.org turbogears.org blog.ianbicking.org zephyrfalcon.org/weblog2/ djangoproject.org cheetahtemplate.org pyblosxom.sourceforge.net webwareforpython.org mems-exchange.org/software/quixote/ twistedmatrix.com Just off the top of my head. Many of those are sites for python web frameworks. A few are blogs of well-known developers. Also try http://www.google.com/search?q=python%20web%20framework . Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Default method arguments
On 15 Nov 2005 08:03:26 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ) print x All I want is to make self.data the default argument for self.f(). (I want to use 'A' class as following : myA = A(5) myA.f() and get printed '5' as a result.) class A: def __init__(self, n): self.data = n def f(self, x=None): if not x: x = self.data print x myA = A(5) myA.f() 5 Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Default method arguments
On 11/15/05, Nicola Larosa [EMAIL PROTECTED] wrote: def f(self, x=None): if not x: Ha! You fell for it! ;-D (Hint: what about x being passed with a value of zero? :-) ) I wasn't sure if you saw my post before you posted - good call. I just tossed off an answer without thinking much, and we see the result. It could have been a good debugging lesson for him if he'd tried to pass 0; I think I'll use that as my excuse. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
On 10 Nov 2005 08:40:17 -0800, Ben Sizer [EMAIL PROTECTED] wrote: Alex Martelli wrote: This is (a minor) one of the many reasons that make webservices the way of the future (hey, even *MSFT* noticed that recently, it seems...). But they are not suitable for all applications, and probably never will be. Your only solution, then, is to write unpopular code. Because, as Alex said, it will otherwise be broken into. Let's look at two very popular pieces of code: Half-Life 2 and Windows XP. How are they secured? Previous version of these software products used sophisticated client-side programming to try and be secure, but the security was nonexistant. Users share keys and cracks with each other. Now, both of these programs require verification (phone and/or web) to be used. The only truly secure method of assuring that they're not used in ways you don't intend is to require the user to contact you to use it, and that's a deal with the devil. One you might need to make if security is that important to you, as Microsoft and Valve have decided it is, but it's a deal with the devil nonetheless. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHON LOOSING FOR JAVA???????
On 11/7/05, Martin v. Löwis [EMAIL PROTECTED] wrote: Fcamattti wrote: Hello for everybody So I have a doubt. I'd like to know what do you think about the joint of efforts of Sun Microsystems and the Google to create a office web based. I sincerely enjoy the idea althoug I'd like to know what will be the future of this wonderful language called Python?? I think I know Although, the future is difficult to predict??? +1 QOTW Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python server
On 7 Nov 2005 10:22:18 -0800, linuxpld [EMAIL PROTECTED] wrote: Hello I`m writing a program (server in future) in python. I would like to write it in such a way that I will be able to write gui in any language and connect to my python program and use functionality included with it. are there any libraries that I could use? Lots...Perhaps you should start off in understanding your problem by learning about sockets: http://www.amk.ca/python/howto/sockets/ Sockets are a generalized method for passing data between programs on the same or different computers. I dont know if i wrote it understandably but maybe picture will explain it: || | python | || - module in python - - connection (???) - -gui in any language (java, c++, python, etc). | server | |---| what could I use as http? mqseries? webservices? what are the possibilites? http, webservices, xmlrpc, corba, people to type in messages between programs, carrier pigeons, and sockets are all possibilities. I'm gonna recommend that you learn sockets, because they're a general solution to this problem, and many methods of inter-program communication are based on sockets, but I don't know the specifics of the program you're designing. How tightly will the client and server interact? In what environment (ie over the internet, over a corporate LAN, on the same computer, on Internet2)? Is there any framework in existance, or is this program being written from scratch? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
___ class a: i=0 def setI(iii): if self.i!=iii: self.i=iii #do some extra works here, e.g, notify the observers that #this property is changed, or do some logging things. ___ In the class a above, when i is changed, I will do some extra works, the extra works could be very import, so I want to keep i invisible to some others, they can only change i by the method setI. But python can't ensure i to be invisible, everyone can change it whenever they want! This is dangerous. class test(object): ... __i = 0 ... def incr(self, n): self.__i += 1; print incremented i ... def geti(self): print got i; return self.__i ... i = property(geti, incr) ... t = test() t.i got i 0 t.i += 5 got i incremented i t.i got i 1 dir(t) ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash_ _', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr_ _', '__setattr__', '__str__', '__weakref__', '_test__i', 'geti', 'i', 'incr'] #here's how the crazy hackers subclassing your code can break your super ... #special private variable! ... t._test__i += 6 t.i got i 7 But, if your users can't figure out that they shouldn't be changing the variable called t._test__i without expecting side effects, what do you think of the users of your class? Python is for consenting adults. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Error correction time! #here's how the crazy hackers subclassing your code can break your super ... #special private variable! ... That should be using your code not subclassing your code. D'oh! Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A Moronicity of Guido van Rossum
But, this post of his shows [Guido's] haughtiness +1 IQOTW (Ironic Quote Of The Week. Thanks for the laughs, Xah) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: grouping array
On 29 Sep 2005 10:01:40 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi if I have an array say x = [[2,2,0,0,1,1], [1,1,0,0,1,1], [1,1,0,0,1,1]] I basically want to group regions that are non zero like I want to get the coordinates of non zero regions..as (x1,y1,x2,y2) [(0,0,2,1),(0,4,2,5)] which show the top left(x1,y1) and bottom right(x2,y2) corners of each group.hope i am clear. I don't understand. Could you give some inputs with expected outputs and some explanation? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python's performance
You've gotta framinate your capacitor to speed it up. (Translated: With no information about your camera, memory card, type of connection, platform, method of access, version of python, version of PIL, or code, how in the world could I help you to diagnose your loosely-specified problem? Ask something that's answerable, and we'll try to help you.) Peace Bill Mill bill.mill at gmail.com On 9/29/05, James Hu [EMAIL PROTECTED] wrote: Hi, I used python and PIL to capture image from a digital camera, It seems like it took more than 1 second to capture a 1280x1024 image, however, the demo capturing application from the company (coded by VB) took only .2s or less for one image with the same size. Don't know why python and PIL is so slow, any idea to improve the performance? Thanks a lot! James -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: python's performance
On 9/29/05, James Hu jhu at metrigenix.com wrote: Hi, I used python and PIL to capture image from a digital camera, It seems like it took more than 1 second to capture a 1280x1024 image, however, the demo capturing application from the company (coded by VB) took only .2s or less for one image with the same size. Don't know why python and PIL is so slow, any idea to improve the performance? Thanks a lot! James -- http://mail.python.org/mailman/listinfo/python-list Bill Mill bill.mill at gmail.com wrote: You've gotta framinate your capacitor to speed it up. (Translated: With no information about your camera, memory card, type of connection, platform, method of access, version of python, version of PIL, or code, how in the world could I help you to diagnose your loosely-specified problem? Ask something that's answerable, and we'll try to help you.) Peace Bill Mill bill.mill at gmail.com On 9/29/05, James Hu [EMAIL PROTECTED] wrote: Thanks for your fast reply. Camera, HAMAMATSU C4742-95-12G04, IEEE1394-based, Can capture frame at 8.8/s at full resolution 1344X1024 Memory: 512M Platform: Win2K and DELL 2.0GHz P4 Python 2.4 PIL: 1.15 Have u been used such camera with PIL before? im_1= Image.fromstring(I, datasize, buf, 'raw', 'I;16') Your help would be greatly appreciated! James Where do datasize and buf come from? Have you profiled your application to make sure that it is the Image.fromstring line which is slowing down your code? (If you don't know how to profile, just ask) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A Moronicity of Guido van Rossum
On 9/29/05, Tim Leslie [EMAIL PROTECTED] wrote: On 29 Sep 2005 07:24:17 -0700, Xah Lee [EMAIL PROTECTED] wrote: Of course, you begin to write things like Java, in three thousand words just to state you are a moron. +1 QOTW. Tim -1 XLEGQOTW (Xah Lee Ever Getting QOTW'd) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] PEP 350: Codetags
On 9/27/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 03:35 PM 9/26/2005 -0700, Micah Elliott wrote: Please read/comment/vote. This circulated as a pre-PEP proposal submitted to c.l.py on August 10, but has changed quite a bit since then. I'm reposting this since it is now Open (under consideration) at http://www.python.org/peps/pep-0350.html. My suggestion: implement some tools, use them for a while, and come back with more focused use cases to show why only this format can work, and why the Python core developers should therefore use it. I'm not saying that you can't have an informational PEP unless it should be used in the stdlib, mind you. Just pointing out that if you can't convince the core developers it's useful, I'm thinking you'll have a hard time convincing the community at large to actually use it. You need to actually have a better mousetrap to present before you ask people to move their cheese. :) +1 I agree with PJE almost entirely. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to show percentage
You need to convert 1 or 3 to a float. How about: def pct(num, den): return (float(num)/den) * 100 ... pct(1, 3) 33.329 Peace Bill Mill bill.mill at gmail.com On 22 Sep 2005 10:51:43 -0700, Sen-Lung Chen [EMAIL PROTECTED] wrote: Dear All: I have a question of show percentage. For example ,I want to show the percentage of 1/3 = 33.33% I use the 1*100/3 = 33 it is 33 not 33.33 , how to show the 33.33 % Thanks -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: C#3.0 and lambdas
On 9/21/05, Scott David Daniels [EMAIL PROTECTED] wrote: Roel Schroeven wrote: ... Christophe schreef: ... And what about a function which computes the line length ? That would have been a better example indeed, since the *p1 trick doesn't work there. def euclidian_distance((x1, y1), (x2, y2)): return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) That's a lot nicer, I think, than this: def euclidian_distance(p1, p2): return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2) But not massively nicer than: def euclidian_distance(p1, p2): (x1, y1), (x2, y2) = p1, p2 return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) But the question is - why go to the effort to remove the (by your admission) slightly nicer version? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: C#3.0 and lambdas
On 9/19/05, Diez B. Roggisch [EMAIL PROTECTED] wrote: meanwhile, over in python-dev land: Is anyone truly attached to nested tuple function parameters; 'def fxn((a,b)): print a,b'? /.../ Would anyone really throw a huge fit if they went away? I am willing to write a PEP for their removal in 2.6 with a deprecation in 2.5 if people are up for it. I am - I think that feature is sort of an orthogonality which should be preserved. No doubt its not one of the most important ones - but if I can write a, (b ,c) = 1, (2,3) I'd like to write def foo(a, (b,c)): ... foo(1, (2,3)) Agreed. I discovered them when I wondered wouldn't it be neat if functions unpacked tuples just like regular code does? And was pleasantly surprised to find that they did. +1 on keeping them. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
On 8/25/05, Mark Dickinson [EMAIL PROTECTED] wrote: I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly, by the rest of the script. Here's the surprise: if I remove or comment out this first line, the script takes more than 15 seconds to run. So it appears that adding a redundant line produces a spectacular six-fold increase in speed! (Actually, I had to add 29 dummy lines at the beginning of the code to get the speed increase; if any one of these lines is removed the running time reverts to around 15 seconds again.) Questions: snip One of my own: what in the world made you think maybe I'll add 29 dummy global variables to speed things up? It seems to work (19x speedup on my machine), I'm just curious what path you followed to get there. And, finally, you should forward this to the python-dev list, if somebody hasn't already. There are more people who know a ton about python internals there. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
On 8/25/05, Erik Max Francis [EMAIL PROTECTED] wrote: Mark Dickinson wrote: Questions: (1) Can anyone else reproduce this behaviour, or is it just some quirk of my setup? (2) Any possible explanations? Is there some optimization that kicks in at a certain number of lines, or at a certain length of bytecode? (3) If (2), is there some way to force the optimization, so that I can get the speed increase without having to add the extra lines? I see no difference in execution times, as expected. The most likely explanation is simply that other things were going on on your system when you ran the first test, but not the second test, resulting in the discrepancy. In other words, the speed change had nothing to do with your dummy lines. Unlikely; 2 people have confirmed these results already. I did find, though, that if I remove all print statements from the program, the dummy and non-dummy variable versions take indentical time. Can others reproduce this? I'm Investigating further... Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
Bill Mill wrote: Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results for fast and slow on my machine (these won't look decent except in a fixed-width font): snip profiles Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the slow version, does not appear at all in the fast profile. I can't figure out why - both printed out their data, so template must have been called somewhere. OK, I'm getting somewhere now. When I replace: template = ( | %s %s %s | %s %s %s | %s %s %s |\n * 3).join([ +---+---+---+\n] * 4) wtih: template =| %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n +---+---+---+\n | %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n +---+---+---+\n | %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n | %s %s %s | %s %s %s | %s %s %s |\n +---+---+---+\n Then the non-dummy version is faster than the dummy version (very slightly, presumably because it doesn't need to allocate 28 dummy variables). Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
On 8/25/05, Jack Diederich [EMAIL PROTECTED] wrote: On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote: On 8/25/05, Erik Max Francis [EMAIL PROTECTED] wrote: Mark Dickinson wrote: Questions: (1) Can anyone else reproduce this behaviour, or is it just some quirk of my setup? (2) Any possible explanations? Is there some optimization that kicks in at a certain number of lines, or at a certain length of bytecode? (3) If (2), is there some way to force the optimization, so that I can get the speed increase without having to add the extra lines? I did find, though, that if I remove all print statements from the program, the dummy and non-dummy variable versions take indentical time. Can others reproduce this? I'm Investigating further... I'm getting similarly freakish results. I tried a little ghetto debugging by putting a printf in dictobject.c's resize method and recompiling python. Sadly I can't get the problem to reproduce itself with the new binary (with or without the printf). The Ubuntu default 2.4.1 is sometimes fast, my hand compiled one (./configure make) is always slow. There are some very arcane low level things going on here. agreed. Also, either I was temporarily insane, or the version with the explicit template no longer runs faster for me, so I hope nobody spends a lot of time on that. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
On 8/25/05, Erik Max Francis [EMAIL PROTECTED] wrote: Bill Mill wrote: Unlikely; 2 people have confirmed these results already. I did find, though, that if I remove all print statements from the program, the dummy and non-dummy variable versions take indentical time. Can others reproduce this? Yes, it's obviously a real effect given the other sightings. I don't see any speed difference, myself (Pentium IV 3.0 GHz running Slackware Linux). Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results for fast and slow on my machine (these won't look decent except in a fixed-width font): Slow: 6766494 function calls (6737594 primitive calls) in 45.740 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 3322320 20.5390.000 31.1520.000 test.py:135(generator expression ) 27520 10.6410.000 41.7920.002 :0(min) 3322320 10.6130.000 10.6130.000 test.py:81(rowitems) 28100/203.6200.000 45.6332.282 test.py:130(search) 275450.1130.0000.1130.000 :0(append) 275200.0980.0000.0980.000 :0(pop) 10.0410.041 45.736 45.736 test.py:36(?) Fast: 540174 function calls (536514 primitive calls) in 3.506 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 2596401.5160.0002.3030.000 test.py:135(generator expression ) 22800.7910.0003.0940.001 :0(min) 2596400.7880.0000.7880.000 test.py:81(rowitems) 2860/200.2690.0003.3910.170 test.py:130(search) 10.0450.0453.4993.499 test.py:2(?) 36450.0210.0000.0210.000 test.py:71(colinsert) 32400.0190.0000.0190.000 test.py:62(rowinsert) 23050.0100.0000.0100.000 :0(append) Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the slow version, does not appear at all in the fast profile. I can't figure out why - both printed out their data, so template must have been called somewhere. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed quirk: redundant line gives six-fold speedup
On 8/25/05, Jack Diederich [EMAIL PROTECTED] wrote: On Thu, Aug 25, 2005 at 09:23:09PM +0300, Stelios Xanthakis wrote: The explanation is this: hash and comparison of objects depends on the state of the memory allocator. A sample case is this: class A: pass dummy0=47 # comment this to get a different result for min a=A() b=A() print min (a, b) the result of 'min' is not only non-deterministic but also depends on whether other things have been allocated before. The same thing can happen for 'dictionary.keys()' if the keys are objects and 'iterate-over-set' when the set contains objects. I'm also pretty sure I've caught a bug in his code, though I'm not sure how it works exactly. I replaced the 'min' built-in with my own min, and he's going to get nondeterministic results from this line: mm = min((c.S, c) for c in rowitems(h))[1].D because 'c' is often the exact same object. A snippet from my debugging version of 'min', which prints out the tuple its handed: (1, __main__.LLentry object at 0x00969710) (1, __main__.LLentry object at 0x00969710) (4, __main__.LLentry object at 0x00969710) snip more 4s from the same object (4, __main__.LLentry object at 0x00969710) (3, __main__.LLentry object at 0x00969710) (3, __main__.LLentry object at 0x00969710) (3, __main__.LLentry object at 0x00969710) (2, __main__.LLentry object at 0x00969710) snip more 2s, same object Although they appear in order here, they don't always. Often, multiple objects have a value of 1, and he's going to get one of them at random as the 'min' object. I'm pretty sure. Mark, can you confirm that this is/isn't a bug? (btw, it still runs fast with and slow without the dummies with my custom min() func) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
They come out even in the computer language shootout: http://shootout.alioth.debian.org/benchmark.php?test=alllang=pythonsort=fullcpu (tied 8-8 in execution time, although perl wins 4-12 on memory consumption) Peace Bill Mill On 8/23/05, km [EMAIL PROTECTED] wrote: Hi all, thing. If *all* your loops are going to do is print stuff, then you're doing the right thing with the version that emits values. ya most of the loops print values. know this). Since you haven't got any working code, it's not possible that you *need* whatever negligible speed difference there might be between Python and Perl. Python, don't let your first attempts at benchmarking dissuade you. Really, trust us. ya i do. Python's strengths lie in four things: the readability of the code, the huge range of library modules available, the elegance of its object oriented constructs, and the helpfulness of its community. Raw speed is not one of its strengths, but there are tens of thousands of people using it quite effectively and without daily concern for its speed (same as Perl, by the way since, again, they are _not_ significantly different in speed no matter what an empty loop test shows). I agree that python emphasizes on readability which i didnt see in many of the languages, but when the application concern is speed, does it mean that python is not yet ready? even most of the googling abt python vs perl convince me that perl is faster than python in most of the aspects. Also the first thing any newbie to python asks me is abt raw speed in comparison with similar languages like perl when i advocate python to perl. regards, KM -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. +1 QOTW (sometimes the zen master has to whack the student on the head) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: help in algorithm
On 10 Aug 2005 12:46:08 -0700, gene tani [EMAIL PROTECTED] wrote: this sounds like LSI / singular value decomposition (?) Why do you think so? I don't see it, but you might see something I don't. LSI can be used to cluster things, but I see no reason to believe that he's using LSI for his clustering. I ask because I've done some LSI [1], and could help him out with that if he is doing it. While I'm on the subject, is there any general interest in my python LSI code? [1] http://llimllib.f2o.org/files/lsi_paper.pdf Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list
Re: The ONLY thing that prevents me from using Python
snip I really wish Python could be more widely available on web server machines. This is just my own experience and I would like to hear your comments. I would like a pony... no, wait, even better, a unicorn! Peace Bill Mill bill.mill at gmail.com PS (the gist is, why don't you offer some constructive comments, instead of ones we can do nothing about?) -- http://mail.python.org/mailman/listinfo/python-list
Re: sample code for parsing html file to get contents of td fields
On 4 Aug 2005 11:54:38 -0700, yaffa [EMAIL PROTECTED] wrote: does anyone have sample code for parsting an html file to get contents of a td field to write to a mysql db? even if you have everything but the mysql db part ill take it. Do you want something like this? In [1]: x = something tdbsomething/b else/td and\nanother thing tdin a td/td and again else In [2]: import re In [3]: r = re.compile('td(.*?)/td', re.S) In [4]: r.findall(x) Out[4]: ['bsomething/b else', 'in a td'] If not, you'll have to explain more clearly what you want. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Ten Essential Development Practices
snip although, as some argue, it's possible [GvR] thinks in base 9.5, that just doesn't seem Pythonic to me. +1 QOTW Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: [Beginner] Calling a function by its name in a string
On 7/27/05, Tito [EMAIL PROTECTED] wrote: Hi all: Is there a metalanguage capability in Python (I know there are many) to call a function having its name in a string? Something like: __call__(foo) instead of: foo() def foo(): print foobarred ... foo() foobarred eval(foo()) foobarred Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [Beginner] Calling a function by its name in a string
On 7/27/05, Tito [EMAIL PROTECTED] wrote: Thank you both for your quick answers. What I wanted is to parameterize a function with another member function, like this: def printFunctionForEach(collection, functionName): for elem in collection: print eval(elem. + functionName + ()) Moreover, I wanted to do it with a property: def printPropertyForEach(collection, propertyName): for elem in collection: print eval(elem. + propertyName) Is there another approach to do it? Sure, piece of cake: class test: ... def func1(self): print 'func1 called' ... class test2: ... def func1(self): print 'other func1' ... x = [test(), test2(), test()] def call_this_func(lst, func_name): ... for e in lst: ... getattr(e, func_name)() ... call_this_func(x, 'func1') func1 called other func1 func1 called Note that the getattr raises an AttributeError if func_name doesn't exist in the object; you should probably wrap it in a try/except. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: is this pythonic?
On 7/21/05, Steven D'Aprano [EMAIL PROTECTED] wrote: On Wed, 20 Jul 2005 16:30:10 -0400, Bill Mill wrote: On 7/20/05, Simon Brunning [EMAIL PROTECTED] wrote: On 7/20/05, Mage [EMAIL PROTECTED] wrote: Or is there better way? for (i, url) in [(i,links[i]) for i in range(len(links))]: for i, url in enumerate(links): +2 for creating seeing a need and crafting a reasonable solution, but -1 for not reading the section on builtins to see if it existed already. To see if *what* existed already? It is well and good to say RTFM, but there are 697 subsections to the Python Library reference, and if you don't know what you are looking for, and beginners rarely are, it isn't obvious which is the right section to read. And the Library Reference isn't even the manual: there is also the global module reference and language reference. If you already know what you are looking for, reading the manual is great advice. Browsing the manual looking for interesting tidbits can even be fun for a certain mindset. But if you don't know enough to know what to look for, where in the 2000-odd sections of the Python references will you find it? I said the *builtins* section. I think you learn pretty quick that figuring out what functions are builtins is pretty important in every language. There's a fair number of people out there giving the advice to read chapter 2 of the library reference cover-to-cover for a good starter on python. Furthermore, I wasn't being hard on the guy, he still added up to +1. Lighten up, I was joking. (As for its pythonicity, I would have recommended isolating it into a function and making it a generator: It is easy to take this to extremes. It isn't necessary to isolate everything into its own object, or class, or module. Too much encapsulation is just as bad as too little. agreed; his listcomp just looks awkward inside the for loop statement; if it were my code, I would put it into a function. He asked if his code was pythonic, and I think the (non-extreme) pythonic thing to do would be to put his listcomp into a function. def my_enumerate(enumerable): i = 0 for elt in enumerable: yield (i, elt) i += 1 for i, url in my_enumerate(links): but it's not too bad as it is. Also, my function is completely untested - it's close to right though.) What is the advantage of your function my_enumerate over the Python built-in enumerate? absolutely none; I just was saying how I would encapsulate it into a function. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Stupid question: Making scripts python-scripts
On 7/21/05, Jan Danielsson [EMAIL PROTECTED] wrote: Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on a NetBSD system, I didn't get a python executable; only a python2.4 executable. Adding #!/usr/pkg/bin/python2.4 as the first row in the script would probably work, but that would be too specific for the system I'm using, imho. I saw someone using #!/usr/bin/env python, but that failed on the system I'm using, so I assume that's something specific too (or is the installation broken?). The env program [1], which usually exists at least on a linux system, executes the program given as its argument. Thus, /usr/bin/env python tries to executes python, which bash will then use to run the python script. As long as env exists, and python is somewhere in the PATH, this is a fairly portable way to run python scripts. Does BSD really not come with the env program? I bet there's an equivalent you could symlink to it. Unfortunately, I've never BSDed, so I can't help you find it. To get a workable subset of the normal env functionality, you could try (assuming you use bash): /home/llimllib $ echo $@ /usr/bin/env /home/llimllib $ chmod a+x /usr/bin/env Peace Bill Mill bill.mill at gmail.com [1]: http://rootr.net/man/man/env/1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Stupid question: Making scripts python-scripts
On 7/21/05, Bill Mill [EMAIL PROTECTED] wrote: On 7/21/05, Jan Danielsson [EMAIL PROTECTED] wrote: Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on a NetBSD system, I didn't get a python executable; only a python2.4 executable. Adding #!/usr/pkg/bin/python2.4 as the first row in the script would probably work, but that would be too specific for the system I'm using, imho. I saw someone using #!/usr/bin/env python, but that failed on the system I'm using, so I assume that's something specific too (or is the installation broken?). The env program [1], which usually exists at least on a linux system, executes the program given as its argument. Thus, /usr/bin/env python tries to executes python, which bash will then use to run the python script. As long as env exists, and python is somewhere in the PATH, this is a fairly portable way to run python scripts. Does BSD really not come with the env program? I bet there's an equivalent you could symlink to it. Unfortunately, I've never BSDed, so I can't help you find it. To get a workable subset of the normal env functionality, you could try (assuming you use bash): /home/llimllib $ echo $@ /usr/bin/env /home/llimllib $ chmod a+x /usr/bin/env ahhh, that should be: /home/llimllib $ echo \$@ /usr/bin/env otherwise bash tries to substitute into the string. Sorry bout that. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: is this pythonic?
On 7/20/05, Bill Mill [EMAIL PROTECTED] wrote: On 7/20/05, Simon Brunning [EMAIL PROTECTED] wrote: On 7/20/05, Mage [EMAIL PROTECTED] wrote: Or is there better way? for (i, url) in [(i,links[i]) for i in range(len(links))]: for i, url in enumerate(links): +2 for creating seeing a need and crafting a reasonable solution, but -1 for not reading the section on builtins to see if it existed already. -1 for me for not reading over my email before sending. creating seeing should be seeing. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: smtplib
On 7/18/05, Alberto Vera [EMAIL PROTECTED] wrote: Hello: Do you know If the smtplib routine have been changed in last releases? I used this script: http://docs.python.org/lib/SMTP-example.html but it didn't work with the last release. Do you know any idea about this change? check out the CVS changelog to see what's changed with it: http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/smtplib.py?rev=1.70view=log Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
odd python/linux/cherrypy behavior
On my laptop, I have an NTFS partition for NT, a FAT partition for data as a dmz which both linux and NT can access, and an ext3 partition for linux. However, I've experienced some weirdness on the FAT partition, and I'm wondering if anybody can tell me why it's happening. Yesterday, I downloaded the new release of cherrypy, and stuck it on the dmz drive. I ran tutorial01, which opens up a server on port 8080 and waits for connections. All seemed well, initialization info printed out, and it said it was waiting for connections on port 8080. However, when I tried to connect to it (via firefox or telnet) it just didn't respond. Not immediately - the connection attempts timed out. I tried different ports, but that didn't change anything. A reboot into NT, run the same file, it works perfectly. Eventually, after thinking it's a hosts file problem, or a firewall problem, I figure out that if I move it to my ext3 drive, it again works perfectly. Prints out the same information, says it's waiting on 8080, but this time, I can access it. Can anybody posit a guess as to why it would behave this way? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: odd python/linux/cherrypy behavior
On 7/16/05, Neil Hodgson [EMAIL PROTECTED] wrote: Bill Mill: ... a FAT partition for data as a dmz which both linux and NT can access ... Yesterday, I downloaded the new release of cherrypy, and stuck it on the dmz drive. ... Eventually, after thinking it's a hosts file problem, or a firewall problem, I figure out that if I move it to my ext3 drive, it again works perfectly. Have you looked at your mount options to make sure they are sane? Possibly you have mounted with only short (truncated) file names or all the files have their execute bit on and that is unexpected or there are non-ASCII characters in file names or ... Definitely not mounted with short file names, and there aren't any non-ASCIIs in the file names; in both cases I imagine that the file wouldn't run at all. In this case, however, the file does run, and open a socket, it just can't seem to receive connections on it. I have tried running the file as su, with no success. The FAT dirs are mounted with the following options: defaults,user,umask=000 . I'm not sure what you mean by the execute bit, but all files do have execute permission. Here's the output of an ls -l on the file I'm talking about: -rwxrwxrwx 1 root root 1073 2005-07-15 21:40 /d/download/cherrypy/tutorial/tut01_helloworld.py Any other ideas? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: odd python/linux/cherrypy behavior
On 7/16/05, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Sat, 16 Jul 2005 19:54:31 -0400, Bill Mill [EMAIL PROTECTED] declaimed the following in comp.lang.python: The FAT dirs are mounted with the following options: defaults,user,umask=000 . I'm not sure what you mean by the execute bit, but all files do have execute permission. Here's the output of an ls -l on the file I'm talking about: -rwxrwxrwx 1 root root 1073 2005-07-15 21:40 /d/download/cherrypy/tutorial/tut01_helloworld.py Out of curiosity, is it possible to change ownership to your user account? Thanks a lot, that worked. Any guess as to why? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Contest
On 7/15/05, Brian Quinlan [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Brian I've decided that it would be be fun to host a weekly Python Brian programming contest. The focus will be on algorithms that require Brian a bit of thought to design but not much code to implement. For some of us that's what we do day-in, day-out at work. It's just not called a contest. To make it more challenging, we sometimes leave out the bit of thought part. ;-) Hmmm...I find that I am rarely faced with challenging algorithmic problems in my day-to-day work. I continuously face difficult design decisions but that is a difficult sort of beast all together. This contest is for people who like thinking about algorithms. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list Questions: Will that random test generator (included in the download) be used to perform the actual testing? How many tests will be run on each program? What is the penalty for a wrong answer? Peace Bill Mill PS - check out http://www.sleepinginairports.net/ before you say you can't sleep in the airport :) -- http://mail.python.org/mailman/listinfo/python-list
Re: String Manipulation
On 13 Jul 2005 07:49:02 -0700, Michael Jordan [EMAIL PROTECTED] wrote: hey, i have this huge text file and i need to go through and remove all punctuation and every instance of the phrase fruitloops=$ where $ is any number 0-100 um, and yeah this is homework but i've tried to no avail. thanks guys. cheerio :). jen Jen, This program iterates through one file and outputs all lines to another file which have the word homework in them. #-- Begin program 1 file_in = file('data.in') file_out = file('data.out') for line in file_in: #line is a string containing one line of the file if homework in line: file_out.write(homework) #--- End program 1 Here is a program which turns a string containing the phrase number=42 into a variable containing the integer 42: #-- Begin program 2 #create a string variable called x x = number=42 #split the string at the '=', resulting in ['number', '42'] n = x.split('=')[1] #turn n from a string into a number, so we could test its value n = int(n) if 0 n 100: print n is between 0 and 100 else: print n is not between 0 and 100 #-- End program 2 And, finally, a program to remove punctuation from a string: # Begin program 3 import string #create a sentence with punctuation punct = This. is a, sentence with - punctuation #remove the punctuation; make sure the first argument #to maketrans is the same length as the second, which #should be all blanks punct = punct.translate(string.maketrans('.,-', ' ')) #read the docs at # http://docs.python.org/lib/node109.html # for more details #End program 3 Hope this helps; you should be able to put the pieces together to do what you want to do. If you can't, feel free to ask more questions. Also, just so you know, there is a list at tutor@python.org set up just to answer questions like these. Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: question on input
On 12 Jul 2005 07:31:47 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I want to accept the user's answer yes or no. If I do this: answer = input('y or n?') Use raw_input instead: answer = raw_input(y or n?) y or n?y answer 'y' Check out the documentation of both functions at http://docs.python.org/lib/built-in-funcs.html for more details. snip Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet Another Python Web Programming Question
Python using CGI, for example, was enough for him until he started getting 500 errors that he wasn't sure how to fix. A common error is that python cgi files need line endings to be in unix text file format, not windows text file format (\n instead of \r\n) [1]. Why this is, I don't know, but it causes a lot of errors for windows folks. I'm a frequent linux/windows switcher, and it's caused me no end of troubles - if you're getting premature end of script headers in your apache error logs, this may be your problem. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Folding in vim
On 7/6/05, Terry Hancock [EMAIL PROTECTED] wrote: On Tuesday 05 July 2005 03:53 pm, Renato Ramonda wrote: Why not use just spaces? Vim simplifies this immensely: set tabstop=4 set shiftwidth=4 set expandtab set smarttab set autoindent AFAICT this gives me all spaces, 4 spaces indent, tab inserts spaces and backspace over a block of 4 spaces deletes all of them (just like deleting a tab). Yep, this is what I just set up in my .vimrc. Works beautifully. I don't use any of the fancy indenters; instead, I just add set foldmethod=indent to my .vimrc (_vimrc on windows), along with most of the aforementioned options (I don't like smarttab); it works nearly perfectly. Then zo opens the fold under the cursor one level, zO opens it recursively, zc and zC close it non- and recursively. zr opens all folds one level, zR opens them all recursively, zm closes them all one level, and zM closes them all recursively. It's pretty sweet. Maybe we should have a big Vim-python tip-a-thon thread? Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Scipy - Latex Annotations in plots
Robert Kern wrote: fortuneteller wrote: Hello, I'm quite new to python and Scipy. Anyway I want to use it to plot graphs. Does anybody know if there is the possibility to use Latex in SciPy's plotting functions like gplt? I don't believe so. matplotlib, however, does have this functionality in recent releases. On 7/6/05, Matthias R. [EMAIL PROTECTED] wrote: Unfortunately matplotlib is only a 2D-plotting library. Do you know another one with 3D-capabilities as well? That would be very nice, Perhaps gnuplot.py (http://gnuplot-py.sourceforge.net/) will work for you? It is a thin wrapper around Gnuplot, which is very good at producing ps format images, and is capable of producing 3 dimensional graphs. Peace Bill Mill bill.mill at gmail.com PS please try to not top-post, you can lose the rest of the thread easily -- http://mail.python.org/mailman/listinfo/python-list
Re: What is different with Python ? (OT I guess)
On 6/14/05, Magnus Lycka [EMAIL PROTECTED] wrote: Andrew Dalke wrote: Andrea Griffini wrote: This is investigating. Programming is more similar to building instead (with a very few exceptions). CS is not like physics or chemistry or biology where you're given a result (the world) and you're looking for the unknown laws. In programming *we* are building the world. This is a huge fundamental difference! Philosophically I disagree. Biology and physics depends on models of how the world works. The success of a model depends on how well it describes and predicts what's observed. Programming too has its model of how things work; you've mentioned algorithmic complexity and there are models of how humans interact with computers. The success depends in part on how well it fits with those models. And this is different from building? I don't disagree with the other things you say, but I think Andrea is right here, although I might have said construction or engineering rather than building. To program is to build. While scientists do build and create things, the ultimate goal of science is understanding. Scientists build so that they can learn. Programmers and engineers learn so that they can build. snip stuff I agree with It seems to me that *real* computer scientists are very rare. I'd like to say that I think that they do, in fact, exist, and that it's a group which should grow and begin to do things more like their biological counterparts. Why? Because, as systems get more complex, they must be studied like biological systems. I spent a while in college studying latent semantic indexing (LSI) [1], which is an algorithm that can be used to group things for clustering, searching, and other uses. It is known *to* be effective in some circumstances, but nobody (at least when I was studying it ~2 years ago) knows *why* it is effective. With the help of my professor, I was helping to try and determine that *why*. We had a hypothesis [2], and my job was basically to build experiments to test our hypothesis. First, I built a framework to perform LSI on arbitrary documents (in python of course, let's keep it on topic :), then I started to do experiments on different bodies of text and different variations of our hypothesis. I kept a lab journal detailing what I had changed between experiments, some of which took days to run. I believe that there are at least a fair number of computer scientists working like this, and I believe that they need to recognize themselves as a separate discipline with separate rules. I'd like to see them open source their code when they publish papers as a matter of standard procedure. I'd like to see them publish reports much more like biologists than like mathematicians. In this way, I think that the scientific computer scientists could begin to become more like real scientists than like engineers. Just my 2 cents. Peace Bill Mill [1] http://javelina.cet.middlebury.edu/lsa/out/lsa_definition.htm [2] http://llimllib.f2o.org/files/lsi_paper.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: \r\n or \n notepad editor end line ???
On 8 Jun 2005 06:24:05 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I use windows notepad editor to write text. For example I write (in d:\myfile.txt): Helo World If I open it with python: FName = open(d:\myfile.txt,'r') h = FName.readlines() print h I get h : ['Helo\n', 'World'] I thought notepad use \r\n to to end the line. What's wrong with it? On windows, opening a file without 'b' in the file type argument does some things you might not expect, including changing /r/n to /n. Try: f = file('d:/deleteme.txt', 'rb') f.read() 'testing\r\n1\r\n2\r\n3' f = file('d:/deleteme.txt', 'r') f.read() 'testing\n1\n2\n3' Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: computer algebra packages
On 6/8/05, Fernando Perez [EMAIL PROTECTED] wrote: Rahul wrote: Hi. The reason is simple enough. I plan to do some academic research related to computer algebra for which i need some package which i can call as a library. Since i am not going to use the package myself..(rather my program will)..it will be helpful to have a python package since i wanted to write the thing in python. if none is available then probably i will need to work on an interface to some package written in some other language or work in that language itself. I've heard of people writing a Python MathLink interface to Mathematica, which essentially turns Mathematica into a Python module. But I don't have any references handy, sorry, and as far as I remember it was done as a private contract. But it's doable. What about http://library.wolfram.com/infocenter/MathSource/585/ ? Seems to be non-proprietary, or something different, but does it work? I don't have Mathematica, so I don't know. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 20 May 2005 10:07:55 -0700, Jason Drew [EMAIL PROTECTED] wrote: Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. Funny that Pythonwin's argument-prompter (or whatever that feature is called) doesn't seem to like it. E.g. if I have def f(tupl): print tupl Then at the Pythonwin prompt when I type f( I correctly get (tupl) in the argument list pop-up box. But if I have def f((a, b)): print a, b then when I type f( I just get (.0) in the argument list pop-up box. Or with def f(p, q, (a, b)): pass Pythonwin prompts with (p, q, .4) However in each case the help() function correctly lists all the arguments. Strange. I'll check if it's a known feature. That sounds like a bug in pythonwin autocomplete. Tuple unpacking in function arguments is definitely a known feature, there were some recent (fairly extensive) clp threads about it.[1] I wish people would use it more, I think it's an awesome feature when properly used. I like it especially for signatures like def change_coord((x, y)). It was one of those features, for me, where I just tried it without knowing of its existence, assuming it would work, and I was pleasantly surprised that it did. Peace Bill Mill bill.mill at gmail.com [1] http://tinyurl.com/89zar I think there was another about ways to improve tuple unpacking, but I didn't find it in a brief search. This is with PythonWin 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 19 May 2005 06:56:45 -0700, rh0dium [EMAIL PROTECTED] wrote: Hi All, While I know there is a zillion ways to do this.. What is the most efficient ( in terms of lines of code ) do simply do this. a=1, b=2, c=3 ... z=26 Now if we really want some bonus points.. a=1, b=2, c=3 ... z=26 aa=27 ab=28 etc.. just for fun, here is one way to do it with a listcomp. Obfuscated python fans, rejoice! alpha = 'abcdefghijklmnopqrstuvwxyz' for i, digraph in enumerate(sorted([''.join((x, y)) for x in alpha \ for y in [''] + [z for z in alpha]], key=len)): ... locals()[digraph] = i + i ... a 1 b 2 ac 29 dg 111 zz 702 26**2 + 26 702 Thanks -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 19 May 2005 11:52:30 -0700, rh0dium [EMAIL PROTECTED] wrote: Call me crazy.. But it doesn't work.. What doesn't work? What did python output when you tried to do it? It is python 2.4 specific, it requires some changes for 2.3, and more for earlier versions of python. for i, digraph in enumerate(sorted([''.join((x, y)) for x in alpha for y in [''] + [z for z in alpha]], key=len)): globals()[digraph]=i+1 How do you implement this sucker?? Works just fine for me. Let me know what error you're getting and I'll help you figure it out. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 19 May 2005 11:59:00 -0700, rh0dium [EMAIL PROTECTED] wrote: This is great but backwards... Ok because you all want to know why.. I need to convert Excel columns A2 into , [1,0] and I need a simple way to do that.. ( The way this works is A-0 and 2-1 -- Yes they interchange -- So B14 == [13,1] ) why didn't you say this in the first place? def coord2tuple(coord): row, col = '', '' alpha = 'abcdefghijklmnopqrstuvwxyz'.upper() pairs = [''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]] pairs = sorted(pairs, key=len) coord = coord.upper() for c in coord: if c in alpha: row += c else: col += c return (int(col)-1, pairs.index(row)) coord2tuple('B14') (13, 1) coord2tuple('ZZ14') (13, 701) coord2tuple('ZZ175') (174, 701) coord2tuple('A2') (1, 0) Are there cols greater than ZZ? I seem to remember that there are not, but I could be wrong. Hope this helps. Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 19 May 2005 12:20:03 -0700, rh0dium [EMAIL PROTECTED] wrote: Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'sorted' is not defined I think you're probably using 2.4 ?? Yes, sorted() is new in python 2.4 .You could use a very lightly tested pure-python partial replacement: def sorted(lst, **kwargs): l2 = lst[:] if kwargs.has_key('key'): f = kwargs['key'] l2.sort(lambda a,b: cmp(f(a), f(b))) return l2 l2.sort() return l2 And from your other email: I need to go the other way! tuple2coord Sorry, I only go one way. It should be transparent how to do it backwards. Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 5/19/05, Peter Otten [EMAIL PROTECTED] wrote: Bill Mill wrote: Traceback (most recent call last): Filestdin,line1,in? NameError: name 'sorted' is not defined I think you're probably using 2.4 ?? Yes, sorted() is new in python 2.4 .You could use a very lightly tested pure-python partial replacement: By the way, sorted() can be removed from your original post. Code has no effect :-) I'm gonna go ahead and disagree with you: sorted([''.join((x, y)) for x in alpha \ ...for y in [''] + [z for z in alpha]], key=len) == \ ... [''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]] False If you want to see why, here's a small example: alpha = 'abc' [''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]] ['a', 'aa', 'ab', 'ac', 'b', 'ba', 'bb', 'bc', 'c', 'ca', 'cb', 'cc'] sorted([''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]], key=len) ['a', 'b', 'c', 'aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Documentation (should be better?)
On 5/12/05, Terry Reedy [EMAIL PROTECTED] wrote: Skip Montanaro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Maybe the Module Index should be renamed Module/Type Index and embellished with the builtin types, so that you'd find float (builtin), string (builtin), dict (builtin), etc. in the appropriate alphabetical positions. +1 TJR +1 Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
On 5/12/05, Ximo [EMAIL PROTECTED] wrote: I am doing my own interpreter with the Python languaje. Do you understand me? Well, to be frank, no. However, Frederik's point still stands; in the python langage, int a is syntactically invalid. If you're writing your own interpreter, it should still be syntactically invalid. Could you perhaps repeat your question with an example of what behavior is surprising you? Peace Bill Mill bill.mill at gmail.com Fredrik Lundh [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Ximo wrote: I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as int a my progrtam return de prompt and nothing more, for exemple: 2+2 4 int a Then I'm finding that de function which execute int a return me nothing, and no int a None what Python version are you using? here's what a normal Python interpreter is supposed to do with your example: 2+2 4 int a File stdin, line 1 int a ^ SyntaxError: invalid syntax /F -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: increment bits
On 12 May 2005 12:19:15 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, How do i manipulate arrays to increment 8 bits at a time. I need to generate a pattern like 01,02,03,.0xFF [hex(n) for n in range(256)] ['0x0', '0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7', '0x8', '0x9', '0xa', '0 xb', '0xc', '0xd', '0xe', '0xf', '0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1b', '0x1c', '0x1d', '0x1e', '0x1f', snipped '0xe8', '0xe9', '0xea', '0xeb', '0xec', '0xed', '0xee', '0xef', '0xf0', '0xf1', '0xf2', '0xf3', '0xf4', '0xf5', '0xf6', '0xf7', '0xf8', '0xf9', '0xfa', '0xfb', '0xfc', '0xfd', '0xfe', '0xff'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Graphing Utilities.
On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote: Hallöchen! Fernando Perez [EMAIL PROTECTED] writes: [...] And I'd also second the matplotlib suggestion, to which I've by now fully switched after years of faithful gnuplot usage. Matplotlib is very good, has an active development community, and it is designed from the ground up not only as a library for rendering plots to screen/disk, but also for embedding into guis (with support for Tk, WX, GTK, QT and FLTK). Why not for Gnuplot, by the way? On sceen, matplotlib looks extremely good, however, I still need Gnuplot for the hardcopy version[*]. It *seems* to me that the programming interfaces are quite different, so a Gnuplot backend for matplotlib would be helpful for me. By hardcopy version, I assume you mean Postscript? From http://matplotlib.sourceforge.net/fonts.html : Postscript Postscript, despite its age, is still a great output format. Most publishers accept it, it scales to arbitrary resolutions, you can import it directly into LaTeX document, and send it directly to postscript printers. The only requirement to generate postscript output is the Numeric module and some AFM fonts on your system. Even the latter is only a quasi-requirement, because matplotlib ships with some of the most popular font files. These are Adobe Font Metric files, which have the '*.afm' extension. matplotlib comes with it's own AFM parser to read these files and select the best match for the font you've chosen. If you want additional fonts, set the AFMPATH environment variable to point to the dir containing your AFM font files. matplotlib willl recursively search any directory in AFMPATH, so you only need to specify a base directory if multiple subdirectories contaning '*.afm' files. Peace Bill Mill bill.mill at gmail.com Tschö, Torsten. [*] because of the pslatex backend, which means that the plot is typeset by the same LaTeX run as your document -- consistent fonts, TeX-quality formulae -- Torsten Bronger, aquisgrana, europa vetus -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Graphing Utilities.
On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote: Hallöchen! Bill Mill [EMAIL PROTECTED] writes: On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote: Fernando Perez [EMAIL PROTECTED] writes: [...] [...] Matplotlib is very good, has an active development community, and it is designed from the ground up not only as a library for rendering plots to screen/disk, but also for embedding into guis (with support for Tk, WX, GTK, QT and FLTK). Why not for Gnuplot, by the way? On sceen, matplotlib looks extremely good, however, I still need Gnuplot for the hardcopy version[*]. It *seems* to me that the programming interfaces are quite different, so a Gnuplot backend for matplotlib would be helpful for me. By hardcopy version, I assume you mean Postscript? Not really. Gnuplot's output is LaTeX with a couple of native Postscript directives inbetween. It's inluded into my document with \input plot.plt rather than \includegraphics{plot.eps}. I mentioned the advantages of this approach in the footnote: Tha's cool, I saw what you wrote. First off, I wasn't sure what you meant by hardcopy, so I thought I'd let you know that matplotlib has PS output. Second, the page I linked to talks about all the font-type features of matplotlib, which I thought might interest you. Having not gotten funky with them, I cannot vouch for their quality. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Graphing Utilities.
On 5/10/05, Kenneth Miller [EMAIL PROTECTED] wrote: Hello All, I am new to Python and i was wondering what graphing utlities would be available to me. I have already tried BLT and after weeks of unsuccesful installs i'd like to find something else. Anything someone would recommend? matplotlib is awesome: http://matplotlib.sourceforge.net/ and gnuplot.py is passable: http://gnuplot-py.sourceforge.net/ (a better version of gnuplot.py is available with the excellent ipython interpreter at http://ipython.scipy.org/) All of the above are cross-platform to at least linux and windows. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
replace string patern with different value
On 9 May 2005 06:23:41 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I would like to replace string with different values, For example : source = 'kode1 bla bla kode1 bla kode1' I have a list with each member will replace each of kode1. L = [11,22,33] So the new source will become: newsource = '11 bla bla 22 bla 33' How can I do it ? I tried to find using string built in function replace, but it will replace pattern with the same value. For this moment I think about change the string into list using string.split and then check one by one and replace it and then convert into string with addition space in the right and left of each element list. L = ['11', '22', '33'] source xyzzy text we've got xyzzy text xyzzy yeah yeah yeah token 'xyzzy' for rep in L: ... source = source.replace(token, rep, 1) ... source 11 text we've got 22 text 33 yeah yeah yeah And, if I may, I recommend the Python Tutorial at http://docs.python.org/tut/tut.html . Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Listing of declared variables and functions
On 9 May 2005 09:58:19 -0700, ohms377 [EMAIL PROTECTED] wrote: Dear python users, In interactive mode, I was wondering if there is a way to list all declared variables and functions (and from global workspace). x = 12 z = 13 import re locals() {'__builtins__': module '__builtin__' (built-in), 're': module 're' from '/us r/lib/python2.4/re.pyc', 'x': 12, '__name__': '__main__', 'z': 13, '__doc__': N one} locals().keys() ['__builtins__', 're', 'x', '__name__', 'z', '__doc__'] globals() {'__builtins__': module '__builtin__' (built-in), 're': module 're' from '/us r/lib/python2.4/re.pyc', 'x': 12, '__name__': '__main__', 'z': 13, '__doc__': N one} Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: hard memory limits
On 5/6/05, Mike Meyer [EMAIL PROTECTED] wrote: Fredrik Lundh [EMAIL PROTECTED] writes: Maurice LING wrote: Will adding more RAM helps in this case? probably. more swap space might also help. or you could use a smarter malloc package. posting more details on your platform, toolchain, python version, and list building approach might also help. Without platform information, it's hard to say. On a modern Unix system, you only run into system resource limits when the system is heavily loaded. Otherwise, you're going to hit per-process limits. In the latter case, adding RAM or swap won't help at all. Raising the per-process limits is the solution. A quick google shows it to be mac os X, and a pretty frequent error message. http://www.google.com/search?hl=enq=%22vm_allocate%20(size%20%3D%22btnG=Google+Search Peace Bill Mill bill.mill at gmail.com mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting number of iteration
On 5/6/05, Florian Lindner [EMAIL PROTECTED] wrote: Hello, when I'm iterating through a list with: for x in list: how can I get the number of the current iteration? Python 2.4 and greater: for n, x in enumerate(lst): print iteration %d on element %s % (n, x) Earlier: n = 0 for x in lst: print iteration %d on element %s % (n, x) n += 1 And you shouldn't use list as a variable name; list() is a built-in function which you'll clobber if you do. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting number of iteration
On 5/6/05, Bill Mill [EMAIL PROTECTED] wrote: On 5/6/05, Florian Lindner [EMAIL PROTECTED] wrote: Hello, when I'm iterating through a list with: for x in list: how can I get the number of the current iteration? Python 2.4 and greater: ummm, make that 2.3 and greater. I always think things are more recent than they are. for n, x in enumerate(lst): print iteration %d on element %s % (n, x) Earlier: n = 0 for x in lst: print iteration %d on element %s % (n, x) n += 1 And you shouldn't use list as a variable name; list() is a built-in function which you'll clobber if you do. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: dictionary comparison
On 5 May 2005 08:19:31 -0700, rickle [EMAIL PROTECTED] wrote: I'm trying to compare sun patch levels on a server to those of what sun is recommending. For those that aren't familiar with sun patch numbering here is a quick run down. A patch number shows up like this: 113680-03 ^^ ^^ patch# revision What I want to do is make a list. I want to show what server x has versus what sun recommends, and if the patch exists, but the revision is different, I want to show that difference. Here are some sample patches that sun recommends: 117000-05 116272-03 116276-01 116278-01 116378-02 116455-01 116602-01 116606-01 Here are some sample patches that server x has: 117000-01 116272-02 116272-01 116602-02 So there are some that are the same, some that sun recommends that server x doesn't have, and some where the patch is the same but the revision is different. I've thrown the data into dictionaries, but I just can't seem to figure out how I should actually compare the data and present it. Here's what I have so far (the split is in place because there is actually a lot more data in the file, so I split it out so I just get the patch number and revision). So I end up with (for example) 116272-01, then split so field[0] is 116272 and field[1] is 01. def sun(): sun = open('sun-patchlist', 'r') for s in sun: sun_fields = s.split(None, 7) for sun_field in sun_fields: sun_field = sun_field.strip() sun_patch = {} sun_patch['number'] = sun_fields[0] sun_patch['rev'] = sun_fields[1] print sun_patch['number'], sun_patch['rev'] sun.close() def serverx(): serverx = open('serverx-patchlist', 'r') for p in serverx: serverx_fields = p.split(None, 7) for serverx_field in serverx_fields: serverx_field = serverx_field.strip() serverx_patch = {} serverx_patch['number'] = serverx_fields[0] serverx_patch['rev'] = serverx_fields[1] print serverx_patch['number'], serverx_patch['rev'] serverx.close() The first thing you should notice about this code is that you copied a good amount of code between functions; this should be a huge warning bell that something can be abstracted out into a function. In this case, it's the parsing of the patch files. Also, you should see that you're creating a new dictionary every iteration through the loop, and furthermore, you're not returning it at the end of your function. Thus, it's destroyed when the function exits and it goes out of scope. snip Anyway, since you at least made an effort, here's some totally untested code that should (I think) do something close to what you're looking for: def parse_patch_file(f): patches = {} for line in f: patch, rev = line.strip().split('-') patches[patch] = rev return patches def diff_patches(sun, serverx): for patch in sun: if not serverx.has_key(patch): print Sun recommends patch %s % patch for patch in serverx: if not sun.has_key(patch): print Serverx has unnecessary patch %s % patch def diff_revs(sun, serverx): for patch, rev in sun.iteritems(): if serverx.has_key(patch) and rev != serverx[patch]: print Sun recommends rev %d of patch %s; serverx has rev %d\ % (rev, patch, serverx[patch]) if __name__ == '__main__': sun = parse_patch_file(open('sun-patchlist')) serverx = parse_patch_file(open('serverx-patchlist')) diff_patches(sun, serverx) diff_revs(sun, serverx) Hope this helps. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
On 4/27/05, monkey [EMAIL PROTECTED] wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. Believe it or not, this has been discussed before :) Some relevant links, in no particular order: http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/e58230e15f7bb072/ec34f252a00c4b31?q=boa+wing+komodornum=1#ec34f252a00c4b31 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/4ac901800452fe52/32f9a7f307d16bbd?q=boa+wing+komodornum=3#32f9a7f307d16bbd http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b4301bf4de581351/84fea0f68251b810?q=idernum=14#84fea0f68251b810 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/6018db6e62e44895/46ef2516271a51d3?tvc=1q=vim+emacs+komodo#46ef2516271a51d3 http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/a917d15f5a16500c/d989575525959c32?q=vim+emacs+komodornum=4#d989575525959c32 http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3a65f2908bb8ba4/12ea5915f8f09546?q=vim+emacs+komodornum=5#12ea5915f8f09546 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/8cf3565673bc4a7e/a4a84c1e7271ca1a?tvc=1q=vim+emacs+komodo#a4a84c1e7271ca1a http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/5de87dcdd817ba26/b2ff72c8e864818b?q=vim+emacs+wingrnum=1#b2ff72c8e864818b http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/766c24a82674da7/47d9c8157639d81e?q=vim+wing+komodornum=2#47d9c8157639d81e http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/b21e43c45f183dc7/3a118074c68f1f35?q=vim+wing+komodornum=3#3a118074c68f1f35 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/2225676eb7e1b4e/cdee764dfa2b5391?q=best+IDernum=1#cdee764dfa2b5391 Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What is situation with threads in Python
On 4/25/05, Leonard J. Reder [EMAIL PROTECTED] wrote: Hello Mark, I took your three day course here at JPL and recall that you said something was wrong with the implementation of threads within Python but I cannot recall what. So what is wrong with threads in Python? I'm going to guess that he meant the Global Interpreter Lock is what's wrong with Python threads. You can read about it in the docs at http://docs.python.org/api/threads.html and get some good analysis from Ian Bicking (with some excellent, and some not so excellent, comments): http://blog.ianbicking.org/gil-of-doom.html . The other part of this question is, if there is something wrong with the threads in Python has anyone wrapped the Posix threads C api using swig to fix this problem? I work on Solaris/Linux systems and this seems like a quick fix - maybe. Nope, since the interpreter is not entirely thread-safe, I don't believe you can wrap pthreads. Enjoyed the class a great deal. I am also sending this to the news group in hopes of various interesting replies. Maybe there is a web article on this topic already that someone could send the URL. Thanks for all replies, Len -- Leonard J. Reder Jet Propulsion Laboratory Interferometry Systems and Technology Section 383 Email: [EMAIL PROTECTED] Phone (Voice): 818-354-3639 Phone (FAX): 818-354-4357 Mail Address: Mail Stop: 171-113 4800 Oak Grove Dr. Pasadena, CA. 91109 --- -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: What's do list comprehensions do that generator expressions don't?
On 25 Apr 2005 23:33:48 +0300, Ville Vainio [EMAIL PROTECTED] wrote: Jeremy == Jeremy Bowers [EMAIL PROTECTED] writes: Jeremy On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: Never. If you really need a list list(x*x for x in xrange(10)) Sadly, we can't remove list comprehensions until 3.0. Jeremy Why remove them? Instead, we have these things called Jeremy comprehensions (which, now that I say that, seems a Jeremy rather odd name), and you can control whether they result Jeremy in a list or a generator with () or []. Still, list comprehensions should be implemented in terms of genexps to get rid of the LC variable that is visible outside the scope of the LC. +1 . I think that we should still have the form [genexp] , but without the dangling variable, and implemented with generator expressions. It seems to me that it is inconsistent if I can do list(genexp) but not [genexp] , since they are so similar. Once that happens, we can tell people who ask the OP's question that [genexp] is just another way to spell list(genexp), and he should use it if he wants the entire list constructed in memory. Jeremy should be relatively simple), it's not worth breaking that Jeremy code. Well, the code that relies on the dangling variable deserves to break. Agreed. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Do I need a nested lambda to do this?
On 4/25/05, R. C. James Harlow [EMAIL PROTECTED] wrote: On Tuesday 26 April 2005 00:34, raoul wrote: I can't figure this one out. Trying to be unnecessarily functional I suspect. With list comprehensions: Python 2.3.4 (#1, Mar 26 2005, 20:54:10) [GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2 Type help, copyright, credits or license for more information. vals = [1.000,2.344,4.2342] tabs = [((0,1),(0,3),(0,4)), ...((2,2),(3,0),(3,9)), ...((3,4),(6,3),(7,1))] [(tuple([(vals[index],subtab[1]) for subtab in tab])) for index,tab in enumerate(tabs)] [((1.0, 1), (1.0, 3), (1.0, 4)), ((2.3439, 2), (2.3439, 0), (2.3439, 9)), ((4.23420004, 4), (4.23420004, 3), (4.23420004, 1))] Slightly nicer, I think: vals [1.0, 2.3439, 4.23420004] tabs [((0, 1), (0, 3), (0, 4)), ((2, 2), (3, 0), (3, 9)), ((3, 4), (6, 3), (7, 1))] [tuple([(v, t[1]) for t in tab]) for v, tab in zip(vals, tabs)] [((1.0, 1), (1.0, 3), (1.0, 4)), ((2.3439, 2), (2.3439, 0), (2.3439, 9)), ((4.23420004, 4), (4.23420004, 3), (4.23420004, 1))] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: a=[ lambda t: t**n for n in range(4) ]
On 22 Apr 2005 14:41:45 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I was thinking about something like the following; a=[ t**n for n in range(4) ] Traceback (most recent call last): File stdin, line 1, in ? NameError: name 't' is not defined or a=[ lambda t: t**n for n in range(4) ] t=2 a [function lambda at 0x403dcc6c, function lambda at 0x403dcca4, function lambda at 0x403dccdc, function lambda at 0x403dcd14] t=3 a [function lambda at 0x403dcc6c, function lambda at 0x403dcca4, function lambda at 0x403dccdc, function lambda at 0x403dcd14] Well, everybody else took away your lambda (greedy people!) but I'm here to say that it doesn't *have* to go away. I didn't think this would be possible, but it is: t = 2 [(lambda n: t**n)(n) for n in range(4)] [1, 2, 4, 8] t = 3 [(lambda n: t**n)(n) for n in range(4)] [1, 3, 9, 27] I just thought that was kinda neat. If you wanted to obfuscate some python, this would be an awesome trick - hide the value of t somewhere early in the function then pull a variation of this out later. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Python does *SLICING* the way it does??
On 20 Apr 2005 12:52:19 GMT, Antoon Pardon [EMAIL PROTECTED] wrote: Op 2005-04-20, Torsten Bronger schreef [EMAIL PROTECTED]: Hallöchen! [EMAIL PROTECTED] (Nick Efford) writes: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Many people I know ask why Python does slicing the way it does. Can anyone /please/ give me a good defense/justification??? I'm referring to why mystring[:4] gives me elements 0, 1, 2 and 3 but *NOT* mystring[4] (5th element). mystring[:4] can be read as the first four characters of mystring. If it included mystring[4], you'd have to read it as the first five characters of mystring, which wouldn't match the appearance of '4' in the slice. [...] It all makes perfect sense when you look at it this way! Well, also in my experience every variant has its warts. You'll never avoid the i+1 or i-1 expressions in your indices or loops (or your mind ;). It's interesting to muse about a language that starts at 1 for all arrays and strings, as some more or less obsolete languages do. I think this is more intuitive, since most people (including mathematicians) start counting at 1. The reason for starting at 0 is easier memory address calculation, so nothing for really high level languages. Personnaly I would like to have the choice. Sometimes I prefer to start at 0, sometimes at 1 and other times at -13 or +7. -1. You can start arrays at 0 or 1 (and arbitrary bases? I don't recall) in VB, and it's an unmitigated disaster. It adds needless complexity. What our slicing system loses in elegance in a few cases, it more than makes up for in consistency throughout all programs. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Python does *SLICING* the way it does??
On 20 Apr 2005 13:39:42 GMT, Antoon Pardon [EMAIL PROTECTED] wrote: Op 2005-04-20, Bill Mill schreef [EMAIL PROTECTED]: On 20 Apr 2005 12:52:19 GMT, Antoon Pardon [EMAIL PROTECTED] wrote: Op 2005-04-20, Torsten Bronger schreef [EMAIL PROTECTED]: Hallöchen! [EMAIL PROTECTED] (Nick Efford) writes: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Many people I know ask why Python does slicing the way it does. Can anyone /please/ give me a good defense/justification??? I'm referring to why mystring[:4] gives me elements 0, 1, 2 and 3 but *NOT* mystring[4] (5th element). mystring[:4] can be read as the first four characters of mystring. If it included mystring[4], you'd have to read it as the first five characters of mystring, which wouldn't match the appearance of '4' in the slice. [...] It all makes perfect sense when you look at it this way! Well, also in my experience every variant has its warts. You'll never avoid the i+1 or i-1 expressions in your indices or loops (or your mind ;). It's interesting to muse about a language that starts at 1 for all arrays and strings, as some more or less obsolete languages do. I think this is more intuitive, since most people (including mathematicians) start counting at 1. The reason for starting at 0 is easier memory address calculation, so nothing for really high level languages. Personnaly I would like to have the choice. Sometimes I prefer to start at 0, sometimes at 1 and other times at -13 or +7. -1. You can start arrays at 0 or 1 (and arbitrary bases? I don't recall) in VB, and it's an unmitigated disaster. It adds needless complexity. Complexity that is now put on the programmers shoulders. If I have a table with indexes going from -13 to +7, I have to add the offset myself if I want to use a list for that. What our slicing system loses in elegance in a few cases, it more than makes up for in consistency throughout all programs. You write this af if other solutions can't be consistent. Propose one, and I won't write it off without thinking, but my bias is way against it from experience. Knowledge gets scattered across the program, unless you're defining the start index every time you use the list, which seems no better than adding an offset to me. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Troll? was: Re: goto statement
On 4/20/05, Robert Kern [EMAIL PROTECTED] wrote: Maxim Kasimov wrote: André Roberge wrote: Maxim Kasimov wrote: by the way, goto statement will be useful for writing more powerful obfuscators Let me get that clear: you want a goto to help with debugging. And you want to obfuscate your code even more? !? Perhaps you need to write in Perl, or some other similar language. Writing in Python is for those that seek clarity (not obfuscation) and less bugs. Which is why a goto statement should definitely never be part of Python! André so insulting to me - you asking i'm a troll, only becose i'm saing that goto maybe sometimes usefull. No, because you said that it was useful for obfuscating code. Obfuscating code is generally not a desirable feature of a language construct. I believe he meant obfuscating bytecode for a commercial product, to try and avoid decompilation, which is often a desirable function for commercial entities. (Not that I have the technical knowledge to agree or disagree with what he said, I'm just trying to help clear up what's become a fairly bogged-down argument.) Peace Bill Mill bill.mill at gmail.com -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python regex Doc (was: Python documentation moronicities)
On 4/18/05, Jeff Epler [EMAIL PROTECTED] wrote: On Mon, Apr 18, 2005 at 01:40:43PM -0700, Xah Lee wrote: i have rewrote the Python's re module documentation. See it here for table of content page: http://xahlee.org/perl-python/python_re-write/lib/module-re.html For those who have long ago consigned Mr. Lee to a killfile, it looks like he's making an honest attempt to improve Python's documentation here. Alright, I feel like I'm feeding the trolls just by posting in this thread. Just so that nobody else has to read the revised docs, no it doesn't: 1) He didn't really change anything besides the intro page and deleting the matching vs. searching page and the examples page. He also put a couple of hr breaks into the doc. 2) notes like NOTE TO DOC WRITERS: The doc sayz: ... followed by the same drum he's been beating for a while, instead of actually editing the section to be correct. 3) adding MAY NEED AN EXAMPLE HERE instead of actually putting one in Mr Lee, I hope you will submit your documentation changes to python's patch tracker on sourceforge.net. I don't fully agree with some of what you've written (e.g., you give top billing to the use of functions like re.search while I would encourage use of the search method on compiled RE objetcts, and I like examples to be given as though from interactive sessions, complete with and ...), but nits can always be picked and I'm not the gatekeeper to Python's documentation. I'd suggest that he actually make an effort at improving the docs before submitting them. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Strings and Lists
On 18 Apr 2005 04:42:17 -0700, Tom Longridge [EMAIL PROTECTED] wrote: My current Python project involves lots repeatating code blocks, mainly centred around a binary string of data. It's a genetic algorithm in which there are lots of strings (the chromosomes) which get mixed, mutated and compared a lot. Given Python's great list processing abilities and the relative inefficiencies some string operations, I was considering using a list of True and False values rather than a binary string. I somehow doubt there would be a clear-cut answer to this, but from this description, does anyone have any reason to think that one way would be much more efficient than the other? (I realise the best way would be to do both and `timeit` to see which is faster, but it's a sizeable program and if anybody considers it a no-brainer I'd much rather know now!) Any advice would be gladly recieved. -- http://mail.python.org/mailman/listinfo/python-list Tom, it seems to me that, if efficiency is your main goal, you should store your data as a list of integers, and use the bit-twiddling operators to get at your data. These should be *very* fast, as well as memory efficient. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A little request about spam
On 4/14/05, mark hellewell [EMAIL PROTECTED] wrote: On 4/14/05, Steven Cummings [EMAIL PROTECTED] wrote: For what it's worth I filed a gmail issue over it a few days after I noticed it. I guess more of you could do so indicating the severity of the issue to the gmail developers. And I thought I was the only one...! I've now done the same. Let's hope they can do something about it, it is a little annoying! Anyone else think the gmail team (or one of their bosses) reads c.l.p? The problem is gone this morning. Here's to b*tching on c.l.p actually solving something raises glass! Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Compute pi to base 12 using Python?
On 13 Apr 2005 19:05:01 -0700, Paul Rubin http://phr.cx@nospam.invalid wrote: Dick Moores [EMAIL PROTECTED] writes: I don't believe GNU bc is available for Windows, is it? I don't know. It probably works ok under Cygwin at least. bc definitely works on cygwin, and is available at http://gnuwin32.sourceforge.net/packages/bc.htm for windows. Make sure you download both the dependencies and the binary package for it to work. I put the dll from the dependancy archive in c:/winnt/system32 and it worked. It should be noted that running the win32 bc from cygwin messed up my terminal, so I recommend running it from a cmd window (which worked fine). Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A little request about spam
On 4/14/05, César Leonardo Blum Silveira [EMAIL PROTECTED] wrote: Yeah that is happening to me too! Almost all my python-list e-mails go to the Spam box. Maybe we should contact the gmail admins? I've already contacted the gmail admins. There was no response. Peace Bill Mill bill.mill at gmail.com On 4/14/05, mark hellewell [EMAIL PROTECTED] wrote: On 4/14/05, James [EMAIL PROTECTED] wrote: Yes - it's been like that for the last month or so now and it's quite annoying, especially seeing as before it was working at near enough 100% accuracy. And I don't suppose there's much we can do about it? mark -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: A little request about spam
On 4/14/05, Fredrik Lundh [EMAIL PROTECTED] wrote: Bill Mill wrote: Maybe we should contact the gmail admins? I've already contacted the gmail admins. There was no response. have you tried reading the newsgroup via http://groups-beta.google.com/group/comp.lang.python while being logged in to your gmail account? Yup, I don't like that interface *nearly* as much as I do the gmail interface. In gmail, I see threads as their subject headers, lined up neatly. Threads which I've read are dimmed, and ones I haven't are bolded. I see people's real email addresses . Threads in which I have a personal conversation with one of the authors pop up to the top when a private email comes in. Spam (The greatest news ever!) is filtered out, and up until recently, it was very successful. In short, the groups-beta interface is very inadequate compared to the gmail one. Peace Bill Mill bill.mill at gmail.com /F -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: preallocate list
On 4/13/05, Jim [EMAIL PROTECTED] wrote: Hi all Is this the best way to preallocate a list of integers? listName = range(0,length) the 0 is unnecessary; range(length) does the same thing. What about non integers? arr = [myobject() for i in range(length)] I've just claimed in the newsgroup above that pre-allocating helps but I might be getting confused with matlab ;) If I have a file with a floating point number on each line, what is the best way of reading them into a list (or other ordered structure)? I was iterating with readline and appending to a list but it is taking ages. I would profile your app to see that it's your append which is taking ages, but to preallocate a list of strings would look like: [This is an average length string for i in range(approx_length)] My guess is that it won't help to preallocate, but time it and let us know. A test to back my guess: import timeit, math def test1(): lst = [0 for i in range(10)] for i in xrange(10): lst[i] = math.sin(i) * i def test2(): lst = [] for i in xrange(10): lst.append(math.sin(i) * i) t1 = timeit.Timer('test1()', 'from __main__ import test1') t2 = timeit.Timer('test2()', 'from __main__ import test2') print time1: %f % t1.timeit(100) print time2: %f % t2.timeit(100) 09:09 AM ~$ python test.py time1: 12.435000 time2: 12.385000 Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: preallocate list
Just a correction: snip I would profile your app to see that it's your append which is taking ages, but to preallocate a list of strings would look like: [This is an average length string for i in range(approx_length)] My guess is that it won't help to preallocate, but time it and let us know. A test to back my guess: import timeit, math def test1(): lst = [0 for i in range(10)] for i in xrange(10): lst[i] = math.sin(i) * i def test2(): lst = [] for i in xrange(10): lst.append(math.sin(i) * i) t1 = timeit.Timer('test1()', 'from __main__ import test1') t2 = timeit.Timer('test2()', 'from __main__ import test2') print time1: %f % t1.timeit(100) print time2: %f % t2.timeit(100) The results change slightly when I actually insert an integer, instead of a float, with lst[i] = i and lst.append(i): 09:14 AM ~$ python test.py time1: 3.352000 time2: 3.672000 The preallocated list is slightly faster in most of my tests, but I still don't think it'll bring a large performance benefit with it unless you're making a truly huge list. I need to wake up before pressing send. Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list
Re: Codig style: or
On 4/13/05, Sara Khalatbari [EMAIL PROTECTED] wrote: Hi! Suppose you're writing a module writing the definition of each function in that module in or . for example: a) This function does this that or: b) This function does blah blah blah What are the differences between and ? I'm using gedit I wanna know a bit about coding style. To be very honest: I have a very strict boss who looks for bugs in my codes he insists to know exactly which 'CODING STYLE AUTHORITATIVE SOURCE' I've based my coding style on when using or . Can anybody out there give me some hint? Can anybody tell me where to find a document on python coding style. the authoritative coding style guide is pep 8: http://www.python.org/peps/pep-0008.html Of course, there are style points that are debatable, but for comments, you should definitely be using triple-quotes. Pep 8 points you to pep 257, which is all about docstrings: http://www.python.org/peps/pep-0257.html Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: some sort of permutations...
On Apr 12, 2005 2:37 AM, Fredrik Lundh [EMAIL PROTECTED] wrote: Bernard A. wrote: i'm looking for a way to have all possible length fixed n-uples from a list, i think generators can help, but was not able to do it myself, maybe some one could point me out to an idea to do it ? did you try googling for python permutations ? here's the first hit: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 I've used that recipe a significant amount, and I feel like its recursion really slows it down (but I haven't been profiled it). Does anyone know of a non-recursive algorithm to do the same thing? And, while I'm asking that question, is there a good reference for finding such algorithms? Do most people keep an algorithms book handy? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Lambda: the Ultimate Design Flaw
On Apr 7, 2005 1:15 AM, Greg Ewing [EMAIL PROTECTED] wrote: Scott David Daniels wrote: Aahz wrote: You just can't have your cake and eat it, too. I've always wondered about this turn of phrase. I seldom eat a cake at one sitting. You need to recursively subdivide the cake until you have a piece small enough to fit in your input buffer. Then the atomicity of the cake-ingestion operation will become apparent. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting a list and counting interchanges
On 7 Apr 2005 10:44:49 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Tim's solution is very nice, it comes from basic things often taught in good computer science courses. I dunno, that comes from my Abstract Algebra course a heck of a lot more than it came from any of my CS classes (I graduated last May) While I'm at it though, I want to thank Tim for that post. It was one of those posts where afterwards you say of course! but beforehand I was totally thinking of it the wrong way. Brought me right back to Abstract. Peace Bill Mill bill.mill at gmail.com In Python when you have to do many (-1)**n you can do: (1-2*(n%2)) This seems quite faster. Bearophile -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting a list and counting interchanges
snip I think it's harder for some people to see why the assert j not in seen must be true, although that's obvious after just a few hours' thought wink. That's where you get to leave comments like: #it follows logically that assert j not in seen or #by implication assert j not in seen just to really frustrate the guy reading your code. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shebang in cross platform scripts
On Apr 6, 2005 9:37 AM, rbt [EMAIL PROTECTED] wrote: Haven't tested this on Windows yet... thought I'd ask here: Does the line below have any negative impact on Windows machines? I develop and test mostly on Unix, but my scripts are often used on Win systems too. #!/usr/bin/env python What the others have said already is true, that it will be ignored on windows, with one caveat. The shebang is interpreted by Apache if your script is a CGI script. So, if your script is a CGI, you will need to have a windows version and a nix version. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shebang in cross platform scripts
On Apr 6, 2005 11:06 AM, Ivan Van Laningham [EMAIL PROTECTED] wrote: Hi All-- Simon Brunning wrote: On Apr 6, 2005 2:37 PM, rbt [EMAIL PROTECTED] wrote: Does the line below have any negative impact on Windows machines? I develop and test mostly on Unix, but my scripts are often used on Win systems too. #!/usr/bin/env python Nope. On Windows it's just a comment. It works fine using cygwin, uwin, mks and pdksh, all available for Windows. Google is your friend. Symbolic links also work under uwin (don't know for sure about the others). That means you can install a link in /usr/bin to whereever python lives, and expect #!/usr/bin/python to work just fine. This works in cygwin as well; I didn't mention cygwin since the OP seemed to be asking about windows distribution, but it's a good point. Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list
Re: change extensions
On Apr 5, 2005 10:43 AM, Jeffrey Maitland [EMAIL PROTECTED] wrote: That approach works, but so does this one. import os, glob input_file_list = glob.glob('*.txt') for in_file in input_file_list: name = in_file.split('.') os.rename(in_file, str(name[0]) + '.' + 'text')) you should really use in_file.splitext - your script renames myfile.with.lots.of.dots.txt to myfile.text instead of myfile.with.lots.of.dots.text . If you *really* wanted to use split(), it oughta be ''.join(in_file.split('.')[:-1]) , but why not use the built-in? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to reload local namespace definitions in the python interpreter?
On Apr 4, 2005 11:10 AM, Steve Holden [EMAIL PROTECTED] wrote: Tim Jarman wrote: [EMAIL PROTECTED] wrote: Hi, I am a beginner using the python interpreter. To reduce typing effort, I created a module called aliases.py containing some aliases for objects I commonly use like - aliases.py : import filecmp, os, commands op = os.path snip By the way, are you aware of the import ... as ... idiom? e.g. import os.path as op This would, of course, require the user to qualify the names by prefixing them with op.. What the OP listed above requires that too. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pseudocode in the wikipedia
On Apr 1, 2005 3:15 PM, James Stroud [EMAIL PROTECTED] wrote: Is anybody else bothered by those stupid pascal-like := assignment operators? I actually like them. I think that the = should be a comparison operator, not a silly ==. I think that comparisons using = are much clearer, especially since you often write many of them in a row, whereas you almost always make one assignment per line. I use := every day in PL/SQL, and it's one of the few positive syntactical features of the language. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list