From http Wed Sep 13 09:49:44 2006 From: http (Paul Rubin) Date: 13 Sep 2006 06:49:44 -0700 Subject: Help me use my Dual Core CPU! References: <1158063943.007271.86000@m73g2000cwd.googlegroups.com> <45071c6d$0$576$ed2619ec@ptn-nntp-reader03.plus.net> <1158128695.301849.148210@p79g2000cwp.googlegroups.com> <7x8xkol0n9.fsf@ruckus.brouhaha.com> <1158132381.716706.243040@e63g2000cwd.googlegroups.com> <7xbqpk5bnc.fsf@ruckus.brouhaha.com> <7xodtkt48l.fsf@ruckus.brouhaha.com> Message-ID: <7xr6yf3mh3.fsf@ruckus.brouhaha.com> Robin Becker writes: > well these guys seem to think there are, perhaps it's a joke > http://anandtech.com/mac/showdoc.aspx?i=2832&p=6 Wow! Yes, it seems to be real ("Clovertown" 4-core cpu). See: http://www.tgdaily.com/2006/03/07/idf_keynotes_welcome_to_intel_3-point-0/ There's even a version that goes out to 32 cores ("Dunnington") on the drawing boards. We better get rid of that GIL soon ;-) From don.pasquale at blabla_tzimeil.com Sat Sep 9 19:15:17 2006 From: don.pasquale at blabla_tzimeil.com (don pasquale) Date: Sun, 10 Sep 2006 02:15:17 +0300 Subject: pyparsing listAllMatches problem References: Message-ID: On Sat, 09 Sep 2006 20:46:29 +0300, Paul McGuire wrote: > Thanks for posting this test case. This is a bug in pyparsing. I'll > have a > fix ready shortly. > > -- Paul Ur welcome, I hope you find the bug and squash it :). I temporalily solved my problem (in case anyone else has it) by changing another definition and including a second call to setResultsName. I modified the Goal definition from Goal = Dict(Group( relation_name + relation_body )) to Goal = Dict(Group( relation_name + relation_body )).setResultsName("glist",listAllMatches=True) if an extra .setResultsName("glist",listAllMatches=True) is added, then both calls to setResultsName (in Goal and Comparison_Predicate) suddenly work as planned! weird huh? I don't think this generally works, but it's worth a try until the bug is fixed... -- ??????????? ?????? ???? ?????????... From g.brandl-nospam at gmx.net Fri Sep 15 01:22:31 2006 From: g.brandl-nospam at gmx.net (Georg Brandl) Date: Fri, 15 Sep 2006 07:22:31 +0200 Subject: RELEASED Python 2.5 (release candidate 2) In-Reply-To: References: <1158158585.959817.189160@e3g2000cwe.googlegroups.com> Message-ID: Georg Brandl wrote: > Ant wrote: >> Anthony Baxter wrote: >> ... >>> code in 2.5 before the final release. *Please* try this >>> release out and let us know about any problems you find. >> >> Not a problem with the release, but with the docs. I've just ported a >> module using the ElementTree package to 2.5, and the Module Index >> (http://docs.python.org/dev/modindex.html) lists the package as >> elementtree, where it should be xml.etree. >> >> Not a major problem, but threw me for a while, since the only reference >> to the actual name of the module is in the title of >> http://docs.python.org/dev/lib/module-elementtree.html (8.13 >> elementtree -- The xml.etree.ElementTree Module). > > Please open a bug in the tracker at http://www.sf.net/projects/python. Wait, don't bother - just fixed it myself. Georg From deets at nospam.web.de Sat Sep 9 11:52:30 2006 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 09 Sep 2006 17:52:30 +0200 Subject: newbie: datastructure `dictionary' question In-Reply-To: References: Message-ID: <4mg69vF6015hU1@uni-berlin.de> jason schrieb: > Hello, > > I am completely new to python and I have question that I unfortunately > could not find in the various documentation online. My best guess is > that the answer should be quitte easy but I have just enterd the learning > phase so that means a hightend chance for stupidity and mistakes on my > part. > > I am trying to fill a nested dictionary from parsing a logfile. However > each time there is only one key entry created and that's it. Just > one entry, while the keys are different. That's 100% sure. I think > therefore that it is an assignment error in my part. [there we have it...] > > To give an static example of the datastructure that I am using to clear > any confusion on the datastructure part: > > records = { 'fam/jason-a' : { > 'date' : 'Fri Sep 8 16:45:55 2006', > 'from' : 'jason', > 'subject' : 'Re: Oh my goes.....', > 'msize' : '237284' }, > 'university/solar-system' : { > 'date' : 'Fri Sep 8 16:45:46 2006', > 'from' : 'jd', > 'subject' : 'Vacancies for students', > 'msize' : '9387' } > } > > Looping over this datastructure is no problem. > rkeys = ['date', 'from', 'subject', 'msize'] > for folder in records.keys(): > print '--' > print folder > for key in rkeys: > print records[folder][key] > > Now for the actual program/dynamic part - assignment in the loop I use the > following function. Note `datum' is not a date object, just a string. > > def parselog(data): > other = 0 > records = {} > > for line in string.split(data, '\n'): > str = line.strip() > if str[:4] == 'From': > mfrom, datum = extrfrom(str), extrdate(str) > print datum, mfrom > elif str[:4] == 'Fold': > folder = extrfolder(str[8:]) > records = {folder : { 'date' : datum, 'mesgbytes' : extrmsize(str[8:]), 'mesgcount' : 1}} > else: > other += 1 > > displrec(records) > > Note, this is not ment as a collision type datastructure, all initial data > entries are unique. My question: Where is my assignment e.g. records = > {folder.... wrong ? What you essentially do is this: records = {"some" : "dict"} records = {"some other" : "dict"} You rebind the name records to a new dictionary. So all your previously stored data is garbage collected. What you most probably want to do (I'm a bit confused about your code & too lazy to dig deeper): records = {} records[folder] = {'date' : ...} Notice that the dict[key]=value syntax mutates the existing dictionary. Diez From metaperl at gmail.com Mon Sep 25 08:53:30 2006 From: metaperl at gmail.com (metaperl) Date: 25 Sep 2006 05:53:30 -0700 Subject: Converting Perl Web Report to Python In-Reply-To: <1159183961.848544.142370@e3g2000cwe.googlegroups.com> References: <1159016655.956844.27090@d34g2000cwd.googlegroups.com> <%5gRg.5231$UG4.3934@newsread2.news.pas.earthlink.net> <1159131929.131598.164460@i42g2000cwa.googlegroups.com> <1159183961.848544.142370@e3g2000cwe.googlegroups.com> Message-ID: <1159188810.477878.212370@b28g2000cwb.googlegroups.com> pmcgover at gmail.com wrote: > Thanks again Dennis, > This should do what I want with additional flexibility... I will > develop the code later this week. During this excersize, I have come > to really appreciate Python over Perl. I love the Python command line > interpreter that allowed me to pretest any code very quickly. What > Python learning resource (book web link or both) do you recommend? I have 3 O'Reilly books that are indispensable: "Python Pocket Reference", "Python Cookbook", and "Learning Python" From yinxianglong at gmail.com Sun Sep 17 07:05:09 2006 From: yinxianglong at gmail.com (=?GB2312?B?0vzP6cH6?=) Date: Sun, 17 Sep 2006 19:05:09 +0800 Subject: How to SendMessage to a SysListView32 control for selecting an item? Message-ID: <977252d80609170405h733186cdy42fb92b2983b27f4@mail.gmail.com> Hi, all: I am writing a python script, which controls a SysListView32 Control. But I can't select an item by sendMessage using win32gui. My code as following: import winGuiAuto import win32gui import commctrl wn = win32gui wga = winGuiAuto hwnd = wn.FindWindow("#32770", "window title") #get the handle of the window listView = wga.findControls(hwnd, wantedClass="SysListView32")[0] #get the handle of the listview control # I can't sendmessage by the next line print wn.SendMessage(listView, commctrl.LVM_SETSELECTIONMARK, 0 ,0) Thanks in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Thu Sep 21 23:11:53 2006 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 21 Sep 2006 22:11:53 -0500 Subject: Building things with setup.py In-Reply-To: <7YHQg.4147$6S3.2437@newssvr25.news.prodigy.net> References: <7YHQg.4147$6S3.2437@newssvr25.news.prodigy.net> Message-ID: James Stroud wrote: > Hello All, > > This is annoying. I am trying to build scipy right now but every .so > file requires my adding "-lpython2.5 -lpthread -lm -lutil -ldl -shared" > to the ld flags. > > Main Question: When building with "setup.py", where can I include this > information so I don't have to link every .so file by hand? If it's actually necessary, python setup.py build_ext -lmylib > Also, why would this not be caught by the developers of scipy and numpy? Because we've never seen it before. There's no reason that you should have to add those libraries manually. Can you post your build log (the one that fails) to scipy-dev? http://www.scipy.org/Mailing_Lists > What factors go into needing to specify libraries and to properly link > .so files manually? Certainly the enthought didn't forget to test the > build process, so why would my machine be special in this regard? > > I'm running Linux FC4 on a dual intel p4 (~3.2 GHz) with sundry > libraries in non-standard places. Is this non-standard part what's > killing me? Possibly. Won't know more until I see the build log. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From cfriedl at bigpond.net.au Thu Sep 7 05:30:45 2006 From: cfriedl at bigpond.net.au (Chris) Date: Thu, 07 Sep 2006 09:30:45 GMT Subject: [ANN] IronPython 1.0 released today! In-Reply-To: <4m835vF4narnU1@uni-berlin.de> References: <4m835vF4narnU1@uni-berlin.de> Message-ID: <9FRLg.24762$rP1.15051@news-server.bigpond.net.au> Diez B. Roggisch wrote: > Chris wrote: > >> Jim Hugunin wrote: >>> I'm extremely happy to announce that we have released IronPython 1.0 >>> today! >>> http://www.codeplex.com/IronPython >> >> >> I'm no code guru but it sounds interesting. So can I import numpy, >> scipy, matplotlib, wxpython etc like I do now with CPython and expect, >> short of a few tweaks, that my code will work? > No, you can't. I'm not sure if there are any bridging attempts being made, > but in this respect IronPython is the same as Jython - a completely > different runtime which executes its own byte-code. > > Diez Disappointing because, apart from python itself, what I find amazing is the wealth of additional packages that, by association, come to be considered part of "python". Anyway thanks for saving me from some fruitless explorations. From __peter__ at web.de Thu Sep 21 09:54:13 2006 From: __peter__ at web.de (Peter Otten) Date: Thu, 21 Sep 2006 15:54:13 +0200 Subject: Decorator cllass hides docstring from doctest? References: Message-ID: Berthold H?llmann wrote: > Saving the following code to a file and running the code through > python does not give the expected error. disableling the "@decor" line > leads to the expected error message. Is this a bug or an overseen > feature? Neither, I'd say. Just an unfortunate interaction between doctest and function decoration. For the most common case where one function is wrapped by another, Python 2.5 has grown a "meta-decorator" >>> import functools >>> def deco(f): ... @functools.wraps(f) ... def g(): ... f() ... return g ... >>> @deco ... def f(): ... "yadda yadda" ... >>> f.__doc__ 'yadda yadda' but with callable objects you're on your own, I think. I came up with: def register_doctest(name, doc): global __test__ if doc: try: __test__ except NameError: __test__ = {name: doc} else: if name in __test__: raise ValueError("name clash") __test__[name] = doc class decor(object): def __init__(self, f): self.f = f register_doctest(f.__name__, f.__doc__) def __call__(self, *args, **kw): return self.f(*args, **kw) @decor def f(a, b): """ >>> f(1,2) False >>> f(2,2) False """ return a == b import doctest doctest.testmod() Peter From raschulmanxx at verizon.net Wed Sep 6 00:08:20 2006 From: raschulmanxx at verizon.net (Richard Schulman) Date: Wed, 06 Sep 2006 04:08:20 GMT Subject: Unicode string handling problem References: <1157511027.277425.266490@h48g2000cwc.googlegroups.com> <4fhsf2d2bn0vub865pdr53s7dfr8k5ao0m@4ax.com> Message-ID: On Wed, 06 Sep 2006 03:55:18 GMT, Richard Schulman wrote: >...I'm now using the codec with >improved results, but am still puzzled as to how to handle the row >termination of \n\n, which is being interpreted as two rows instead of >one. Of course, I could do a double read on each row and ignore the second read, which merely fetches the final of the two u'\n' characters. But that's not very elegant, and I'm sure there's a better way to do it (hint, hint someone). Richard Schulman (for email, drop the 'xx' in the reply-to) From jimburton1 at gmail.com Fri Sep 29 06:45:41 2006 From: jimburton1 at gmail.com (jimburton) Date: 29 Sep 2006 03:45:41 -0700 Subject: Organising unit tests Message-ID: <1159526741.807715.43600@m73g2000cwd.googlegroups.com> I have a number of unit tests organised hierarchically, all of which inherit fixtures from a base class. To run these all at once I started out using from basic import map, directionalpan, layerorder, layervisibility, listlayers, streamlayerlist # ... lots more ... suite0 = unittest.TestLoader().loadTestsFromTestCase(directionalpan.TestPan) suite1 = unittest.TestLoader().loadTestsFromTestCase(layerorder.TestLayerorder) # ... lots more ... alltests = unittest.TestSuite([suite0 , suite1 ....]) unittest.TextTestRunner(verbosity=2).run(alltests) Which is unmaintainable. the TestLoader docs warn that loadTestsFromModule will not play nicely with my situation and indeed if I try suite0 = unittest.TestLoader().loadTestsFromModule(basic) then run the tests, it hasn't picked any up. I suppose I could collect and run the tests with a shell script...what are my options here to avoid hardcoding and maintaining the list of tests, and how is it normally done? Thanks. From ldo at geek-central.gen.new_zealand Mon Sep 25 03:03:36 2006 From: ldo at geek-central.gen.new_zealand (Lawrence D'Oliveiro) Date: Mon, 25 Sep 2006 19:03:36 +1200 Subject: QuoteSQL References: Message-ID: In message , Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> Yes, I have done blobs. Still need a quoting function for the >> specials, though. > > Why? What makes your data so different from mine? "select * from details where person_name like" " concat(\"%%\", %s, \"%%\")" \ % \ QuoteSQL(name, True) From steve at holdenweb.com Tue Sep 12 12:50:46 2006 From: steve at holdenweb.com (Steve Holden) Date: Tue, 12 Sep 2006 17:50:46 +0100 Subject: Is it just me, or is Sqlite3 goofy? In-Reply-To: <1158078076.198865.6690@e63g2000cwd.googlegroups.com> References: <1158078076.198865.6690@e63g2000cwd.googlegroups.com> Message-ID: Paul Boddie wrote: > Fredrik Lundh wrote: > >>Steve Holden wrote: >> >> >>>Sure. But if you go back to the start of the thread you'll remember the >>>OP was originally complaining that SQLite was being promoted in the >>>Python docs as SQL compliant. It clearly isn't if its response to the >>>insertion of a data value that conflicts with the declared column type >>>is to store a value whose type is something else. >> >>the standard actually says "If the value of any input parameter provided >>by the SQL-agent falls outside the set of allowed values of the data >>type of the parameter /.../ the effect is implementation-defined" so >>that's perfectly SQL92 compliant. > > > To be fair, that text originates in section 12.3, referring to input > parameters to procedures. Meanwhile, the following text (subclause > 13.8, "") appears to be more pertinent: > > "If the data type of the target identified by the i-th is > an exact numeric type, then the data type of the i-th item of the > shall be an exact numeric type." > > I have used SQLite (releases 2 and 3) to my satisfaction, aware of the > "common knowledge" around the limitations (or features) of SQLite with > respect to data types. I'd agree with the complainant that the > behaviour of SQLite isn't what one would expect, although I started my > relational database experience using an Oracle database system and > admit that I may have been spoilt, thus saving Mr Holden - a > self-confessed Yorkshireman, I believe - the effort involved in > pointing out the relative luxury of my professional upbringing. ;-) > Spoilt? I should say so. When I were a lad we 'ad to scrape around for half a bit here and half a bit there - you didn't find whole bits just lying around in them days. As fer integers, you 'ad to save up for a year just to get sixteen bits. We used ter dream abaht 'avin' 64 bits, but there were no chance unless yer Dad were rich. Most of our strings were put together from characters we'd dredged out of t' canal, you 'ad to try and ignore the mud. We'd 'ave given our eye teeth for a bit of UTF-8 on a Sunday. These kids wi' their Oracle databases didn't know they were born. I can remember 'avin' to optimise programs by making sure that the next instruction were comin' under the heads of t' drum just as the last instruction were finishing. But yer tell these young folk nowadays and they just don't believe yer. etc., etc. pythonistical-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From jussij at zeusedit.com Mon Sep 11 18:54:08 2006 From: jussij at zeusedit.com (jussij at zeusedit.com) Date: 11 Sep 2006 15:54:08 -0700 Subject: Looking for the Perfect Editor References: <1157658338.661425.207140@b28g2000cwb.googlegroups.com> Message-ID: <1158015248.563755.32980@p79g2000cwp.googlegroups.com> Omar wrote: > I'd love the perfect editor that would be: Zeus for Windows understands Python, Java Script, HTML an many other languages: http://www.zeusedit.com/features.html Note: Zeus is shareware (45 day trial). It will do Python syntax highlighting, code folding, class browsing, smart indenting, project/workspace management etc etc. You can even write Zeus macros in Python or Java Script:) Jussi Jumppanen Author: Zeus for Windows From cliff at develix.com Thu Sep 14 06:22:54 2006 From: cliff at develix.com (Cliff Wells) Date: Thu, 14 Sep 2006 03:22:54 -0700 Subject: Why not event-driven packages in other than the main thread? In-Reply-To: References: Message-ID: <1158229374.3622.109.camel@devilbox> On Thu, 2006-09-14 at 11:13 +0200, Tor Erik wrote: > Hi, > > I've developed an application were I've used Tkinter for the GUI. > When I ran the GUI in another thread than the main, it kept locking > up. > I experienced similar problems with Twisted. > > Both of these tools are event-based, so I guess that is the root of the > problem... > > But could anyone tell me why running these in a thread other than the > main one doesn't work? They probably use signals (Twisted I'm sure does) and it's documented that signals don't work with threads: http://docs.python.org/lib/module-signal.html Regards, Cliff -- From rokkamraja at gmail.com Fri Sep 22 09:19:10 2006 From: rokkamraja at gmail.com (Raja Rokkam) Date: Fri, 22 Sep 2006 18:49:10 +0530 Subject: Python Network Programming Message-ID: <357297a00609220619j32cb5f3fs5afd40120d5f60b@mail.gmail.com> Hi, I am currently doing my final year project "Secure mobile Robot Management" . I have done the theoretical aspects of it till now and now thinking of coding it . I would like to code in Python , but i am new to Python Network Programming . Some of features of my project are: 1. Each robot can send data to any other robot. 2. Each robot can receive data from any other robot. 3. Every Robot has atleast 1 other bot in its communication range. 4. maximum size of a data packet is limited to 35 bytes 5. each mobile robot maintains a table with routes 6. all the routes stored in the routing table include a ??eld named life-time. 7. Route Discovery Process initiated if there is no known route to other bot. 8. There is no server over here . 9. every bot should be able to process the data from other bots and both multicast/unicast need to be supported. Assume the environment is gridded mesh and bots exploring the area. They need to perform a set of tasks (assume finding some locations which are dangerous or smthing like that). My main concern is how to go about modifying the headers such that everything fits in 35bytes . I would like to know how to proceed and if any links or resources in this regard. How to modify the headers ? ie. all in 35 bytes . Thank You, Raja. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bignose+hates-spam at benfinney.id.au Fri Sep 22 07:58:33 2006 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Fri, 22 Sep 2006 21:58:33 +1000 Subject: CONSTRUCT - New/Old Style Classes, build-in/extension types References: <1158923250.815731.261980@k70g2000cwa.googlegroups.com> Message-ID: <87zmcsxgd2.fsf@benfinney.id.au> "Ilias Lazaridis" writes: > Where can I find _compact_ documentation about Can you tell us what is lacking about the documentation at ? Specifically, what problems have you found in understanding these topics from the documentation available at that site? -- \ "The World is not dangerous because of those who do harm but | `\ because of those who look at it without doing anything." -- | _o__) Albert Einstein | Ben Finney From ejatwellkeeperdotcom Thu Sep 28 14:31:19 2006 From: ejatwellkeeperdotcom (Erik Johnson) Date: Thu, 28 Sep 2006 12:31:19 -0600 Subject: using the email module References: <451bfcca$1@nntp.zianet.com> Message-ID: <451c150f$1@nntp.zianet.com> "Sybren Stuvel" wrote: > If the HTML document should really be attached, give it a > Content-Disposition: Attachment > header. Check out the accompanying headers as well, by simply emailing > yourself an attached HTML file and examining the email source. html = """\ ... """ attachment = MIMEText(html, 'html') attachment['Content-Disposition'] = 'attachment; filename="sample.html"' msg.attach(attachment) # Ah! Yes, that works! Thank you! ;) From bj_666 at gmx.net Wed Sep 20 17:54:49 2006 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: Wed, 20 Sep 2006 23:54:49 +0200 Subject: "list index out of range" error References: <1158787569.955853.223030@h48g2000cwc.googlegroups.com> Message-ID: In <1158787569.955853.223030 at h48g2000cwc.googlegroups.com>, sam wrote: > i'm trying to code a version of a selection sort and the heart of the > code is as follows (no_lines is simply the number of items to be > sorted, read out of an input file): > > for j in range(0, no_lines): > > k = 0 > while k < no_lines: > sorted_check = 0 > if list_initial[k] < list_initial[k+1]: > temp_str = list_initial[k] > elif list_initial[k] == list_initial[k+1]: > temp_str = list_initial[k] > elif list_initial[k] > list_initial[k+1]: > temp_str = list_initial[k+1] > sorted_check = 1 > k += 1 > > list_initial.remove(temp_str) > list_final.append(temp_str) > no_lines -= 1 > > if sorted_check == 0: > break > > problem is, i keep getting a "list index out of range" error. i've had > this problem before in different contexts with lists in loops. > > i thought i had it cracked when it occurred to me that i needed to > decrement no_lines to take into account that list_initial was shrinking > as i deleted sorted items, but i still got the same error. it's > probably something trivial, but i can't seem to get round it by using > while loops, and i had the same problem with cmp(), hence the explicit > comparison above, which still doesn't work. can anyone help a beginner > out with this? It has nothing to do with `cmp()` vs. explicit testing but with indexing the `k+1` element. Let's assume `no_lines` is 10 then the elements have the indexes 0 to 9. Within the while loop `k` is incremented and the loop body is executed as long as `k < 10`. When `k == 9` you try to access the element at index `k+1`, but there is no element at index 10. So you get the `IndexError`. Ciao, Marc 'BlackJack' Rintsch From sybrenUSE at YOURthirdtower.com.imagination Fri Sep 29 12:20:08 2006 From: sybrenUSE at YOURthirdtower.com.imagination (Sybren Stuvel) Date: Fri, 29 Sep 2006 18:20:08 +0200 Subject: retry in exception References: <451d4294$1@news.vo.lu> Message-ID: Antoine De Groote enlightened us with: > I hope I don't upset anybody by comparing Python to Ruby (again). Is > there something like Ruby's retry keyword in Python? Please don't assume that everybody knows Ruby through and through... Sybren -- Sybren St??vel St??vel IT - http://www.stuvel.eu/ From MonkeeSage at gmail.com Fri Sep 22 15:09:13 2006 From: MonkeeSage at gmail.com (MonkeeSage) Date: 22 Sep 2006 12:09:13 -0700 Subject: Does Python provide "Struct" data structure? References: <1158936980.959486.304260@i3g2000cwc.googlegroups.com> <4nietsFahdftU1@individual.net> Message-ID: <1158952153.009201.70000@m73g2000cwd.googlegroups.com> Hi Daniel, To avoid problems you could vendor the ipython file you require, but an easier solution may just be to implement your own version of the class (it's extreemly easy): class struct(): def __init__(self, *args, **kwargs): for k, v in kwargs.items(): setattr(self, k, v) mystruct = struct(echo = 1, verb = 'Verbose', filedir = 'C:/temp') print mystruct.filedir Regards, Jordan From fabrizio.cornelli at gmail.com Fri Sep 1 04:59:29 2006 From: fabrizio.cornelli at gmail.com (Fabrizio Cornelli) Date: Fri, 1 Sep 2006 10:59:29 +0200 Subject: Strange string encoding behaviour with pymssql Message-ID: <48787d890609010159i797084c5vdefeeb3a833a75fd@mail.gmail.com> Hello, I'm using pymssql to extract data from a legacy table with a non-ascii encoded name. The strange thing is that I can make my query from the idle's console, but it doesn't work from python. (I'm working in a windows environment) The error shows that there's a problem related to the encoding, I've tried to excplicit it in a -*- coding: latin-1 -*- fashion, but it seems it's not enough. Converting with unicode(query,encode) trying all the known encoding formats dowsn't work as well. I tried something like: mssql.query("select id_attivit? from prodotti") and I have an error in the form: pymssql.DatabaseError: internal error: SQL Server message 207, severity 16, stat e 3, line 1: Il nome di colonna 'id_attivit?' non ? valido. As you can see 'id_attivit?' has been wrongly converted in 'id_attivit?' . Why, I wonder, idle's console and pythonwin can manage correctly the string and python.exe does not? Is it a problem related to pymssql and this is not the right place where to post it, or is there someone that could show me a solution? Thanks in advance for any hint. -- Fabrizio Zeno Cornelli -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjmachin at lexicon.net Thu Sep 28 21:32:00 2006 From: sjmachin at lexicon.net (John Machin) Date: 28 Sep 2006 18:32:00 -0700 Subject: sqlite3 error References: <1159394058.945948.119410@h48g2000cwc.googlegroups.com> Message-ID: <1159493520.289291.276850@b28g2000cwb.googlegroups.com> John Salerno wrote: > John Machin wrote: > > John Salerno wrote: > >> CREATE TABLE Researchers ( > >> researcherID varchar(9) PRIMARY KEY NOT NULL, > >> birthYear int(4) DEFAULT NULL, > >> birthMonth int(2) DEFAULT NULL, > >> birthDay int(2) DEFAULT NULL, > >> birthCountry varchar(50) DEFAULT NULL, > >> birthState char(2) DEFAULT NULL, > >> birthCity varchar(50) DEFAULT NULL, > >> nameFirst varchar(50) NOT NULL, > >> nameLast varchar(50) NOT NULL, > >> nameGiven varchar(255) DEFAULT NULL, > > > > A bit OT, but one answer to the "can you make a living with just > > Python" question is "Yup, tool of choice for rummaging in and fixing > > data that's been mangled by users cramming it into dodgy data models" > > :-) > > [snip] > > > (2) It's not apparent how you would use the first, last, and given > > names columns, especially with two of them being "not null". Consider > > how you would store e.g.: > > J Edgar Hoover > > DJ Delorie > > Sukarno > > 35 > > Maggie Cheung Man-Yuk > > Molnar Janos > > Fatimah binte Rahman > > Zhang Manyu > > Not sure I follow you on some of these examples. In the case of J Edgar > Hoover, I would just put the full name for his first name, or if "J" is > entered, then just that, I suppose. Given name will be first name + > middle name(s). (I took most of this schema from a baseball database, so > maybe it's just something that worked better there.) You sure to be using "last name" to mean "surname" in the sense of unchanging family name e.g. John and Mary Smith are the children of Fred Smith, who is the son of Joe Smith. You would address a letter to Mary as "Dear Ms Smith", and in follow-on paragraphs in (say) a news article might refer to her using only the surname e.g. "Smith also announced ...". The problems are (1) there are cultures that don't have the concept of a surname, and if they do, it may not be the "last name" (2) the name may consist of only one word (giving you problems with "not null") or not even be a word. DJ Delorie -- his "given name" *is* DJ Sukarno -- one word name 35 -- some jurisdictions allow name to include (or consist solely of) digits Maggie Cheung Man-Yuk -- surname is Cheung [Hong Kong romanisation] Molnar Janos -- surname is Molnar Fatimah binte Rahman -- no surname; daughter of person whose given name is Rahman Zhang Manyu -- surname is Zhang [pinyin romanisation]; same person as Maggie Cheung Man-Yuk It gets better: Iceland: Jon Bjornsson and Hildur Bjornsdottir are the children of Bjorn Eiriksson. Portuguese: Jose Carlos Fernandes [mothers's family name] Rodrigues [fathers's family name]; first step in shortening gives Jose Carlos Rodrigues -- no drama here, but compare with Spanish: Jose Carlos Fernandez [father's family name] Rodriguez [mother's family name], shortened to Jose Carlos Fernandez. [parts of] Somalia, Ethiopia: [using English given-name words for clarity] Tom Dick Harry and Janet Dick Harry are the children of Dick Harry Fred, who is the son of Harry Fred Joe. Vietnamese: Full name e.g. Nguyen Thi Hoa Dung -- I have seen this recorded as last name = Nguyen (that's the family name; doing well so far), but first name = Thi. Thi means "Ms" or "female". The "first name" is actually Dung. Given the popularity of Nguyen as a family name (about 50% !!) , the recorded information has narrowed the choice to about 25% of the Vietnamese population :-( Cheers, John From franz.steinhaeusler at gmx.at Sat Sep 16 14:54:06 2006 From: franz.steinhaeusler at gmx.at (Franz Steinhäusler) Date: Sat, 16 Sep 2006 20:54:06 +0200 Subject: XPN 0.6.5 released References: <20060912201557.3812.4625.XPN@orion.homeinvalid> <20060914193558.2234.50297.XPN@orion.homeinvalid> <1158325872.846004.66150@k70g2000cwa.googlegroups.com> <599og29q5ano6pn3s0fi13533h86j747kk@4ax.com> <20060916175424.2237.2442.XPN@orion.homeinvalid> Message-ID: On Sat, 16 Sep 2006 17:54:27 GMT, Nemesis wrote: >Mentre io pensavo ad una intro simpatica "Franz Steinh?usler" scriveva: > > >> For the find, I personally would prefer to jump default to "body", >> but this is of course a matter of taste. > >Do you mean you would like the focus to be set on the "body" search >field? Yes, that I meant. > >> I dos prompt, all the time the prompt doesn't return anymore >> (are there still open windows)? >> >> >> I quit with ctrl-break: >> >> Traceback (most recent call last): >> >> File "c:\Programme\xpn\xpn.py", line 507, in destroy >> >> self.purge_groups() >> >> File "c:\Programme\xpn\xpn.py", line 2456, in purge_groups >> >> articles.update(articles_dict) >> >> File "C:\Python24\lib\UserDict.py", line 147, in update >> >> self[k] = v >> >> File "c:\Python24\lib\shelve.py", line 129, in __setitem__ >> >> p.dump(value) >> >> KeyboardInterrupt > >I don't know how "CTRL+break" interact with XPN, it's better to close it >with its exit function "CTRL+E". Because it hanged. The dos prompt didn't return, so I have to type ctrl-c or ctrl-break to get the prompt back. > >> I changed the key Find message to ctrl f, and then I restart, I got: >> >> >> Traceback (most recent call last): >> File "c:\Programme\xpn\xpn.py", line 2987, in ? >> main=MainWin(options.use_home,options.custom_dir) >> File "c:\Programme\xpn\xpn.py", line 2917, in __init__ >> self.show_subscribed() >> File "c:\Programme\xpn\xpn.py", line 557, in show_subscribed >> total=len(articles.keys()) >> File "c:\Python24\lib\shelve.py", line 98, in keys >> return self.dict.keys() >> File "C:\Python24\lib\bsddb\__init__.py", line 238, in keys >> return self.db.keys() >> DBPageNotFoundError: (-30988, 'DB_PAGE_NOTFOUND: Requested page not >> found') >> I cannot start the program anymore. >> >> maybe it has something to to with shortcuts.dat. >> (I don't know). > >No I don't think it is related to the shortcuts, it seems that >your articles db is corrupted, it got broken when the application has >been closed not in the right way. Aha. I try again any further. -- Franz Steinhaeusler From shejo284 at gmail.com Thu Sep 28 08:53:06 2006 From: shejo284 at gmail.com (Sheldon) Date: 28 Sep 2006 05:53:06 -0700 Subject: Resuming a program's execution after correcting error Message-ID: <1159447986.754423.258550@e3g2000cwe.googlegroups.com> Hi. Does anyone know if one can resume a python script at the error point after the error is corrected? I have a large program that take forever if I have to restart from scratch everytime. The error was the data writing a file so it seemed such a waste if all the data was lost and must be recalculated again. Sincerely, Sheldon From johannes at axandra.com Mon Sep 25 13:27:47 2006 From: johannes at axandra.com (johannes at axandra.com) Date: 25 Sep 2006 10:27:47 -0700 Subject: Job offer python programmer References: <1159189896.956716.84320@k70g2000cwa.googlegroups.com> <7xzmcokrv3.fsf@ruckus.brouhaha.com> Message-ID: <1159205267.826430.12470@h48g2000cwc.googlegroups.com> Paul Rubin wrote: > johannes at axandra.com writes: > > We're looking for a software developer Python/PHP/Ajax/MySQL for web > > applications (full time job). Maybe someone in this group might be > > interested in this job. > > Further information can be found here: > > About the job: http://www.Axandra.de/python > > Well, that page is in German, so I'm guessing you want a German speaker? Hello Paul, Thank you for your reply. We need a German speaker. Please accept my apologies for not being clear in the initial post. All the best, Johannes From steve at holdenweb.com Tue Sep 26 09:56:12 2006 From: steve at holdenweb.com (Steve Holden) Date: Tue, 26 Sep 2006 09:56:12 -0400 Subject: Remap Mysql tuple to dictionary In-Reply-To: References: <2rTRg.95640$AD5.1277027@phobos.telenet-ops.be> Message-ID: Lawrence D'Oliveiro wrote: > In message , Fredrik > Lundh wrote: > > >>Lawrence D'Oliveiro wrote: >> >> > SQL databases like MySQL are _designed_ for efficiency. >> >>unlike the Python data types, you mean ? > > > Did I say it was unlike anything? Can you please stop this incessant carping? c.l.py used to be a fun place to hang out. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From bignose+hates-spam at benfinney.id.au Wed Sep 13 22:34:23 2006 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 14 Sep 2006 12:34:23 +1000 Subject: Python to JavaScript Compiler? Anyone written such a beast? References: Message-ID: <87hczbmb0w.fsf@benfinney.id.au> kenneth.m.mcdonald at sbcglobal.net writes: > Of course, I'm not talking about something that would transform any > Python code into semantically JavaScript code, but simply something > that would analyze a "restricted" Python source file, and spit out > equivalent JavaScript. You may be looking for Pyjamas: -- \ Hercules Grytpype-Thynne: "Well, Neddie, I'm going to be | `\ frank." Ned Seagoon: "Right, I'll be Tom." Count Moriarty: | _o__) "I'll be Gladys." *slap* -- The Goon Show, _World War I_ | Ben Finney From fuzzyman at gmail.com Wed Sep 13 17:45:29 2006 From: fuzzyman at gmail.com (Fuzzyman) Date: 13 Sep 2006 14:45:29 -0700 Subject: Python blogging software In-Reply-To: References: <1158132558.3622.29.camel@devilbox> <1158160960.920246.107630@b28g2000cwb.googlegroups.com> Message-ID: <1158183929.155925.6050@m73g2000cwd.googlegroups.com> Cliff Wells wrote: > On Wed, 2006-09-13 at 08:22 -0700, Fuzzyman wrote: > > Cliff Wells wrote: > > > On Wed, 2006-09-13 at 00:29 -0700, Cliff Wells wrote: > > > > > > > Anyone aware of any functional (doesn't need to be complete, beta is > > > > fine) blog software written in Python? > > > > > > Hmph. And as soon as I hit send I find > > > > > > http://wiki.python.org/moin/PythonBlogSoftware > > > > > > Okay, so is there any *not* on that list that should be considered (and > > > perhaps added to the list)? > > > > Firedrop2 is a client-side blog program (generates static HTML to be > > uploaded to your webserver). > > I looked at this but didn't care for it as it doesn't appear to allow > for comments (feature-wise it's a few steps down from Frog, which I > already have working). > Because it is client side (rather than running on the server), it has no built in comments facility. I use Haloscan for comments, but I'm always on the look out for a neat comments system to integrate with Firedrop. I personally prefer the 'client side' approach, as it makes migrating content to another server trivially easy. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml From roy at panix.com Tue Sep 12 23:49:09 2006 From: roy at panix.com (Roy Smith) Date: Tue, 12 Sep 2006 23:49:09 -0400 Subject: Are Python's reserved words reserved in places they dont need to be? References: <1158072199.681163.212310@p79g2000cwp.googlegroups.com> <1hlki4l.hxeyzim53ewmN%aleax@mac.com> <1158118298.156680.7500@m73g2000cwd.googlegroups.com> Message-ID: In article <1158118298.156680.7500 at m73g2000cwd.googlegroups.com>, "Carl Banks" wrote: > Alex Martelli wrote: > > > IBM (PL/I's inventor and rabid defender) found out the hard way that > > making the parser more complicated, slow and bug-prone in order to allow > > such absurd obfuscation was NOT a popular trade-off -- despite IBM's > > alleged monopoly power, PL/I is now basically dead while the older, > > crankier languages that PL/I wanted to replace, Cobol and particularly > > Fortran, are still quite alive (and with reserved words ALWAYS reserved > > -- like in C, Python, Java, C#, Haskell, and basically every language > > that's even halfway sensible;-). > > Except Fortran doesn't have any reserved words either: > > PROGRAM KWDS > REAL REAL,WRITE > WRITE=1.0 > REAL=2.0 > WRITE(*,*)WRITE,REAL > END > > (Not sure whether it's true in Fortran 9x.) > > > Carl Banks As I remember, you didn't need the whitespace either. IIRC, your example above could have been written as: PROGRAMKWDS REALREAL,WRITE WRITE=1.0 REAL=2.0 WRITE(*,*)WRITE,REAL END and worked just as well. I have nightmares thinking about writing a fortran parser. Oh yeah, spaces were the same as zeros on input, too. What a wonderful language. Isn't it wonderful how nothing you write ever gets lost once google gets it's hands on it: http://mirrorspace.org/python/doc/humor/index.html#habits (personally, I think the one about the little girl buying a wabbit in the pet store is the best of the collection). From vatamane at gmail.com Fri Sep 29 04:16:24 2006 From: vatamane at gmail.com (Nick Vatamaniuc) Date: 29 Sep 2006 01:16:24 -0700 Subject: analyzing removable media References: <1159506620.982412.264010@k70g2000cwa.googlegroups.com> Message-ID: <1159517784.680533.178870@i42g2000cwa.googlegroups.com> glenn wrote: > Hi > can anyone tell me how given a directory or file path, I can > pythonically tell if that item is on 'removable media', or sometype of > vfs, the label of the media (or volume) and perhaps any other details > about the media itself? > thanks > Glenn It won't be trivial because one of the goals of the operating systems is to hide the differences between various types of storage devices and make them all look the same (i.e. a jump drive, a CD-ROM, a network volume are presented uniformly to the user as just another path in the file system). But you can probably use guesswork on unix OS's, as somebody above suggested, and examine the path. If the path contains common media mount points then that should give you a clue. On Windows you cannot easily know. For example if your file is on D:\file.txt, it is not immediatly obvious if D is a jumpdrive, a networked drive, a hard drive, or a CD-ROM. The only thing I can think of is to try to examine the Windows registry with the _winreg module. Here are the docs: http://docs.python.org/lib/module--winreg.html There might be a key burried in there some place that will tell you which drives are what type. From sanzhiyan at gmail.com Fri Sep 22 11:25:55 2006 From: sanzhiyan at gmail.com (Saizan) Date: 22 Sep 2006 08:25:55 -0700 Subject: Isn't bool __invert__ behaviour "strange"? In-Reply-To: <4nibt5Fag01tU2@individual.net> References: <1158934100.450529.304810@i3g2000cwc.googlegroups.com> <4nibt5Fag01tU2@individual.net> Message-ID: <1158938755.403604.91180@d34g2000cwd.googlegroups.com> Bjoern Schliessmann wrote: > Saizan wrote: > > > Why subclassing bool from int either __invert__ or __neg__ haven't > > been overrided to produce a boolean negation? > > I wonder what -True or -False should evaluate to. > > Regards, > > > Bj?rn > > -- > BOFH excuse #297: > > Too many interrupts Well in boolean notation -True == False and -False == True, actually you may prefer ? or a line over the term, but since there's no such operator in python I think we should use "-" which is also the operator used by Bool himself in his formulation for negation which was 1-x. Now that I think of it 1-x should work as a negation in Python, too, since True == 1 and False == 0, but it would be a little annoying to write expressions in this way. From hrnetindia at yahoo.com Wed Sep 27 03:17:43 2006 From: hrnetindia at yahoo.com (hrnetindia) Date: Wed, 27 Sep 2006 07:17:43 -0000 Subject: Python Lead / Developers required for a Telecom Company, Hyderabad Message-ID: World's No:1 Telecom Product Development (Billing Settlement) company urgently requires the following: Position: Team Lead / Software Engineer Skills: Essential: Python Other: Perl / XML / J2ME Experinece: 2-5 years of experience using Python. Location: Hyderabad, India Please mail the CV to hrnetindia at gmail.com Thanks HR Net Consultants Pvt .Ltd. # 405 Amough Plaza ,Beside ITC Kakatiya Hotel Begumpet,Hyderabad 500016,AP,India Tel :91+40-66756565 ( 4 lines) www.hrnetindia.com From jhefferon at smcvt.edu Sat Sep 16 07:15:59 2006 From: jhefferon at smcvt.edu (Jim) Date: 16 Sep 2006 04:15:59 -0700 Subject: PostgreSQL, psycopg2 and OID-less tables In-Reply-To: <1158386881.666330.246150@d34g2000cwd.googlegroups.com> References: <6xyOg.2274$dL2.1462@fe20.usenetserver.com> <1158386881.666330.246150@d34g2000cwd.googlegroups.com> Message-ID: <1158405359.258007.229910@b28g2000cwb.googlegroups.com> Frank Millman wrote: > I therefore use the following - > cur.execute("select currval('%s_%s_Seq')" % (tableid, columnid) I use this also (although isn't it right that sometimes the name of the sequence is not so straightforward? for instance, isn't there a limit on the number of chars?). Can anyone say what is an advantage of the two nextval() solutions described earlier in this thread over the currval() solution listed here? Jim From casevh at comcast.net Thu Sep 7 15:45:56 2006 From: casevh at comcast.net (casevh at comcast.net) Date: 7 Sep 2006 12:45:56 -0700 Subject: How to build extensions on Windows? In-Reply-To: <1157656285.191995.222400@m79g2000cwm.googlegroups.com> References: <1157656285.191995.222400@m79g2000cwm.googlegroups.com> Message-ID: <1157658356.525163.20420@i42g2000cwa.googlegroups.com> > 1. Get MinGW gcc and/or g++, preferably via MinGW installer from [1]. > You may have to restart your computer or manually edit PATH system > environment variable to include MinGW's bin directory (default is > c:\mingw\bin). Then check if it is there by typing `path` in the cmd > window. 1a. [Optional] Install MSYS, also from [1]. If your extension relies on another C library, this may make it easier to compile that library. > > 2. Get pexports-0.42h.zip from [2] and extract pexports.exe file > > 3. Prepare MinGW compatible .a library file > pexports.exe c:\WINDOWS\system32\python24.dll > python24.def > c:\mingw\bin\dlltool.exe --dllname python24.dll --def python24.def > --output-lib libpython24.a > > 4. Place the new libpython24.a file in the Python's libs directory (but > not in the Lib dir), default is c:\python24\libs I believe steps 2 through 4 are only required for Python 2.3 or earlier. I have not needed to do those steps for Python 2.4 and 2.5. > > 5. Build your extension by executing your setup script with > `--compiler=mingw32` parameter. > python setup.py build --compiler=mingw32 > > Additionally you may wish to put a distutils.cfg file in the > c:\python\lib\distutils dir containing following entries: > [build] > compiler = mingw32 > > This will tell the distutils script to use MinGW compiler by default > when executing `python setup.py build` command. > > best, > fw > > [1] http://sourceforge.net/projects/mingw/ > [2] http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip From aahz at pythoncraft.com Fri Sep 15 00:36:21 2006 From: aahz at pythoncraft.com (Aahz) Date: 14 Sep 2006 21:36:21 -0700 Subject: What's more pythonic? References: Message-ID: In article , Dan Stromberg wrote: > >Is sample1 or sample2 the more pythonic way of comparing? Depending on what versions of Python you're targetting, some people would argue neither (advocating the deprecation of __cmp__). I'm not sure what the current status of __cmp__ is for Python 3.0. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "LL YR VWL R BLNG T S" -- www.nancybuttons.com From steve at holdenweb.com Thu Sep 28 16:04:01 2006 From: steve at holdenweb.com (Steve Holden) Date: Thu, 28 Sep 2006 21:04:01 +0100 Subject: preemptive OOP? In-Reply-To: References: <451c1a6d$1@nntp.zianet.com> Message-ID: John Salerno wrote: > Erik Johnson wrote: > > >> My feeling is that there is no good reason to add the complexity of your >>own custom classes if they provide no additional data or behaviour. If you >>know you have plans to add your own attributes and/or methods to MyNotebook >>soon, there's no harm in doing this now, but why? You can always create your >>own custom subclass at the point when you have something of value to add and >>through the mircale of polymorphism, it will function everywhere a Notebook >>would. > > > I think you're right. In fact, one thing I always loved about Python was > that OOP is optional, and here I am trying to force it upon myself > unnecessarily! :) However, if you want to simplify the code, you could start by saying myNotebook = wx.Notebook regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From antroy at gmail.com Fri Sep 22 04:58:24 2006 From: antroy at gmail.com (Ant) Date: 22 Sep 2006 01:58:24 -0700 Subject: Don't use regular expressions to "validate" email addresses (was: I need some help with a regexp please) In-Reply-To: References: <1158858881.894280.93230@d34g2000cwd.googlegroups.com> <1158874471.410073.71570@i3g2000cwc.googlegroups.com> <1158881568.914183.112660@i3g2000cwc.googlegroups.com> Message-ID: <1158915504.159622.154230@m7g2000cwm.googlegroups.com> Ben Finney wrote: ... > The best advice I've seen when people ask "How do I validate whether > an email address is valid?" was "Try sending mail to it". There are advantages to the regex method. It is faster than sending an email and getting a positive or negative return code. The delay may not be acceptable in many applications. Secondly, the false negatives found by a reasonable regex will be few compared to the number you'd get if the smtp server went down, or a remote relay was having problems delivering the message etc etc. >From a business point of view, it is probably more important to reduce the number of false negatives than to reduce the number of false positives - every false negative is a potential loss of a customer. False positives? Who cares really as long as they are paying ;-) From fredrik at pythonware.com Wed Sep 20 07:32:49 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 20 Sep 2006 13:32:49 +0200 Subject: high level, fast XML package for Python? In-Reply-To: <450CF5CF.3090109@v.loewis.de> References: <1158326455.361129.247990@i3g2000cwc.googlegroups.com> <450CF5CF.3090109@v.loewis.de> Message-ID: Martin v. L?wis wrote: >> Is there a standard xml package for Python? Preferably high-level, fast >> and that can parse in-file, not in-memory since I have to deal with >> potentially MBs of data. > > It seems that everybody is proposing libraries that use in-memory > representations. There is a standard xml package for Python, it's > called "xml" (and comes with the standard library). It contains a > SAX interface, xml.sax, which can parse files incrementally. note that the requirements included "high-level" and "fast"; sax is low-level, error-prone, and once you've finally fixed all the remaining bugs in your state machine, not that fast, really. From lutz at rmi.net Sat Sep 30 15:11:41 2006 From: lutz at rmi.net (Mark Lutz) Date: 30 Sep 2006 12:11:41 -0700 Subject: Mark Lutz Python interview References: <1159554334.170062.182720@i3g2000cwc.googlegroups.com> <1159561253.807662.309910@h48g2000cwc.googlegroups.com> Message-ID: <1159643501.320802.262970@i3g2000cwc.googlegroups.com> Fuzzyman wrote: > Mark Lutz wrote: > > Python author and trainer Mark Lutz will be interviewed > > on the radio show Tech Talk this Sunday, October 1st, > > at 6PM Eastern time. He'll be answering questions about > > Python, his books, and his Python training services. > > > > Does he always talk in the third person ? ;-) Yes, I've heard that he does. :-) From lists at fabis-site.net Tue Sep 26 12:41:53 2006 From: lists at fabis-site.net (Fabian Steiner) Date: Tue, 26 Sep 2006 18:41:53 +0200 Subject: Splitting device addresses into parts Message-ID: I often have to deal with strings like "PCI:2:3.0" or "PCI:3.4:0" and need the single numbers as tuple (2, 3, 0) or (3, 4, 0). Is there any simple way to achieve this? So far I am using regular expressions but I would like to avoid them ... Regards, Fabian Steiner From steve at holdenweb.com Sat Sep 9 07:17:48 2006 From: steve at holdenweb.com (Steve Holden) Date: Sat, 09 Sep 2006 12:17:48 +0100 Subject: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?) In-Reply-To: <1157782714.618336.148840@e3g2000cwe.googlegroups.com> References: <1157418942.105174.228650@p79g2000cwp.googlegroups.com> <44fd309b$0$306$626a54ce@news.free.fr> <1157667594.051943.265040@d34g2000cwd.googlegroups.com> <1157705273.423649.132210@i42g2000cwa.googlegroups.com> <1157749692.092338.240820@m73g2000cwd.googlegroups.com> <1157782714.618336.148840@e3g2000cwe.googlegroups.com> Message-ID: mensanator at aol.com wrote: > Paul McNett wrote: > >>mensanator at aol.com wrote: >> >>>Do you know what INNER JOIN means? >>> >>>Do you know how important it is to a relational database? >>> >>>Can you explain how an INNER JOIN can even work, in theory, >>>with dynamic data types? >> >>Let's stop the pissing contest and just see how it works. After all, >>this is Python and we can easily just try it out. Here's my example. >>Please tell me how this causes unexpected results, > > > When we use a best case scenario, we get what we expect. > > >>and why it isn't SQL. > > > It isn't SQL simply because SQL won't let you insert text > into a numeric field. > Yup, I have to agree that's pretty crappy. (Makes mental note to limit use of SQLite). regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From scott.daniels at acm.org Fri Sep 22 19:04:25 2006 From: scott.daniels at acm.org (Scott David Daniels) Date: Fri, 22 Sep 2006 16:04:25 -0700 Subject: Is it just me, or is Sqlite3 goofy? In-Reply-To: References: <1157418942.105174.228650@p79g2000cwp.googlegroups.com> <1157477207.223616.210780@h48g2000cwc.googlegroups.com> <1157484212.885076.304340@h48g2000cwc.googlegroups.com> <1158042568.767805.221940@m73g2000cwd.googlegroups.com> <1158081840.659296.286340@b28g2000cwb.googlegroups.com> <1158083866.689838.150070@p79g2000cwp.googlegroups.com> <1158089301.155482.151530@i42g2000cwa.googlegroups.com> Message-ID: <4514645e$1@nntp0.pdx.net> Fredrik Lundh wrote: >... dynamic typing != random typing. So true. To get a really good random typing going, you need a cryptographically strong random number generator to feed the application of type constructors to values during the execution of a program. Perhaps the best way to do this is to modify the the interpreter. We could call the new language "Python?!", or actually use an interobang if Unicode has such a character. --Scott David Daniels scott.daniels at acm.org From gagsl-py at yahoo.com.ar Sat Sep 23 05:57:58 2006 From: gagsl-py at yahoo.com.ar (Gabriel Genellina) Date: Sat, 23 Sep 2006 06:57:58 -0300 Subject: Application logging to screen and file - any favorite modules (no luck on cheeseshop) In-Reply-To: <4nkdflFaj5doU1@individual.net> References: <1158990612.569086.204230@b28g2000cwb.googlegroups.com> <4nkdflFaj5doU1@individual.net> Message-ID: <7.0.1.0.0.20060923064733.051d2658@yahoo.com.ar> At Saturday 23/9/2006 06:35, Bjoern Schliessmann wrote: > > Hello, I am looking for a module which has > > * log levels > > * output to stdout and file (either/or based on config) > > * nicely formatted log output (e.g., indentation when appropriate) > >Sorry for being nosey, but how'd you use indentation in a log? I do - what's wrong? Imagine the following on a single line... [328] 2006-09-23T06:41:50 BLATHER(-100) VerboseSecurity Unauthorized: Your [328] user account does not have the required permission. Access to [328] 'manage_main' of (Folder instance at 033C8290) (/Softlab/otros) [328] denied. Your user account, softlab, exists at /acl_users. Access [328] requires one of the following roles: ['Softlab']. Your roles in this [328] context are ['Authenticated', 'Manager', 'Owner']. Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From fcorreia at gmail.com Wed Sep 27 10:59:12 2006 From: fcorreia at gmail.com (Filipe) Date: 27 Sep 2006 07:59:12 -0700 Subject: Decoding group4 tiff with PIL Message-ID: <1159369152.751796.127670@m73g2000cwd.googlegroups.com> Is decoding group4 tiff possible with Python Imaging Library? I'm trying to convert some image files (several formats, among which, G4 tiffs) to PNG but everything I read about it seems to indicate PIL doesn't support group4 encoding, and won't support it in the short term. yet, I found something[1] that seems like some sort of plugin for PIL and that does look promising, although it seems to be in a bit of an alpha state. However, I don't know where to start.. Should I copy libtiff.py to some location? Also found an alternative[2] to PIL, but I'd rather have PIL doing everything, no matter the format of the file read, if possible. Haven't tried this alternative yet. [1] http://effbot.python-hosting.com/file/stuff/sandbox/pil/libtiff.py [2] http://www.haynold.com/software_projects/2004/pytiff/ Any thoughts? Cheers, Filipe From crosseyedpenguin at cox.net Thu Sep 14 16:43:08 2006 From: crosseyedpenguin at cox.net (Roger) Date: Thu, 14 Sep 2006 13:43:08 -0700 Subject: Looking for the Perfect Editor In-Reply-To: <1158206057.688002.144980@i42g2000cwa.googlegroups.com> References: <1157658338.661425.207140@b28g2000cwb.googlegroups.com> <1158167657.792186.221490@e3g2000cwe.googlegroups.com> <1158206057.688002.144980@i42g2000cwa.googlegroups.com> Message-ID: <4509BEDC.9090100@cox.net> Jay wrote: > I, too, am a hardcore fan of jEdit. It's nice to finally see some user > support on this forum. :-) The biggest problem I have with anything written in Java is the long startup time. The editor may be great but the platform is mediocre. I am a SciTE bigot. I have recently tried SPE and UliPad. UliPad would be my second choice and is still installed, but SPE was quickly removed. One feature I like about SciTE is being able to position the cursor anywhere on a word and hit CTL-F to find the NEXT occurrence. With UliPad, you have to select the entire word you want to search for, and then when you hit CTL-F -- it first finds the same occurrence you selected -- you have to hit F3 to find the next. I think SciTE is better engineered. Still, much of your choice is personal preference. I have noticed that any two people using the same editor will use different keystroke and mouse sequences when presented with similar editing problems. Good discussion - I thank the originator of the thread. Roger From sofiafig at gmail.com Mon Sep 11 08:29:17 2006 From: sofiafig at gmail.com (sofiafig at gmail.com) Date: 11 Sep 2006 05:29:17 -0700 Subject: extracting substrings from a file Message-ID: <1157977756.841188.8550@p79g2000cwp.googlegroups.com> Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? Many thanks in advance Sofia From tim.peters at gmail.com Sun Sep 17 14:46:45 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sun, 17 Sep 2006 14:46:45 -0400 Subject: Hardlinks on NTFS In-Reply-To: <76fd5acf0609171131t3378018bqbe734307dfe0045@mail.gmail.com> References: <450D81BB.20005@freakmail.de> <76fd5acf0609171131t3378018bqbe734307dfe0045@mail.gmail.com> Message-ID: <1f7befae0609171146o2150925dk729b20b22a56a1de@mail.gmail.com> [Wildemar Wildenburger] >> I'm thinking of letting my program create hardlinks (or symlinks). I >> know python allows doing this for ext, reiser and the like, but >> apparently not for ntfs systems. >> Is there any package out there that lets me create links in a platform >> independent way? [Calvin Spealman] > Why isn't NTFS handled the same as any other hardlink supporting > filesystem? Is it a choice or a bug? None of the above. It's not the filesystem, it's what the platform C supports. POSIX specifies a small pile of standard routines for manipulating hard and symbolic links, and Python exposes those /when/ they're available. Microsoft's C supplies none of them. So it's a question of someone on Windows wanting this enough to volunteer to write code, tests, and docs, and volunteer to maintain, a pile of Microsoft-specific code to provide workalike functionality on Windows. From Alain.montmory at thalesgroup.com Fri Sep 29 11:26:29 2006 From: Alain.montmory at thalesgroup.com (alain MONTMORY) Date: Fri, 29 Sep 2006 17:26:29 +0200 Subject: "ValueError: Empty module name" on basic import In-Reply-To: <1159541352.702121.246240@i3g2000cwc.googlegroups.com> References: <1159541352.702121.246240@i3g2000cwc.googlegroups.com> Message-ID: <451D3B25.5090307@thalesgroup.com> Thank for your response :-) I have tried (it's my first try ..) : ./TestOfficiel TestPythonFoo multiply 3 2 and i get : [montmory at esoppe1 swigCallPython]$ ./TestOfficiel TestPythonFoo multiply 3 2 ImportError: No module named TestPythonFoo Failed to load "TestPythonFoo" Then i tried what you suggest below : [montmory at esoppe1 swigCallPython]$ python Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> __import__("TestPythonFoo") and it works !!! why this doesn't work with the api pModule = PyImport_Import(pName); pModule is null after the call is there a PYTHONPATH to set or semething else... thanks Alain John Machin a ?crit : > alain MONTMORY wrote: > >> Hello everybody, >> >> I am a newbie to python so I hope I am at the right place to expose my >> problem..... :-[ >> >> I am working on linux mandrake 10.1 with python : >> python -V >> Python 2.3.4 >> I am trying o run the example which stay in the documentation in paragraph >> http://www.python.org/doc/2.4.2/ext/pure-embedding.html 5.3 Pure Embedding >> I download the code example from >> http://www.python.org/doc/2.4.2/ext/run-func.txt >> I call the file "TestOfficiel.c" and I compile it with : >> gcc -g -I/usr/include/python2.3/ TestOfficiel.c -o TestOfficiel >> -lpython2.3 -ldl >> all is OK (or seems to be...). >> as stated in the documentation I creat a file "TestPythonFoo.py" which >> contain >> " >> def multiply(a,b): >> print "Will compute", a, "times", b >> c = 0 >> for i in range(0, a): >> c = c + b >> return c >> " >> I launch >> ./TestOfficiel ./TestPythonFoo.py multiply 3 2 >> and as a result : >> ValueError: Empty module name >> Failed to load "./TestPythonFoo.py" >> > > This is (I believe) because of the "." at the front. > > >> if I try an absolute path to the python file : >> ./TestOfficiel `pwd`/TestPythonFoo.py multiply 3 2 >> I obtain : >> ImportError: No module named >> /space/ESOPPE_PROJET/Outils/SwigPython/swigCallPython/TestPythonFoo.py >> > > It's quite correct, there never could be a module named that. The name > of your module is TestPythonFoo -- so all you should have to do is > ./TestOfficiel TestPythonFoo multiply 3 2 > > >> Failed to load >> "/space/ESOPPE_PROJET/Outils/SwigPython/swigCallPython/TestPythonFoo.py" >> > > > >> Of course the file exist : >> [montmory at esoppe1 swigCallPython]$ ll >> /space/ESOPPE_PROJET/Outils/SwigPython/swigCallPython/TestPythonFoo.py >> -rwxrwx--x 1 montmory esoppe 126 sep 29 14:04 >> /space/ESOPPE_PROJET/Outils/SwigPython/swigCallPython/TestPythonFoo.py* >> >> I found lot of post about "ValueError: Empty module name" but no clear >> solution (clear for me...). >> What's wrong ? >> my python version? >> Additionnal informations : >> gcc version 3.4.1 (Mandrakelinux 10.1 3.4.1-4mdk) >> >> Thanks for your help, >> >> best regards, >> >> Alain >> >> >> >> >> --------------070105030901000008070407 >> Content-Type: text/plain >> Content-Disposition: inline; >> filename="TestOfficiel.c" >> X-Google-AttachSize: 2022 >> >> #include >> >> int >> main(int argc, char *argv[]) >> { >> PyObject *pName, *pModule, *pDict, *pFunc; >> PyObject *pArgs, *pValue; >> int i; >> >> if (argc < 3) { >> fprintf(stderr,"Usage: call pythonfile funcname [args]\n"); >> > > "pythonfile" is confusing; it should be "modulename". > > > Yes you are right, but i left the example file "as it is" >> return 1; >> } >> >> Py_Initialize(); >> pName = PyString_FromString(argv[1]); >> /* Error checking of pName left out */ >> >> pModule = PyImport_Import(pName); >> > > As the docs for this function say, it just calls the same routine that > is called by the __import__ built-in function. One can experiment with > that: > > > OS-prompt>copy con foo.py > print 'hello fubar world' > ^Z > 1 file(s) copied. > > OS-prompt>python > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>>> __import__("foo") >>>> > hello fubar world > > >>>> __import__("foo.py") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named py > >>>> __import__("") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ValueError: Empty module name > >>>> __import__(r".\foo") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ValueError: Empty module name > >>>> __import__(r"./foo") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ValueError: Empty module name > >>>> __import__(r"/foo") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named /foo > >>>> __import__(r".foo") >>>> > Traceback (most recent call last): > File "", line 1, in ? > ValueError: Empty module name > > > Hmmm ... "empty module name" is rather misleading when it starts with a > "." -- I can feel a bugfix^^^^^^ enhancement request coming on :-) > > HTH, > John > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skip at pobox.com Mon Sep 25 13:42:41 2006 From: skip at pobox.com (skip at pobox.com) Date: Mon, 25 Sep 2006 12:42:41 -0500 Subject: Emphasizing a gtk.Label In-Reply-To: References: Message-ID: <17688.5393.88012.517580@montanaro.dyndns.org> >> I want to give some emphasis to a Label from gtk, without breaking >> gnome theme... What would be the best solution? Maybe: mylabel.set_markup("""My Label""") ? For more details, check out the PyGTK docs for the Label widget: http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtklabel.html and the Pango markup language: http://www.moeraki.com/pygtkreference/pygtk2reference/pango-markup-language.html Skip From larry at hastings.org Fri Sep 29 12:15:22 2006 From: larry at hastings.org (Larry Hastings) Date: 29 Sep 2006 09:15:22 -0700 Subject: PATCH: Speed up direct string concatenation by 20+%! In-Reply-To: References: <1159495643.213830.289620@m7g2000cwm.googlegroups.com> <451CD389.3010800@jessikat.plus.net> <1159540482.924744.164420@k70g2000cwa.googlegroups.com> <1159545255.339364.299020@k70g2000cwa.googlegroups.com> Message-ID: <1159546522.251704.301530@b28g2000cwb.googlegroups.com> Fredrik Lundh wrote: > >> what's in "s" when that loop is done? > > It's equivalent to " 'a' * 10000000 ". (I shan't post it here.) > but what *is* it ? an ordinary PyString object with a flattened buffer, > or something else ? At the exact moment that the loop is done, it's a PyStringConcatenationObject * which points to a deep one-sided tree of more PyStringConcatenationObject * objects. Its ob_sval is NULL, which means that the first time someone asks for its value (via the macro PyString_AS_STRING()) it will be computed. When it's computed, the interpreter will allocate a buffer of 10000001 bytes and walk the tree, filling the buffer with ten million 'a's followed by a zero. It'll then dereference all its children. The PyStringConcatenationObject struct is a child of PyStringObject, and external users can ignore the difference as long as they use the macros in stringobject.h (e.g. using PyString_AS_STRING(), rather than casting to PyStringObject and using ob_sval directly). Sorry for misunderstanding the nature of your question the first time, /larry/ From arvind.sachivan at in.bosch.com Wed Sep 6 02:17:52 2006 From: arvind.sachivan at in.bosch.com (Aravind) Date: Wed, 6 Sep 2006 11:47:52 +0530 Subject: IDE Message-ID: hi, i am a newbie to python but used with some developement in c++ and VB. Can anyone suggest me a good IDE for python for developing apps...? i've seen Qt designer.. some of my friends said it can be used for python also but they r not sure. pls help... thanks in advance.... From steven.bethard at gmail.com Sat Sep 9 13:25:26 2006 From: steven.bethard at gmail.com (Steven Bethard) Date: Sat, 09 Sep 2006 11:25:26 -0600 Subject: Request for tips on my first python script. In-Reply-To: References: Message-ID: Lex Hider wrote: > try: > opts, args = getopt.getopt(sys.argv[1:], "l:", > ["latest=", "notfound"]) > except getopt.GetoptError: > sys.exit(2) > #usage() > > for opt, arg in opts: > if opt in ("-l", "--latest"): > latest = int(arg) > elif opt in ("--notfound"): > ignoreNotFound = True #add notfound files to log You should definitely consider using optparse or argparse_. Here's a rewrite using argparse:: parser = argparse.ArgumentParser(description='podcast aggregator') parser.add_argument('-l', '--latest', type=int) parser.add_argument('--notfound', action='store_true') values = parser.parse_args() Then just use ``values.latest`` and ``values.notfound`` instead of ``latest`` and ``ignoreNotFound`` in the rest of your code. Using argparse also allows you to easily add your other directories as command line options, e.g.:: parser.add_argument('podDir', nargs='?', default=os.path.join(HOME, 'Podcasts')) If you then use ``values.podDir`` instead of ``podDir`` throughout your code, your users can invoke your script in either of the following ways:: GodCast.py # no args, use "$HOME/Podcasts" GodCast.py podcast_dir # podDir specified, use "podcast_dir" If I were writing your script, I would add optional or positional arguments for all of ``maxChecksPerDay``, ``myTemp``, ``downDir``, ``logFile``, ``cacheDir`` and ``feedList``. (If you'd like your code to look more like the Python "standard", I'd use `PEP 8`_ compliant names, e.g. ``pod_dir`` instead of ``podDir`` and ``make_dirs`` instead of ``makeDirs``.) .. _argparse: http://argparse.python-hosting.com/ .. _PEP 8: http://www.python.org/dev/peps/pep-0008/ HTH, STeVe From jmike at alum.mit.edu Fri Sep 22 12:02:49 2006 From: jmike at alum.mit.edu (jmike at alum.mit.edu) Date: 22 Sep 2006 09:02:49 -0700 Subject: XML parser that sorts elements? In-Reply-To: <4niermFadrl8U1@uni-berlin.de> References: <1158939240.213404.239690@m73g2000cwd.googlegroups.com> <4niermFadrl8U1@uni-berlin.de> Message-ID: <1158940969.102922.69460@h48g2000cwc.googlegroups.com> Diez B. Roggisch wrote: > You can sort them by obtaining them as tree of nodes, e.g. using element > tree or minidom. > > But you should be aware that this will change the structure of your document > and it isn't always desirable to do so - e.g. html pages would look funny > to say the least if sorted in that way. > > Diez In this particular case, I need to sort the elements, and the specific application I'm testing guarantees that the order of the elements "in the same scope" (this may not be the right term in XML semantics, but it's what I know how to say) does not matter. That probably means that the specific application I'm testing is not using XML in a standard way, but so be it. I'm looking at minidom now and I think maybe there's enough documentation there that I can get a handle on it and do what I need to do. Thanks. (But if anyone else has a specific example I can crib from, that'd be great.) --JMike From p.lavarre at ieee.org Tue Sep 26 15:00:04 2006 From: p.lavarre at ieee.org (p.lavarre at ieee.org) Date: 26 Sep 2006 12:00:04 -0700 Subject: Python CTypes translation of (pv != NULL) In-Reply-To: References: <1159230428.257680.296550@m73g2000cwd.googlegroups.com> Message-ID: <1159297203.610395.173710@i3g2000cwc.googlegroups.com> > >Q: The C idea of (pv != NULL) is said most directly in Python ctypes > >how? > > Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in > ) Actually, no. I see three answers or zero, depending on how you like to count. Yes that flat edition helps makes this clear, thank you - there I can more easily grab an ordered list of all matches of text than in the more prominent shadow: http://docs.python.org/dev/lib/module-ctypes.html I see direct discussion only of how to construct null pointers, no discussion of how to test for them. Specifically: The hint { bool(null_ptr) == False } could be read to mean try == False, in the "Pointers" text. The hint { ("values", POINTER(c_int))] ... bar.values = None } could be read to say try == None, in the "Calling functions" text. The hint { if item.name is None } could be read to say try is None, in the "Accessing values exported from dlls" text. I'm such a Python newbie that I didn't know is None existed alongside == None. I guess I'll next dig into that along with the answer below from CTypes author Thomas Heller. From swell at netcourrier.com Thu Sep 21 10:05:39 2006 From: swell at netcourrier.com (swell at netcourrier.com) Date: 21 Sep 2006 07:05:39 -0700 Subject: Tk eventloop Message-ID: <1158847539.514578.146830@e3g2000cwe.googlegroups.com> Hi I try/struggle to use an ActiveX component in a Tk app. When i execute it i can catch the first event and then when i try to change the value of the w widget everything blocks and nothing is updated anymore. Does someone have an idea of what is wrong and how to smartly integrate these events with the Tk event loop. Thx Manu import win32com.client import pythoncom import MyComponent from Tkinter import * class Event1(MyComponent.IEvents): def OnUpdate(self, ItemName, UserTag): global w v = ptrAx.getV(ItemName) print "%s" % v w.configure(text='a') root = Tk() w = Label(root,text="test") w.pack() ptrAx = win32com.client.DispatchWithEvents(r'MyComponent',Event1) ptrAx.StartUpdates() root.mainloop() From mail at microcorp.co.za Sun Sep 3 06:29:22 2006 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Sun, 3 Sep 2006 12:29:22 +0200 Subject: Tkinter listbox and ftputil References: <1157119078.055806.7750@h48g2000cwc.googlegroups.com> <1157216128.331707.174070@e3g2000cwe.googlegroups.com> Message-ID: <012e01c6cf44$45327be0$03000080@hendrik> wrote by email: Please keep it on the list... | Hi, | Hi and Thanks for all your help,everything work.But I have one | question,in string I am "new",and I don't know how to exactly split: | | example: | | '-rw-r--r-- 1 admin at v-programs.byethost31.com | v-programs.byethost31.com 2376 Aug 28 08:48 sun.gif' | | | in new entry must write just filename: sun.gif not: | | '-rw-r--r-- 1 admin at v-programs.byethost31.com | v-programs.byethost31.com 2376 Aug 28 08:48 sun.gif' | | .... so can you help to I split: | | '-rw-r--r-- 1 admin at v-programs.byethost31.com | v-programs.byethost31.com 2376 Aug 28 08:48 sun.gif' from that | import just: sun.gif | | THANK | YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IDLE 1.1.3 ==== No Subprocess ==== >>> NameOfString = '-rw-r--r-- 1 admin at v-programs.byethost31.com v-programs.byethost31.com 2376 Aug 28 08:48 sun.gif' >>> NameOfList = NameOfString.split() >>> print NameOfList[:] ['-rw-r--r--', '1', 'admin at v-programs.byethost31.com', 'v-programs.byethost31.com', '2376', 'Aug', '28', '08:48', 'sun.gif'] >>> print NameOfList[-1] sun.gif >>> That should see you on yer way... - Have you read the tutorial? You should also learn to use the interactive interpreter - it is your friend... - Hendrik From gagsl-py at yahoo.com.ar Thu Sep 21 05:25:12 2006 From: gagsl-py at yahoo.com.ar (Gabriel Genellina) Date: Thu, 21 Sep 2006 06:25:12 -0300 Subject: how to use timer in python In-Reply-To: References: Message-ID: <7.0.1.0.0.20060921062043.05853c48@yahoo.com.ar> At Thursday 21/9/2006 06:03, yxh wrote: >how to use timer in python. >the functionnality is like the MFC SetTimer() Use the Timer class. Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From simon at brunningonline.net Tue Sep 26 06:10:42 2006 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 26 Sep 2006 11:10:42 +0100 Subject: where are isinstance types documented? In-Reply-To: <1159264747.304650.92260@e3g2000cwe.googlegroups.com> References: <1159264747.304650.92260@e3g2000cwe.googlegroups.com> Message-ID: <8c7f10c60609260310h64c4853ajfe7736748c9ed1ef@mail.gmail.com> On 26 Sep 2006 02:59:07 -0700, codefire wrote: > I'm using the isinstance built-in function. I've found the docs for it, > but there are no docs on the supported types. > > For example isinstance(a, int) works fine but isinstance(s, string) > doesn't - because 'string is not known'. In this case, you want "str" rather than "string". I can't find a single page with a list of built-in types (which doesn't mean that one doesn't exist) but I think you can find them all hanging off this page: . -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From jeff at taupro.com Thu Sep 28 01:28:05 2006 From: jeff at taupro.com (Jeff Rush) Date: Thu, 28 Sep 2006 00:28:05 -0500 Subject: Be Paid to Attend PyCon 2007! Message-ID: <451B5D65.4010102@taupro.com> PyCon 2007, to be held in Dallas at the same location as in 2006, is coming up and we need instructors to fill Tutorial Day on Feb 22. Last year we had tutorials for: Python 102 Internet Programming with Python Getting Started with wxPython Text & Data Processing Plone Rapid Bootcamp Using Databases with Python A Game-Free Introduction to PyGame Getting Started with the Twisted Framework Agile Development and Testing in Python Classes are half-day affairs (3-hours with a 15-min break) and net the instructor $500-$1500 (depending upon enrollment). One or two of those would easily cover your expenses for attending PyCon and then some. And since tutorials are held the day BEFORE the main conference, you won't miss any talks either. Tutorials have more stringent requirements than talks, often providing class handouts and finely tuned presentations. For this reason we want the best. And if you're short on topic ideas, or a potential student who would like a specific topic covered, check out our wiki page at http://us.pycon.org/TX2007/TalkIdeas Instructors, email your (plain text) proposals, 250 to 1000 words long, to . The deadline for submissions is _Nov 15_ with an acceptance decision by Nov 22. Your proposal should cover: * Instructor name(s) * Contact Information * Summary of proposed presentation * Presentation outline * Intended audience (non-programmers, beginning programmers, advanced users, core Python developers, etc.) * (Recommended) At least one previous presentation/teaching engagement reference So get cranking and let us see your best. Jeff Rush PyCon 2007 Co-Chair From knipknap at gmail.com Mon Sep 18 11:46:59 2006 From: knipknap at gmail.com (Samuel) Date: 18 Sep 2006 08:46:59 -0700 Subject: Creating database structures in a portable way Message-ID: <1158594419.579160.194570@m73g2000cwd.googlegroups.com> Hi, I am looking for a library that takes an XML file that specifies a table structure, and generates the CREATE/DROP/ALTER SQL statements to create the tables in the database. In particular, I am trying to port a PHP application that currently uses the AdoDB XML schema: > http://phplens.com/lens/adodb/docs-datadict.htm#xmlschema Is there a way to do something similar with the DB-API modules in Python? Thanks, -Samuel From andychambers2002 at yahoo.co.uk Thu Sep 14 07:27:23 2006 From: andychambers2002 at yahoo.co.uk (andychambers2002 at yahoo.co.uk) Date: 14 Sep 2006 04:27:23 -0700 Subject: Force sleep to ignore interrupts References: <1158230884.705465.17010@k70g2000cwa.googlegroups.com> Message-ID: <1158233243.911621.240570@h48g2000cwc.googlegroups.com> Jeremy Sanders wrote: > andychambers2002 at yahoo.co.uk wrote: > > > It works as I want when used in the main application thread. > > That is, when you hit Ctr + C, it stops running. However, if > > the class that subclasses it, also subclasses Thread, it breaks > > in that hitting Ctrl + C interrupts the call to sleep which puts > > the event loop out of sync with real time. > > Maybe you could install a signal handler to ignore ctrl+c, when required > > import signal > signal.signal(signal.SIGINT, signal.SIG_IGN) That worked nicely. Thanks Andy From mail at microcorp.co.za Tue Sep 12 02:34:15 2006 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Tue, 12 Sep 2006 08:34:15 +0200 Subject: Pyserial problem. script stops reading. Message-ID: <022601c6d63f$88e17b00$03000080@hendrik> "Frederic Wenzel" Wrote: >On 9/9/06, Frederic Wenzel wrote: >> On 9/9/06, Hendrik van Rooyen wrote: >> > | I wrote a script on Linux that uses pyserial to read status messages >> > | from a serial line using readlines(). For now, it just displays what >> > | it gets on stdout: >> > | (...) >> > | ser = serial.Serial(port=1, >> > | baudrate=1200, >> > | rtscts=1, >> > | >> > | If the script does not time out there, I am not sure what else it is >> > | doing. It seems to be in a wait state it does not get out of. > >When it stopped working again (unfortunately) I pressed ctrl c and got the following output? > >14:53 | 0008 | 02 | | 5 |Rack Abs.| - | --752 >14:53 | 0005 | 02 | | 2 |Rack Abs.| - | 00752 >14:53 | 0008 | 02 |Traceback (most recent call last): > File "serialhandler.py", line 34, in ? > lines = sh.readLines() > File "serialhandler.py", line 29, in readLines > return self.ser.readlines() > File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 78, in readlines > line = self.readline(eol=eol) > File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 60, in readline > c = self.read(1) > File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line 269, in read > ready,_,_ = select.select([self.fd],[],[], self._timeout) >KeyboardInterrupt > > >Apparently this is the place where it gets stuck. The select.select >line does not return, not even for a timeout. > >Fred This seems a real PITA - it looks normal to me - it is as if the device has simply stopped sending for some reason. Can you: 1) set the external device up to ignore flow control? 2) check the cable for loose connections - wriggling it around while the transmission is running might point at something - but be gentle - else you can easily draw false conclusions, or break something that is in fact ok... does anybody else know how to check the value of the time out, what its for and what happens when it times out? - hth - Hendrik -------------- next part -------------- An HTML attachment was scrubbed... URL: From bignose+hates-spam at benfinney.id.au Wed Sep 27 20:04:13 2006 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 28 Sep 2006 10:04:13 +1000 Subject: does anybody earn a living programming in python? References: <1159225798.492198.89880@b28g2000cwb.googlegroups.com> <1159278999.374338.76170@m73g2000cwd.googlegroups.com> <1159280328.671934.42180@h48g2000cwc.googlegroups.com> <1159285305.562672.152460@d34g2000cwd.googlegroups.com> <1159380986.289804.185550@b28g2000cwb.googlegroups.com> Message-ID: <878xk4luv6.fsf@benfinney.id.au> "Dan Bishop" writes: > It's so frustrating seeing all those job postings that require a > "mimimum 10 years experience". I think it shows a huge gulf of communication between the person writing the job requirements and the person who actually asked for the position to be filled. If someone has been doing the same thing for 10 years, they're not the sort of programmer I want coming anywhere *near* the systems I depend on. If, instead, they've been doing lots of different things for 10 years, I'm not a bit interested that one of them happened to be consistent throughout that period. -- \ "Those who will not reason, are bigots, those who cannot, are | `\ fools, and those who dare not, are slaves." -- "Lord" George | _o__) Gordon Noel Byron | Ben Finney From raschulmanxx at verizon.net Thu Sep 7 12:56:57 2006 From: raschulmanxx at verizon.net (Richard Schulman) Date: Thu, 07 Sep 2006 16:56:57 GMT Subject: Unicode string handling problem References: <1157506499.619835.62950@e3g2000cwe.googlegroups.com> <7iesf2d82cegjj3haubc6rhcbkk3lcq230@4ax.com> <1157520599.406234.201050@d34g2000cwd.googlegroups.com> Message-ID: Many thanks for your help, John, in giving me the tools to work successfully in Python with Unicode from here on out. It turns out that the Unicode input files I was working with (from MS Word and MS Notepad) were indeed creating eol sequences of \r\n, not \n\n as I had originally thought. The file reading statement that I was using, with unpredictable results, was #in_file = codecs.open("c:\\pythonapps\\in-graf2.my","rU",encoding="utf-16LE") This was reading to the \n on first read (outputting the whole line, including the \n but, weirdly, not the preceding \r). Then, also weirdly, the next readline would read the same \n again, interpreting that as the entirety of a phantom second line. So each input file line ended up producing two output lines. Once the mode string "rU" was dropped, as in in_file = codecs.open("c:\\pythonapps\\in-graf2.my",encoding="utf-16LE") all suddenly became well: no more doubled readlines, and one could see the \r\n termination of each line. This behavior of "rU" was not at all what I had expected from the brief discussion of it in _Python Cookbook_. Which all goes to point out how difficult it is to cook challenging dishes with sketchy recipes alone. There is no substitute for the helpful advice of an experienced chef. -Richard Schulman (remove "xx" for email reply) On 5 Sep 2006 22:29:59 -0700, "John Machin" wrote: >Richard Schulman wrote: >[big snip] >> >> The BOM is little-endian, I believe. >Correct. > >> >in_file = codecs.open(filepath, mode, encoding="utf16???????") >> >> Right you are. Here is the output produced by so doing: > >You don't say which encoding you used, but I guess that you used >utf_16_le. > >> >> >> u'\ufeffINSERT INTO [...] VALUES\N' > >Use utf_16 -- it will strip off the BOM for you. > >> >> u'\n' >> 0 [The counter value] >> >[snip] >> Yes, it did. Many thanks! Now I've got to figure out the best way to >> handle that \n\n at the end of each row, which the program is >> interpreting as two rows. > >Well we don't know yet exactly what you have there. We need a byte dump >of the first few bytes of your file. Get into the interactive >interpreter and do this: > >open('yourfile', 'rb').read(200) >(the 'b' is for binary, in case you are on Windows) >That will show us exactly what's there, without *any* EOL >interpretation at all. > > >> That represents two surprises: first, I >> thought that Microsoft files ended as \n\r ; > >Nah. Wrong on two counts. In text mode, Microsoft *lines* end in \r\n >(not \n\r); *files* may end in ctrl-Z aka chr(26) -- an inheritance >from CP/M. > >Ummmm ... are you saying the file has \n\r at the end of each row?? How >did you know that if you didn't know what if any BOM it had??? Who >created the file???? > >> second, I thought that >> Python mode "rU" was supposed to be the universal eol handler and >> would handle the \n\r as one mark. > >Nah again. It contemplates only \n, \r, and \r\n as end of line. See >the docs. Thus \n\r becomes *two* newlines when read with "rU". > >Having "\n\r" at the end of each row does fit with your symptoms: > >| >>> bom = u"\ufeff" >| >>> guff = '\n\r'.join(['abc', 'def', 'ghi']) >| >>> guffu = unicode(guff) >| >>> import codecs >| >>> f = codecs.open('guff.utf16le', 'wb', encoding='utf_16_le') >| >>> f.write(bom+guffu) >| >>> f.close() > >| >>> open('guff.utf16le', 'rb').read() #### see exactly what we've got > >| >'\xff\xfea\x00b\x00c\x00\n\x00\r\x00d\x00e\x00f\x00\n\x00\r\x00g\x00h\x00i\x00' > >| >>> codecs.open('guff.utf16le', 'r', encoding='utf_16').read() >| u'abc\n\rdef\n\rghi' ######### Look, Mom, no BOM! > >| >>> codecs.open('guff.utf16le', 'rU', encoding='utf_16').read() >| u'abc\n\ndef\n\nghi' #### U means \r -> \n > >| >>> codecs.open('guff.utf16le', 'rU', encoding='utf_16_le').read() >| u'\ufeffabc\n\ndef\n\nghi' ######### reproduces your second >experience > >| >>> open('guff.utf16le', 'rU').readlines() >| ['\xff\xfea\x00b\x00c\x00\n', '\x00\n', '\x00d\x00e\x00f\x00\n', >'\x00\n', '\x00 >| g\x00h\x00i\x00'] >| >>> f = open('guff.utf16le', 'rU') >| >>> f.readline() >| '\xff\xfea\x00b\x00c\x00\n' >| >>> f.readline() >| '\x00\n' ######### reproduces your first experience >| >>> f.readline() >| '\x00d\x00e\x00f\x00\n' >| >>> > >If that file is a one-off, you can obviously fix it by >throwing away every second line. Otherwise, if it's an ongoing >exercise, you need to talk sternly to the file's creator :-) > >HTH, >John From sonaldgr8 at gmail.com Tue Sep 5 03:12:18 2006 From: sonaldgr8 at gmail.com (sonald) Date: 5 Sep 2006 00:12:18 -0700 Subject: =?iso-8859-1?q?How_to_allow_special_character's_like_=EF, =F9, acute_e_etc...?= Message-ID: <1157440337.996056.88220@i3g2000cwc.googlegroups.com> Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file, 2. Text checks for max. length of the field & whether the field is mandatory or optional Example: Text('Description', 100, optional=True) Parameters: "Name of the field" => 'Description' "Max length " => 100 "Optional" => 'True' (the field is not mandaory) 3. valid-text expressions, Example: ValidText('Minor', '[yYnN]') Parameters: name => field name regex => the regular expression y/Y for Yes & n/N for No Recently we are getting data, where, the name contains non-english characters like: ' ATHUMANI? ', ' LUCIANA S. SENG?ONGO '...etc Using the Text function, these names are not validated as they contain special characters or non-english characters (?,?). But the data is correct. Is there any function that can allow such special character's but not numbers...? Secondly, If I were to get the data in Russian text, are there any (lingual) packages available so that i can use the the same module for validation. Such that I just have to import the package and the module can be used for validating russian text or japanese text.... Regards, Sonal. From drew at zenoss.com Mon Sep 18 17:41:54 2006 From: drew at zenoss.com (Drew Bray) Date: Mon, 18 Sep 2006 17:41:54 -0400 Subject: Zenoss Version 0.22.3 Available Message-ID: 09-18-2006 Announcing Zenoss Version 0.22.3 All, Version 0.22.3 of Zenoss is available for download. Version 0.22.3 is a dot release of version 0.22.0, which added several new features, including: * Support for Nagios Plugins (zenagios) * Addition of a GUI for the selection of Alerting Rules * Adds Email alerts with configurable body text * Automated maintenance windows * Allows the assignment of users to the systems they manage Zenoss Version 0.22.3 provides several minor bug fixes and enhancements, including: * Use of latin-1 encoding when calling xml-rpc * Improved handling of Unicode items * Repaired bad zenagios heartbeat timeout * Corrected zenagios unpack of config (component and eventKey were backward) * Take off newline when reading configfile values * Fixed additional date-time zone problems Download Links: * Source: http://www.zenoss.org/download/latest/src * Zenwin: http://www.zenoss.org/download/latest/zenwin * Documentation: http://www.zenoss.org/download/latest/docs * Release Notes: http://www.zenoss.org/download/latest/relnotes Project Blurb: Zenoss is Python-based, network/systems monitoring application that offers a single integrated package for end to end monitoring (discovery, configuration, availability, performance, events, alerts) of resources across the stack (servers, applications, networks, environment, etc...). Zenoss was recognized as one of the "Top 10 Open Source Projects to Watch" by Network World in August of 2006. (http://www.zenoss.org/ about/news_items/articles/nw-10towatch) Zenoss is currently hiring talented Zope & Python developers. Join the team! http://www.zenoss.org/jobs. Enjoy, Drew Project Zenoss drew at zenoss.com From p.lavarre at ieee.org Mon Sep 25 22:34:58 2006 From: p.lavarre at ieee.org (p.lavarre at ieee.org) Date: 25 Sep 2006 19:34:58 -0700 Subject: shlex.split != shlex.shlex get_token til eof References: <1158949149.537922.272920@h48g2000cwc.googlegroups.com> <1158963562.701766.283150@d34g2000cwd.googlegroups.com> Message-ID: <1159238098.139446.232380@b28g2000cwb.googlegroups.com> > I see shlex.split gives me what I want ... > shlex.shlex surprisingly gives me something else ... > I can get closer ... by hacking ... > .wordchars += ".+-" Kindly offline I was told, Try patching .whitespace_split = True instead. Compare: shlex.split("//./PhysicalDrive9 //./Cdrom9 //./Tape9 //./A:") lex = shlex.shlex("//./PhysicalDrive9 //./Cdrom9 //./Tape9 //./A:") lex.whitespace_split = True list(lex) Why and how often this patch makes shlex.shlex and shlex.split agree, I still don't know - but for these specific examples, it works. From gagsl-py at yahoo.com.ar Thu Sep 21 19:16:22 2006 From: gagsl-py at yahoo.com.ar (Gabriel Genellina) Date: Thu, 21 Sep 2006 20:16:22 -0300 Subject: parsing java files In-Reply-To: References: Message-ID: <7.0.1.0.0.20060921201411.039f8de0@yahoo.com.ar> At Thursday 21/9/2006 17:51, st?phane bard wrote: >i would like to parse java files an detect >class name's, attributes name's type's and visibility (and or list of >methods). > >is there any module who can parse easily a java file without using >(jython)? I would get the needed info using javadoc (in Java) and then process the output in Python. Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From jstroud at mbi.ucla.edu Mon Sep 11 00:36:42 2006 From: jstroud at mbi.ucla.edu (James Stroud) Date: Mon, 11 Sep 2006 04:36:42 GMT Subject: Simple regex with whitespaces In-Reply-To: <1157945804.805624.32620@p79g2000cwp.googlegroups.com> References: <1157945804.805624.32620@p79g2000cwp.googlegroups.com> Message-ID: mathieu.malaterre at gmail.com wrote: > Hello, > > I cannot figure out a way to find a regular expression that would > match one and only one of these two strings: > > s1 = ' how are you' > s2 = ' hello world how are you' > > All I could come up with was: > patt = re.compile('^[ ]*([A-Za-z]+)[ ]+([A-Za-z]+)$') > > Which of course does not work. I cannot express the fact: sentence > have 0 or 1 whitespace, separation of group have two or more > whitespaces. > > Any suggestion ? Thanks a bunch ! > Mathieu > py> import re py> s1 = ' how are you' py> s2 = ' hello world how are you' py> s3 = 'group here now here but not here but now here' py> patt_2plus = re.compile(r'(?:(?:\S+(?:\s|$))+(?:\s+|$)){2,}') py> patt_3plus = re.compile(r'(?:(?:\S+(?:\s|$))+(?:\s+|$)){3,}') positive tests: py> patt_2plus.search(s2).group(0) 'hello world how are you' py> patt_2plus.search(s3).group(0) 'group here now here but not here but now here' py> patt_3plus.search(s3).group(0) 'group here now here but not here but now here' negative tests: py> patt_3plus.search(s2).group(0) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'NoneType' object has no attribute 'group' py> patt_3plus.search(s1).group(0) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'NoneType' object has no attribute 'group' py> patt_2plus.search(s1).group(0) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'NoneType' object has no attribute 'group' James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ From mark_galeck_spam_magnet at yahoo.com Tue Sep 5 00:40:02 2006 From: mark_galeck_spam_magnet at yahoo.com (mark_galeck_spam_magnet at yahoo.com) Date: 4 Sep 2006 21:40:02 -0700 Subject: why have to "from compiler import *" Message-ID: <1157431202.681992.287340@i42g2000cwa.googlegroups.com> Hi, why does >>> import compiler >>> compileFile("foo.py") complain name 'compileFile' not defined. But >>>from compiler import * works. Why? (I did read the tutorial, it seems to say "import module" should work. Thank you, Mark From Roberto.Bonvallet at cern.ch Fri Sep 8 11:36:18 2006 From: Roberto.Bonvallet at cern.ch (Roberto Bonvallet) Date: 8 Sep 2006 15:36:18 GMT Subject: Request for tips on my first python script. References: Message-ID: Lex Hider wrote: > Any tips on the code quality and use of python would be appreciated. I've > got a feeling the overall structure is up the creek. [...] > for opt, arg in opts: > if opt in ("-l", "--latest"): > latest = int(arg) > elif opt in ("--notfound"): > ignoreNotFound = True #add notfound files to log Subtle bug here: ("--notfound") is not a tuple, is just a string, so what you are actually testing is whether opt is a substring of "--not-found". To actually build a 1-element tuple, you have to put a trailing comma: elif opt in ("--notfound", ): but it would be clearer if you just use: elif opt == "--notfound": -- Roberto Bonvallet From claudio.grondi at freenet.de Wed Sep 6 14:05:00 2006 From: claudio.grondi at freenet.de (Claudio Grondi) Date: Wed, 06 Sep 2006 20:05:00 +0200 Subject: IronPython 1.0 - Bugs or Features? In-Reply-To: References: Message-ID: Marc 'BlackJack' Rintsch wrote: > In , Claudio Grondi wrote: > > >>The context: >> C:\IronPython> ipy.exe >> IronPython 1.0.60816 on .NET 2.0.50727.42 >> Copyright (c) Microsoft Corporation. All rights reserved. >>vs. >> C:\Python24> python.exe >> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] >>on win32 >> >>IronPython raises "UnboundLocalError: local variable 'strData' >>referenced before assignment" error in following case: >> >> while(someCondition): >> try: >> strData = strSomeValue() >> except: >> pass >> if( type(strData) == str ) : ### <<< HERE THE ERROR >> doSomething() >> >>CPython 2.4.2 doesn't raise an error with same code. > > > Well I get a `NameError` for `someCondition`. Please post a minimal > *working* example that produced the error. I can't as after constructing one according to what I have thought was the cause of it I detected that the error was caused by the exception in the line strData = strSomeValue() (see also my other posting) I have just misinterpreted the origin of the "UnboundLocalError:" as raised while parsing and was wondering how it comes, that the parser is able to detect such things ... Sorry for the eventually caused confusion. Claudio Grondi From ldo at geek-central.gen.new_zealand Sun Sep 24 00:49:22 2006 From: ldo at geek-central.gen.new_zealand (Lawrence D'Oliveiro) Date: Sun, 24 Sep 2006 16:49:22 +1200 Subject: A critique of cgi.escape References: Message-ID: In message , Jon Ribbens wrote: > In article , Fredrik > Lundh wrote: >> Lawrence D'Oliveiro wrote: >>> >>> So I think the default for the second argument to cgi.escape should be >>> changed to True. Or alternatively, the second argument should be removed >>> altogether, and quotes should always be escaped. >> >> you're confused: cgi.escape(s) is designed to be used for ordinary text, >> cgi.escape(s, True) is designed for attributes. if you use the code the >> way it's intended to be used, it works perfectly fine. > > He's not confused, he's correct; the author of cgi.escape is the > confused one. Thanks for backing me up. :) > > One thing that is flat-out wrong, by the way, is that cgi.escape() > does not encode the apostrophe (') character. This is essentially > identical to the quote character in HTML, so any code which escaping > one should always be escaping the other. I must confess I did a double-take on this. But I rechecked the HTML spec (HTML 4.0, section 3.2.2, "Attributes"), and you're right--single quotes ARE allowed as an alternative to double quotes. It's just I've never used them as quotes. :) From maric at aristote.info Fri Sep 8 08:00:55 2006 From: maric at aristote.info (Maric Michaud) Date: Fri, 8 Sep 2006 14:00:55 +0200 Subject: Request for tips on my first python script. In-Reply-To: <200609081356.47882.maric@aristote.info> References: <200609081356.47882.maric@aristote.info> Message-ID: <200609081400.56221.maric@aristote.info> Le vendredi 08 septembre 2006 13:56, Maric Michaud a ?crit?: > maric at redflag2 jeu sep 07 09:17:51:~/test$ export HOME=/etc > maric at redflag2 ven sep 08 13:53:17:/home/maric/test$ cd ~ > maric at redflag2 ven sep 08 13:53:22:~$ pwd > /etc > maric at redflag2 ven sep 08 13:55:46:~$ python -c 'import os > > > print os.path.expanduser("~") > > ' > > /etc Of course it's not the same as : maric at redflag2 ven sep 08 13:58:25:~$ export HOME=/etc maric at redflag2 ven sep 08 14:00:11:~$ python -c 'import os print os.path.expanduser("~maric") ' /home/maric -- _____________ Maric Michaud _____________ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 From luuk at invalid.lan Mon Sep 11 07:54:18 2006 From: luuk at invalid.lan (Luuk) Date: Mon, 11 Sep 2006 13:54:18 +0200 Subject: efficient text file search. References: <1157973527.817462.207420@h48g2000cwc.googlegroups.com> <45054921$0$4526$e4fe514c@news.xs4all.nl> <1157974937.286653.5500@h48g2000cwc.googlegroups.com> Message-ID: <45054e6a$0$4512$e4fe514c@news.xs4all.nl> "noro" schreef in bericht news:1157974937.286653.5500 at h48g2000cwc.googlegroups.com... > :) > > via python... > > Luuk wrote: >> "noro" schreef in bericht >> news:1157973527.817462.207420 at h48g2000cwc.googlegroups.com... >> > Is there a more efficient method to find a string in a text file then: >> > >> > f=file('somefile') >> > for line in f: >> > if 'string' in line: >> > print 'FOUND' >> > >> >> >> yes, more efficient would be: >> grep (http://www.gnu.org/software/grep/) > ok, a more serious answer: some googling turned op the following. Second paragraph of chapter 14 of http://www.amk.ca/python/2.1/ a.. The speed of line-oriented file I/O has been improved because people often complain about its lack of speed, and because it's often been used as a na?ve benchmark. The readline() method of file objects has therefore been rewritten to be much faster. The exact amount of the speedup will vary from platform to platform depending on how slow the C library's getc() was, but is around 66%, and potentially much faster on some particular operating systems. Tim Peters did much of the benchmarking and coding for this change, motivated by a discussion in comp.lang.python. A new module and method for file objects was also added, contributed by Jeff Epler. The new method, xreadlines(), is similar to the existing xrange() built-in. xreadlines() returns an opaque sequence object that only supports being iterated over, reading a line on every iteration but not reading the entire file into memory as the existing readlines() method does. You'd use it like this: for line in sys.stdin.xreadlines(): # ... do something for each line ... ... For a fuller discussion of the line I/O changes, see the python-dev summary for January 1-15, 2001 at http://www.amk.ca/python/dev/2001-01-1.html. From deets at nospam.web.de Fri Sep 22 11:47:02 2006 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 22 Sep 2006 17:47:02 +0200 Subject: XML parser that sorts elements? References: <1158939240.213404.239690@m73g2000cwd.googlegroups.com> Message-ID: <4niermFadrl8U1@uni-berlin.de> jmike at alum.mit.edu wrote: > Hi everyone, > > I am a total newbie to XML parsing. I've written a couple of toy > examples under the instruction of tutorials available on the web. > > The problem I want to solve is this. I have an XML snippet (in a > string) that looks like this: > > > hello > goodbye > > > and I want to alphabetize not only the attributes of an element, but I > also want to alphabetize the elements in the same scope: > > > goodbye > hello > > > I've found a "Canonizer" class, that subclasses saxlib.HandlerBase, and > played around with it and vaguely understand what it's doing. But what > I get out of it is > > > hello > goodbye > > > in other words it sorts the attributes of each element, but doesn't > touch the order of the elements. > > How can I sort the elements? I think I want to subclass the parser, to > present the elements to the content handler in different order, but I > couldn't immediately find any examples of the parser being subclassed. You can sort them by obtaining them as tree of nodes, e.g. using element tree or minidom. But you should be aware that this will change the structure of your document and it isn't always desirable to do so - e.g. html pages would look funny to say the least if sorted in that way. Diez From deets at nospam.web.de Sun Sep 24 17:48:56 2006 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 24 Sep 2006 23:48:56 +0200 Subject: Daemonizing python In-Reply-To: References: Message-ID: <4nocq8Fb434vU1@uni-berlin.de> NinjaZombie schrieb: > Hi! > > I was wondering if it is possible to turn the current python proccess into > a unix daemon, but not doing it like this: > python myscript.py & > but from code programaticaly. There is a good daemonization recipe on activstate: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 Diez From hancock at anansispaceworks.com Tue Sep 12 16:34:12 2006 From: hancock at anansispaceworks.com (Terry Hancock) Date: Tue, 12 Sep 2006 15:34:12 -0500 Subject: Clarify Regex in Python. In-Reply-To: <1158062822.975420.185210@p79g2000cwp.googlegroups.com> References: <1158062822.975420.185210@p79g2000cwp.googlegroups.com> Message-ID: <450719C4.1090707@anansispaceworks.com> cooldudevamsee at gmail.com wrote: > After may frustrated attempts I came to know that "match" function > in python re package actually start the matchs at the begining of the > subject, where "search" will find the given pattern any where in the > subject. > > My Problem is, I want to know how can I force match functions to > match the pattern any location in the subject. i.e I want to turn off > before said behaviour. re.match = re.search perhaps? Stupid thing to do, but it meets the spec. Cheers, Terry -- Terry Hancock (hancock at AnansiSpaceworks.com) Anansi Spaceworks http://www.AnansiSpaceworks.com From bradfordh at gmail.com Fri Sep 8 17:58:48 2006 From: bradfordh at gmail.com (Tempo) Date: 8 Sep 2006 14:58:48 -0700 Subject: urlopen() error Message-ID: <1157752728.685285.197130@i42g2000cwa.googlegroups.com> Hello. I am getting an error and it has gotten me stuck. I think the best thing I can do is post my code and the error message and thank everybody in advanced for any help that you give this issue. Thank you. ############# Here's the code: ############# import urllib2 import re import xlrd from BeautifulSoup import BeautifulSoup book = xlrd.open_workbook("ige_virtualMoney.xls") sh = book.sheet_by_index(0) rx = 1 for rx in range(sh.nrows): u = sh.cell_value(rx, 0) page = urllib2.urlopen(u) soup = BeautifulSoup(page) p = soup.findAll('span', "sale") p = str(p) p2 = re.findall('\$\d+\.\d\d', p) for price in p2: print price ###################### Here are the error messages: ###################### Traceback (most recent call last): File "E:\Python24\scraper.py", line 16, in -toplevel- page = urllib2.urlopen(u) File "E:\Python24\lib\urllib2.py", line 130, in urlopen return _opener.open(url, data) File "E:\Python24\lib\urllib2.py", line 350, in open protocol = req.get_type() File "E:\Python24\lib\urllib2.py", line 233, in get_type raise ValueError, "unknown url type: %s" % self.__original ValueError: unknown url type: List From altemurbugra at gmail.com Mon Sep 25 18:14:03 2006 From: altemurbugra at gmail.com (altemurbugra at gmail.com) Date: 25 Sep 2006 15:14:03 -0700 Subject: Makin search on the other site and getting data and writing in xml In-Reply-To: References: <1159178422.607126.214270@m7g2000cwm.googlegroups.com> Message-ID: <1159222443.540807.232040@k70g2000cwa.googlegroups.com> I dont mean only google, also other sites aswell From mail at microcorp.co.za Thu Sep 28 01:48:17 2006 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Thu, 28 Sep 2006 07:48:17 +0200 Subject: does anybody earn a living programming in python? References: <1159225798.492198.89880@b28g2000cwb.googlegroups.com><1159271339.775493.132180@i3g2000cwc.googlegroups.com> Message-ID: <014b01c6e2c1$b30d5a00$03000080@hendrik> "Steven D'Aprano" Wrote: > On Tue, 26 Sep 2006 22:00:55 +1000, Anthony Baxter wrote: > > > This seems to be a very, very silly original post. I know of plenty of > > people who make a living programming Python. It's been the vast > > majority of the programming (for money) I've done in the last ten > > years, and there's countless other people I know here in Melbourne in > > the same position. > > Countless people? Are we talking aleph-zero people (countable infinity) or > one of the uncountable infinities? > > > -- > Steven. Oh dont be so pedantic - countless - without count - probably just means that nobody has bothered to count them... - Hendrik > > From ldo at geek-central.gen.new_zealand Tue Sep 26 17:20:23 2006 From: ldo at geek-central.gen.new_zealand (Lawrence D'Oliveiro) Date: Wed, 27 Sep 2006 09:20:23 +1200 Subject: QuoteSQL References: Message-ID: In message , Steve Holden wrote: > Lawrence D'Oliveiro wrote: > >> In message , Duncan Booth wrote: >> >>>In particular it currently turns newlines in backslash followed by n >>>which (since MySQL ignores the extra backslash escape) is equivalent to >>>turning newlines into the character n. >> >> But \n is valid MySQL syntax for a newline. > > Phew. It's a good hob that MySQL is the only database in the known > universe, then, isn't it. It's the one I was talking about in this thread. From wahab at chemie.uni-halle.de Wed Sep 27 15:46:53 2006 From: wahab at chemie.uni-halle.de (Mirco Wahab) Date: Wed, 27 Sep 2006 21:46:53 +0200 Subject: Battlefield Weapon Popularity Trend In-Reply-To: <12hlc1hf2amom31@corp.supernews.com> References: <1159326181.251558.123500@m73g2000cwd.googlegroups.com> <12hlc1hf2amom31@corp.supernews.com> Message-ID: Thus spoke Chris Mattern (on 2006-09-27 19:09): > In article , Mirco Wahab wrote: >> >>When the Samurai of medieval Japan were confronted >>with new 'battlefield language', e.g. early Shotguns, > > "early Shotguns" :D. Your mastery of the history of > firearms overwhelms me. You want a fight? With a muzzle-loaded gun? Three shots for everybody -- 5 minutes time? BTW: (http://en.wikipedia.org/wiki/Musket) The date of the origin of muskets remains unknown, but they are mentioned as early as the late 15th century, and they were primarily designed for use by infantry. Muskets became obsolete by the middle of the 19th century, as rifles superseded them. Regards Mirco From http Wed Sep 27 23:40:20 2006 From: http (Paul Rubin) Date: 27 Sep 2006 20:40:20 -0700 Subject: a query on sorting References: <20060927092030.76520.qmail@web8508.mail.in.yahoo.com> Message-ID: <7xlko464m3.fsf@ruckus.brouhaha.com> Gabriel Genellina writes: > > >>> sorted((x[1], x[0]) for x in enumerate(a)) > >[(1, 7), (2, 4), (2, 8), (3, 2), (4, 1), (5, 3), (6, 5), (7, 6), (9, 0)] > > Why forcing to use enumerate if it doesn't fit? And a generator won't > help here since you have to access all the items. > > sorted([(a[i],i) for i in range(len(a))]) I think sorted((x,i) for i,x in enumerate(a)) looks nicer than the above. From meyer at acm.org Tue Sep 5 13:19:57 2006 From: meyer at acm.org (Andre Meyer) Date: Tue, 5 Sep 2006 19:19:57 +0200 Subject: threading support in python In-Reply-To: <17661.44847.579165.784506@montanaro.dyndns.org> References: <1157381880.697001.260070@m73g2000cwd.googlegroups.com> <1157387626.242107.92070@p79g2000cwp.googlegroups.com> <1157398593.191972.240270@p79g2000cwp.googlegroups.com> <1157422764.573537.116340@m79g2000cwm.googlegroups.com> <1157467255.633817.3740@m73g2000cwd.googlegroups.com> <17661.37027.891231.814161@montanaro.dyndns.org> <17661.44847.579165.784506@montanaro.dyndns.org> Message-ID: <7008329d0609051019t3ab9e840ge0021ff20b24e4f0@mail.gmail.com> This seems to be an important issue and fit for discussion in the context of Py3k. What is Guido's opinion? As a developer of a multi-threaded system I would like to know more about these issues, so it's no time wasted for me... ;-) regards Andre On 9/5/06, skip at pobox.com wrote: > > > Steve> Given the effort that GIL-removal would take, I'm beginning to > Steve> wonder if PyPy doesn't offer a better way forward than CPython, > Steve> in terms of execution speed improvements returned per > Steve> developer-hour. > > How about execution speed improvements per hour of discussion about > removing > the GIL? ;-) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Mon Sep 25 10:04:32 2006 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 25 Sep 2006 16:04:32 +0200 Subject: Newbie question: PyQt & Form::init() References: <4nq42vFbgfogU1@uni-berlin.de> Message-ID: <4nq5vgFbiqhiU1@uni-berlin.de> Sven Ehret wrote: > Diez B. Roggisch wrote: > >> Sven Ehret wrote: >> >>> Hello List, >>> >>> I am trying to learn Python and followed the tutorial at >>> http://www.cs.usfca.edu/~afedosov/qttut/. Being happy that it works, I >>> am now trying to do my own project, but I am having problems with >>> initialization of my form. >>> >>> I want to automatically fill a couple of comboboxes upon starting the >>> program. I read on the net that I simply have to add a function >>> called ?Form1.Init()? with the content I wish to have executed at start >>> time. However, it never gets executed, so it seems. When I re-write the >>> application to have the code executed at the press of a button, it >>> works. What am I doing wrong? >> >> Show us more code, and we show you the problem. At least we can try then, >> until someone finally implements >> >> from __future__ import mindreading >> >> Diez > > Oh, sorry. *blush* > here is my code (two files): > > form1.py: > # -*- coding: utf-8 -*- > > # Form implementation generated from reading ui file 'form1.ui' > # > # Created: Mo Sep 25 15:38:56 2006 > # by: The PyQt User Interface Compiler (pyuic) 3.14.1 > # > # WARNING! All changes made in this file will be lost! > > > from qt import * > > > class Form1(QDialog): > def __init__(self,parent = None,name = None,modal = 0,fl = 0): > QDialog.__init__(self,parent,name,modal,fl) > > if not name: > self.setName("Form1") > > > > self.pushButton1 = QPushButton(self,"pushButton1") > self.pushButton1.setGeometry(QRect(410,340,80,30)) > > self.comboBox1 = QComboBox(0,self,"comboBox1") > self.comboBox1.setGeometry(QRect(310,10,120,31)) > self.comboBox1.setSizeLimit(12) > self.comboBox1.setMaxCount(12) > > self.comboBox2 = QComboBox(0,self,"comboBox2") > self.comboBox2.setGeometry(QRect(431,10,60,31)) > > self.buttonGroup1 = QButtonGroup(self,"buttonGroup1") > self.buttonGroup1.setGeometry(QRect(10,50,480,200)) > > self.pushButton3 = QPushButton(self,"pushButton3") > self.pushButton3.setGeometry(QRect(200,320,101,24)) > > self.textLabel1 = QLabel(self,"textLabel1") > self.textLabel1.setGeometry(QRect(71,10,160,30)) > > self.languageChange() > > self.resize(QSize(504,380).expandedTo(self.minimumSizeHint())) > self.clearWState(Qt.WState_Polished) > > self.connect(self.pushButton1,SIGNAL("clicked()"),self.close) > self.connect(self.comboBox1,SIGNAL("activated(const > QString&)"),self.AddMonthsToCombo) When you just invoke self.AddMonthsToCombo() here, things should work. Diez From blair.houghton at gmail.com Wed Sep 27 10:35:01 2006 From: blair.houghton at gmail.com (Blair P. Houghton) Date: 27 Sep 2006 07:35:01 -0700 Subject: does anybody earn a living programming in python? In-Reply-To: <1159225798.492198.89880@b28g2000cwb.googlegroups.com> References: <1159225798.492198.89880@b28g2000cwb.googlegroups.com> Message-ID: <1159367701.124853.131510@b28g2000cwb.googlegroups.com> walterbyrd wrote: > If so, I doubt there are many. > > I wonder why that is? Because Java has Sun's crazy-money behind it, and that pisses Microsoft off, so C# has MS's crazy-money behind it. And long before that, C was /the/ language because it was the only one that would allow you to actually program systems properly. I happen to know that Google does most of its admin scripting in Python. It can't be a small job, running a few hundred thousand servers worldwide and keeping them all up to date for system and security. --Blair From http Thu Sep 28 19:32:15 2006 From: http (Paul Rubin) Date: 28 Sep 2006 16:32:15 -0700 Subject: eval(source, {'builtins': {}}) archived as Faq References: <1159484841.655115.15190@m7g2000cwm.googlegroups.com> Message-ID: <7x8xk3y3cw.fsf@ruckus.brouhaha.com> p.lavarre at ieee.org writes: > Q: How can I tell Python to calculate what quoted strings and numbers > mean, without also accidentally accepting OS commands as input? > > A: eval(source, {'builtins': {}}) That is dangerous. Consider source = "9**9**9". There's a better recipe on ASPN: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469 From johnjsal at NOSPAMgmail.com Tue Sep 12 09:45:31 2006 From: johnjsal at NOSPAMgmail.com (John Salerno) Date: Tue, 12 Sep 2006 13:45:31 GMT Subject: question about including something like sqlite in python In-Reply-To: References: <9tiNg.2735$No6.53971@news.tufts.edu> Message-ID: <%RyNg.2737$No6.53952@news.tufts.edu> Dan Sommers wrote: > It's difficult to imagine > any one developer (or development shop) using the entire library, so at > least one module must be extraneous. That's a good point. I guess I am just trying to figure out why I'm a little surprised sqlite was included, but at the same time I'm excited to use it and the fact that it will now be standard has caused me to look into more than otherwise. :) From iainking at gmail.com Mon Sep 11 11:27:12 2006 From: iainking at gmail.com (Iain King) Date: 11 Sep 2006 08:27:12 -0700 Subject: PIL cannot open TIFF image in Windows In-Reply-To: References: Message-ID: <1157988432.247513.83750@h48g2000cwc.googlegroups.com> Michele Petrazzo wrote: > Rob Williscroft wrote: > > > I downloaded some test images from: > > > > > > > > I do the same and modified your code for try FreeImagePy and the results > are: > > ok: 41 error: 20 total: 61 > > Better than PIL, but a lot of problems with > > lower-rgb-planar- > 8 and flower-rgb-contig- > 8 > > IrfanView seem that can load all the images... > > > Rob. > > Bye, > Michele I've been working with tifs a lot, and I've yet to find a perfect python solution to them. The usual images to screw things up for me are jpeg encoded pages. Best solution I've found is a try/except fall through: try: open image with PIL except: try: open image with FreeImagePy except: try: open image with wxPython except: fail Right now my program to compile multipage tiffs no longer does any of the image work itself - it processes the index file, and then generates a batch file. The batch file is a lot of calls to irfanview /append. I've yet to find a tiff irfanview can't open. Iain From tim at tdw.net Tue Sep 5 19:29:26 2006 From: tim at tdw.net (Tim Williams) Date: Wed, 6 Sep 2006 00:29:26 +0100 Subject: Removing from a List in Place In-Reply-To: References: Message-ID: <9afea2ac0609051629r19ba140fka87809462d6e3365@mail.gmail.com> On 5 Sep 2006 16:05:36 -0700, bayerj wrote: > > I'm going to assume that it's supposed to work like this, but could > > someone tell me the reasoning behind it? I.E. why is 3 skipped? > > Because: > > >>> alist[2] > 3 > > You are removing the third item, not the second. > Actually, he's removing 2 from the list, but then the length of the list shrinks by 1 and iteration stops. The example would have been better if alist = ['a','b','c'] and 'b' was removed. L.remove(value) -- remove first occurrence of value you were possibly thinking of alist.pop(2), which removes the item alist[2] from alist HTH :) -- Tim Williams From vedran_dekovic at yahoo.com Sat Sep 30 09:17:44 2006 From: vedran_dekovic at yahoo.com (vedran_dekovic at yahoo.com) Date: 30 Sep 2006 06:17:44 -0700 Subject: Python pyphone module download Message-ID: <1159622264.778399.88770@i42g2000cwa.googlegroups.com> Hello, I was install python pyphone,but I can't run it becose I must download module gtk.Where to I find module gtk (gtk.exe) Thanks!!!!!!!!!!!!!!!!!!!!!!!! From steve at holdenweb.com Tue Sep 12 12:39:51 2006 From: steve at holdenweb.com (Steve Holden) Date: Tue, 12 Sep 2006 17:39:51 +0100 Subject: "filtered view" upon lists? In-Reply-To: <4506D471.7010905@freakmail.de> References: <878xkpb5wa.fsf@gmail.com> <4506D471.7010905@freakmail.de> Message-ID: Wildemar Wildenburger wrote: > Jorge Godoy wrote: > > Wildemar Wildenburger writes: > > > >> I don't know how else to call what I'm currently implementing: An > object that > >> behaves like a list but doesn't store it's own items but rather > pulls them > >> from a larger list (if they match a certain criterion). > >> Changes to the filter are instantly reflected in the underlying list. > >> Clear enough? > > > > It looks like you're implementing a callable to me. This is a method > that > > returns results based on some input -- here your original list and > filter. > > Then you'll use this method wherever you need that filtered list. > > > Ok, so I'm not clear enough ;) . > I don't just want to extract certain elements from a list, I want an > object that looks like a list, however all changes made to that object > are automagically reflected in the original list. (I guess that is one > of those 'if it's hard to explain, ...' cases.) > > I should have included an example right away ... here goes: > > # I have a list > l = [1, 2, 3, 4, 5, 6, 7] > > # I then want to create a Filter instance > # (Filter beeing a *class* implemented by me) > # where isEven() returns True whenever an item of l > # should be included in f (in this case, even numbers). > # (I'm asking if something like this exists in the libs > # or elsewhere) > f = Filter(l, isEven) > > # The desired behavior now goes something like this: > f > >>> [2, 4, 6] > del f[1] > f > >>> [2, 6] > l > >>> [1, 2, 3, 5, 6, 7] > f.append(77) > f > >>> [2, 6, 77] > # 77 being intentionally uneven > l > >>> [1, 2, 3, 5, 6, 7, 77] > # could be [1, 2, 3, 5, 6, 77, 7] as well > # I don't care here > > # and so forth ... > > I think SQL views are the direct analog. > I don't think they are. If you add a non-conforming row to a SQL view it doesn't appear int he view. If you modify a row in an updateable view so it no longer confirms with the view's conditions it disappears from the view. This is a classic cause of user perplexity - they update a record without being aware that they are using a view and suddenly it "disappears". Also you don't say whether changes to l are supposed to be reflected in f in the same way that changes to f are reflected in l. It might be better if you were to explain your use case: what is this beast supposed to be for? > > I don't believe it is generic. Nobody knows your data specs or filtering > > needs. > Hence the additional function in the Filter constructor ;) . You suggest > the same thing below, so that is obviously no problem. > > > Use of list comprehension might make it easier to code this: > > > > > I sort of wanted to avoid these. Though my lists shouldn't terribly > long, so performance is not an issue so much. I simply want to avoid > having two datasets that I have to sync. Major pain, I believe. > > > Coding all that really is quite straight forward, but it is a lot of > mule-work. I hoped (no, I still hope) that there might be somethin like > that around already. > > A bit clearer now? > Hardly at all. Frankly it doesn't seem as though you really know what the specifications are yourself, so you can hardly expect us to divine them by use of our psychic powers. Besides which, psychic powers cost extra ;-) So give us that use case so we get a bit more insight into why you even see the need for such a thing and how you want it ti behave. Or is all this just theoretical? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From MonkeeSage at gmail.com Sun Sep 24 23:47:24 2006 From: MonkeeSage at gmail.com (MonkeeSage) Date: 24 Sep 2006 20:47:24 -0700 Subject: ruby %w equivalent References: <1159137139.987228.294950@i42g2000cwa.googlegroups.com> Message-ID: <1159156044.207187.209530@i42g2000cwa.googlegroups.com> Tim Chase wrote: > to give it that perl/ruby-ish feel of terseness and obscurity. Don't feel bad, you always have things like r'%s\%s' % (u'blah', u'blah') and so on. But of course, it's only the other guys who are evil / ugly / stupid. As the human torch says, "Flame On". :) [Full disclosure: I like ruby _and_ I like python (gasp!), and see no need to artificially criticize one or the other; I try rather to utilize the strengths of both.] Regards, Jordan From franz.steinhaeusler at gmx.at Sun Sep 17 14:49:21 2006 From: franz.steinhaeusler at gmx.at (Franz Steinhaeusler) Date: Sun, 17 Sep 2006 20:49:21 +0200 (CEST) Subject: Webbrowser written totally in Python Message-ID: Hello NG, is there any (GUI) webbrowser written completly in Python? in pyGtk, pyQt, wxPython or TkInter? -- Franz Steinhaeusler From p.lavarre at ieee.org Sat Sep 23 16:54:34 2006 From: p.lavarre at ieee.org (p.lavarre at ieee.org) Date: 23 Sep 2006 13:54:34 -0700 Subject: help with debugging a ctypes problem In-Reply-To: References: Message-ID: <1159044873.990755.108160@i42g2000cwa.googlegroups.com> > help figuring out how to debug ... ctypes ... > a commercial dll. A certain function takes five arguments, foo(a, b, c, d, e). > Can I view the appropriate stack? ... Any other ideas or advice? etc? Did you call the foo of _cdecl ctypes.cdll or the foo of _stdcall = ctypes.windll? What is the sizeof each argument type? Preferably fetched by compiling some C to printf them? Would it help to call C in another Dll to return the stack pointer, so Python could print the stack? From sjmachin at lexicon.net Wed Sep 13 12:17:50 2006 From: sjmachin at lexicon.net (John Machin) Date: 13 Sep 2006 09:17:50 -0700 Subject: How to build extensions on Windows? In-Reply-To: References: <1157649612.956390.306640@d34g2000cwd.googlegroups.com> Message-ID: <1158164270.297334.209790@d34g2000cwd.googlegroups.com> Fredrik Lundh wrote: > Kevin D.Smith wrote: > > > This almost worked (at least, it appears to). I got the module to > > build and install using VS 2005. It works fine if I run python from > > the directory where I built the extension. However, if you go to any > > other directory, run python, and try to import the module, I get the > > following error: > > > > ImportError: dynamic module does not define init function (initsasSQL) > > > > Why would it work from one directory, but not another? > > do you perhaps have a different "sassql.dll" file in your Python path? > > (Python's standard import mechanism looks for PYD, DLL, PY, PYW, and > PYC, in that order.) > Any support for the radical notion of the error message giving the full path of the file that it's complaining about? If so, I'll lob in an enhancement request in the morning ... Cheers, John From edgar at edgar-matzinger.nl Tue Sep 12 08:03:25 2006 From: edgar at edgar-matzinger.nl (Edgar Matzinger) Date: Tue, 12 Sep 2006 14:03:25 +0200 Subject: FW: Re: [Spambayes] How to create a valid RPM? Message-ID: <1158062605l.18089l.0l@nlxth001> ls, On 09/12/2006 11:48:10 AM, skip at pobox.com wrote: > >> when I download python-spambayes-1.0rc2-2.src.rpm, install it and >> run rpmbuild -ba ../SPECS/python-spambayes.spec, I get a lot of >> error messages. It complains about a lot of installed but >> unpackaged files. How can I create a valid RPM? > > Dunno. Did you try "python setup.py bdist_rpm"? This is a bit more This gives the same errors. In fact it calls rpmbuild... > general than just SpamBayes. You might get some useful help from > comp.lang.python (aka python-list at python.org). can anyone of you guys help me? It seems that the spec-file does not contain a valid %files section. Thanks, cu l8r, Edgar. -- \|||/ (o o) Just curious... ----ooO-(_)-Ooo------------------------------------------------------- From ingo.bear_NOSPAM at freenet.de Sun Sep 24 05:07:24 2006 From: ingo.bear_NOSPAM at freenet.de (Ingo Linkweiler) Date: Sun, 24 Sep 2006 11:07:24 +0200 Subject: Verify an e-mail-adress - syntax and dns Message-ID: Has anyone a function/script to verify an e-mail-address? It should: a) check the syntax b) verify an existing mailserver or DNS/MX records ingo From rtw at freenet.co.uk Fri Sep 22 16:47:21 2006 From: rtw at freenet.co.uk (Rob Williscroft) Date: Fri, 22 Sep 2006 15:47:21 -0500 Subject: distutils on Windows with VC++ 8 References: <45136400.5030600@v.loewis.de> <4514479B.5070808@v.loewis.de> Message-ID: =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= wrote in news:4514479B.5070808 @v.loewis.de in comp.lang.python: > Rob Williscroft schrieb: >> Download the 1.1 SDK: >> >> > 3647-4070-9F41-A333C6B9181D&displaylang=en> >> >> yes it does have 90 odd megabytes of stuff you don't want but the C/C++ >> compiler is in there. > > That's yet another option. Somebody reported that the compiler in the > .NET SDK won't support generating optimized code, though. That's a > problem for some people. I belive that was true "Academic" releases of Visual Studio, AIUI it was never true of the 7.1 compiler that came with .NET 1.1 SDK's. > >> I think the VS 2003 toolkit is a framework for extending Visual Studio >> 2003, IOW a bunch of .NET dlls, some examples and a helpfile (no >> compiler). > > I don't think so. It was (as it's no longer officially available) a > command-line only version of the compiler. In any case, it is > (or was) different from the .NET SDK. Having read Noel Byron's reply also, I'm tempted to say there is some confusion here between a Visual *Studio* toolkit (VS 2003) and a Visual *C++* toolkit (VC 2003). There is defenitly a Visual Studio Toolkit I downloaded the 2005 version reciently (to test IornPython integration), and I remember coming accross a 2003 version too ('cause Microsoft never like to make a download easy to find ;-)). Rob. -- http://www.victim-prime.dsl.pipex.com/ From johnjsal at NOSPAMgmail.com Wed Sep 27 09:54:15 2006 From: johnjsal at NOSPAMgmail.com (John Salerno) Date: Wed, 27 Sep 2006 13:54:15 GMT Subject: a different question: can you earn a living with *just* python? In-Reply-To: <1159337418.630332.80100@k70g2000cwa.googlegroups.com> References: <1159305924.604677.118300@i42g2000cwa.googlegroups.com> <1159337418.630332.80100@k70g2000cwa.googlegroups.com> Message-ID: sjdevnull at yahoo.com wrote: > Yes, and making sure that the first several you learn are disparate in > their common idioms and programming models is incredibly worthwile to > your development as a programmer IMO. You're right about that. While I'm definitely no expert in it, I did start learning C# last year (even before I started with Python), and though I never got too far with it, it was a great experience to learn a language like that, and then move on to something as different as Python. It really helped me to see how things are done differently given the type of language you are using. From george.sakkis at gmail.com Tue Sep 26 12:21:08 2006 From: george.sakkis at gmail.com (George Sakkis) Date: 26 Sep 2006 09:21:08 -0700 Subject: identifying new not inherited methods References: <1159285472.965554.170420@d34g2000cwd.googlegroups.com> Message-ID: <1159287668.323389.209520@b28g2000cwb.googlegroups.com> malkaro... at gmail.com wrote: > Hi, > > I am writing a library in which I need to find the names of methods > which are implemented in a class, rather than inherited from another > class. To explain more, and to find if there is another way of doing > it, here is what I want to do: I am defining two classes, say A and B, > as: > > class A(object): > def list_cmds(self): > 'implementation needed' > ? > def __init__(self): > ... (rest of class) > > class B(A): > def cmd1(self, args): > pass > def cmd2(self, args): > pass > > I need an implementation of list_cmds in A above so that I can get a > result: > > >>> b=B() > >>> b.list_cmds() > ['cmd1','cmd2'] #order not important > > I will be happy if anybody can point to me any way of doing it, using > class attributes, metaclasses or otherwise. What I don't want to do is > modifying class B, which contains just the cmds, if possible. > > Many thanks in advance. > > k I'd rather have it as a function, not attached to a specific class: from inspect import getmembers, ismethod def listMethods(obj): d = obj.__class__.__dict__ return [name for name,_ in getmembers(obj,ismethod) if name in d] HTH, George From Ferdy.Bonvo at gmail.com Tue Sep 19 14:01:23 2006 From: Ferdy.Bonvo at gmail.com (Ferdy.Bonvo at gmail.com) Date: 19 Sep 2006 11:01:23 -0700 Subject: Nano Technology Application For Health,Wellness and Beauty Message-ID: <1158688883.046410.110720@d34g2000cwd.googlegroups.com> Dear lovely moderator, please allow me to spread this information, somebody might need it, please forgive me if you are bothered Dear All, this might be useful for you and your family I have already use it and prove that my family health is now very much improve,no more headache, no more back pain, no more 'night owl' to get better sleep,and help my autism brother to be more calm and easy to handle, perhaps it may help others with mental or physical disease --------------------------------------------------------------------------------------------------------------- Technically engineered natural minerals have been structurally bonded in glass, at molecular level, using several high heat fusion methods. This combination of the techniques causes a catalytic energy conversion creating a long lasting, specific natural Nano resonance in the BIO DISC. Transferring the "Nano Energising Frequency" into or through liquid affects the nanos within the liquid. When the mineral nanos come into contact with their specific frequency they behave completely differ ently from the host atom for instance: they boil quicker, are lighter and refract more light. This natural resonance has the ability to create a molecular structure in all manufactured or treated liquid and vegetation. Product benefits: -It will enhance taste of food and beverages -It helps to improve sleep -It has the ability to balance ying and yang and create a CHI Life force -It helps to create energized water by placing drinking water on top of it -By drinking the energized water created from Bio Disc will help you detoxify and hydrate all body cells -It enhance your immune system of the body -It reduces stress levels -It increased take up of nutrients -It increases oxygenation of the blood -It has calming effects of the resonance increases mental Cognition -Rejuvenating molecular structures and nano cells, reduces bacteria formation, extends shelf life, improves taste and slows down the aging process. -Fruit, vegetables and meat lose molecular structure as they age. All can be revitalised at a molecular level by Qi technology resonance. -Put it in the pocket to reduce Jet Lag -Improve Wine Taste -Expose Positive and Expels Negative Effects -Pour cosmetics/lotions on the surface of BIO DISC to maximize the benefits of cosmetics/lotions -Place BIO DISC on any wound/injury to accelerate the healing process -Move it counter clock wise to remove muscle injury -Remove Fat From Milk -Put cigarettes box on BIO DISC for 30 minutes to remove Tar and Nicotine from cigarettes -It accelerates relaxation into deeper meditation NO SIDE EFFECTS AT ALL Product Specification Appearance: Round Clear Glass Specific Size: Diam 9cm Thickness 10mm Specific Weight: 130grs Country of Origin: Germany Lifetime : 15 years Certified by: Prognos For more info and inquiry: http://masterpiece.myqnet.biz From grahn+nntp at snipabacken.dyndns.org Mon Sep 11 16:39:28 2006 From: grahn+nntp at snipabacken.dyndns.org (Jorgen Grahn) Date: 11 Sep 2006 20:39:28 GMT Subject: best way of testing a program exists before using it? References: <45057B5E.7010306@googlemail.com> Message-ID: On Mon, 11 Sep 2006 16:21:04 +0100, Steve Holden wrote: > Hari Sekhon wrote: ... >> What is the best way of making sure that the command is installed on the >> system before I try to execute it, like the python equivalent of the >> unix command "which"? ... > The easiest way to test whether the command will run is to try and run > it. If the program doesn't exist then you'll get an exception, which you > can catch. Otherwise you'll be stuck with non-portable mechanisms for > each platform anyway ... You don't get an exception from os.system, and it's worse for os.popen and friends. In some situations (AFAICS) you're toast if the command doesn't exist; for example, if you feed sys.stdin to something that doesn't exist and want to back out and feed it to the second best command. It would have been nice if there was an os.path.isexecutable which walked the $PATH. Of course, that wouldn't guarantee that the file actually /was/ executable, but ... /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From brendon at brendontowle.com Mon Sep 25 10:09:26 2006 From: brendon at brendontowle.com (Brendon Towle) Date: Mon, 25 Sep 2006 09:09:26 -0500 Subject: Python API to OS X Address Book? Message-ID: <20060925140926.21C149EEFA@ws6-2.us4.outblaze.com> Essentially, I'm looking for a Python equivalent to the ObjectiveC stuff that can be found at: http://developer.apple.com/documentation/UserExperience/Conceptual/AddressBook/index.html Google got me that far, but was not particularly helpful past that. Anyone have any pointers? B. From paul at boddie.org.uk Wed Sep 27 15:51:17 2006 From: paul at boddie.org.uk (Paul Boddie) Date: 27 Sep 2006 12:51:17 -0700 Subject: does anybody earn a living programming in python? References: <1159225798.492198.89880@b28g2000cwb.googlegroups.com> <1159278999.374338.76170@m73g2000cwd.googlegroups.com> <1159280328.671934.42180@h48g2000cwc.googlegroups.com> <1159285305.562672.152460@d34g2000cwd.googlegroups.com> <1159380986.289804.185550@b28g2000cwb.googlegroups.com> Message-ID: <1159386677.677912.165810@i3g2000cwc.googlegroups.com> Dan Bishop wrote: > > Are you hiring? :-) No, just complaining. ;-) > It's so frustrating seeing all those job postings that require a > "mimimum 10 years experience". I've seen adverts with phrasing that could have been interpreted as having meant "minimum 10 years .NET experience", and that was a couple of years ago. Of course, despite the presumed lack of knowledge of the recruiter who wrote the advert, it's quite possible that something else was meant, but the quality of prose in such adverts is usually either so poor that you wonder whether "good written communication skills" wouldn't also be beneficial in the recruitment business, or the text merely consists of a checklist of recruitment clich?s, that it's hard to know exactly what they're getting at sometimes. Paul From srikrishnamohan at gmail.com Tue Sep 5 11:43:57 2006 From: srikrishnamohan at gmail.com (km) Date: Tue, 5 Sep 2006 21:13:57 +0530 Subject: threading support in python In-Reply-To: References: <1157381880.697001.260070@m73g2000cwd.googlegroups.com> <1157387626.242107.92070@p79g2000cwp.googlegroups.com> <1157398593.191972.240270@p79g2000cwp.googlegroups.com> <1157422764.573537.116340@m79g2000cwm.googlegroups.com> <7xejuqhh94.fsf@ruckus.brouhaha.com> Message-ID: True, since smartness is a comparison, my friends who have chosen java over python for considerations of a true threading support in a language are smarter, which makes me a dumbo ! :-) KM On 9/5/06, Richard Brodie wrote: > > "km" wrote in message > news:mailman.20.1157468962.5279.python-list at python.org... > > > I know many of my friends who did not choose python for obvious reasons > > of the nature of thread execution in the presence of GIL which means > > that one is wasting sophisticated hardware resources. > > It would probably be easier to find smarter friends than to remove the > GIL from Python. > > > -- > http://mail.python.org/mailman/listinfo/python-list > From Eric_Dexter at msn.com Mon Sep 4 11:03:09 2006 From: Eric_Dexter at msn.com (Eric_Dexter at msn.com) Date: 4 Sep 2006 08:03:09 -0700 Subject: This seems to crash my program and gives me errors on the #include statements In-Reply-To: References: <1157375279.790255.321010@b28g2000cwb.googlegroups.com> Message-ID: <1157382189.013651.326640@b28g2000cwb.googlegroups.com> It is giving errors on the import statements.. I will get an error on the line where I import this routine import csoundroutines and then the when I import the the program that tried to import csoundroutines I get an error and on down the chain.. when I go back to where I started in csoundroutines all the import errors go away.. I can't tell if thier is a problem with se.py that starts all the errors or if I am not getting all the right import statements... There is a short file on sourceforge that gives the csoundroutines library I am trying to debug and expand.. https://sourceforge.net/project/showfiles.php?group_id=156455&package Steve Holden wrote: > Eric_Dexter at msn.com wrote: > > I was trying to add this to my project but I must be missing some > > includes or there is a serius error somewhere > > > [...] > > > > I cut and pasted this.. It seems to be crashing my program.. I am not > > sure that I have all the right imports.. seems to be fine when I go to > > > > an older version of the file... I uploaded it onto source forge. > > > > https://sourceforge.net/project/showfiles.php?group_id=156455&package... > > > > http://www.dexrow.com > > > > Nobody, or very few people, are going to bother to download code from > sourceforge just to help you debug it. > > As far as I can see you haven't yet explained *how* your program fails: > does it give a Python error traceback (in which case we would need to > see that traceback, which will at least tell us where the error occurs) > or something else? "A serious error" tells us effectively nothing except > that your program isn't doing what you want it to do, so even reading > the source probably won't help. > > Have you tried reproducing the "serious error" in a smaller program that > you could include as a part of a posting on this list? > > You are hiding the very information that is needed to help you solve > your problem. > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC/Ltd http://www.holdenweb.com > Skype: holdenweb http://holdenweb.blogspot.com > Recent Ramblings http://del.icio.us/steve.holden From exogen at gmail.com Mon Sep 25 15:40:22 2006 From: exogen at gmail.com (Brian Beck) Date: Mon, 25 Sep 2006 15:40:22 -0400 Subject: ANN: dmath 0.9 - Math routines for the Decimal type Message-ID: Hi all, I'm pleased to announce the first release of my new library, dmath. It is available under the MIT/X11 license. Download ======== Cheese Shop: http://cheeseshop.python.org/pypi/dmath/0.9 Google Code: http://code.google.com/p/dmath/ What is dmath? ============== dmath provides the standard math routines for Python's arbitrary-precision Decimal type. These include acos, asin, atan, atan2, ceil, cos, cosh, degrees, e, exp, floor, golden_ratio, hypot, log, log10, pi, pow, radians, sign, sin, sinh, sqrt, tan, and tanh. About this release: =================== This is the first release and I'm calling this release 0.9 because it just needs some testing and maybe some speed improvements, otherwise it's ready to use. There is currently some work being done in Python sandbox/trunk to convert the decimal module to C, and maybe they'll include fast versions of all these routines. You can follow development details and announcements on my blog here: http://blog.case.edu/bmb12/ How do I use it? ================= Use it just like math and cmath, but make sure you give it Decimals: >>> from dmath import * >>> from decimal import Decimal as D, getcontext >>> getcontext().prec = 50 >>> asin(D(1)) Decimal("1.5707963267948966192313216916397514420985846996876") >>> golden_ratio() Decimal("1.6180339887498948482045868343656381177203091798058") -- Brian Beck Adventurer of the First Order From steve at holdenweb.com Wed Sep 27 12:58:51 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 27 Sep 2006 17:58:51 +0100 Subject: Surprise using the 'is' operator In-Reply-To: <451AA338.4030607@tobiah.org> References: <451A9824.6040106@tobiah.org> <451AA338.4030607@tobiah.org> Message-ID: tobiah wrote: > Simon Brunning wrote: > >>On 9/27/06, tobiah wrote: >> >>>Suppose I fill an list with 100 million random integers in the range >>>of 1 - 65535. Wouldn't I save much memory if all of the ocurrances >>>of '12345' pointed to the same integer object? Why should more be made, >>>when they all do the same thing, and are not subject to change? >> >>If you were to drop that list, then to generate another large list of >>integers, you'd want to re-use the memory from the first lot, wouldn't >>you? >> >>(BTW, AFAIK, integers are kept seperate from other objects >>memory-wise, so memory used for integers won'tr be re-used for other >>object types. but memory used for integers can be re-used for *other* >>integers. I think.) >> > > > I'm confused now, but yes, I would want to reuse the memory for > the other integers. That's why I understand why I get the same > id back for small integers, but why limit that to (-5, 257)? > > Thanks, > > Toby > It's what's called an "implementation detail". Don't even worry about it until you need to shave every microsecond off your program's execution time, as reliance on such details reduces portability. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From http Fri Sep 15 19:51:59 2006 From: http (Paul Rubin) Date: 15 Sep 2006 16:51:59 -0700 Subject: Tkinter.Button(... command) lambda and argument problem References: <1158363383.752921.58920@d34g2000cwd.googlegroups.com> Message-ID: <7x1wqcsn6o.fsf@ruckus.brouhaha.com> "Jay" writes: > I'm having a problem using lambda to use a command with an argument for > a button in Tkinter. > > buttons = range(5) > for x in xrange(5): > self.highlight(x)) > buttons[x].pack(side=LEFT) > > The buttons are correctly numbered 1 through 5, but no matter which > button I click on, it sends the number 4 as an argument to the > highlight function. x is not bound by the lambda and so the lambda body gets it from the outside environment at the time the body is executed. You have to capture it at the time you create the lambda. There's an ugly but idiomatic trick in Python usually used for that: buttons[x] = Button(frame, text=str(x+1), \ command=lambda x=x: self.highlight(x)) See the "x=x" gives the lambda an arg whose default value is set to x at the time the lambda is created, as opposed to when it's called. From larry.bates at websafe.com Thu Sep 28 12:32:54 2006 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 28 Sep 2006 11:32:54 -0500 Subject: XSLT speed comparisons In-Reply-To: References: <1159392275.988709.72990@m7g2000cwm.googlegroups.com> <451BD332.1080505@websafe.com> Message-ID: <451BF936.9080809@websafe.com> Jan Dries wrote: > Larry Bates wrote: >> Damian wrote: > [...] >> > What I've got is: >> > two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for >> > XML/XSLT) >> > both on the same box (Windows Server 2003) >> > both using the same XML, XSLT, CSS >> > >> > The problem is, the Python version is (at a guess) about three times >> > slower than the ASP one. I'm very new to the language and it's likely >> > that I'm doing something wrong here: > [...] >> > >> For max speed you might want to try pyrxp: >> >> http://www.reportlab.org/pyrxp.html >> > > Except that pyrxp, to the best of my knowledge, is an XML parser and > doesn't support XSLT, which is a requirement for Damian. > > Regards, > Jan Oops, I should have read the OPs post closer. -Larry From robert.kern at gmail.com Sun Sep 17 03:34:02 2006 From: robert.kern at gmail.com (Robert Kern) Date: Sun, 17 Sep 2006 02:34:02 -0500 Subject: Finding dynamic libraries In-Reply-To: <1158477794.780781.83700@i42g2000cwa.googlegroups.com> References: <1158367145.252363.21230@d34g2000cwd.googlegroups.com> <1158477794.780781.83700@i42g2000cwa.googlegroups.com> Message-ID: MonkeeSage wrote: > Robert Kern wrote: >> No, his extensions link against other shared libraries which are not Python >> extensions. Those shared libraries are in nonstandard locations because he is >> running his tests before installing the libraries and his Python code. > > In that case, couldn't it be done by placing a copy/symlink to the > shared library in the same directory as the python extension, then > reload()'ing the extension from the already running python process? I > think, but am not certain, so don't hold me to it, that dlopen and > kindred will search the working directory for a library before falling > back to the cache or LD_LIBRARY_PATH and so on. Worth a shot mabye. It depends on the OS. Most Linux systems do not. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ramasubramani.g at gmail.com Wed Sep 6 23:49:04 2006 From: ramasubramani.g at gmail.com (Rama) Date: Thu, 7 Sep 2006 09:19:04 +0530 Subject: newbe who is also senior having a senior moment In-Reply-To: References: Message-ID: <3f8d3ac50609062049n2ae0a25pae45bc98e762af8f@mail.gmail.com> On 07/09/06, stan wrote: > > > File "C:\Python24\2L file for iTunes", line 4, in -toplevel- > import win32com.client > ImportError: No module named win32com.client > > can someone pls point me in the right direction here as I am trying to > urgently fix the file for someones birthday in game (I know pathetic) > > Try installing the python for win32 extensions - http://starship.python.net/crew/mhammond/win32/ thanks, Rama -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnjsal at NOSPAMgmail.com Mon Sep 25 16:11:54 2006 From: johnjsal at NOSPAMgmail.com (John Salerno) Date: Mon, 25 Sep 2006 20:11:54 GMT Subject: Leave the putdowns in the Perl community, the Python world does not need them In-Reply-To: References: <1159188351.960448.43660@d34g2000cwd.googlegroups.com> Message-ID: Steven Bethard wrote: > [1] He's the author of Python's unicode support and Python 2.5's > elementtree module. Is that all? ;) He also implemented the partition string method, which for some reason I think is the coolest thing since sliced lists. :) From jjl at pobox.com Wed Sep 27 15:58:41 2006 From: jjl at pobox.com (John J. Lee) Date: 27 Sep 2006 20:58:41 +0100 Subject: Talking to marketing people about Python References: <1159187290.052703.116370@i42g2000cwa.googlegroups.com> <1159211679.627442.111850@i42g2000cwa.googlegroups.com> Message-ID: "Carl Banks" writes: [...] > Still don't know whether labeling something as written in Python is > intended to be a "badge of honor" or "advance warning". :-) I'm always surprised when people name *applications* with 'Py' in the name, unless they're squarely aimed at the geek market (but I guess quite a few open source apps *do* fall into that category). It does seem quite a frequent occurence for that to happen. John From laurent.pointal at wanadoo.fr Mon Sep 18 13:52:08 2006 From: laurent.pointal at wanadoo.fr (Laurent Pointal) Date: Mon, 18 Sep 2006 19:52:08 +0200 Subject: Pythondocs.info : collaborative Python documentation project References: <1158426978.573858.159320@m7g2000cwm.googlegroups.com> Message-ID: <450edcc8$0$25913$ba4acef3@news.orange.fr> nicolasfr at gmail.com wrote: > Hi, > > I am a bit disapointed with the current Python online documentation. I > have read many messages of people complaining about the documentation, > it's lack of examples and the use of complicated sentences that you > need to read 10 times before understanding what it means. > > That's why I have started a collaborative project to make a user > contributed Python documentation. The wiki is online here: > http://www.pythondocs.info > > This is a fresh new website, so there's not much on it, but I hope to > make it grow quickly. Help and contributions are welcome; Please > register and start posting your own documentation on it. > > Regards, > > Nicolas. > ----- > http://www.pythondocs.info You're realy nor the first one, see http://mail.python.org/pipermail/python-list/2004-May/219580.html (and following thread) Other (never achieved) projects... http://www.pythondocs.org/ Even Skip Montanaro python-glossary site seem to not have been continued... http://mail.python.org/pipermail/python-list/2004-May/219682.html From deets at nospam.web.de Fri Sep 29 10:15:52 2006 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 29 Sep 2006 16:15:52 +0200 Subject: File I/O References: <1159524677.406011.250420@i3g2000cwc.googlegroups.com> <1159526934.077334.69080@i42g2000cwa.googlegroups.com> <1159527353.447436.107610@i42g2000cwa.googlegroups.com> <4o4eipFcp21dU1@uni-berlin.de> <1159534659.445774.230620@i3g2000cwc.googlegroups.com> Message-ID: <4o4o4oFcv8p5U1@uni-berlin.de> jimburton wrote: > > Diez B. Roggisch wrote: >> Kirt wrote: >> >> > >> > jimburton wrote: >> >> Kirt wrote: >> >> > Hi! I need some help in file I/O >> >> > >> >> > I have an xml file.. >> >> [snip] >> >> See http://diveintopython.org/xml_processing/ >> > >> > i dont wanna parse the xml file.. >> >> If you play soccer, do you insist on playing with a baseball bat? >> > I've been known to open a bottle of wine with a pencil. Works fine. Good to know that you can get drunk under any circumstances. I have seen a bazillion bad xml/html parsing-hacks using regexes and the like, which stopped working after somehow the xml came all in one line, or some other implicit assumption about its layout failed to be met. From outstretchedarm at hotmail.com Thu Sep 7 10:33:00 2006 From: outstretchedarm at hotmail.com (Omar) Date: 7 Sep 2006 07:33:00 -0700 Subject: 4 Simple Questions About Python/IDLE In-Reply-To: References: <1157637224.725618.164500@e3g2000cwe.googlegroups.com> Message-ID: <1157639580.217361.273200@i42g2000cwa.googlegroups.com> thanks. i have saved and double clicked as suggested. when I save and double click a simple "hello program", the b&w python shell briefly comes up, then disappears. is this how it should work? From http Wed Sep 27 16:32:36 2006 From: http (Paul Rubin) Date: 27 Sep 2006 13:32:36 -0700 Subject: OT: productivity and long computing delays References: <7xzmcl2inu.fsf_-_@ruckus.brouhaha.com> Message-ID: <7xr6xx2gpn.fsf@ruckus.brouhaha.com> skip at pobox.com writes: > Paul> Anyway, I did the same build on a 2 ghz Athlon 64 and was > Paul> surprised that the speedup was only 35% or so. I'd have to get a > Paul> multiprocessor box to obtain really substantial gains. > > Maybe your build process is i/o bound. If you're using GNU make and have > the make dependencies set up properly, the -jN flag (for N = 2 or 3) may > speed things up. It's almost all CPU-bound on both the Pentium M and the Athlon. But I wasn't as much asking for technical approaches to speeding up calculation, as for general strategy about dealing with this downtime productively (I figured it was ok to ask this, given the other thread about RSI). My workday is getting chopped up in a manner sort of like memory fragmentation in a program, where you end up with a lot of disjoint free regions that are individually too small to use. As for the technical part, the underlying problem has to do with the build system. I should be able to edit a source file, type "make" and recompile just that file and maybe a few related ones. But the results of doing that are often incorrect, and to make sure the right thing happens I have to rebuild. I'm not in a position right now to start a side project to figure out what's wrong with the build system and fix it. From andreas.huesgen at arcor.de Wed Sep 13 07:52:32 2006 From: andreas.huesgen at arcor.de (Andreas Huesgen) Date: Wed, 13 Sep 2006 13:52:32 +0200 Subject: python reference counting and exceptions In-Reply-To: <2773CAC687FD5F4689F526998C7E4E5FF1E99C@au3010avexu1.global.avaya.com> References: <2773CAC687FD5F4689F526998C7E4E5FF1E99C@au3010avexu1.global.avaya.com> Message-ID: <4507F100.60604@arcor.de> Delaney, Timothy (Tim) wrote: > RIIA - Resource Initialisation is Acquisition > > Python is adding an RIIA mechanism in 2.5 - look at the "with" > statement. > Ah, thanks, thats exactly what I was looking for. Gabriel Genellina wrote: > Yes: the try/finally construct, which is *not* the same as a try/except. The finally clause is always executed, whether or not an exception is raised. Yes, of course it must be the try finally construct and not try/except. Shame on me.... ;) Andreas Huesgen From johnjsal at NOSPAMgmail.com Thu Sep 28 10:05:16 2006 From: johnjsal at NOSPAMgmail.com (John Salerno) Date: Thu, 28 Sep 2006 14:05:16 GMT Subject: sqlite3 error In-Reply-To: References: Message-ID: Dennis Lee Bieber wrote: > On Wed, 27 Sep 2006 18:41:54 GMT, John Salerno > declaimed the following in comp.lang.python: > >> You're right! I think that must have been leftover from when it wasn't >> the last line in the query. Thanks! > > You also, based upon the cut&paste, have a stray > > "") > > (or something similar in the last line) I don't see this. The code works now, though. Maybe it was something carried over by pasting. From steve at holdenweb.com Wed Sep 6 03:52:34 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 06 Sep 2006 08:52:34 +0100 Subject: threading support in python In-Reply-To: <1157526371.291426.191730@m79g2000cwm.googlegroups.com> References: <7xzmddojc5.fsf@ruckus.brouhaha.com> <1157526371.291426.191730@m79g2000cwm.googlegroups.com> Message-ID: sjdevnull at yahoo.com wrote: > Paul Rubin wrote: > >>Jean-Paul Calderone writes: >> >>>>which more explicitly shows the semantics actually desired. Not that >>>>"huge" a benefit as far as I can tell. Lisp programmers have gotten >>>>along fine without it for 40+ years... >>> >>>Uh yea. No lisp programmer has ever written a with-* function... ever. >> >>The context was Lisp programmers have gotten along fine without >>counting on the refcounting GC semantics that sjdevnull advocates >>Python stay with. GC is supposed to make it look like every object >>stays around forever, and any finalizer that causes an explicit >>internal state change in an extant object (like closing a file or >>socket) is not in the GC spirit to begin with. > > > I disagree, strongly. If you want "every object stays around forever" > semantics, you can just not free anything. GC is actually supposed to > free things that are unreachable at least when memory becomes tight, > and nearly every useful garbage collected language allows destructors > that could have effects visible to the rest of the program. Reference > counting allows more deterministic semantics that can eliminate > repeating scope information multiple times. > Clearly you guys are determined to disagree. It seemed obvious to me that Paul's reference to making it "look like every object stays around forever" doesn't exclude their being garbage-collected once the program no longer contains any reference to them. You simplify the problems involved with GC-triggered destructors to the point of triviality. There are exceedingly subtle and difficult issues here: read some of the posts to the python-dev list about such issues and then see if you still feel the same way. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From root at onyx.ataraxy.com Wed Sep 6 01:47:15 2006 From: root at onyx.ataraxy.com (root) Date: Wed, 06 Sep 2006 01:47:15 -0400 Subject: Chegou um cartão para Você FROM: O Carteiro Return-Path: Mime-Version: 1.0 Content-type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Priority: 1 Importance: High Message-ID: <1155861778.2.4410301365277695156.1.15768020@mail.ocarteirro.com> Cartões e Muito mais

Olá Amigo(a),
Veja o cartão surpresa que prepararam para você:

http://www.ocarteiro.com/lercartao.html?id=1917116965A4137

Você também poderá visualizá-lo em http://www.ocarteiro.com.br colocando o número do seu cartão: 1917116965A4137
Message-ID: From metaperl at gmail.com Thu Sep 14 17:14:02 2006 From: metaperl at gmail.com (metaperl) Date: 14 Sep 2006 14:14:02 -0700 Subject: best small database? In-Reply-To: References: <0rdNg.6440$c22.5757@trnddc07> Message-ID: <1158268442.259665.169570@i42g2000cwa.googlegroups.com> David Isaac wrote: > Thanks to all for the suggestions and much else > to think about. > > Summarizing: > > Those who were willing to consider a database suggested: > anydbm > Gadfly > SQLite (included with Python 2.5) > Schevo You missed buzhug: http://buzhug.sourceforge.net/ A very thorough pure Python database. From limodou at gmail.com Thu Sep 14 08:45:11 2006 From: limodou at gmail.com (limodou) Date: Thu, 14 Sep 2006 20:45:11 +0800 Subject: Looking for the Perfect Editor In-Reply-To: <48iig2hl4h93vmp70t62gnoslfqkitso64@4ax.com> References: <1157658338.661425.207140@b28g2000cwb.googlegroups.com> <48iig2hl4h93vmp70t62gnoslfqkitso64@4ax.com> Message-ID: <505f13c0609140545j64eac05fk54162915b373ad7b@mail.gmail.com> On 9/14/06, Franz Steinhaeusler wrote: > On 7 Sep 2006 13:18:22 -0700, "Omar" > wrote: > > >I'd love the perfect editor that would be: > > > >a) free > > DrPython and spe; both written in Python and wxPython using SciTe's > control scintilla) and SciTE. > > DrPython on: > http://sourceforge.net/projects/drpython/ (Projectpage) > http://drpython.sourceforge.net/ (Homepage) > > > > >b) enable me to drag and drop code snippets from a sort of browser into > >the code > > DrPython Codemarks plugin. > > > > >c) can run programs right from within > > DrPython => Program => Run (default F5) > > > > >d) can edit > > - PYTHON > DrPython, spe, SciTE. > > > - Javascript > no definite support. > > > - HTML > DrPython (the others, I don't know) > > > - actionscript (since I'm also learning flash) > > Sepy on Sourceforge (also written in Python with wxPython) > http://sourceforge.net/projects/sepy/ > > > > >e) easy to learn > > > > SciTE especially. > > >suggestions? > These things UliPad also can do. And it also support html, javascript, css, java, etc syntax highlight. UliPad also support Input Assistant, even include custom calltips and auto-complete, and many features, you can find in http://wiki.woodpecker.org.cn/moin/UliPad It also has a directory browser, wizard, plugins-system, code snippets manage. Just using it, you'll find out what it's. -- I like python! My Blog: http://www.donews.net/limodou UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad UliPad Maillist: http://groups.google.com/group/ulipad From felipe.lessa at gmail.com Thu Sep 7 10:20:12 2006 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Thu, 7 Sep 2006 11:20:12 -0300 Subject: [ANN] IronPython 1.0 released today! In-Reply-To: References: Message-ID: 2006/9/5, Jim Hugunin : > I'm extremely happy to announce that we have released IronPython 1.0 today! > http://www.codeplex.com/IronPython Does IronPython runs Twisted? -- Felipe. From p.lavarre at ieee.org Tue Sep 26 15:34:42 2006 From: p.lavarre at ieee.org (p.lavarre at ieee.org) Date: 26 Sep 2006 12:34:42 -0700 Subject: Python CTypes translation of (pv != NULL) In-Reply-To: References: <1159230428.257680.296550@m73g2000cwd.googlegroups.com> Message-ID: <1159299282.448590.325200@h48g2000cwc.googlegroups.com> > > > > Q: The C idea of (pv != NULL) ... > > > > CTypes tutorial ... == False ... == None ... is None ... > > Generally ... 'if pv: ....' ... should work. > Except for c_void_p, c_char_p and c_wchar_p instances. Please can we give me an example of these exceptions? Indeed those types are the _p types I use most often. Now here 'bool(pv)' and 'if pv' tell me that null is False and non-null is True, for every kind of null or non-null that I know how to construct. Is that mapping somehow not reliable across all instances? Or not cross-platform? You did mean to say that the Python fragments 'bool(pv)' and 'if pv' somehow are not accurate translations of the C fragments 'pv != NULL' and 'if pv'? Something other kind of Python is? From duncan.booth at invalid.invalid Thu Sep 21 16:35:25 2006 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 21 Sep 2006 20:35:25 GMT Subject: Strange behaviour of 'is' References: Message-ID: "Fijoy George" wrote: > My understanding was that every literal is a constructure of an > object. Thus, the '2.' in 'x = 2.' and the '2.' in 'x is 2.' are > different objects. Therefore, the comparison yields false. What gave you that idea? The compiler may or may not fold together identical immutable objects when it compiles your code. In your first example the comparison is False because the two lines are compiled separately. If compiled together it might have returned True: >>> x = 2.; x is 2. True However this is purely an implementation detail. The language doesn't actually require either behaviour. From rhymes at myself.com Tue Sep 5 13:36:53 2006 From: rhymes at myself.com (Lawrence Oluyede) Date: Tue, 5 Sep 2006 19:36:53 +0200 Subject: threading support in python References: <1157381880.697001.260070@m73g2000cwd.googlegroups.com> <1157387626.242107.92070@p79g2000cwp.googlegroups.com> <1157398593.191972.240270@p79g2000cwp.googlegroups.com> <1157422764.573537.116340@m79g2000cwm.googlegroups.com> <1157468259.924431.270850@h48g2000cwc.googlegroups.com> <1hl7hvw.qrhoy6180zbjcN%rhymes@myself.com> Message-ID: <1hl7i8q.bs2uvl1urk88wN%rhymes@myself.com> Lawrence Oluyede wrote: > Take a look here: > http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/00 > 2049.html > and this thread: > http://www.mail-archive.com/users at lists.ironpython.com/msg01826.html Also this: http://www.codeproject.com/useritems/ipaspnet.asp Google is you friend! :-) -- Lawrence - http://www.oluyede.org/blog "Nothing is more dangerous than an idea if it's the only one you have" - E. A. Chartier From steve at holdenweb.com Sat Sep 30 17:52:48 2006 From: steve at holdenweb.com (Steve Holden) Date: Sat, 30 Sep 2006 22:52:48 +0100 Subject: Escapeism In-Reply-To: <1159642864.799937.247960@h48g2000cwc.googlegroups.com> References: <1159607884.182985.63200@m7g2000cwm.googlegroups.com> <1159635727.840033.169540@m73g2000cwd.googlegroups.com> <1159642864.799937.247960@h48g2000cwc.googlegroups.com> Message-ID: Kay Schluehr wrote: > Steve Holden wrote: > >>Kay Schluehr wrote: >> >>>Sybren Stuvel wrote: >>> >>> >>>>Kay Schluehr enlightened us with: >>>> >>>> >>>>>Usually I struggle a short while with \ and either succeed or give up. >>>>>Today I'm in a different mood and don't give up. So here is my >>>>>question: >>>>> >>>>>You have an unknown character string c such as '\n' , '\a' , '\7' etc. >>>>> >>>>>How do you echo them using print? >>>>> >>>>>print_str( c ) prints representation '\a' to stdout for c = '\a' >>>>>print_str( c ) prints representation '\n' for c = '\n' >>>>>... >>>>> >>>>>It is required that not a beep or a linebreak shall be printed. >>>> >>>>try "print repr(c)". >>> >>> >>>This yields the hexadecimal representation of the ASCII character and >>>does not simply echo the keystrokes '\' and 'a' for '\a' ignoring the >>>escape semantics. One way to achieve this naturally is by prefixing >>>'\a' with r where r'\a' indicates a "raw" string. But unfortunately >>>"rawrification" applies only to string literals and not to string >>>objects ( such as c ). I consider creating a table consisting of pairs >>>{'\0': r'\0','\1': r'\1',...} i.e. a handcrafted mapping but maybe >>>I've overlooked some simple function or trick that does the same for >>>me. >>> >> >>No, you've overlooked the fact that if you print the string containing >>the two characters "backslash" and "lower case a" then it will print >>exactly those two characters. See: >> >>In [30]: c = "\\a" >> >>In [31]: len(c) >>Out[31]: 2 >> >>In [32]: print c >>\a > > > I'm interested in the transition between two literals from which one is > a string literal containing \ as a "meta character" s.t. '\a' has > actually length 1 and is beep when printed to stdout and its "raw" form > without a meta character interpretation of \ that leads to the result > you described. Using the string prefix r to '\a' indicates the raw form > to the compiler. But there seems to be no runtime counterpart. I've > suggested a naive implementation such as > > def rawform(c): > return {'\a': r'\a'}[c] > > Here the function returns for the single input character '\a' the two > character raw form by means of escaping \ ( and raises a KeyError > exception otherwise ). > > >>>>c = '\a' >>>>print rawform(c) > > \a > > This has the same effect as writing: > >>>>c = r'\a' >>>>print c > > \a > > But there is some ambiguity due to the the fact that applying '\7' to > rawform() yields r'\a' and not r'\7'. So one needs more specification > for disambiguation using e.g. an extra parameter. > In [33]: "\7" == "\a" Out[33]: True Sorry. It can't possibly know which of two alternative representation were used to represent a particular character in a literal. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From sjmachin at lexicon.net Tue Sep 5 19:29:11 2006 From: sjmachin at lexicon.net (John Machin) Date: 5 Sep 2006 16:29:11 -0700 Subject: Removing from a List in Place In-Reply-To: <1157497536.751534.211710@e3g2000cwe.googlegroups.com> References: <1157497536.751534.211710@e3g2000cwe.googlegroups.com> Message-ID: <1157498951.249712.208640@d34g2000cwd.googlegroups.com> bayerj wrote: > > I'm going to assume that it's supposed to work like this, but could > > someone tell me the reasoning behind it? I.E. why is 3 skipped? > > Because: > > >>> alist[2] > 3 > > You are removing the third item, not the second. This is incorrect. You may need to remind yourself that the arg of remove is a value to be searched for and then removed, not an index. del alist[2] would remove the third item. You may have been confused by the OP's obfuscatory example alist = [1, 2, 3]. Consider this equivalent: | >>> alist = ['foo', 'bar', 'zot'] | >>> for item in alist: | ... print item | ... if item == 'bar': | ... alist.remove(item) | ... | foo | bar | >>> alist | ['foo', 'zot'] | >>> HTH, John From fredrik at pythonware.com Sun Sep 17 11:16:03 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 17 Sep 2006 17:16:03 +0200 Subject: Python programs always open source? References: <450d07e1$0$19729$88260bb3@free.teranews.com> <1158505549.695813.206860@h48g2000cwc.googlegroups.com> Message-ID: "Jay" wrote: > Speaking of the bytecode, how does one create it? http://effbot.org/zone/python-compile.htm#compiling-python-modules From ldo at geek-central.gen.new_zealand Sat Sep 23 08:14:27 2006 From: ldo at geek-central.gen.new_zealand (Lawrence D'Oliveiro) Date: Sun, 24 Sep 2006 00:14:27 +1200 Subject: "re" vs "sre"? References: Message-ID: In message , Peter Otten wrote: > Lawrence D'Oliveiro wrote: > >> I learned about Python regular expressions from the Web documentation >> . This describes a module named >> "re". Then I saw some code written by a colleague, and he was using a >> module named "sre". I checked my Python 2.4.3 installation, and sure >> enough, I have a module named "sre" as well as "re". Curious, I fired up >> an interactive Python session, and looked to see what the docstrings were >> for these modules. And for the "re" module, the help says: >> >> re - Minimal "re" compatibility wrapper. See "sre" for >> documentation. >> >> and "sre" seems to have the more complete set of docstrings. >> >> So which one should we be using? > > Here's what Python 2.5 has to say on the matter: >>>> import sre > __main__:1: DeprecationWarning: The sre module is deprecated, please > import re. That's good. Does "help(re)" still say it's a "compatibility wrapper"? From corridor.infinite at gmail.com Wed Sep 6 13:17:43 2006 From: corridor.infinite at gmail.com (Infinite Corridor) Date: 6 Sep 2006 10:17:43 -0700 Subject: 22, invalid agument error Message-ID: <1157563063.063705.317970@m73g2000cwd.googlegroups.com> I am trying to get an echoserver running on my N80 Nokia cell phone, that uses "python for s60". What worked: I ran echoclient on the phone and echoserver on my Powerbook and it worked. What doesnt work: When I try running the same scripts, so that I run echoclient on the laptop and echoserver on the cellphone, the echoserver doesnt work(Yes, I have changed the IP address correctly). The error I get is: File "e:/python/echoserver.py". line 15 in ? sockobj.bind(('',40007)) # bind it to server port number File "", line 1, in bind error: (22, 'Invalid argument') Why is this program showing an error on the cellphone when it is running fine on the Mac? Thanks, any help will be appreciated. Dave From tim.golden at viacom-outdoor.co.uk Wed Sep 6 05:53:54 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 6 Sep 2006 10:53:54 +0100 Subject: Import a textfile to MS SQL with python Message-ID: [joel.sjoo at gmail.com] | I'm a dba for SQL server and I Will import a textfile to SQL. For | example I use a file with 3 columns. ID, Name and Surname and the | columns are tab separated. I don't know much about programming. | Anyway, I use this code below. It works, but it will not split the | columns. Split the problem into two parts: 1) Determine the correct row/column values from your tab-separated file 2) Write the values into your database table The first part is probably best handled by the built-in csv module. While you can roll your own there are quite a few gotchas you have to dodge - embedded delimiters and so on. Something like this: import csv # by default reader uses "," as delimiter; specify tab instead reader = csv.reader (open ("test.tsv"), delimiter="\t") data = [] for line in reader: data.append (line) # or data = list (reader) print data # # Something like: # [[1, "Tim", "Golden"], [2, "Fred", "Smith"], ...] # OK, now you've got a list of lists, each entry being one row in your original file, each item one column. To get it into your database, you'll need something like the following -- ignoring the possibility of executemany. # uses data from above import # pymssql, oracle, sqlite, etc. db = .connect (... whatever you need ...) q = db.cursor () for row in data: q.execute ( "INSERT INTO python (id, namn, efternamn) VALUES (?, ?, ?)", row ) db.commit () # if needed etc. db.close () This works because the DB-API says that an .execute takes as its first parameter the SQL command plus any parameters as "?" (or something else depending on the paramstyle, but this is probably the most common). Then as the second parameter you pass a list/tuple containing as many items as the number of "?" in the command. You don't need to worry about quoting for strings etc; the db interface module should take care of that. Behind the scenes, this code will be doing something like this for you: INSERT INTO python (id, namn, efternamn) VALUES (1, 'Tim', 'Golden') INSERT INTO python (id, namn, efternamn) VALUES (2, 'Fred', 'Smith') and so on, for all the rows in your original data. Some db interface modules implement .executemany, which means that you specify the statement once and pass the whole list at one go. Whether it's more efficient than looping yourself depends on what's happening behind the scenes. It's certainly a touch tidier. Hope all that is intelligble and helpful TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From skip at pobox.com Tue Sep 5 16:20:03 2006 From: skip at pobox.com (skip at pobox.com) Date: Tue, 5 Sep 2006 15:20:03 -0500 Subject: Is it just me, or is Sqlite3 goofy? In-Reply-To: <1157484212.885076.304340@h48g2000cwc.googlegroups.com> References: <1157418942.105174.228650@p79g2000cwp.googlegroups.com> <1157477207.223616.210780@h48g2000cwc.googlegroups.com> <1157484212.885076.304340@h48g2000cwc.googlegroups.com> Message-ID: <17661.56307.689596.660304@montanaro.dyndns.org> >> What I'll do is re-format my rant, suggest how *I* would do the >> documentation, fix the errors I found in the examples and send it off >> to the Python bug tracking as suggested in the manuals. >> How's that as a plan? That's fine. Reformat your rant as a documentation bug report on SourceForge: http://sourceforge.net/projects/python If you mention specific sqlite documentation urls you think should be referenced in the pysqlite docs it would make it easier to accept. Skip From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Sep 22 10:58:30 2006 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 22 Sep 2006 16:58:30 +0200 Subject: Python 2.5 WinXP AMD64 References: <1158845864.338644.23180@d34g2000cwd.googlegroups.com> <45129e77$0$23923$626a54ce@news.free.fr> <4nfrhbFa4kbiU1@individual.net> <9xSQg.3515$vJ2.2333@newssvr12.news.prodigy.com> Message-ID: <4nic0mFag01tU3@individual.net> Bryan Olson wrote: > The O.P. has a 64-bit Athlon processor, but is running a 32-bit > OS. The processor emulates its 32-bit predecessor in "legacy > mode", so 32-bit software runs. Ah, of course. Thanks for all replies! :) Regards, Bj?rn -- BOFH excuse #13: we're waiting for [the phone company] to fix that line From fredrik at pythonware.com Tue Sep 26 12:48:15 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 26 Sep 2006 18:48:15 +0200 Subject: A critique of cgi.escape In-Reply-To: <451948FC.9040009@sweetapp.com> References: <7xu02u1wl6.fsf@ruckus.brouhaha.com> <451948FC.9040009@sweetapp.com> Message-ID: Brian Quinlan wrote: > I'd have to dig through the revision history to be sure, but I imagine > that cgi.escape was originally only used in the cgi module (and there > only in it's various print_* functions). Then it started being used by > other core Python modules e.g. cgitb, DocXMLRPCServer. nah, it's an official API for simple HTML/XML escaping, and it's perfectly usable for what it's supposed to be used for. however, if you're doing serious web hacking, you *should* of course work at the XHTML information set level whenever you can, where you focus on the data you want to publish (using Unicode strings for any- thing that's even remotely resembles human text), and the framework makes sure that it gets to the other side in once piece, using HTML4 or XHTML as necessary, and escaping and encoding things properly and efficiently on the way. it's 2006. transferring data from Python applications to web browsers is no rocket science. From fdu.xiaojf at gmail.com Thu Sep 21 03:34:21 2006 From: fdu.xiaojf at gmail.com (fdu.xiaojf at gmail.com) Date: Thu, 21 Sep 2006 15:34:21 +0800 Subject: Is it possible to save a running program and reload next time ? Message-ID: <4512407D.5020307@gmail.com> Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the program can save all running data to a file when I want it to stop, and can reload the data and continue to run from where it stops when the computer is free ? Regards, xiaojf From meyer at acm.org Sat Sep 9 14:54:20 2006 From: meyer at acm.org (Andre Meyer) Date: Sat, 9 Sep 2006 20:54:20 +0200 Subject: Building Python Based Web Application In-Reply-To: <4503071e$0$27248$636a55ce@news.free.fr> References: <4503071e$0$27248$636a55ce@news.free.fr> Message-ID: <7008329d0609091154o12a1b4e4md33012dbb7d97f38@mail.gmail.com> Karrigell can really be recommended. Simple, but powerful. No need for SQL (though it can), just use the pure Python buzhug, Karrigell services and (Cheetah) templates. Works great. regards Andre -------------- next part -------------- An HTML attachment was scrubbed... URL: From tenax.raccoon at gmail.com Sat Sep 2 23:02:32 2006 From: tenax.raccoon at gmail.com (Jason) Date: 2 Sep 2006 20:02:32 -0700 Subject: How to run Python file? In-Reply-To: <1157205463.043880.67340@m79g2000cwm.googlegroups.com> References: <1157205463.043880.67340@m79g2000cwm.googlegroups.com> Message-ID: <1157252552.558447.260150@b28g2000cwb.googlegroups.com> mistral wrote: > I have installed ActivePython > http://www.activestate.com/Products/ActivePython/ > How I can run Python file, test.py? You can open up the folder containing the "test.py" file, then double-click on the file to run it. A command-line window should pop up, and your program will run in it. Once the Python program is done running, the command window will probably close immediately. --Jason From sjmachin at lexicon.net Mon Sep 25 10:35:19 2006 From: sjmachin at lexicon.net (John Machin) Date: 25 Sep 2006 07:35:19 -0700 Subject: Leave the putdowns in the Perl community, the Python world does not need them In-Reply-To: References: <1159188351.960448.43660@d34g2000cwd.googlegroups.com> Message-ID: <1159194919.604700.233570@b28g2000cwb.googlegroups.com> Steven Bethard wrote: > metaperl wrote: > > I was shocked to see the personal insults hurled in this thread: > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/d0758cb9545cad4b > > I see that this is a Fredrik Lundh thread. I've felt the same way > before, but Fredrik has been around a long time[1] and if you listen [snip] > > [1] He's the author of Python's unicode support and Python 2.5's > elementtree module. and a very serious upgrade of the re kit plus PIL plus a book .... and BTW: insult? OP, look at the TV news; if insult's the worst that happens to you, burn some joss and be very grateful :-) From fredrik at pythonware.com Fri Sep 29 13:00:15 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 29 Sep 2006 19:00:15 +0200 Subject: Making sure script only runs once instance at a time. In-Reply-To: <7xac4izkkv.fsf@ruckus.brouhaha.com> References: <451D25A3.7010803@googlemail.com> <7xac4izkkv.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: > Don't use the presence or absence of a file as a lock. Have the file > there all the time, and have the app open it and use fcntl to get an > exclusive kernel lock on the file descriptor. doesn't work on all file systems, though... From simon at brunningonline.net Tue Sep 26 06:27:44 2006 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 26 Sep 2006 11:27:44 +0100 Subject: concat next line with previous In-Reply-To: <1159265785.829893.47120@m73g2000cwd.googlegroups.com> References: <1159265785.829893.47120@m73g2000cwd.googlegroups.com> Message-ID: <8c7f10c60609260327q28c95e04xd310c7b4469ebdc9@mail.gmail.com> On 26 Sep 2006 03:16:25 -0700, s99999999s2003 at yahoo.com wrote: > what is the python way to concat 2 lines eg > > line 1 with some text > line 2 with some text > > i want to bring line 2 up , such that i get one whole string. > > line 1 with some text line 2 with some text line1 = "line 1 with some text" line2 = "line 2 with some text" # Simplest way: line3 = line1 + line2 # More general - joining a sequence of strings, with delimiter lines = [line1, line2] line3 = ", ".join(lines) -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From fredrik at pythonware.com Thu Sep 28 01:29:31 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 28 Sep 2006 07:29:31 +0200 Subject: Difference between two dates in seconds In-Reply-To: References: <495c267b0609271112h1deb1926kdcec5b074efeba45@mail.gmail.com> Message-ID: Steven D'Aprano wrote: > Arguably a better solution would be to do this: > > seconds = td.days * 24*60*60 + td.seconds if you're targeting an audience that cannot figure out what the expression does based on the names of the result and the names of the attributes, chances are that 24*60*60 won't make a lot more sense either. in such cases, you're better off using a named constant. (that also allows you to change the value, would the need arise.) why stop at 24*60*60, btw? if you're really serious about working from basic units, you should probably make it 24*60*60*9192631770*BASIC_SECOND_UNIT ::: and yes, if you want the CPython compilator to do the multiplication for you, put parentheses around the subexpression: >>> def get_seconds(td): ... return td.days * (24*60*60) + td.seconds ... >>> import dis >>> dis.dis(get_seconds) 2 0 LOAD_FAST 0 (td) 3 LOAD_ATTR 0 (days) 6 LOAD_CONST 4 (86400) 9 BINARY_MULTIPLY 10 LOAD_FAST 0 (td) 13 LOAD_ATTR 1 (seconds) 16 BINARY_ADD 17 RETURN_VALUE From uche.ogbuji at gmail.com Fri Sep 29 09:10:20 2006 From: uche.ogbuji at gmail.com (uche.ogbuji at gmail.com) Date: 29 Sep 2006 06:10:20 -0700 Subject: XSLT speed comparisons In-Reply-To: <1159392275.988709.72990@m7g2000cwm.googlegroups.com> References: <1159392275.988709.72990@m7g2000cwm.googlegroups.com> Message-ID: <1159535420.602412.71400@m7g2000cwm.googlegroups.com> Damian wrote: > Hi, I'm from an ASP.NET background an am considering making the switch > to Python. I decided to develop my next project in tandem to test the > waters and everything is working well, loving the language, etc. > > What I've got is: > two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for > XML/XSLT) > both on the same box (Windows Server 2003) > both using the same XML, XSLT, CSS > > The problem is, the Python version is (at a guess) about three times > slower than the ASP one. I'm very new to the language and it's likely The ASP one being MSXML, right? In that case that result doesn't surprise me. > that I'm doing something wrong here: Now wrong, but we can definitely simplify your API > from os import environ > from Ft.Lib.Uri import OsPathToUri > from Ft.Xml import InputSource > from Ft.Xml.Xslt import Processor > > def buildPage(): > try: > xsluri = OsPathToUri('xsl/plainpage.xsl') > xmluri = OsPathToUri('website.xml') > > xsl = InputSource.DefaultFactory.fromUri(xsluri) > xml = InputSource.DefaultFactory.fromUri(xmluri) > > proc = Processor.Processor() > proc.appendStylesheet(xsl) > > params = {"url":environ['QUERY_STRING'].split("=")[1]} > for i, v in enumerate(environ['QUERY_STRING'].split("/")[1:]): > params["selected_section%s" % (i + 1)] = "/" + v > > return proc.run(xml, topLevelParams=params) > except: > return "Error blah blah" > > print "Content-Type: text/html\n\n" > print buildPage() This should work: from os import environ from Ft.Xml.Xslt import Transform def buildPage(): try: params = {"url":environ['QUERY_STRING'].split("=")[1]} for i, v in enumerate(environ['QUERY_STRING'].split("/")[1:]): params["selected_section%s" % (i + 1)] = "/" + v return Transform('website.xml', 'xsl/plainpage.xsl', topLevelParams=params) except: return "Error blah blah" print "Content-Type: text/html\n\n" print buildPage() -- % -- For what it's worth I just developed, and switched to WSGI middleware that only does the transform on the server side if the client doesn't understand XSLT. It's called applyxslt and is part of wsgi.xml [1]. That reduces server load, and with caching (via Myghty), there's really no issue for me. For more on WSGI middleware see [2]. [1] http://uche.ogbuji.net/tech/4suite/wsgixml/ [2] http://www.ibm.com/developerworks/library/wa-wsgi/ -- Uche Ogbuji Fourthought, Inc. http://uche.ogbuji.net http://fourthought.com http://copia.ogbuji.net http://4Suite.org Articles: http://uche.ogbuji.net/tech/publications/ From simonwittber at gmail.com Wed Sep 13 03:26:21 2006 From: simonwittber at gmail.com (Simon Wittber) Date: 13 Sep 2006 00:26:21 -0700 Subject: Help me use my Dual Core CPU! References: <1158063943.007271.86000@m73g2000cwd.googlegroups.com> <45071c6d$0$576$ed2619ec@ptn-nntp-reader03.plus.net> <1158128695.301849.148210@p79g2000cwp.googlegroups.com> <7x8xkol0n9.fsf@ruckus.brouhaha.com> Message-ID: <1158132381.716706.243040@e63g2000cwd.googlegroups.com> Paul Rubin wrote: > "Simon Wittber" writes: > > I've just noticed that os.fork is not available on Win32. Ouch. > > Use the subprocess module. I can't see how subprocess.Popen can replace a fork. Using a manually started process is not really viable, as it does not automatically share pre-built (read-only) data between the processes. If it can, I'd really like to know how... Yikes. This is a bummer. The conclusion seems to be, I cannot use any common cross platform, true concurrency strategies in my games. On top of that, I can't really use any form of concurrency on Win32. Lets hope we get some super fast SMP friendly backends for PyPy sooner rather than later! -Sw. From maric at aristote.info Fri Sep 8 07:56:47 2006 From: maric at aristote.info (Maric Michaud) Date: Fri, 8 Sep 2006 13:56:47 +0200 Subject: Request for tips on my first python script. In-Reply-To: References: Message-ID: <200609081356.47882.maric@aristote.info> Le vendredi 08 septembre 2006 13:41, Sybren Stuvel a ?crit?: > > HOME = os.path.expanduser("~") > > I wouldn't use this. Just use os.environ['HOME']. In most cases it > turns out to be the same directory, but it adds more flexibility. If > someone wants your app to read/write to another directory, he/she can > simply change the HOME environment variable. and ? maric at redflag2 jeu sep 07 09:17:51:~/test$ export HOME=/etc maric at redflag2 ven sep 08 13:53:17:/home/maric/test$ cd ~ maric at redflag2 ven sep 08 13:53:22:~$ pwd /etc maric at redflag2 ven sep 08 13:55:46:~$ python -c 'import os > print os.path.expanduser("~") > ' /etc -- _____________ Maric Michaud _____________ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 From sc_wizard29 at hotmail.com Fri Sep 15 03:18:14 2006 From: sc_wizard29 at hotmail.com (sc_wizard29 at hotmail.com) Date: 15 Sep 2006 00:18:14 -0700 Subject: Check if variable is an instance of a File object Message-ID: <1158304694.673361.62600@b28g2000cwb.googlegroups.com> Hi everyone, Maybe these questions will sound strange to you, but I sometime have a hard time switching from Java to Python ;-) Let's say I have a function like this : def show_lines(file): for next_line in file: ... What can I do to be sure that the input argument is indeed a 'File' object ? #1 : should I start by checking that 'file' is indeed an instance of a File object ? (and how do I do this ?) #2 : should I do nothing ? (but I don't like the idea of risking to have a runtime exception raised somewhere) Thanks for helping... From steve at holdenweb.com Tue Sep 12 15:50:12 2006 From: steve at holdenweb.com (Steve Holden) Date: Tue, 12 Sep 2006 20:50:12 +0100 Subject: "filtered view" upon lists? In-Reply-To: <450705F0.8050002@freakmail.de> References: <878xkpb5wa.fsf@gmail.com> <4506D471.7010905@freakmail.de> <450705F0.8050002@freakmail.de> Message-ID: <45070F74.3000706@holdenweb.com> Wildemar Wildenburger wrote: > Steve Holden wrote: > >>> I think SQL views are the direct analog. >>> >> I don't think they are. If you add a non-conforming row to a SQL view >> it doesn't appear int he view. If you modify a row in an updateable >> view so it no longer confirms with the view's conditions it disappears >> from the view. > > Me and my wording again: I typed 'direct analog' but meant 'somewhat > analog'. > >> Also you don't say whether changes to l are supposed to be reflected >> in f in the same way that changes to f are reflected in l. > > Right. Yes, the synchronicity (a word?) is meant to be in both directions. > >> It might be better if you were to explain your use case: what is this >> beast supposed to be for? > > I have a database of interconnected objects. Each object has a list > tuples; these tuples hold references to other objects and details about > the type of connection. > The 'views' I am imagining are sub-lists of this one list, based on the > connection types. Order is important here, that's why I'm not using sets. > BTW: I have gone the way of nested lists before and found it too rigid > and complicated to use. > > >>> A bit clearer now? >>> >> Hardly at all. Frankly it doesn't seem as though you really know what >> the specifications are yourself, so you can hardly expect us to divine >> them by use of our psychic powers. Besides which, psychic powers cost >> extra ;-) > > Right again. I'm not sure what I want yet as I'm still exploring ideas. > If something /like/ the above had existed (which by now I'm gathering is > not the case) I'd just adapted my ideas to the specs given. > > >> So give us that use case so we get a bit more insight into why you >> even see the need for such a thing and how you want it ti behave. Or >> is all this just theoretical? > > No no, its very much real. Just not as fleshed out as it might be --- > I'm sort of an explorative coder; I usually don't know how something is > going to work until it works. > That's all very well, but you might want to Google for "YAGNI". You still haven't given us mcuh of a clue about the real need. > Thx for the effort :)Happy to (tray to) help. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From bearophileHUGS at lycos.com Sat Sep 30 21:15:04 2006 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: 30 Sep 2006 18:15:04 -0700 Subject: builtin regular expressions? In-Reply-To: References: <451e37a5$1@news.vo.lu> Message-ID: <1159665303.981559.101610@k70g2000cwa.googlegroups.com> Thorsten Kampe: > And the simple reason why Regular Expressions are not a part of the > core Python language is that Regular Expressions are overrated. They > are simply not the preferred tool for every kind of text manipulation > and extraction. And their syntax is ugly and low level, they are difficult to read and debug. A way better syntax can probably be adopted (reverb and Pyparsing seem much more pythonic). Bye, bearophile From steve at holdenweb.com Fri Sep 22 21:16:58 2006 From: steve at holdenweb.com (Steve Holden) Date: Fri, 22 Sep 2006 21:16:58 -0400 Subject: Isn't bool __invert__ behaviour "strange"? In-Reply-To: <1158959361.458232.278660@h48g2000cwc.googlegroups.com> References: <1158934100.450529.304810@i3g2000cwc.googlegroups.com> <1158938953.622976.184960@i3g2000cwc.googlegroups.com> <1158942134.691147.308530@i42g2000cwa.googlegroups.com> <4nihfbFa61lsU1@individual.net> <1158943743.930685.106630@m73g2000cwd.googlegroups.com> <4nivr5Fan2s7U2@individual.net> <1158959361.458232.278660@h48g2000cwc.googlegroups.com> Message-ID: MonkeeSage wrote: > Hi Saizan, > > I don't really see anything wrong with creating a custom class for > evaluating those kinds of logical statements. It does make the code for > statements more concise and easy to follow (with less binding > ambiguity). Mabye something like this would help: > > class logic(int): > def __sub__(self): > return logic(not self) > def eval(self, statement): > return bool(statement) > def make_logical(self, *args): > out = [] > for arg in args: > out.append(logic(arg)) > return out > > l = logic() > # init a buch of variables (or a list) at once > x, y, z = l.make_logical(True, False, True) > # or one at a time > v = logic(False) > # evaluate a statement > print l.eval((x and y) or (-z or -v)) # True > Is this a serious suggestion, or simply an attempt at sardonic obscurantism? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From steve at holdenweb.com Tue Sep 26 20:05:12 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 27 Sep 2006 01:05:12 +0100 Subject: QuoteSQL In-Reply-To: References: Message-ID: Lawrence D'Oliveiro wrote: > In message , Steve > Holden wrote: [...] >>Sadly your assertions alone fail to convince. Perhaps you could provide >>a concrete example? > > > Sorry, that turned out to be wrong. You do in fact need to escape the > escapes on wildcards. Thank you. -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From sjmachin at lexicon.net Tue Sep 26 09:02:44 2006 From: sjmachin at lexicon.net (John Machin) Date: 26 Sep 2006 06:02:44 -0700 Subject: Printing a percent sign In-Reply-To: References: <1159216705.649649.116260@d34g2000cwd.googlegroups.com> <1159217483.513555.126120@e3g2000cwe.googlegroups.com> <1159230293.270822.50390@d34g2000cwd.googlegroups.com> <1159263309.699677.301130@m7g2000cwm.googlegroups.com> <1159268765.544655.229070@i3g2000cwc.googlegroups.com> Message-ID: <1159275763.985455.153220@m7g2000cwm.googlegroups.com> Fredrik Lundh wrote: > John Machin wrote: > > > I'll take your word for it; it's been quite a while :-) *Something* in > > the dim dark past worked like that > > makefiles? Bingo! Actually, double bingo!! >From the docs for GNU Make: """ Because dollar signs are used to start make variable references, if you really want a dollar sign in a target or prerequisite you must write two of them, `$$' (see How to Use Variables). If you have enabled secondary expansion (see Secondary Expansion) and you want a literal dollar sign in the prerequisites lise [sic], you must actually write four dollar signs (`$$$$'). """ Cheers, John From nogradi at gmail.com Fri Sep 15 18:49:13 2006 From: nogradi at gmail.com (Daniel Nogradi) Date: Sat, 16 Sep 2006 00:49:13 +0200 Subject: something for itertools In-Reply-To: <9afea2ac0609151528na82058fs5d454274b4e785ab@mail.gmail.com> References: <9afea2ac0609151528na82058fs5d454274b4e785ab@mail.gmail.com> Message-ID: <5f56302b0609151549t48dd70d7pd136f29255bc7cf6@mail.gmail.com> > > In a recent thread, > > http://mail.python.org/pipermail/python-list/2006-September/361512.html, > > a couple of very useful and enlightening itertools examples were given > > and was wondering if my problem also can be solved in an elegant way > > by itertools. > > > > I have a bunch of tuples with varying lengths and would like to have > > all of them the length of the maximal and pad with None's. So > > something like > > > > a = ( 1, 2, 3 ) > > b = ( 10, 20 ) > > c = ( 'x', 'y', 'z', 'e', 'f' ) > > > > should turn into > > > > a = ( 1, 2, 3, None, None ) > > b = ( 10, 20, None, None, None ) > > c = ( 'x', 'y', 'z', 'e', 'f' ) > > > > or maybe a one liner :) > > >>> (a + 5*(None,))[:5] > (1, 2, 3, None, None) > > >>> pad_to = 5 > >>> (a + pad_to*(None,))[:pad_to] > (1, 2, 3, None, None) > >>> (b + pad_to*(None,))[:pad_to] > (10, 20, None, None, None) > >>> (c + pad_to*(None,))[:pad_to] > ('x', 'y', 'z', 'e', 'f') > >>> Well, something like this is what I actually do. But for this first I have to loop over all tuples and pick out the maximal length, so over all it won't be a one liner but two loops. From sandravandale at yahoo.com Mon Sep 18 15:44:32 2006 From: sandravandale at yahoo.com (Sandra-24) Date: 18 Sep 2006 12:44:32 -0700 Subject: Cross-process dictionary/hashtable Message-ID: <1158608672.610841.271530@b28g2000cwb.googlegroups.com> A dictionary that can be shared across processes without being marshaled? Is there such a thing already for python? If not is there one for C maybe? I was just thinking how useful such a thing could be. It's a great way to share things between processes. For example I use a cache that subclasses a dictionary. It would be trivial to modify it to work across processes by changing the base class and the locking mechanism. Thanks, -Sandra From onurb at xiludom.gro Mon Sep 18 08:10:11 2006 From: onurb at xiludom.gro (Bruno Desthuilliers) Date: Mon, 18 Sep 2006 14:10:11 +0200 Subject: Where can i download mod_webkit from? In-Reply-To: <1158544714.687305.163330@m73g2000cwd.googlegroups.com> References: <1158544714.687305.163330@m73g2000cwd.googlegroups.com> Message-ID: <450e8ca4$0$15663$626a54ce@news.free.fr> goykhmanster at gmail.com wrote: > Hi > > I am trying to get webware for python running on Apache. I want to get > it working with mod_webkit, but for the life of me i can't find a > webpage where i can download a source for it or maybe an rpm. If > anyone knows the download page, i'd greatly appreciate if you share it > with me. http://www.webwareforpython.org/WebKit/Docs/InstallGuide.html#mod-webkit """ The source code and a README file describing how to configure and build mod_webkit are located in the Webware/WebKit/Adapters/mod_webkit """ > Thanks > -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in 'onurb at xiludom.gro'.split('@')])" From michele.simionato at gmail.com Wed Sep 20 11:49:39 2006 From: michele.simionato at gmail.com (Michele Simionato) Date: 20 Sep 2006 08:49:39 -0700 Subject: CONSTRUCT - Adding Functionality to the Overall System In-Reply-To: <1158510136.181915.272700@d34g2000cwd.googlegroups.com> References: <1158510136.181915.272700@d34g2000cwd.googlegroups.com> Message-ID: <1158767379.579861.91080@k70g2000cwa.googlegroups.com> (I don't believe I am responding to a notorious troll ...) One (bad) solution is to write in your sitecustomize.py the following: $ echo /usr/lib/python/sitecustomize.py import __builtin__ class Object(object): def debug(self): print 'some debug info' __builtin__.object = Object then you can do for instance >>> class C(object): pass >>> C().debug() some debug info All class inheriting from object will have the additional debug method. However I DO NOT RECOMMEND THIS SOLUTION FOR ANY SERIOUS WORK. For instance, it broke my IPython installation and I am pretty sure it will broke other things too. But it may work for debugging purposes, if not for production use, so I thought it was worth posting. Michee Simionato From gandalf at designaproduct.biz Tue Sep 12 10:05:12 2006 From: gandalf at designaproduct.biz (Laszlo Nagy) Date: Tue, 12 Sep 2006 16:05:12 +0200 Subject: Secure XMLRPC Server / PEM Files In-Reply-To: <1158016994.349214.264610@q16g2000cwq.googlegroups.com> References: <1158001318.771982.319880@m73g2000cwd.googlegroups.com> <4505B54C.30905@designaproduct.biz> <1158005948.883368.185320@m73g2000cwd.googlegroups.com> <1158016994.349214.264610@q16g2000cwq.googlegroups.com> Message-ID: <4506BE98.3030504@designaproduct.biz> Daniel Crespo ?rta: > Hi Laszlo, > > I have read that. It's the wrapper for the usage of OpenSSL, so I have > to install it. I have downloaded the Borland C++ compiler, and I'm > doing so right now, but I'm not getting good results yet. > You do not need any compiler. You just need to install the openssl binaries and the wrapper. > I tried to import OpenSSL, it seems to work. > Great. > Now, I want to try the code I submited earlier, but I need the .pem > files. You told me to change generate.sh to generate.bat. How can I do > that? > Basically, use "del" instead of "rm" and use "move" instead of "mv". Use instead of $1. Moreover, openssl.exe must be on your path. That's all. Try this (untested): openssl req -config openssl.cnf -new -out my-server.csr openssl rsa -in privkey.pem -out my-server.key openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 1500 openssl x509 -in my-server.cert -out my-server.der.crt -outform DER move my-server.csr yourdomain.com.csr move my-server.cert yourdomain.com.cert.pem move my-server.key yourdomain.com.key.pem move my-server.der.crt yourdomain.com.der.crt del privkey.pem Laszlo From peonleon at gmail.com Tue Sep 5 19:47:07 2006 From: peonleon at gmail.com (Leon) Date: 5 Sep 2006 16:47:07 -0700 Subject: Higher-level OpenGL modules References: <1157453086.806159.49430@d34g2000cwd.googlegroups.com> <1157495726.835786.243180@p79g2000cwp.googlegroups.com> Message-ID: <1157500027.412280.109570@i42g2000cwa.googlegroups.com> Thanks guys!, Ill look into your suggestions. I'm actually currently working directly with pyOpenGL, but hopefully Ill find something that would make me more efficient. I might end up writing a library myself. From ralmeida at gmail.com Tue Sep 19 09:18:11 2006 From: ralmeida at gmail.com (Rob De Almeida) Date: 19 Sep 2006 06:18:11 -0700 Subject: Compile AST to bytecode? In-Reply-To: References: <1158668372.706298.123280@i3g2000cwc.googlegroups.com> Message-ID: <1158671891.530951.277330@k70g2000cwa.googlegroups.com> Duncan Booth wrote: > > I would like to compile an AST to bytecode, so I can eval it later. > I'm not sure there are any properly documented functions for converting an > AST to a code object, so your best bet may be to examine what a > pycodegen class like Expression or Module actually does. Thanks, Duncan. It worked perfectly. :-) For arbitrary nodes I just had to wrap them inside an Expression node: >>> ast = compiler.ast.Expression(node) >>> ast.filename = 'dummy' >>> c = compiler.pycodegen.ExpressionCodeGenerator(ast) >>> obj = eval(c.getCode(), scope) --Rob From anthra.norell at tiscalinet.ch Sat Sep 2 04:48:34 2006 From: anthra.norell at tiscalinet.ch (Anthra Norell) Date: Sat, 2 Sep 2006 10:48:34 +0200 Subject: Using eval with substitutions References: <1157022920.299174.22860@m73g2000cwd.googlegroups.com> <1157171590.425375.157380@e3g2000cwe.googlegroups.com> Message-ID: <015601c6ce6c$933d5d60$0201a8c0@mcuf7> ----- Original Message ----- From: "Carl Banks" Newsgroups: comp.lang.python To: Sent: Saturday, September 02, 2006 6:33 AM Subject: Re: Using eval with substitutions > abhishek at ocf.berkeley.edu wrote: > > >>> a,b=3,4 > > >>> x="a+b" ... > Careful. Here be dragons. ... > However, this is just a big potentially dangerous hack. It's probably ... > Carl Banks ----------------------- Dragons indeed! To wit, I did get carried away a little with my suggestions and derived a class Formlua_Expander from SE. A few hours later it worked just beautifully: >>> FE = FORMEX.Formula_Expander () >>> FE.define ('l=102.8') >>> FE.define ('d=8.5') >>> FE.define ('pi=3.14159') >>> FE.define ('r=d/2') >>> FE.define ('section=r*r*pi') >>> FE.define ('pipe_volume=l*section') >>> FE ('pipe_volume') 5833.3828517499996 >>> FE.expand ('pipe_volume') '((102.8)*(((8.5)/2)*((8.5)/2)*(3.14159)))' The expansion cascade: Data Chain ---------------------------------------------------------------------------------- pipe_volume 0 -------------------------------------------------------------------------------- (l*section) 1 -------------------------------------------------------------------------------- (l*(r*r*pi)) 2 -------------------------------------------------------------------------------- (l*((d/2)*(d/2)*pi)) 3 -------------------------------------------------------------------------------- ((102.8)*(((8.5)/2)*((8.5)/2)*(3.14159))) ---------------------------------------------------------------------------------- Wonderful! Some more: >>> FE.define ('m_per_foot=0.3048') >>> FE.define ('pipe_volume_metric=pipe_volume*m_per_foot') >>> FE ('pipe_volume_metric') Traceback (most recent call last): File "", line 1, in -toplevel- FE ('pipe_volume_metric') File "c:\i\sony\fre\src\python\FORMEX.py", line 175, in __call__ try: return eval (expression) File "", line 1 (((102.8)*(((8.5)/2)*((8.5)/2)*(3.14159)))*m_pe((8.5)/2)_foot(102.8)e) ^ Oops! >>> FE.show (1) ... (1st pass) ... 1: |pipe_volume_metric|->|(pipe_volume*m_per_foot)| (2nd pass) ... 1: |pipe_volume|->|(l*section)| (3rd pass) ... 1: |section|->|(r*r*pi)| (4th pass) ... 1: |r|->|(d/2)| (5th pass) ... 1: |d|->|(8.5)| 2: |l|->|(102.8)| 3: |m_per_foot|->|(0.3048)| 4: |pi|->|(3.14159)| Data Chain ---------------------------------------------------------------------------------- pipe_volume_metric 0 -------------------------------------------------------------------------------- (pipe_volume*m_per_foot) 1 -------------------------------------------------------------------------------- ((l*section)*m_per_foot) 2 -------------------------------------------------------------------------------- ((l*(r*r*pi))*m_per_foot) 3 -------------------------------------------------------------------------------- ((l*((d/2)*(d/2)*pi))*m_pe(d/2)_foot) 4 -------------------------------------------------------------------------------- (((102.8)*(((8.5)/2)*((8.5)/2)*(3.14159)))*m_pe((8.5)/2)_foot(102.8)e) ---------------------------------------------------------------------------------- An unwanted substitution occurs in pass 4 when the 'r' in 'm_per_foot' is replaced by the substitution meant for 'r' (radius). Conclusion: Forget it! - Forget this approach anyway. There are probably formula parsers out there that are more intelligent than this hack. Frederic (Learning by making mistakes is faster than by avoiding mistakes and if it's fun on top of it all the better.) From bignose+hates-spam at benfinney.id.au Wed Sep 27 00:44:00 2006 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 27 Sep 2006 14:44:00 +1000 Subject: optparse References: Message-ID: <87hcytnckv.fsf@benfinney.id.au> rick writes: > usage: DelimTOFixedWidth.py [options] That's not the command-line argument style that optparse models. It should be: command_name [options] In other words, the options (optionally) appear before the non-option arguments. This is the convention followed by most command-line tools, and it's what users expect. There are other command-line parser modules (e.g. argparse), perhaps you can look to them for different functionality. -- \ "If nature has made any one thing less susceptible than all | `\ others of exclusive property, it is the action of the thinking | _o__) power called an idea" -- Thomas Jefferson | Ben Finney From roy at panix.com Sat Sep 30 19:36:50 2006 From: roy at panix.com (Roy Smith) Date: Sat, 30 Sep 2006 19:36:50 -0400 Subject: builtin regular expressions? References: <451e37a5$1@news.vo.lu> <87k63ly1gi.fsf@gmail.com> <877izlxsiy.fsf@gmail.com> <451ea5cc$1@news.vo.lu> <1159642479.968928.34760@k70g2000cwa.googlegroups.com> Message-ID: In article , Marc 'BlackJack' Rintsch wrote: > In , Mirco Wahab wrote: > > > I fail to see the benefit of a re-object, I consider these to > > be just there because regexes aren't in the core language. > > One benefit is that it's an object. You can stuff it into a dictionary or > give it as argument to a function. More to the point: You can stick it in a bottle, you can hold it in your hand, AMEN! From nemesis at nowhere.invalid Tue Sep 12 16:15:58 2006 From: nemesis at nowhere.invalid (Nemesis) Date: Tue, 12 Sep 2006 20:15:58 GMT Subject: [ANN] XPN 0.6.5 released Message-ID: <20060912201557.3812.4625.XPN@orion.homeinvalid> XPN (X Python Newsreader) is a multi-platform newsreader with Unicode support. It is written with Python+GTK. It has features like scoring/actions, X-Face and Face decoding, muting of quoted text, newsrc import/export, find article and search in the body, spoiler char/rot13, random taglines and configurable attribution lines. You can find it on: http://xpn.altervista.org/index-en.html or http://sf.net/projects/xpn Changes in this release: * v0.6.5: now is possible to customize the keyboad shortcuts. XPN will also check for duplicated shortcuts * v0.6.5: added a new way to show threads, now is possible to put the threads expander in the From column * v0.6.5: now is possible to subscribe a group writing its name manually so you don't have to download the groups list * v0.6.5: now is possible to limit the number of articles headers to download with the Get New Headers function * v0.6.5: now is possible to choose the headers to show in the Article Pane, and the background color of this area now is customizable * v0.6.5: added two new layouts for the main window * v0.6.5: now is possible to re-apply the scoring/action rules on the articles you have already downloaded. * v0.6.5: fixed a bug in the Config Window that caused XPN not to change the color for URLs. * v0.6.5: fixed a bug that caused XPN not open the next article when the first thread was selected and collapsed * v0.6.5: fixed a bug in the View Parent function * v0.6.5: fixed a bug in the Export Newsrc function, that caused ad crash trying to export groups with 0 articles inside. XPN is translated in Italian French and German, if you'd like to translate it in your language and you are familiar with gettext and po-files editing please contact me (xpn at altervista.org). -- I got real close to seeing Elvis, but my shovel broke. |\ | |HomePage : http://nem01.altervista.org | \|emesis |XPN (my nr): http://xpn.altervista.org From DustanGroups at gmail.com Mon Sep 25 22:05:29 2006 From: DustanGroups at gmail.com (Dustan) Date: 25 Sep 2006 19:05:29 -0700 Subject: does anybody earn a living programming in python? In-Reply-To: <1159235326.385036.233440@i3g2000cwc.googlegroups.com> References: <1159225798.492198.89880@b28g2000cwb.googlegroups.com> <1159235326.385036.233440@i3g2000cwc.googlegroups.com> Message-ID: <1159236329.338078.326440@i3g2000cwc.googlegroups.com> walterbyrd wrote: > > > > Well I do. So do the other dozen or so developers at my company. We're looking > > to hire a few more, in fact. > > > > I'm surprised. It seems I never see listings for python developers. > > I didn't mean any disrespect. I think python is a great language. It > just doesn't seem like there is much demand for professional python > developers. What about Google? A good portion of their work is in python... From torerik81 at gmail.com Sat Sep 9 10:10:03 2006 From: torerik81 at gmail.com (Tor Erik) Date: Sat, 09 Sep 2006 16:10:03 +0200 Subject: What algorithm does Python use to evaluate: if substring in string Message-ID: I would be surprised if it is the naive: m = 0 s1 = "me" s2 = "locate me" s1len = len(s1) s2len = len(s2) found = False while m + s1len <= s2len: if s1 == s2len[m:m+s1len]: found = True break m += 1 From wildemar at freakmail.de Fri Sep 15 07:02:05 2006 From: wildemar at freakmail.de (Wildemar Wildenburger) Date: Fri, 15 Sep 2006 13:02:05 +0200 Subject: Looking for the Perfect Editor In-Reply-To: <624934630609150047w74c7d752i9fc9020044c76bb1@mail.gmail.com> References: <1157658338.661425.207140@b28g2000cwb.googlegroups.com> <624934630609141419x679948a9qb644f597b2ff32fe@mail.gmail.com> <4509D2E4.9060503@freakmail.de> <624934630609150047w74c7d752i9fc9020044c76bb1@mail.gmail.com> Message-ID: <450A882D.3050605@freakmail.de> Ramon Diaz-Uriarte wrote: > - I was referring to executing arbitrary sections of a Python file in > a Python interpreter in an "integrated way". When I tried JEdit, I > think that Jython was the way to go. (And I think this was also the > case for a while, at least to judge from D. Metrz's review > http://www-128.ibm.com/developerworks/library/l-cpyide/ > > >> The console plugin (probably THE most useful of the pack) gives you a >> system shell and means to start compilers/interpreters based on your > > But isn't this a "generic console": you go to the console, and then > type "python2.3" or "python2.4" or whatever? How do you send arbitrary > selections of Python code from the file you are editing to this shell? > Is there a way to mark a section of code and have it evaluated by the > python interpreter? Or a function definition? Ahh, I see. Well, you're right, that is not that easily possible. But you know what? I've never missed such functionality; the "if __name__ ..." trick always sufficed for me. Buts thats taste of course, lets not debate that. So OK, jEdit is not that 'integrated' after all. Oh well ... :) wildemar From herrekberg at users.sf.net Tue Sep 26 19:19:25 2006 From: herrekberg at users.sf.net (Pontus Ekberg) Date: Wed, 27 Sep 2006 01:19:25 +0200 Subject: problem moving from char to integer References: <1159312523.880618.316150@m7g2000cwm.googlegroups.com> Message-ID: Melih Onvural wrote: > Group, > > I'm trying to get a very basic cast from a string to an integer > working. Here is what I'm doing: > > for i in url: > result[counter] = int(i) > counter += 1; > > return result; > > anything that I'm doing drastically wrong? Mac OS 10.4, MacPython > upgraded to 2.4. Thanks for any help, > > Melih In what way does it not work? Please post the entire code or at least the result of your code. From bob at passcal.nmt.edu Thu Sep 28 17:54:29 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 28 Sep 2006 15:54:29 -0600 Subject: Tkinter Text widget incremental search Message-ID: <6vOdnRIsBY4L2YHYnZ2dnUVZ_v-dnZ2d@nmt.edu> I want to create a search function on a Text() widget full of text like the incremental search in emacs -- if you type an "f" emacs goes to the first "f", type another "f" and it goes to the first place where "ff" shows up in the text, etc. How would you search the text of the Text() for a string like "ff" and get back the proper index position (line.char) AND have that take into account word wrapping? Text().get(0.0, END).split("\n") returns a bunch of lines, but one line in the List may be many text widget/screen lines. Thanks! Bob From cappy2112 at gmail.com Sat Sep 23 14:17:13 2006 From: cappy2112 at gmail.com (Cappy2112) Date: 23 Sep 2006 11:17:13 -0700 Subject: Fatal error after RE-installing Python 2.3.4 In-Reply-To: <1158979319.243945.286330@k70g2000cwa.googlegroups.com> References: <1158977123.908194.304080@i3g2000cwc.googlegroups.com> <1158979319.243945.286330@k70g2000cwa.googlegroups.com> Message-ID: <1159035433.781412.238850@i3g2000cwc.googlegroups.com> > What happens when you run "C:\Python2.3\python.exe" from the command > line (or the equivalent path)? How about pythonw.exe (or the windowed > equivalent, not sure about the naming)? >>Are .py and .pyw files displayed with the correct icons? Yes. >>When installing Python packages, is Python 2.3 detected as the default installation? Yes >>> Finally, does your $PATH include the Python directory? That could also > cause problems if it doesn't. I doubt that the path would cause this type of problem. If the path wasn't found the exe wouldn't run, and this error wouldnt be displayed. >>> And, what sorts of warnings did PyChecker display? Missing files/modules? Missing modules, mostly, but Pychecker isnt a concern at this point. It was merely what prompted me to re-install everything. All of my tests scripts could be executed via python my script.py, from a cmd console before I re-installed. I have unisntaleld & re-installed Python 2.3.4 many times- using different installers, to eliminate a corrupted installation medmium, but they all result in the same error when I run python from a cmd console. From gerrit.muller at embeddedsystems.nl Tue Sep 12 05:52:11 2006 From: gerrit.muller at embeddedsystems.nl (Gerrit Muller) Date: Tue, 12 Sep 2006 11:52:11 +0200 Subject: Get CPU usage of a single process in Windows In-Reply-To: <1157737328.810771.148890@m79g2000cwm.googlegroups.com> References: <1157737328.810771.148890@m79g2000cwm.googlegroups.com> Message-ID: Tim Golden wrote: <...snip...> >>This should be possible as Taskmanager tracks CPU usage for every >>process... Anyone know how this can be done? >> > > WMI can probably do the trick. If you can find something on Google > for wmi cpu usage (or something similar) then translation to Python's > usually quite easy. I'm fairly sure I've got an example somewhere, but > I can't lay my hands on it at the mo. > > TJG > Tim Golden's general documentation/examples about WMI are at: . If you have a working example of CPU usage could you post the result? I would be interested. kind regards, Gerrit Muller -- Gaudi systems architecting: From daniel.huangfei at gmail.com Sun Sep 24 04:13:25 2006 From: daniel.huangfei at gmail.com (daniel) Date: 24 Sep 2006 01:13:25 -0700 Subject: where the hell is the run command of PyPe editor? Message-ID: <1159085605.006385.299880@i3g2000cwc.googlegroups.com> I'm trying to use PyPe, but I just got so frustrated when attempting to run a script, this is the very first feature I would use for an editor, OMG. I browsed through every single menu item and gave up... any help would be appreciated, (the most silly question ever, sounds like a new computer user. ;--( ) From wescpy at gmail.com Wed Sep 27 03:16:56 2006 From: wescpy at gmail.com (wesley chun) Date: Wed, 27 Sep 2006 00:16:56 -0700 Subject: does anybody earn a living programming in python? Message-ID: <78b3a9580609270016u47b3b100m253af879ee3d895d@mail.gmail.com> > From: "OKB (not okblacke)" > Date: Wed, 27 Sep 2006 04:04:02 GMT > >> - at yahoo, we developed yahoo!mail in python (and some C++) >> - at synarc, i wrote software for doctors in python (and some C) >> - at ironport, most everything is in python (and some C, PyRex) > > This is interesting to me in that all these jobs also involve C. > I'm not the original poster, but I'd be interested to hear about people > who make a living programming Python WITHOUT knowing C. you make a good point, however, when you have to write an extension (performance, protect source code, library interface, etc.), you must write it in the natively-supported language in which the implementation of Python you're using is compiled in. for (C)Python, it's C/C++, Java for Jython, and C#/VB.NET for IronPython. if you have been successful at building projects completely in pure Python, that's great, but you're limited in that you won't be able to take advantage of the benefits of extensions or necessarily be able to hook up to native libraries that don't already have a Python adapter written for them. for the past employment i listed, the primary use of C was either an extension or a library adapter. of course, i never claimed above to have written any of that C code. ;-) my final thought is that you cannot truly appreciate a tool like Python until you've been in the trenches with C and done all that stuff that is now a "waste of time." cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com From grante at visi.com Fri Sep 15 15:47:07 2006 From: grante at visi.com (Grant Edwards) Date: Fri, 15 Sep 2006 19:47:07 -0000 Subject: Limitate speed of a socket-based data transferring References: <1158234888.710617.63500@h48g2000cwc.googlegroups.com> <12gllfkki918r7a@corp.supernews.com> Message-ID: <12gm0prphne2hc9@corp.supernews.com> On 2006-09-15, Steve Holden wrote: >>>The sender will send at whatever rate they are capable of, so >>>packets may just become backlogged on your receiving socket >> >> >> When that happens, the sending end of the socket will throttle >> down to match the rate at which data is being read from the >> socket. > > Of course this depends crucially on the window size. Since the > addition of the window scaling TCP option it's been possible > to specify very large windows, which are useful over > high-bandwidth high-delay links. True. If the window size is large compared to the amount of data being transferred, then the throttling won't happen. > The remote (send) throttling will only start to cut in when > the window is full (since the whole point of the sliding > window mechanism is to allow continuous transmission in the > face of acknowledgment delay). Yup. -- Grant Edwards grante Yow! -- I have seen the at FUN -- visi.com From sjdevnull at yahoo.com Fri Sep 22 16:50:12 2006 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: 22 Sep 2006 13:50:12 -0700 Subject: what is the best practice to separate Pygtk and long running thread code In-Reply-To: <1158912461.178598.256050@k70g2000cwa.googlegroups.com> References: <1158912461.178598.256050@k70g2000cwa.googlegroups.com> Message-ID: <1158958212.238667.275240@m7g2000cwm.googlegroups.com> seb wrote: > Hi, > > I am using pygtk for the first times. > > I am wondering what would be the best "pattern" to interface pygtk with > a thread. > > The thread is collecting informations (over the network for example) or > is doing some long calculations. It sounds like you don't need to share all your memory--any time you're trying to "seperate" threads, you probably want to be using processes instead. From aahz at pythoncraft.com Wed Sep 27 00:40:08 2006 From: aahz at pythoncraft.com (Aahz) Date: 26 Sep 2006 21:40:08 -0700 Subject: does anybody earn a living programming in python? References: Message-ID: In article , OKB (not okblacke) wrote: > > This is interesting to me in that all these jobs also involve C. >I'm not the original poster, but I'd be interested to hear about people >who make a living programming Python WITHOUT knowing C. In more than two years in my current job, the only time I've done any C programming was one time when we wanted to precisely specify how much memory was getting consumed per unit time. IOW, it was more of a sysadmin usage because we were trying to figure out why one machine was crashing. I spend less than 5% of my time in Java or shell scripting. There's a fair amount of SQL, and we have a proprietary HTML templating language that uses a lot of pseudo-Python. Other than that, it's all Python, baby. We actually do have a fair amount of code in Postscript, but I'm not one of the people maintaining that. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "LL YR VWL R BLNG T S" -- www.nancybuttons.com From onurb at xiludom.gro Fri Sep 1 05:24:58 2006 From: onurb at xiludom.gro (Bruno Desthuilliers) Date: Fri, 01 Sep 2006 11:24:58 +0200 Subject: Python style: to check or not to check args and data members In-Reply-To: References: <44f78549$0$11377$636a55ce@news.free.fr> Message-ID: <44f7fc6b$0$26046$626a54ce@news.free.fr> Joel Hedlund wrote: > Bruno >> Your email address seem to be wrong. let's say "disguised" !-) > I tried to reply to you > directly in order to avoid thread bloat but my mail bounced. I don't think it's a good idea anyway - this thread is on topic here and may be of interest to others too IMHO. And while we're at it : please avoid top-posting. > Thanks for the quick reply though. I've skimmed through some docs on > your suggestions and I'll be sure to read up on them properly later. But > as I said to Robert Kern in this thread, this does not really seem > resolve the > problem of setting an approprate level of validation. The "appropriate" level of validation depends on the context. There's just no one-size-fits-all solution here. The only guideline I could come with is too be parano?d about what comes from the outside world and mostly confident about what comes from other parts of the application. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in 'onurb at xiludom.gro'.split('@')])" From timr at probo.com Sat Sep 9 02:17:16 2006 From: timr at probo.com (Tim Roberts) Date: Sat, 09 Sep 2006 06:17:16 GMT Subject: Get CPU usage of a single process in Windows References: Message-ID: Tor Erik wrote: > >This should be possible as Taskmanager tracks CPU usage for every >process... Anyone know how this can be done? I answered this in the python-win32 mailing list. Task manager and perfmon do this by using the performance counter APIs. Python-Win32 includes an interface for that (import win32pdh), but I've never used it. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From faulkner612 at comcast.net Mon Sep 18 16:29:49 2006 From: faulkner612 at comcast.net (faulkner) Date: 18 Sep 2006 13:29:49 -0700 Subject: How to find number of characters in a unicode string? In-Reply-To: <20060918221814.08625ea2.randhol+valid_for_reply_from_news@pvv.org> References: <20060918221814.08625ea2.randhol+valid_for_reply_from_news@pvv.org> Message-ID: <1158611389.437088.44660@i3g2000cwc.googlegroups.com> are you sure you're using unicode objects? len(u'\uffff') == 1 the encodings module should help you turn '\xff\xff' into u'\uffff'. Preben Randhol wrote: > Hi > > If I use len() on a string containing unicode letters I get the number > of bytes the string uses. This means that len() can report size 6 when > the unicode string only contains 3 characters (that one would write by > hand or see on the screen). Is there a way to calculate in characters > and not in bytes to represent the characters. > > The reason for asking is that PyGTK needs number of characters to set > the width of Entry widgets to a certain length, and it expects viewable > characters and not number of bytes to represent them. > > > Thanks in advance > > > Preben From steve at holdenweb.com Wed Sep 13 15:15:59 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 13 Sep 2006 15:15:59 -0400 Subject: page contents are not refreshed In-Reply-To: <1158174404.950910.260050@b28g2000cwb.googlegroups.com> References: <1158169681.776776.93090@e3g2000cwe.googlegroups.com> <1158174404.950910.260050@b28g2000cwb.googlegroups.com> Message-ID: waylan wrote: > Gleb Rybkin wrote: > >>when running apache, mod_python in windows. >> >>This looks pretty strange. Creating a simple python file that shows >>current time will correctly display the time in apache the first time, >>but freezes afterwards and shows the same time on all subsequent clicks >>as long as the file is not modified. >> >>Any ideas what's wrong? Thanks. > > > The first time the page was requested mod_python compiled and loaded > your code. Every request after that mod_python refers to the already > loaded code in memory in which your expression had already been > evaluated the first time. > > Therefore, you need to make curtime a 'callable object' so that it will > be re-evaluated on each request. Unfortunelty, I don't recall if simply > wraping your strftime() expression in a function will be enough or if > its more complex that that. That said, I **think** this should work: > >>from mod_python import apache >>from time import strftime, gmtime >> > > def curtime(): > return strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) > > >>def handler(req): >> req.content_type = "text/plain" >> req.send_http_header() >> req.write(str(curtime())) >> return apache.OK > > This is a very long way round for a shortcut (though it does have the merit of working). Why not just def handler(req): req.content_type = "text/plain" req.send_http_header() curtime = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) req.write(str(curtime)) return apache.OK Or even def handler(req): req.content_type = "text/plain" req.send_http_header() req.write(strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())) return apache.OK regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From gregpinero at gmail.com Wed Sep 20 01:06:16 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Wed, 20 Sep 2006 01:06:16 -0400 Subject: How to get a Fix to an Abandoned Project? In-Reply-To: <312cfe2b0609192121w436e649ayf3ce10fec066367c@mail.gmail.com> References: <1hlxp3x.1dtd1eug5y80N%rhymes@myself.com> <312cfe2b0609192121w436e649ayf3ce10fec066367c@mail.gmail.com> Message-ID: <312cfe2b0609192206g204e8aeej20f337b6f0e87b6b@mail.gmail.com> Say hello to pydelicious's new home ;-) http://code.google.com/p/pydelicious/ -Greg From nemesis at nowhere.invalid Thu Sep 14 15:36:01 2006 From: nemesis at nowhere.invalid (Nemesis) Date: Thu, 14 Sep 2006 19:36:01 GMT Subject: [ANN] XPN 0.6.5 released References: <20060912201557.3812.4625.XPN@orion.homeinvalid> Message-ID: <20060914193558.2234.50297.XPN@orion.homeinvalid> Mentre io pensavo ad una intro simpatica "Franz Steinhaeusler" scriveva: >>XPN (X Python Newsreader) is a multi-platform newsreader with Unicode [...] > Hello Nemesis, > that is a great program, thank you. Thanks. > I will try to use it and also attempt to > customize it, so that it works like forte agent. > Even better would it be to have it in wxPython I disagree :-D > Some little points: > > There is no progress bar or other info, if I subscribe one list. > There is a little in the lower left corner, but if a lot of headers > and bodies are received, the program seems to hang. > I actually killed it, because I thought that hanging. XPN is monothreaded, so when it is downloading the headers (it is a monolotic job) the progress bar can't be updated. > It would be nice, if I click on the groups pane another group, > the messages appear immediatly, without needing to double click the > group. You can configure this behaviour, in the Configure Window go to "Misc"->"Miscellaneous" and you'll find two check buttons One Click Enter Group One Click Enter Article > When composing messages, the tab size is 8. It would be nice to > have the possibility to adjust this size. Hmm, it is a GTK default I don't know if I can change it, I'll check it. -- I don't have a solution but I admire the problem. |\ | |HomePage : http://nem01.altervista.org | \|emesis |XPN (my nr): http://xpn.altervista.org From esj at harvee.org Fri Sep 29 13:53:46 2006 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 29 Sep 2006 13:53:46 -0400 Subject: another distutils question Message-ID: is there anyway I can, in a setup.py file, set and internal equivalent to the '--install-scripts' commandline option? script installation directory but I don't want on the command line where things can go horribly wrong if the user forgets. I would like to create a new default setting for this commandline option as well as a couple of other such as the data default directory. --- eric From chris.cavalaria at free.fr Fri Sep 15 06:35:04 2006 From: chris.cavalaria at free.fr (Christophe) Date: Fri, 15 Sep 2006 12:35:04 +0200 Subject: add without carry In-Reply-To: <450a7e5c$0$14661$626a54ce@news.free.fr> References: <1158308274.680123.100070@i42g2000cwa.googlegroups.com> <1158311964.932017.186470@i3g2000cwc.googlegroups.com> <1158312804.852104.204850@i42g2000cwa.googlegroups.com> <450a7e5c$0$14661$626a54ce@news.free.fr> Message-ID: <450a81be$0$31676$626a54ce@news.free.fr> Bruno Desthuilliers a ?crit : > Bryan Olson wrote: >> Hugh wrote: >>> Sorry, here's an example... >>> >>> 5+7=12 >>> >>> added without carrying, 5+7=2 >>> >>> i.e the result is always less than 10 >> Are you looking for bitwise exclusive or? In Python it's >> the '^' operator. For example: >> >> print 5 ^ 7 >> >> >>>> 10 ^ 21 > 31 > > Not really "less than 10"... But you must use numbers smaller than 10 as input! Still : >>> 8 ^ 2 10 :D From robin at NOSPAMreportlab.com Fri Sep 29 04:04:25 2006 From: robin at NOSPAMreportlab.com (Robin Becker) Date: Fri, 29 Sep 2006 08:04:25 +0000 Subject: PATCH: Speed up direct string concatenation by 20+%! In-Reply-To: <1159495643.213830.289620@m7g2000cwm.googlegroups.com> References: <1159495643.213830.289620@m7g2000cwm.googlegroups.com> Message-ID: <451CD389.3010800@jessikat.plus.net> Larry Hastings wrote: ______ > THE PATCH > > The core concept: adding two strings together no longer returns a pure > "string" object. Instead, it returns a "string concatenation" object > which holds references to the two strings but does not actually > concatenate > them... yet. The strings are concatenated only when someone requests > the > string's value, at which point it allocates all the space it needs and > renders the concatenated string all at once. > > More to the point, if you add multiple strings together (a + b + c), > it *doesn't* compute the intermediate strings (a + b). > > Upsides to this approach: ........ wouldn't this approach apply to other additions eg list+list seq+seq etc etc. I suppose the utility of such an approach depends on the frequency with which multiple strings/lists/sequences etc are added together in real code. -- Robin Becker From nogradi at gmail.com Mon Sep 4 17:52:15 2006 From: nogradi at gmail.com (Daniel Nogradi) Date: Mon, 4 Sep 2006 23:52:15 +0200 Subject: [ANN] markup.py 1.5 - a lightweight HTML/XML generator Message-ID: <5f56302b0609041452w7eec63d8o26a1b478b94c8274@mail.gmail.com> A new release of markup.py is available at http://markup.sourceforge.net/ The markup module is an intuitive, lightweight, easy-to-use, customizable and pythonic HTML/XML generator. New features in the 1.5 release include: * use attribute=None to have no value for an attribute such as the emptyattr in