Dr. Dobb's Python-URL! - weekly Python news and links (Sep 6)
QOTW: The bad news is that I seem to be an anti-channeler, so my interest is perhaps not a *good* sign - Jim Jewett I'm sorry this letter is so long. I didn't have time to write a shorter one. - Blaise Pascal (1657) The Python 2.5 release date is now September 19th. http://www.python.org/dev/peps/pep-0356/ http://groups.google.com/group/comp.lang.python/browse_thread/thread/53084d0465a1f5fc/ IronPython runs on Mono too. Here is How. http://groups.google.com/group/comp.lang.python/browse_thread/thread/398aca428247ad7e/ Call For Proposals: PyCon 2007 http://mail.python.org/pipermail/python-announce-list/2006-August/005201.html Call For Tutorials: PyCon 2007 http://mail.python.org/pipermail/python-announce-list/2006-August/005202.html The best way to find out if something is a number is to use it like one and see what happens. http://groups.google.com/group/comp.lang.python/browse_thread/thread/91427c4160b8ab9c/ This week's flame war was brought to you by threading, processes and the letters G-I-L http://groups.google.com/group/comp.lang.python/browse_thread/thread/545f279ccf46f87b/ Subclassing the int class does not make ints mutable. http://groups.google.com/group/comp.lang.python/browse_thread/thread/011dbd0545df9dad/ Why was PEP 359 (make syntax) rejected when it would make line-for-line translations of XML into python so much easier? Asked and answered. http://groups.google.com/group/comp.lang.python/browse_thread/thread/dab58e645d80c7c2/ Releases of Note IronPython 1.0 - Python implementation for .Net http://groups.google.com/group/comp.lang.python/browse_thread/thread/0b3059f37075a97f/ http://blogs.msdn.com/hugunin/archive/2006/09/05/741605.aspx markup.py 1.5 - A lightweight HTML/XML generator http://groups.google.com/group/comp.lang.python/browse_thread/thread/5049614dea04334f/ matplotlib 0.87.5 Quality 2D plots in python http://cheeseshop.python.org/pypi/matplotlib rawdog 2.10 - RSS Aggregator http://cheeseshop.python.org/pypi/rawdog/2.10 Upcoming Community Events Plone Conference 2006, October 25-27 (Seattle, Washington) http://plone.org/events/conferences/seattle-2006 Open Source Developers Conference December 5-8 (Melbourne, Australia) http://www.osdc.com.au/ PyCon 2007, February 23-25 (Dallas, TX) http://us.pycon.org/TX2007/HomePage RuPy 2007, April 7-8 (Poznan, Poland) http://rupy.wmid.amu.edu.pl/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/python/success The Python Software
Re: How to get all the file of a oppoint directory from a FTP
snowf wrote: There are no such a method using to download a whole directory in the lib of ' ftplib '. thanks for anybody's help! So you'll have to lash one up: (untested) Firstly, alist = [] ftpobj.retrlines('list', alist.append) should get you a list of filenames. Secondly, for fname in alist: f = open(fname, wb) ftpobj.retrbinary('RETR ' + fname, f.write) f.close() should do the business. Instead of using f.write as the callback, you might like to wrap that in a function that counts the bytes received, displays progress, etc. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
IDE
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get all the file of a oppoint directory from a FTP
John Machin wrote: snowf wrote: There are no such a method using to download a whole directory in the lib of ' ftplib '. thanks for anybody's help! So you'll have to lash one up: (untested) Firstly, alist = [] ftpobj.retrlines('list', alist.append) should get you a list of filenames. Secondly, for fname in alist: f = open(fname, wb) ftpobj.retrbinary('RETR ' + fname, f.write) f.close() should do the business. Instead of using f.write as the callback, you might like to wrap that in a function that counts the bytes received, displays progress, etc. HTH, John Thanks for you reply! I will have a try with your suggest and show the result later. -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE
I recommend you Stani's Python Editor (SPE) which is available for Windows, Linux and Mac. http://www.stani.be/python/spe A short tutorial about SPE can be found at: http://www.serpia.org/spe good luck -- http://mail.python.org/mailman/listinfo/python-list
Re: Dice gen and analyser script for RPGs: comments sought
Richard Buckle [EMAIL PROTECTED] writes: Comments, insights and overall evaluations are especially welcomed re: * Cleanliness of design * Pythonicity of design * Pythonicity of code * Efficiency of code * Quality of docstrings * Conformance with modern docstring standards * Conformance with coding standards e.g. PEP 8 I look forward to receiving your comments and criticisms. I looked at this for a minute and found it carefully written but somewhat hard to understand. I think it's maybe more OOP-y than Python programs usually are; perhaps it's Java-like. There are some efficiency issues that would be serious if the code were being used on large problems, but probably no big deal for 3D6 or the like. In particular, you call histogram.numSamples() in a bunch of places and each call results in scanning through the dict. You might want to cache this value in the histogram instance. Making histogram a subclass of dict also seems a little bit peculiar. You might find it more in the functional programming spirit to use gencomps rather than listcomps in a few places: return sum([freq * val for val, freq in self.items()]) becomes return sum((freq * val) for val, freq in self.iteritems()) etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Better way to replace/remove characters in a list of strings.
In [EMAIL PROTECTED], George Sakkis wrote: Chris Brat wrote: Wouldn't this only cause problems with large lists - for once off scripts with small lists it doesn't seem like a big issue to me. The extra memory to allocate the new list is usually a minor issue; the important one is correctness, if the original list is referenced by more than one names. It's not the allocation of the new list itself that might be an issue but the content, which will be copied in this case, before the old list and its content is freed. If you have 200 MiB worth of strings in the list and change all 'u's to 'x's with large_list = [item.replace('u', 'x') for item in large_list] another list with 200 MiB strings will be created. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Paul Rubin wrote: Jean-Paul Calderone [EMAIL PROTECTED] 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Paul Rubin wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: Having memory protection is superior to not having it--OS designers spent years implementing it, why would you toss out a fair chunk of it? Being explicit about what you're sharing is generally better than not. Part of the win of programming in Python instead of C is having the language do memory management for you--no more null pointers dereferences or malloc/free errors. Using shared memory puts all that squarely back in your lap. Huh? Why couldn't you use garbage collection with objects allocated in shm? The worst theoretical case is about the same programatically as having garbage collected objects in a multithreaded program. Python doesn't actually support that as of yet, but it could. In the interim, if the memory you're sharing is array-like then you can already take full advantage of multiprocess solutions in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Paul Rubin wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: I think it's even worse. The standard Python library offers shared memory, but not cross-process locks. File locks are supported by the standard library (at least on Unix, I've not tried on Windows). They work cross-process and are a normal method of interprocess locking even in C code. I may be missing your point but I didn't realize you could use file locks to synchronize shared memory in any useful way. You can, absolutely. If you're sharing memory through mmap it's usually the preferred solution; fcntl locks ranges of an open file, so you lock exactly the portions of the mmap that you're using at a given time. It's not an unusual use at all, Unix programs have used file locks in this manner for upwards of a decade--things like the Apache public runtime use fcntl or flock for interprocess mutexes, and they're quite efficient. (The futexes you mentioned are a very recent Linux innovation). -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Part of the win of programming in Python instead of C is having the language do memory management for you--no more null pointers dereferences or malloc/free errors. Using shared memory puts all that squarely back in your lap. Huh? Why couldn't you use garbage collection with objects allocated in shm? The worst theoretical case is about the same programatically as having garbage collected objects in a multithreaded program. I'm talking about using a module like mmap or the now-AWOL shm module, which gives you a big shared byte array that you have to do your own memory management in. POSH is a slight improvement over this, since it does its own ref counting, but that is slightly leaky, and POSH has to marshal every object into the shared area. Python doesn't actually support that as of yet, but it could. Well, yeah, with a radically different memory system that's even more pie in the sky than the GIL and refcount removal that we've been discussing. In the interim, if the memory you're sharing is array-like then you can already take full advantage of multiprocess solutions in Python. But then you're back to doing your own memory management within that array. Sure, that's tolerable for some applications (C programmers do it for everything), but not exactly joy. And as already mentioned, the stdlib currently gives no way to implement shared memory locks (file locks aren't the same thing). POSH and the old shm library do, but POSH is apparently not that reliable, and nobody knows what happened to shm. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: You can, absolutely. If you're sharing memory through mmap it's usually the preferred solution; fcntl locks ranges of an open file, so you lock exactly the portions of the mmap that you're using at a given time. How can it do that without having to touch the PTE for every single page in the range, which might be gigabytes? For that matter, how can it do that on regions smaller than a page? And how does another process query whether a region is locked, without taking a kernel trap if it's locked? This sounds absolutely horrendous compared to a futex, which should usually be just one or two user-mode instructions and no context switches. It's not an unusual use at all, Unix programs have used file locks in this manner for upwards of a decade--things like the Apache public runtime use fcntl or flock for interprocess mutexes, and they're quite efficient. (The futexes you mentioned are a very recent Linux innovation). Apache doesn't use shared memory in the same way that something like a database does, so maybe it can more easily tolerate the overhead of fcntl. Futex is just a somewhat standardized way to do what programmers have done less portably since the dawn of multiprocessors. -- http://mail.python.org/mailman/listinfo/python-list
Re: CONSTRUCT -
Simon Forman wrote: Fredrik Lundh wrote: Simon Forman wrote: I'm sorry, your post makes very little sense. you're somewhat new here, right ? ;-) /F Yah, I've been posting here about three months now. Why, did I miss something? :-) Yes: the previous posts from the same poster. Ilias Lazaridis' communications can be a little obscure, to say the least, and it's apparent that his approach to language evaluaation doesn't emphasize community experience too heavily. Still, it takes all sorts to make a newsgroup ... 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I think your whole experience is based on it. But shouldn't a significant feature like that be explained in the Python manuals? Why should I go dig up Sqlite FAQs to learn what should have been in the manuals? I don't know, but I will take a stab at a plausible explanation. First, sqlite support has only been in Python for a month or three. Its first official unveiling will be when 2.5 is released. Although possibly too late for the final release, now would be a good time to straighten out the documentation. And you would be the best person to do it, since you're teh one this has bitten in the tender parts. Second, it's common when wrapping functionality into Python to rely on the documentation for the thing being wrapped. The thinner the wrapper, the more you tend to rely on the underlying documentation. Also, the more functionally rich the thing you've wrapped, the more you rely on the underlying documentation. I wouldn't be at all surprised if the pysqlite author operated under that assumption. Ok, that's certainly plausible. But it's not an excuse. The thinner the documentation, the greater the emphasis should be made to point the reader to a more adequate source. Simply listing the Sqlite home page at the bottom of the page is hardly good enough. It should be explicitly stated in bold letters that the reader should go read the Sqlite FAQ because it radically differs from *real* databases and provide a seperate link to it in the body of the documentation. Whoa, there! This isn't commercial software we are talking about. While I appreciate the need to continually better Python's documentation, the should implies a moral imperative that the (volunteer) developers are unikely to find compelling. That the Python developers didn't pick up on the issue is not surprising. I'm not sure how many of them are (py)sqlite users, probably relatively few. I would be surprised if they had never used ANY database. A little thing like dynamic field typing will simply make it impossible to migrate your Sqlite data to a *real* database. 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 the ticket. Great idea. Changes to the documentation can be suggested in plain ASCII, you don't have to grok the LaTeX markup. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I think your whole experience is based on it. But shouldn't a significant feature like that be explained in the Python manuals? Why should I go dig up Sqlite FAQs to learn what should have been in the manuals? I don't know, but I will take a stab at a plausible explanation. First, sqlite support has only been in Python for a month or three. Its first official unveiling will be when 2.5 is released. Although possibly too late for the final release, now would be a good time to straighten out the documentation. And you would be the best person to do it, since you're the one this has bitten in the tender parts. Second, it's common when wrapping functionality into Python to rely on the documentation for the thing being wrapped. The thinner the wrapper, the more you tend to rely on the underlying documentation. Also, the more functionally rich the thing you've wrapped, the more you rely on the underlying documentation. I wouldn't be at all surprised if the pysqlite author operated under that assumption. Ok, that's certainly plausible. But it's not an excuse. The thinner the documentation, the greater the emphasis should be made to point the reader to a more adequate source. Simply listing the Sqlite home page at the bottom of the page is hardly good enough. It should be explicitly stated in bold letters that the reader should go read the Sqlite FAQ because it radically differs from *real* databases and provide a seperate link to it in the body of the documentation. Whoa, there! This isn't commercial software we are talking about. While I appreciate the need to continually better Python's documentation, the should implies a moral imperative that the (volunteer) developers are unlikely to find compelling. That the Python developers didn't pick up on the issue is not surprising. I'm not sure how many of them are (py)sqlite users, probably relatively few. I would be surprised if they had never used ANY database. A little thing like dynamic field typing will simply make it impossible to migrate your Sqlite data to a *real* database. 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 the ticket. Great idea. Changes to the documentation can be suggested in plain ASCII, you don't have to grok the LaTeX markup. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] wrote: Paul Rubin wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: Having memory protection is superior to not having it--OS designers spent years implementing it, why would you toss out a fair chunk of it? Being explicit about what you're sharing is generally better than not. Part of the win of programming in Python instead of C is having the language do memory management for you--no more null pointers dereferences or malloc/free errors. Using shared memory puts all that squarely back in your lap. Huh? Why couldn't you use garbage collection with objects allocated in shm? The worst theoretical case is about the same programatically as having garbage collected objects in a multithreaded program. Python doesn't actually support that as of yet, but it could. In the interim, if the memory you're sharing is array-like then you can already take full advantage of multiprocess solutions in Python. Ah, right. So then we end up with processes that have to suspend because they can't collect garbage? Could covers a multitude of sins, and distributed garbage collection across shard memory is by no means a trivial 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 -- http://mail.python.org/mailman/listinfo/python-list
Import a textfile to MS SQL with python
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. I have tried to change the argumnts in str(alllines[]) Some of the columns can include many characters and some not. For exampel names can be Bo or Lars-Ture. I be glad if some can help me with this. Regar Joel import pymssql import string,re myconn = pymssql.connect(host='lisa',user='sa',password='AGpu83!#',database='junk') mycursor = myconn.cursor() inpfile=open('c:\\temp\\test.txt','r') for alllines in inpfile.read().split('\n'): stmt=insert into python (id, namn, efternamn) values ('%s', '%s', '%s') %(str(alllines[0]),str(alllines[2:10]),str(alllines[3:10])) mycursor.execute(stmt) print stmt inpfile.close() myconn.commit() myconn.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] wrote: Paul Rubin wrote: Jean-Paul Calderone [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: any portable way to print? (and i mean on a printer)
Liquid Snake wrote: I think my question is clear.., is there any way to print any text on a portable way?..., and actually, i don't know how to print at all.., just give me some pointers, name a module, and i can investigate for myself.. sorry for my english, thanks in advance.. ps: i prefer a Standard Library module. No, there is no way to print any text (did yo also want to print graphics?) portably (by which I mean a way that will work on Windows, Linux, Solaris, HP-UX, AIX, ...). Sorry. This answer is final. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Removing from a List in Place
[EMAIL PROTECTED] wrote: Tim Williams: You could also use a list comprehension for your case alist = [1 ,2 ,3] alist = [x for x in alist if x != 2] alist [1, 3] The list comprehension filtering is the simpler and often the best solution. For memory-conscious people this is another possible (un-pythonic) solution, usable in less dynamic languages too (not much tested), expecially if the good elements are few (Psyco may help too). I haven't tested its speed, but in Python it may be slower than the simpler comprehension filtering solution: array = [1,2,3,1,5,1,6,0] good = lambda x: x 2 slow = 0 for fast, item in enumerate(array): print item, if good(item): if slow != fast: array[slow] = array[fast] slow += 1 print \n, array del array[slow:] print array Output: 1 2 3 1 5 1 6 0 [3, 5, 6, 1, 5, 1, 6, 0] [3, 5, 6] This would be a way-premature optimisation until you had proven the need for it in the context of a specific program. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get all the file of a oppoint directory from a FTP
snowf wrote: There are no such a method using to download a whole directory in the lib of ' ftplib '. thanks for anybody's help! If your Python distrbution contains a Tools directory you should look for the ftpmirror.py utility in it. If you don't have Tools then you can extract them from the Python source tarball. 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 -- http://mail.python.org/mailman/listinfo/python-list
RE: Import a textfile to MS SQL with python
[EMAIL PROTECTED] | I'm a dba for SQL server and I Will import a textfile to SQL. Not a Python answer, but unless you're in it for the learning experience, I *seriously* suggest you look at the built-in BULK INSERT command to see if it meets your needs. Random URL: http://www.sqlteam.com/item.asp?ItemID=3207 If it doesn't, then by all means post back and I'm sure we can talk you through the Python side of things. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Higher-level OpenGL modules
[EMAIL PROTECTED] wrote: http://pyopengl.sourceforge.net/ I wouldn't begin to tell you how to install this.. Looks like russian roulette with virus since the .dll's are not available and are not linked from the site but are available from lots of places in the google search. I think you're very mistaken... it's a little over-complex, but everything you need is up there, on the installation and download pages, and the only other .dlls you need are the OpenGL ones which the original poster will already have. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Import a textfile to MS SQL with python
[EMAIL PROTECTED] wrote: 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. I have tried to change the argumnts in str(alllines[]) Some of the columns can include many characters and some not. For exampel names can be Bo or Lars-Ture. I be glad if some can help me with this. Regar Joel import pymssql import string,re myconn = pymssql.connect(host='lisa',user='sa',password='AGpu83!#',database='junk') Thanks for letting us know the administrator password for your database. You might want to consider changing it (unless you modified this line before posting). mycursor = myconn.cursor() inpfile=open('c:\\temp\\test.txt','r') for alllines in inpfile.read().split('\n'): stmt=insert into python (id, namn, efternamn) values ('%s', '%s', '%s') %(str(alllines[0]),str(alllines[2:10]),str(alllines[3:10])) mycursor.execute(stmt) print stmt This is much better expressed as something like the following (untested): stmt = insert into python (id, namn, efternamn) values (?, ?, ?) for line in inpfile: mycursor.execute(stmt, tuple(line.split())) Note that the (?, ?, ?) list of parameter markers assumes that pymssql uses the qmark paramstyle, you'll have to check the documentation if you get SQL syntax errors or similar - I couldn't easily find a reference on the web. The point of passing the tuple of data values as a second argument to the .execute() method is to have the DB module take care of any necessary quoting and representation issues. Otherwise values that (for example) include a singel quotes, such as O'Reilly can be problematical. inpfile.close() myconn.commit() myconn.close() 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject or SQLAlchemy?
lazaridis_com wrote: Bruno Desthuilliers wrote: lazaridis_com wrote: Ο/Η Bruno Desthuilliers έγραψε: lazaridis_com wrote: John Salerno wrote: Are there any major differences between these two? It seems they can both be used with TurboGears, and SQLAlchemy with Django. I'm just wondering what everyone's preference is, and why, and if there are even more choices for ORM. Thanks. You can review the Persit Case, which will shortly evaluate the stated ORM's: http://case.lazaridis.com/wiki/Persist It is possibly of importance to remember some requirements which should be relevant for an persistency mechanism targetting an OO language: RDBMS are not persistency mechanism, they are data management tools. possibly. but this is not relevant, as the Persist case does not deal with RDBMS. Then your post is irrelevant since there's a clear indication that the OP question was about RDBMS integration in Python (hint: SQLObject and SQLAlchemy both start with 'SQL'). ... Of course it's relevant. Of course not. I'm just wondering what everyone's preference is, and why, and if there are even more choices for ORM. You may not know it but the R in ORM stands for Relational, which actually implies a RDBMS. The persist case evaluates python persistency Once again, it has nothing to do with persistency. I can use an ORM connected to an in-memory SQLite db. systems (or mechanisms), and will show my personal preference: I don't give a damn about your personal preferences. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
RE: a Pywin Outlook adress Book Question
[Kai Mayfarth] | Ist there a way to search a Adressbook over Python for a | special contact. | I know how i read and write a contact, but know i have to search over | Python for some contacts, because the adress book has know over 1700 | entrys, and it tooks a long time to get them all over the Com | object to | python. As far as I can see from a quick glance, there is no method of the AddressList or AddressEntries objects which calls into the Outlook code itself to search, so you seem to be stuck with iterating over all the AddressEntry items until you find the one you want. From what you say above you already know how to do that. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
[EMAIL PROTECTED] wrote: (snip) But shouldn't a significant feature like that be explained in the Python manuals? Why should it ? It's a SQLite feature, not a Python one. Why should I go dig up Sqlite FAQs to learn what should have been in the manuals? Why should you read the manuals at all then ? Live with it or use a real RDBMS. I don't mind living with it as long as it's documented. It is. In SQLite manual. Or do you hope the Python manual to also fully document PostgreSQL, MySQL, Oracle, Apache, Posix, Win32 etc ? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: [Article] OpenOffice.org and Python
MC enlightened us with: Thanks! You're welcome! - and Python 2.4.x? I've used Python 2.4.3 to write the article. - I have Python 2.4 and then embbed Python 2.3 of OOo ; how install some things in this last Python? I dream to call Pywin32 from OOo... Please rephrase that question, it doesn't make much sense to me. - when I drive OOo from Python, via COM/Ole-automation, many things not run (getStruct...); no solution? I don't know, I don't use Windows. You also describe a method that wasn't used in my article. Perhaps it would be better if you did use the methods I describe. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Import a textfile to MS SQL with python
i know the bulk instert functions i ms sql but i will use this script for oracle in a linux enviroment to so i think python is a good choice. regard joel -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Steve Holden wrote: [EMAIL PROTECTED] wrote: Paul Rubin wrote: Jean-Paul Calderone [EMAIL PROTECTED] 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 No doubt that it's hard. On the other hand, current CPython captures programmer-friendly behavior quite well. My main assertions are that: 1. Saying that GC is just freeing memory after it won't be referenced anymore is disingenuous; it is _already_ common practice in Python (and other languages) for destructors to close files, sockets, and otherwise deallocate non-memory resources. 2. The ref-counting semantics are extremely valuable to the programmer. Throwing them out without careful consideration is a bad idea--ref-counting is _not_ simply one GC implementation among many, it actually offers useful semantics and the cost of giving up those semantics should be considered before throwing out refcounting. I'm actually willing to be convinced on (2); I think that what ref-counting offers is a massive improvement over nondeterministic GC, and it seems that refcounting has historically been supportable, but if there are real tangible benefits to python programmers from eliminating it that outweigh the niceties of deterministic GC, then I'd be okay with sacrificing it. It just seems like people are very cavalier about giving up something that is a very nice feature in order to make other implementations simpler. (1) I think is here to stay, if you're going to tell programmers that their destructors can't make program-visible changes (e.g. closing the database connection when a dbconn is destroyed), that's a _huge_ change from current practice that needs serious debate. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Throwing them out without careful consideration is a bad idea--ref-counting is _not_ simply one GC implementation among many, it actually offers useful semantics and the cost of giving up those semantics should be considered before throwing out refcounting. It's too late to consider anything before throwing out refcounting. Refcounting has already been thrown out (in Jython, IronPython, and maybe PyPy). It's just an implementation artifact of CPython and MANY other language implementations have gotten along perfectly well without it. (1) I think is here to stay, if you're going to tell programmers that their destructors can't make program-visible changes (e.g. closing the database connection when a dbconn is destroyed), that's a _huge_ change from current practice that needs serious debate. We had that debate already (PEP 343). Yes, there is some sloppy current practice by CPython users that relies on the GC to close the db conn. That practice already fails in several other Python implementations and with PEP 343, we now have a clean way to fix it. I don't understand why you're so fixated on keeping the sloppy method around. The benefit is marginal at best. If you want stack-like deallocation of something, ask for it explicitly. -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice.org and Python
Sybren, you did not understand Michel question because Ubuntu seems to be the only distribution coming with OpenOffice and Python 2.4 compiled together. Others platform such as Windoze are limitated to Python 2.3 when working with OpenOffice and compiling is a pain especially under Windoze. Olivier. -- http://mail.python.org/mailman/listinfo/python-list
RE: a Pywin Outlook adress Book Question
| [Kai Mayfarth] | | | Ist there a way to search a Adressbook over Python for a | | special contact. [TJG] | As far as I can see from a quick glance, there is no method | of the AddressList or AddressEntries objects which calls into | the Outlook code itself to search Although now I Google a little more, it looks like AddressEntryFilter might well do what you want. Worth a look, anyway :) 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get all the file of a oppoint directory from a FTP
Steve Holden wrote: snowf wrote: There are no such a method using to download a whole directory in the lib of ' ftplib '. thanks for anybody's help! If your Python distrbution contains a Tools directory you should look for the ftpmirror.py utility in it. If you don't have Tools then you can extract them from the Python source tarball. 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 Thank you for your reply . : ) -- http://mail.python.org/mailman/listinfo/python-list
RE: Import a textfile to MS SQL with python
[EMAIL PROTECTED] | 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: code 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], ...] # /code 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. code # uses data from above import database module # pymssql, oracle, sqlite, etc. db = database module.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 () /code 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice.org and Python
olive enlightened us with: you did not understand Michel question because Ubuntu seems to be the only distribution coming with OpenOffice and Python 2.4 compiled together. Ah, okay. I have no other distributions here, so I rely on others to give me more information about them. Others platform such as Windoze are limitated to Python 2.3 when working with OpenOffice and compiling is a pain especially under Windoze. Poor people. If there is anything in my code that doesn't work with Python 2.3, or with your system in general, please let me know what code that is, and how to fix it. I'll implement the changes into the article. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Import a textfile to MS SQL with python
Ok thanks Tim. I'm possible to read the file now as you described but when I pass it to the DB I got an error says: [['1', 'Joel', 'Sjoo'], ['2', 'Sture', 'Andersson'], ['3', 'Arne', 'Svensson']] Traceback (most recent call last): File txttosql6.py, line 23, in ? row File C:\Python24\Lib\site-packages\pymssql.py, line 120, in execute self.executemany(operation, (params,)) File C:\Python24\Lib\site-packages\pymssql.py, line 146, in executemany raise DatabaseError, internal error: %s (%s) % (self.__source.errmsg(), se lf.__source.stdmsg()) pymssql.DatabaseError: internal error: None (None) I dont know if it is the pymssql module that not work with this code. I a code that you described. import csv import pymssql reader = csv.reader (open (c:\\temp\\test.txt), delimiter=\t) data = [] for line in reader: data.append (line) myconn = pymssql.connect(host='lisa',user='sa',password='',database='junk') mycursor = myconn.cursor() for row in data: mycursor.execute( INSERT INTO python (id, namn, efternamn) VALUES (?, ?, ?), row ) db.commit () # if needed etc. db.close () -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
You can use multiple processes to simulate threads via an IPC mechanism. I use D-Bus to achieve this. http://www.freedesktop.org/wiki/Software/dbus km wrote: Hi all, Are there any alternate ways of attaining true threading in python ? if GIL doesnt go then does it mean that python is useless for computation intensive scientific applications which are in need of parallelization in threading context ? regards, KM --- On 4 Sep 2006 07:58:00 -0700, bayerj [EMAIL PROTECTED] wrote: Hi, GIL won't go. You might want to read http://blog.ianbicking.org/gil-of-doom.html . Regards, -Justin -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython GUI update with data from a MySQL database
I solved the problem by using a more recent version of MySQLdb, compatible with MySQL 5.0. -- http://mail.python.org/mailman/listinfo/python-list
How to insert an email-link into wxPython's HtmlWindow
Hello. I don't know if this topic is appropriate in this group (and my English is not good). My problem is here: I created a HtmlWindow in wxPython, then I wrote some code and set it to the page-text. In these code there was a line a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/a (where name was my real username). Then I showed this HtmlWindow and I thought there would be a mail-sending box when I clicked on the [EMAIL PROTECTED] link (like when I clicked it in a web browser). But there just came a Python Error-titled dialog: Unable to open requested HTML document mailto:[EMAIL PROTECTED] What should I do to solve this problem? (My OS is WinXP.) Thanks. -- http://mail.python.org/mailman/listinfo/python-list
RE: Import a textfile to MS SQL with python
[EMAIL PROTECTED] | Traceback (most recent call last): | File txttosql6.py, line 23, in ? | row | File C:\Python24\Lib\site-packages\pymssql.py, line 120, in execute | self.executemany(operation, (params,)) | File C:\Python24\Lib\site-packages\pymssql.py, line 146, in | executemany | raise DatabaseError, internal error: %s (%s) % | (self.__source.errmsg(), se | lf.__source.stdmsg()) | pymssql.DatabaseError: internal error: None (None) Are you calling .execute or .executemany? Your code below has .execute, but the traceback is coming from .executemany. If you're using the latter, you need to pass the whole list at once: . . . mycursor = myconn.cursor() # omit: for row in data: mycursor.executemany ( INSERT INTO python (id, namn, efternamn) VALUES (?, ?, ?), data ) If that's not the problem, I can't easily see what it is. I don't usually use pymssql, but I do have it installed, so if I get a chance later, I'll give it a go. 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice.org and Python
Hi! Poor people. Poor people... but (very) rich client!!! ;-) @+ Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
sci-py error
Hi! When installing scipy I get this error: python setup.py install Traceback (most recent call last): File setup.py, line 55, in ? setup_package() File setup.py, line 28, in setup_package from numpy.distutils.core import setup File /usr/local/lib/python2.4/site-packages/numpy/__init__.py, line 40, in ? import linalg File /usr/local/lib/python2.4/site-packages/numpy/linalg/__init__.py, line 4, in ? from linalg import * File /usr/local/lib/python2.4/site-packages/numpy/linalg/linalg.py, line 25, in ? from numpy.linalg import lapack_lite ImportError: /usr/lib/libblas.so.3: undefined symbol: e_wsfe Can anybody help me? Thanks, Cecilia -- http://mail.python.org/mailman/listinfo/python-list
Getting Process Name on Win32
Hi, I want to list the names of all the processes running on my machine. I am stuck at this point and do not know how to extract the name of a process. Using win32process.EnumProcesses, I am able to obtain the pids of all the processes and using win32api.OpenProcess() I have obtained a handle to the process. However, I could not find an appropriate method to provide me the name of the process. I went through the available documentation on the http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32.html site - but could not find something to help me. Could some one please guide me on this? thanks,Rama -- http://mail.python.org/mailman/listinfo/python-list
RE: Getting Process Name on Win32
[Rama] | I want to list the names of all the processes running on | my machine. I am stuck at this point and do not know how to | extract the name of a process. WMI is good for this kind of thing: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting Process Name on Win32
On 06/09/06, Tim Golden [EMAIL PROTECTED] wrote: [Rama]|I want to list the names of all the processes running on| my machine. I am stuck at this point and do not know how to| extract the name of a process.WMI is good for this kind of thing: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processesAwesome. That works for me. Just curious, however - is there any way at all to get this through the win32* modules? I notice that there is a Windows API - QueryFullProcessImageName - but I don't see this in these modules (or maybe I am not looking closely enought). thanks,Rama -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting Process Name on Win32
[BTW, there is a list/newsgroup specifically for pywin32] on 06.09.2006 12:56 Rama said the following: Hi, I want to list the names of all the processes running on my machine. I am stuck at this point and do not know how to extract the name of a process. Using win32process.EnumProcesses, I am able to obtain the pids of all the processes and using win32api.OpenProcess() I have obtained a handle to the process. However, I could not find an appropriate method to provide me the name of the process. I went through the available documentation on the http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32.html site - but could not find something to help me. Could some one please guide me on this? This is not directly what you wanted, but it works for me:: In [1]: import win32com.client In [2]: wmi = win32com.client.GetObject('winmgmts:') In [3]: procs = wmi.ExecQuery('Select * from win32_process') In [4]: for proc in procs: ...: print proc.Name ...: System Idle Process ... [censored] There are also python-packages that encapsulate dealing with wmi. cheers, stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject or SQLAlchemy?
alex23 wrote: lazaridis_com wrote: The persist case evaluates python persistency systems (or mechanisms), and will show my personal preference: Do you feel that evaluating-for-evaluation's-sake produces a more measured understanding of the value of a product than that taken from its use in, say, actual development? I don't evaluate for evaluating-for-evaluation's-sake, see the home page of the project: The project selects Open Source Subsystems for integration into a Coherent Software Production System. http://case.lazaridis.com/wiki . -- http://mail.python.org/mailman/listinfo/python-list
Re: Import a textfile to MS SQL with python
i gott the same results with both executemany and execute. i will try with some other sql modules. if you try tim so let me now if you cot it to work. many thanks for your help. regards joel -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject or SQLAlchemy?
Bruno Desthuilliers wrote: lazaridis_com wrote: Bruno Desthuilliers wrote: lazaridis_com wrote: Ο/Η Bruno Desthuilliers έγραψε: lazaridis_com wrote: John Salerno wrote: Are there any major differences between these two? It seems they can both be used with TurboGears, and SQLAlchemy with Django. I'm just wondering what everyone's preference is, and why, and if there are even more choices for ORM. Thanks. You can review the Persit Case, which will shortly evaluate the stated ORM's: http://case.lazaridis.com/wiki/Persist It is possibly of importance to remember some requirements which should be relevant for an persistency mechanism targetting an OO language: RDBMS are not persistency mechanism, they are data management tools. possibly. but this is not relevant, as the Persist case does not deal with RDBMS. Then your post is irrelevant since there's a clear indication that the OP question was about RDBMS integration in Python (hint: SQLObject and SQLAlchemy both start with 'SQL'). ... Of course it's relevant. Of course not. You are right. It's not relevant for _you_. I'm just wondering what everyone's preference is, and why, and if there are even more choices for ORM. You may not know it but the R in ORM stands for Relational, which actually implies a RDBMS. ...which is completely irrelevant to _me_. Thus I'm looking for an ORM which decouples the R part nicely. The persist case evaluates python persistency Once again, it has nothing to do with persistency. I can use an ORM connected to an in-memory SQLite db. What _you_ do is not _my_ use case. systems (or mechanisms), and will show my personal preference: I don't give a damn about your personal preferences. _You_ are not the central part of this topic. _I_ am not the central part of this topic. The OP asked for personal preferences: I'm just wondering what everyone's preference is, and why, and if there are even more choices for ORM. I present my personal preferences here: http://case.lazaridis.com/wiki/Persist nothing special. . -- http://mail.python.org/mailman/listinfo/python-list
getting quick arp request
Hello, What I need : I need to write a scanner that test all the IP adresses that repond on a given port. The Ip list is of roughly of length 200. I need to get the response every 60 seconds (or better). I would prefer first not to use nmap. Configuration : * Python 2.4.1. To test what is going on I use ethereal. I am using winXP pro on a 2GHZ P4 and 512 Mo. *** Problem : *** I tried to implement a simplistic threaded version where each thread is opening a blocking socket on the IP and port. I have monitored using etherereal that I get one arp query every second roughly. I am expecting a speed on the same oder of magnitude as the one that one can get from a standard IP/port scanner. To compare, I have used angry Ip scanner and I have seen that roughly 200 arp request where sent in 20 seconds. *** Also : *** I have also considered using some asynchrone connection but AFAIK you need first to open the socket and so to use the arp protocol. Thanks I advance for your help. Sebastien. * Code sample : * # Sebastien 6/9/2006 for testing purposes import time import Queue from threading import * import threading import socket try : import psyco psyco.full() except : pass class socket_test (Thread): def __init__ (self,adresse): Thread.__init__(self) self.PORT=21 self.adresse=str(adresse) print in thread adresse = , self.adresse self.service=[] self.start() def run(self) : service_unit=socket.socket(socket.AF_INET, socket.SOCK_STREAM) service_unit.setblocking(1) print socket Ip = ,self.adresse try : service_unit.connect((str(self.adresse), self.PORT)) except Exception,e: print exception ,e self.service.append(service_unit) class groupe_thread : def __init__(self,liste): self.liste=liste def go(self): print self.liste = ,self.liste for el in self.liste : print go starting thread on : ,el s=socket_test(el) liste=[] base =192.168.3. rang=range(1,50) for r in rang: add=base+str(r) liste.append(add) a=groupe_thread(liste) ut= a.go() print the end (main) .. -- http://mail.python.org/mailman/listinfo/python-list
Re: CONSTRUCT -
Steve Holden wrote: lazaridis_com wrote: Georg Brandl wrote: lazaridis_com wrote: Georg Brandl wrote: lazaridis_com wrote: I would like to fulfill the following task: The construct: if __name__ == '__main__': should be changed to something like: if identifier.name == '__main__': The term identifier should be selected based on the meaning of the __double-underscore-enclosure__ of the entities. import sys class _identifier: def __getattr__(self, name): return sys._getframe(1).f_globals['__%s__' % name] identifier = _identifier() ok, I understand. this one would work with modules. but how would look a more general solution, which would work with objects too? Why can't you try to come up with something yourself? You should have had enough exposure to the Python language by now. I am not a (python) domain expert. Thus I am asking here for available standard-solutions, before I implement an own solution. There is no standard solution for the problem you mention. I see. Can one point me to the relevant documentation? Or at least give me the relevant key-words / Search Phrases? I remember to have located a relevant PEP, but I cannot find it again. . -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 released today!
Jim Hugunin wrote: I'm extremely happy to announce that we have released IronPython 1.0 today! http://www.codeplex.com/IronPython Way to go, Jim!! I am impressed with the effort. --greg -- http://mail.python.org/mailman/listinfo/python-list
Re: getting quick arp request
seb wrote: I need to write a scanner that test all the IP adresses that repond on a given port. ... I am using winXP pro on a 2GHZ P4 and 512 Mo. If you have XP Service Pack 2, it cripples port-scanning as part of a 'security' fix. Broadly speaking, it limits the rate at which you can make connections at the OS level; this will show up as event 4226 in the Event Viewer if it affects you. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
python vs java
hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. Pls help. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: I don't mind living with it as long as it's documented. It is. In SQLite manual. Or do you hope the Python manual to also fully document PostgreSQL, MySQL, Oracle, Apache, Posix, Win32 etc ? With those other applications, you have a separate download. With sqlite, you don't, on Windows at least. Surely all the 'included batteries' should have local documentation, especially with the type conversions. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Netstat Speed
On Sat, 2 Sep 2006 20:13:01 +0200, Sybren Stuvel [EMAIL PROTECTED] wrote: Jorgen Grahn enlightened us with: | def ip_is_active(addr): | Return success if 'addr' shows up in the output from 'netstat -an'. | We assume that a suitable version of netstat exists. | If I have an if in the docstring, I always write the else case as well: Returns True if 'addr' shows up in the output from 'netstat -an', and False otherwise. We assume that a suitable version of netstat exists. This makes it clear what happens in either case. Tastes differ. I think it's clear enough without the else. Note that I changed the name of the function too, to make it read like a test (or rather an assertion): if not ip_is_active('127.0.0.1'). /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
running script in pyalamode
Is there a way to run a script within the editor of pyalamode? Or does one need to open and run the saved .py file? -- http://mail.python.org/mailman/listinfo/python-list
Re: getting quick arp request
Hi Ben, I am indeed using XP SP2. I have checked on the event viewer and I have not seen the event 4226. Besides I also run on the same PC angry Ip scanner 2.21. Checking using ethereal the arp request are all dispatched quit quickly (see my mail above). Thanks for the advice anyway. Sebastien. Ben Sizer wrote: seb wrote: I need to write a scanner that test all the IP adresses that repond on a given port. ... I am using winXP pro on a 2GHZ P4 and 512 Mo. If you have XP Service Pack 2, it cripples port-scanning as part of a 'security' fix. Broadly speaking, it limits the rate at which you can make connections at the OS level; this will show up as event 4226 in the Event Viewer if it affects you. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
RE: Import a textfile to MS SQL with python
[EMAIL PROTECTED] | i gott the same results with both executemany and execute. i will try | with some other sql modules. if you try tim so let me now if | you cot it | to work. OK, the relevant thing here is the paramstyle. When I made that misguided claim earlier that ? was the most common parameter character, I didn't check whether pymssql actually uses it. And it doesn't. code import pymssql print pymssql.paramstyle # pyformat /code This means that you are expected to put %s everywhere you want a substitution from your parameter list. Again, don't bother quoting for strings etc. Therefore, the following works for this db-module: code import pymssql db = pymssql.connect (...) # # Fake some data as tho' it had come from # your text file. # data = data = [[1, 'Tim', 'Golden'], [2, 'Fred', 'Smith']] q = db.cursor () q.execute (CREATE TABLE ztemp (id INT, first_name VARCHAR (60), last_name VARCHAR (60))) q.executemany (INSERT INTO ztemp (id, first_name, last_name) VALUES (%s, %s, %s), data) q.execute (SELECT * FROM ztemp) for row in q.fetchall (): print row q.execute (DROP TABLE ztemp) /code 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. That's true to an extent. Both Java and Python come with extensive standard libraries, providing a useful toolkit for the programmer. Python does have a number of cross-platform GUI toolkits abailable too, including one in the standard library, although WxWidgets (formerly WxWindows) is also popular. I'd say that Python is easier to learn and more productive as a language, but Java has a much larger selection of add-ons and libraries available. I can't give you much more help without knowing what the app will do, and therefore what language features or library/framework support would be helpful. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
Re: getting quick arp request
Hi Ben, I am indeed using XP SP2. - Some more info : - 1) I have checked on the event viewer and I have not seen the event 4226 while I have run the code sample above. 2) I can still see this error (4226) recently In the log so that I must have bumped against this limit trying to put pull this out. 3) I have installed today process explorer (from sysinternals). I am not completly used to it but you can have a look at the TCP/IP connections opened by the processes. It appears that I have alwyas 10 connections opened (and the IP adresses progress durning the scan from Ip adresse 192.168.3.1 - 254). 4) Besides I also run on the same PC angry Ip scanner 2.21. Checking using ethereal the arp request are all dispatched quit quickly (see my mail above). NEW RESULT : --- Something is limiting the TCP/IP connections from my python program at 10 maximum at the same time. I do not see this limit in my code. I did not bumped over the 4226 error. = Where does this limit come from. = How can I overcome it. Thanks for the advice anyway. Sebastien. Ben Sizer wrote: seb wrote: I need to write a scanner that test all the IP adresses that repond on a given port. ... I am using winXP pro on a 2GHZ P4 and 512 Mo. If you have XP Service Pack 2, it cripples port-scanning as part of a 'security' fix. Broadly speaking, it limits the rate at which you can make connections at the OS level; this will show up as event 4226 in the Event Viewer if it affects you. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
accessing the DHCP Server Management API
Hello, I need to get a list of active leases on a windows dhcp server. Experts from Microsoft statet: A: Go to the Address leases of each scope in the DHCP snap-in and dump the leases to a text file from the DHCP server snap-in. The text file gives you all the information for every active lease. You might also want to query the DHCP server management API: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcpenumsubnetclients.asp. (http://www.microsoft.com/technet/community/chats/trans/windowsnet/wnet_05_0303.mspx) Option A is not really an option for programmatic access :) So my question: Has anyone accessed the DHCP Server Management API from Python before? I googled my browser smoking with hopes that that API might be accessible via WMI, but to no avail for me. Any recommendation how to access this information via Python? pyDHCPSMA anyone? Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Import a textfile to MS SQL with python
Yes i got it to work now. Thank you for all help Tim and Steve. I hope it will work for Oracle to :) Regards Joel -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
Jim Hugunin wrote: I'm extremely happy to announce that we have released IronPython 1.0 today! http://www.codeplex.com/IronPython snip 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? At work we seem to be doing more and more with dotNet and perhaps this is a way of bringing my tools into the same environment. In any event, what you've done sounds cool. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: How to insert an email-link into wxPython's HtmlWindow
Override OnLinkClicked() and check the passed link info for the 'mail:' prefix. And if its there, don't call the OnLinkClicked() method of the base class, to prevent wxWidgets from loading this link as a HTML ressource. Now, you have reduced your problem to: how do I call the standard Email client? I have no idea... Have fun, Noel -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: some of my friends told that python and java are similar in the idea of platform independency. Similar in goal, but quite different in approach. Python supports lots of platforms and goes to great lengths to offer facades around whatever features a platform does have, so as to offer the same benefits as Unix. Java lives in a virtualised environment where it pretends there aren't any platforms. Perl pretends everything _is_ Unix and falls flat when it isn't. If you can cope with this, Java is simpler and less platform-bound. If you actually need to get OS-level work done, Python is wonderful. You can write stuff that hooks in at a fairly deep level, yet really is portable. -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 released today!
Great, I couldn't do better Ok, I couldn't do it all... ;o) But I'm a little bit concerned. Have you ever thought of using a different file prefix for python files depending on .NET assemblies like .pyi? Sooner or later we want to associate IronPython files with IronPython in the windows shell. Don't get me wrong, I really appreciate your effort of bringing Python to .NET. But I fear a lof of users could be disappointed if they start a IronPython file with CPython and vice versa. Just my 0.05, Noel -- http://mail.python.org/mailman/listinfo/python-list
Re: any portable way to print? (and i mean on a printer)
Steve Holden wrote: Liquid Snake wrote: I think my question is clear.., is there any way to print any text on a portable way?..., and actually, i don't know how to print at all.., just give me some pointers, name a module, and i can investigate for myself.. sorry for my english, thanks in advance.. ps: i prefer a Standard Library module. No, there is no way to print any text (did yo also want to print graphics?) portably (by which I mean a way that will work on Windows, Linux, Solaris, HP-UX, AIX, ...). Well, that's not quite true, Steve. Python bindings for various cross-platform frameworks should manage this quite well, depending on what the original poster meant by text. PyQt4, for example, provides classes that let you print to native printers on Linux, Mac OS X, Windows and various other Unix platforms: http://www.riverbankcomputing.co.uk/pyqt/ However, the original poster did specify a preference for a standard library module, so your answer is probably correct within that context. :-) If the printer was a network printer, there might be some more options to explore. I think there's potential for a pure Python solution to this problem to be added to the desktop module: http://cheeseshop.python.org/pypi/desktop/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
Chris: 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, IronPython is currently unable to load CPython DLLs. Neil -- http://mail.python.org/mailman/listinfo/python-list
[no subject]
The original message was included as attachment Deleted0.txt Description: Binary data -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
Chris wrote: Jim Hugunin wrote: I'm extremely happy to announce that we have released IronPython 1.0 today! http://www.codeplex.com/IronPython snip 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? At work we seem to be doing more and more with dotNet and perhaps this is a way of bringing my tools into the same environment. 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 -- http://mail.python.org/mailman/listinfo/python-list
ricerca
Stiamo cercando uno sviluppatore Python esperto in Vue 5 Infinite. Grazie Willy -- http://mail.python.org/mailman/listinfo/python-list
IronPython 1.0 - Bugs or Features?
(just wanted to share my experience with IronPython 1.0) 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: code while(someCondition): try: strData = strSomeValue() except: pass if( type(strData) == str ) : ### HERE THE ERROR doSomething() /code CPython 2.4.2 doesn't raise an error with same code. As strData is not set anywhere before in the code it seems, that IronPython is somehow right, but I am not sure if it is a bug or a feature. Another problem with IronPython where CPython 2.4.2 runs ok was while I was trying to do: f = file(r'\\.\PhysicalDrive0', 'rb') getting ValueError: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of \\.\ in the path. Here the same - I am not sure if it is a bug or a feature. Can someone knowledgeable elaborate on it a bit please? Claudio Grondi -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
On Wed, 6 Sep 2006 17:53:29 +0530, Aravind [EMAIL PROTECTED] wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. Well, what Java and Python (and some other languages) have in common is a large standard library. The C++ standard library is smaller, and doesn't cover things like advanced file I/O, networking, concurrency, or user interfaces. You either have to find third-party portable libraries for the things you want to do, or target a specific platform. As a side note, Python differs from Java by happily including non-portable things in its standard library. If Unix people need access to poll(2); fine, then they make it available, even though it won't work on e.g. Win32. And document that it isn't portable. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Read from .glade
Hello, I've got the following problem: I've got a Userinterface that is made in Glade, so i've got a .glade file. What I want is to get the id's of every widget from the class GtkEntry from a given window. The glade file is like ?xml version=1.0 standalone=no? !--*- mode: xml -*-- !DOCTYPE glade-interface SYSTEM http://glade.gnome.org/glade-2.0.dtd; glade-interface widget class=GtkWindow id=TEVOinvoeren property name=visibleTrue/property property name=title translatable=yesTevo - Invoeren/property property name=typeGTK_WINDOW_TOPLEVEL/property property name=window_positionGTK_WIN_POS_NONE/property property name=modalFalse/property property name=resizableTrue/property property name=destroy_with_parentFalse/property property name=decoratedTrue/property property name=skip_taskbar_hintFalse/property property name=skip_pager_hintFalse/property property name=type_hintGDK_WINDOW_TYPE_HINT_NORMAL/property property name=gravityGDK_GRAVITY_NORTH_WEST/property property name=focus_on_mapTrue/property property name=urgency_hintFalse/property child widget class=GtkWindow id=TEVOklanttoevoegen property name=visibleTrue/property property name=title translatable=yeswindow1/property property name=typeGTK_WINDOW_TOPLEVEL/property property name=window_positionGTK_WIN_POS_NONE/property property name=modalFalse/property property name=resizableTrue/property property name=destroy_with_parentFalse/property property name=decoratedTrue/property property name=skip_taskbar_hintFalse/property property name=skip_pager_hintFalse/property property name=type_hintGDK_WINDOW_TYPE_HINT_NORMAL/property property name=gravityGDK_GRAVITY_NORTH_WEST/property property name=focus_on_mapTrue/property property name=urgency_hintFalse/property signal name=destroy handler=on_TEVOklanttoevoegen_destroy last_modification_time=Wed, 06 Sep 2006 08:51:33 GMT/ child widget class=GtkFixed id=fixed10 property name=visibleTrue/property child widget class=GtkEntry id=entry_cnaam property name=width_request184/property property name=height_request16/property property name=visibleTrue/property property name=can_focusTrue/property property name=editableTrue/property property name=visibilityTrue/property property name=max_length0/property property name=text translatable=yes/property property name=has_frameTrue/property property name=invisible_char*/property property name=activates_defaultFalse/property /widget packing property name=x88/property property name=y88/property /packing /child . Kind regards, Ralf Brand -- http://mail.python.org/mailman/listinfo/python-list
change property after inheritance
Suppose a class has properties and I want to change the setter in a derived class. If the base class is mine, I can do this: http://www.kylev.com/2004/10/13/fun-with-python-properties/ Should I? (I.e., is that a good solution?) And what if I cannot change the base class? How to proceed then? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Well, not quite IMHO. Java treats the problem by taking the autistic attitude of pretending the underlying platform doesn't exists - which can be a major PITA. Python is much more pragmatic, and can even offer really strong integration with the platform *without* sacrifying portability - the core language is platform-independant and tries to help you wrinting platform-independant code (cf the os and os.path modules), and platform-specific stuff is usually isolated in distinct packages with a BIG caution note on it !-) Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. With a GUI ? If so, you probably want to check out wxPython or PyGTK (wxPython will also buy you MacOS X IIRC, and wil perhaps be easier to install on Windows). Else (web, command-line, what else ?), you should not have any particular problem as long as you avoid using platform-specific packages and always use the portability helper features (ie os.path etc). Coming from C++, you'll probably need a few days to grasp Python's object model and idioms (Python looks much less like a dumbed-down C++ than Java), but my bet is that you'll be productive *way* sooner with Python, and *much* more productive. My 2 cents, -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE
Aravind wrote: 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. What you're talking about here is a GUI designer tool, not an IDE. GUI designer tools are bound to a particular GUI toolkit, so you need to choose your GUI toolkit too. There are some GUI toolkits available for Python, the most used being TK (the one in the stdlib), wxWidget (a C++ portable toolkit running on Windows/Unices/MacOS X) and GTK (a C toolkit initially written for Linux, but there's a Windows port AFAIK), with the corresponding bindings for Python resp. Tkinter, wxPython and PyGTK. QTDesigner is for QT, another GUI toolkit running on bowth Windows and Linux - but there are (was) some licencing limitations on Windows. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE
Aravind wrote: 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 Active State Komodo Runs on Windows, Linux and Mac OS X there is even a cheap $29 personal version available. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter bus error right away
Hi, I just tried to run Tkinter on OS X 10.3.9 under Python 2.4.3, and I'm getting a bus error as soon as I call Tk(). Googling has turned up info other Tkinter bus errors, but not this one that occurs right away, before doing anything fancy. Tk/Tcl is definitely installed on my computer, as verified by running wish and seeing the window come up. info patchlevel returns 8.4.5. Here's the tail of the output from python -v: Python 2.4.3 (#1, Mar 30 2006, 11:02:15) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type help, copyright, credits or license for more information. import readline # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/readline.so from Tkinter import * # /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkinter.pyc has bad mtime import Tkinter # from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkinter.py # wrote /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkinter.pyc import _tkinter # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/_tkinter.so # /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkconstants.pyc matches /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkconstants.py import Tkconstants # precompiled from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk/Tkconstants.pyc import MacOS # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/MacOS.so root = Tk() Bus error Any suggestions? Is this an Aqua vs. X11 issue? Many thanks, Ben Kovitz -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 - Bugs or Features?
In [EMAIL PROTECTED], 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: code while(someCondition): try: strData = strSomeValue() except: pass if( type(strData) == str ) : ### HERE THE ERROR doSomething() /code 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. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
On 9/6/06, Aravind [EMAIL PROTECTED] wrote: hi,some of my friends told that python and java are similar in the idea ofplatform independency. Can anyone give me an idea as i'm a newbie to javaand python but used to C++. My idea is to develop an app which can run both in windows and linux. IMHO i think that in general Python is better than Java for many reason: 1) Java - statically typed, all variable name must be explicitly declared 1) Python - you never declare anything. An assignment statement binds a name to an object, and the object can be of any type. 2) Java - verbose, too many words than are necessary. 2) Python - concise, clean-cut brevity. 3) Java - not compact 3) Python - Compact stupid example: Java public class HelloWorld { public static void main (String[] args) { System.out.println(Hello, world!); } } Python print Hello, world 4)Python - You can create mixed list 4)Java - You can't 5) Java learning is not fast and easy 5) Python learning is fast and easy also for newbie developers There are other many advantages but it depends from what you want do. -- MorphNon sono i popoli a dover aver paura dei propri governi, ma i governi che devono aver paura dei propri popoli. (V) -- http://mail.python.org/mailman/listinfo/python-list
Re: sci-py error
Cecilia Marini Bettolo wrote: Hi! When installing scipy I get this error: python setup.py install Traceback (most recent call last): File setup.py, line 55, in ? setup_package() File setup.py, line 28, in setup_package from numpy.distutils.core import setup File /usr/local/lib/python2.4/site-packages/numpy/__init__.py, line 40, in ? import linalg File /usr/local/lib/python2.4/site-packages/numpy/linalg/__init__.py, line 4, in ? from linalg import * File /usr/local/lib/python2.4/site-packages/numpy/linalg/linalg.py, line 25, in ? from numpy.linalg import lapack_lite ImportError: /usr/lib/libblas.so.3: undefined symbol: e_wsfe Your numpy package was built incorrectly. e_wsfe is a symbol that should be provided by libg2c, the FORTRAN runtime for g77. http://www.scipy.org/FAQ#head-26562f0a9e046b53eae17de300fc06408f9c91a8 Please ask again on the numpy mailing list and provide some more information, like your platform, the versions of your compilers, and some more details about how you went about building numpy and any errors or warnings you got. http://www.scipy.org/Mailing_Lists -- 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: change property after inheritance
Le mercredi 06 septembre 2006 16:33, David Isaac a écrit : Suppose a class has properties and I want to change the setter in a derived class. If the base class is mine, I can do this: http://www.kylev.com/2004/10/13/fun-with-python-properties/ Should I? (I.e., is that a good solution?) Why not ? This ontroduce the notion of public getter a la C++/Java while the property is overloadable by itself (as below), but it's correct design IMHO. And what if I cannot change the base class? How to proceed then? Like that : In [44]: class a(object) : : p=property(lambda s : getattr(s, '_p', None)) : : In [46]: class b(a) : : p=property(a.p.fget, lambda s, v : setattr(s, '_p', v)) : : In [47]: print a().p None In [48]: a().p = 5 --- exceptions.AttributeErrorTraceback (most recent call last) /home/maric/ipython console AttributeError: can't set attribute In [49]: ib=b() In [50]: print ib.p None In [51]: ib.p = 5 In [52]: print ib.p 5 In [53]: ib._p Out[53]: 5 -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from .glade
On Wednesday, September 06, 2006, at 10:36AM, [EMAIL PROTECTED] wrote: Hello, I've got the following problem: I've got a Userinterface that is made in Glade, so i've got a .glade file. What I want is to get the id's of every widget from the class GtkEntry from a given window. The glade file is like ?xml version=1.0 standalone=no? !--*- mode: xml -*-- !DOCTYPE glade-interface SYSTEM http://glade.gnome.org/glade-2.0.dtd; glade-interface widget class=GtkWindow id=TEVOinvoeren snip rest of glade xml file Kind regards, Ralf Brand You want to use one of the XML processing libraries. The simplest (and should be fine for this use) is dom. Here is some code I wrote as part of GladeGen - see http://www.linuxjournal.com/article/7421 that you should be able to easily extract the piece you need: doc = xml.dom.minidom.parse(self.glade_file) # look for widgets and get their widget type and name for node in doc.getElementsByTagName('widget'): widget = str(node.getAttribute('class')) name = str(node.getAttribute('id')) if self.top_window is None and widget == 'GtkWindow': self.top_window = name # if the widget type is in list of widgets user specified # in config file, include it in the list if widget in GladeGenConfig.include_widget_types: # (widget type, name) # ('GtkWindow', 'window1') self.widgets.append((widget, name)) HTH, Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
[EMAIL PROTECTED] wrote: Bryan Olson wrote: I think it's even worse. The standard Python library offers shared memory, but not cross-process locks. File locks are supported by the standard library (at least on Unix, I've not tried on Windows). They work cross-process and are a normal method of interprocess locking even in C code. Ah, O.K. Like Paul, I was unaware how Unix file worked with mmap. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 - Bugs or Features?
Claudio Grondi wrote: (just wanted to share my experience with IronPython 1.0) 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: code while(someCondition): try: strData = strSomeValue() except: pass if( type(strData) == str ) : ### HERE THE ERROR doSomething() /code CPython 2.4.2 doesn't raise an error with same code. As strData is not set anywhere before in the code it seems, that IronPython is somehow right, but I am not sure if it is a bug or a feature. Another problem with IronPython where CPython 2.4.2 runs ok was while I was trying to do: f = file(r'\\.\PhysicalDrive0', 'rb') getting ValueError: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of \\.\ in the path. Here the same - I am not sure if it is a bug or a feature. Can someone knowledgeable elaborate on it a bit please? Claudio Grondi Your problem is a blanket exception handler that ignores the exception. Blanket exceptions are almost always a bad idea. Blanket exceptions with pass as the only command in the except: block is ALWAYS a bad idea. Basically the line strData = strSomeValue() caused an exception. Since it was inside a try: block, it then executed what was in the except: block. Since all that was in the except: block was pass, it just fell through to the if statement. At that point strData is not defined because the try block failed and never create strData object. It is doing EXACTLY what you told it to do. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Secure Postgres access
Hi folks, I would like to access a remote Postgres server from a Python program in a secure way. Postgres doesn't currently listen to the Internet for connections, and I'd prefer to keep it that way. I know how to forward ports using SSH, but I don't like doing this because then anyone who knows the port number can connect to Postgres over the same tunnel. (I'm not the only user on the client machine.) What I envision is something like wrapping an SSH connection which then opens psql once connected, but I'm not too picky. Both Postgres and the Python program are running on Linux. Any ideas? Thanks very much for any help. Reid -- http://mail.python.org/mailman/listinfo/python-list
Refactor a buffered class...
Hello, i'm looking for this behaviour and i write a piece of code which works, but it looks odd to me. can someone help me to refactor it ? i would like to walk across a list of items by series of N (N=3 below) of these. i had explicit mark of end of a sequence (here it is '.') which may be any length and is composed of words. for: s = this . is a . test to . check if it . works . well . it looks . like . the output should be (if grouping by 3) like: = this . = this . is a . = this . is a . test to . = is a . test to . check if it . = test to . check if it . works . = check if it . works . well . = works . well . it looks . = well . it looks . like . my piece of code : import sys class MyBuffer: def __init__(self): self.acc = [] self.sentries = [0, ] def append(self, item): self.acc.append(item) def addSentry(self): self.sentries.append(len(self.acc)) print sys.stderr, \t, self.sentries def checkSentry(self, size, keepFirst): n = len(self.sentries) - 1 if keepFirst and n size: return self.acc if n % size == 0: result = self.acc first = self.sentries[1] self.acc = self.acc[first:] self.sentries = [x - first for x in self.sentries] self.sentries.pop(0) return result s = this . is a . test to . check if it . works . well . it looks . like . l = s.split() print l mb = MyBuffer() n = 0 for x in l: mb.append(x) if x == '.': # end of something print +, n n += 1 mb.addSentry() current = mb.checkSentry(3, True) # GROUPING BY 3 if current: print =, current -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 - Bugs or Features?
Claudio Grondi wrote: Another problem with IronPython where CPython 2.4.2 runs ok was while I was trying to do: f = file(r'\\.\PhysicalDrive0', 'rb') getting ValueError: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of \\.\ in the path. Here the same - I am not sure if it is a bug or a feature. Can someone knowledgeable elaborate on it a bit please? I guess it's M$ being overprotective. Certainly it works in CPython as expected, f = file(r'\\.\PhysicalDrive0', 'rb') f open file '\\.\PhysicalDrive0', mode 'rb' at 0x01292650 I have used similar to get boot sectors etc, but then did you really think Bill would let us play with our own hardware? Just wait till DRM gets here. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Secure Postgres access
Reid Priedhorsky [EMAIL PROTECTED] writes: I know how to forward ports using SSH, but I don't like doing this because then anyone who knows the port number can connect to Postgres over the same tunnel. (I'm not the only user on the client machine.) Wouldn't they need a database password? -- http://mail.python.org/mailman/listinfo/python-list
Re: Secure Postgres access
Can't you limit SSH tunneling access to the IP and/or MAC that you want to access ? It's simplest than any other solution. -- http://mail.python.org/mailman/listinfo/python-list
22, invalid agument error
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 string, 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: EVIDENCE: 911 was CONTROLLED DEMOLITION to make muslims 2nd class
[EMAIL PROTECTED] wrote: [snip rubbish] You cannot even spell your own handle. http://en.wikipedia.org/wiki/Thermite Socks -- http://mail.python.org/mailman/listinfo/python-list
Scientific computing and data visualization.
Hallo I would like to have a high class open source tools for scientific computing and powerful 2D and 3D data visualisation. Therefore I chose python, numpy and scipy as a base. Now I am in search for a visualisation tool. I tried matplotlib and py_opendx with OpenDx. OpenDx seems to me very good but the project py_opendx looks like closed. After py_opendx instalation and subsequent testing I got an error that needs discussion with author or an experienced user. Unfortunately a mail to author returned as undeliverable. Does anybody now about suitable visualisation tool? Does anybody have an experience with OpenDx and py_opendx instalation? Thanks for your response. fiepye -- http://mail.python.org/mailman/listinfo/python-list
Path?
I installed Python 2.5 on Windows XP. I got the following system that works well. --- Python 2.5b3 (r25b3:51041, Aug 3 2006, 09:35:06) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. IDLE 1.2b3 import sys sys.path ['C:\\Python25\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\wx-2.6-msw-ansi'] --- Question: How did I end up with the second item in path? Is that a zip file? There is no such a file in system32. What would be the correct way to set path to assist the search? Thanks for any advice. == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Refactor a buffered class...
[EMAIL PROTECTED] wrote: Hello, i'm looking for this behaviour and i write a piece of code which works, but it looks odd to me. can someone help me to refactor it ? i would like to walk across a list of items by series of N (N=3 below) of these. i had explicit mark of end of a sequence (here it is '.') which may be any length and is composed of words. for: s = this . is a . test to . check if it . works . well . it looks . like . the output should be (if grouping by 3) like: = this . = this . is a . = this . is a . test to . = is a . test to . check if it . = test to . check if it . works . = check if it . works . well . = works . well . it looks . = well . it looks . like . my piece of code : import sys class MyBuffer: def __init__(self): self.acc = [] self.sentries = [0, ] def append(self, item): self.acc.append(item) def addSentry(self): self.sentries.append(len(self.acc)) print sys.stderr, \t, self.sentries def checkSentry(self, size, keepFirst): n = len(self.sentries) - 1 if keepFirst and n size: return self.acc if n % size == 0: result = self.acc first = self.sentries[1] self.acc = self.acc[first:] self.sentries = [x - first for x in self.sentries] self.sentries.pop(0) return result s = this . is a . test to . check if it . works . well . it looks . like . l = s.split() print l mb = MyBuffer() n = 0 for x in l: mb.append(x) if x == '.': # end of something print +, n n += 1 mb.addSentry() current = mb.checkSentry(3, True) # GROUPING BY 3 if current: print =, current If you just need to 'walk across a list of items', then your buffer class and helper function seem unnecessary complex. A generator would do the trick, something like: def chunker(s, chunk_size=3, sentry=.): ... buffer=[] ... sentry_count = 0 ... for item in s: ... buffer.append(item) ... if item == sentry: ... sentry_count += 1 ... if sentry_count chunk_size: ... del buffer[:buffer.index(sentry)+1] ... yield buffer ... s = this . is a . test to . check if it . works . well . it looks. like . for p in chunker(s.split()): print .join(p) ... this . this . is a . this . is a . test to . is a . test to . check if it . test to . check if it . works . check if it . works . well . works . well . it looks. like . HTH Michael -- http://mail.python.org/mailman/listinfo/python-list
Script Bug?
okay,I'm going through this python tutorial, and according to the tutorial, I can type this: [code] myList = [1,2,3,4] for index in range(len(myList)): myList[index] += 1 print myList [/code] however, in my IDLE python shell, when I type [code] myList = [1,2,3,4] for index in range(len(myList)):[/code] it just gives me a prompt [code] [/code] ? why doesn't it just bring me to line three? I need to have persistence, cause little snags like these discourage me. I know I need thicker skin to write code. any advice is appreciated -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 - Bugs or Features?
Larry Bates wrote: Claudio Grondi wrote: (just wanted to share my experience with IronPython 1.0) 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: code while(someCondition): try: strData = strSomeValue() except: pass if( type(strData) == str ) : ### HERE THE ERROR doSomething() /code CPython 2.4.2 doesn't raise an error with same code. As strData is not set anywhere before in the code it seems, that IronPython is somehow right, but I am not sure if it is a bug or a feature. Another problem with IronPython where CPython 2.4.2 runs ok was while I was trying to do: f = file(r'\\.\PhysicalDrive0', 'rb') getting ValueError: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of \\.\ in the path. Here the same - I am not sure if it is a bug or a feature. Can someone knowledgeable elaborate on it a bit please? Claudio Grondi Your problem is a blanket exception handler that ignores the exception. Blanket exceptions are almost always a bad idea. Blanket exceptions with pass as the only command in the except: block is ALWAYS a bad idea. Basically the line strData = strSomeValue() caused an exception. Since it was inside a try: block, it then executed what was in the except: block. Since all that was in the except: block was pass, it just fell through to the if statement. At that point strData is not defined because the try block failed and never create strData object. It is doing EXACTLY what you told it to do. Sorry for the confusion caused, but you are right. The actual code was a bit more complex, so I tried to get it down to the principle, but haven't expected, that f = file(r'\\.\PhysicalDrive0', 'rb') buried within strSomeValue() throws an exception as in CPython the code was running ok. So the second problem was the cause also for the first one ... I also erroneously assumed, that the first problem was detected during parsing ... so, by the way: how can I distinguish an error raised while parsing the code and an error raised when actually running the code? Claudio Grondi -- http://mail.python.org/mailman/listinfo/python-list