ANN: Naja 1.2.1 is now available
Naja is a download manager and a website grabber written in Python/wxPython.You can add some plugins (newsreader, FTP - FTPS - SFTP client,WebDAV client) and take control of your downloads from your office. Naja supports proxy (HTTP, HTTPS, FTP,SOCKS v4a, SOCKSv5), and use some authentication methods.The downloading maybe achieved by splitting the file being downloaded into several parts and downloading these parts at the same time (HTTP,HTTPS,FTP). Donwload speeds are increased by downloading the file from the mirrors sites,when the sites propose it. Others features: Csv filter Cheksums (CRC32, MD2, MD4, MD5, SHA, SHA1, MDC2, RMD160) Crypt (Only for the eXtended version) and Decrypt (AES, DES, 3DES ...) newsreader, newsposter (uue, yEnc) CGI WebDAV Server Web Interface basic and digest authentication for client and server Compress and decompress (zip, tar.gz, tar.bz2) Picture viewer Text Editor Naja is available for download from the Keyphrene web site: http://www.keyphrene.com/products/naja -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ReleaseForge 0.7.1 - A SourceForge release tool
ReleaseForge 0.7.1 is now available for download. This is a minor bugfix release. This version corrects a formatting bug when submitting project news. Additionally, auto-generated PyQt files were re-generated with pyuic version 3.14 (which fixes a QSizePolicy problem). About ReleaseForge: ReleaseForge is a GUI application designed for project administrators and release engineers of projects that are hosted at SourceForge. It is intended to make it easier and faster to create a new release and edit existing releases rather than using the SourceForge Web interface. ReleaseForge streamlines the release effort by prompting you for information regarding your new release (version info, change log, release notes, files to include, etc). It then seamlessly negotiates with the SourceForge Web server, creating your release, posting your release notes/change log, uploading your files to the SourceForge FTP server, selecting the files for inclusion in your release on the SourceForge Web server, updating the file attributes of each of the files and then, if appropriate, notifying monitoring users of the new release. --- http://releaseforge.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
dllimporter -- import dlls for zip archived or frozen applications
'Dllimporter' is a package to facilitate the import of shared libraries (aka dlls or extension modules) for Python applications running from a zip archive or an executable (a frozen application). The standard Python import mechanism cannot import extension modules being part of a zip archived or frozen package. 'Dllimporter' overcomes this restriction. The package provides a class 'dllimporter' the instances of which implement Pythons 'importer' protocol (see PEP-0302). These instances are designed to be used as importers on Pythons 'sys.meta_path' (again see PEP-0302, for details). Download: http://www.dieter.handshake.de/pyprojects/dllimporter.tgz Dieter -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ZODB 3.4 beta 1 released
I'm pleased to announce the release of ZODB 3.4 beta 1. This corresponds to the ZODB that will ship in Zope 2.8b2. You can download a source tarball or Windows installer from: http://zope.org/Products/ZODB3.4 Note that there are two Windows installers, for Python 2.3 (2.3.5 is recommended) and Python 2.4 (2.4.1 is recommended). ZODB 3.4b1 contains many bugfixes and new features, including: - savepoint/rollback support, a powerful generalization of subtransactions allowing to revert to any savepoint'ed state within a transaction - auto-synchronization with storages after a transaction commit or abort, and at the explict start (transaction.begin()) of a transaction - a way to register callbacks invoked just before a transaction starts to commit -- see the new transaction.beforeCommitHook() - a new release of ZConfig See the news file for details: http://zope.org/Products/ZODB3.4/NEWS.html Note that ZODB 3.4 does not support any version of Zope 2.6 or 2.7. Current Zope 2.8 and Zope 3 development use ZODB 3.4. The ZODB 3.3 line is officially retired (3.3.1 final was the last release in the 3.3 line). -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Announcing : pyglfw
Hello folks, I am please to announce the first release of pyglfw, a python binding for GLFW written as an extension module. GLFW is simple framework acting like a glue between OpenGL and the system. The aim of pyglfw is simply for me to get my hands on writing an extension for Python, so this is quite an alpha code I release. Although it works fine, it might need some fixing in some areas. Please have a look at it and feel free to let me know what you think about it. Here is the hope page of pyglfw : http://www.defuze.org/oss/pyglfw/ Regards, - Sylvain This message was sent using IMP, the Internet Messaging Program. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
first release of PyPy
The PyPy 0.6 release *The PyPy Development Team is happy to announce the first public release of PyPy after two years of spare-time and half a year of EU funded development. The 0.6 release is eminently a preview release.* What it is and where to start - Getting started:http://codespeak.net/pypy/index.cgi?doc/getting_started.html PyPy Documentation: http://codespeak.net/pypy/index.cgi?doc PyPy Homepage: http://codespeak.net/pypy/ PyPy is a MIT-licensed reimplementation of Python written in Python itself. The long term goals are an implementation that is flexible and easy to experiment with and retarget to different platforms (also non-C ones) and such that high performance can be achieved through high-level implementations of dynamic optimisation techniques. The interpreter and object model implementations shipped with 0.6 can be run on top of CPython and implement the core language features of Python as of CPython 2.3. PyPy passes around 90% of the Python language regression tests that do not depend deeply on C-extensions. Some of that functionality is still made available by PyPy piggy-backing on the host CPython interpreter. Double interpretation and abstractions in the code-base make it so that PyPy running on CPython is quite slow (around 2000x slower than CPython ), this is expected. This release is intended for people that want to look and get a feel into what we are doing, playing with interpreter and perusing the codebase. Possibly to join in the fun and efforts. Interesting bits and highlights - The release is also a snap-shot of our ongoing efforts towards low-level translation and experimenting with unique features. * By default, PyPy is a Python version that works completely with new-style-classes semantics. However, support for old-style classes is still available. Implementations, mostly as user-level code, of their metaclass and instance object are included and can be re-made the default with the ``--oldstyle`` option. * In PyPy, bytecode interpretation and object manipulations are well separated between a bytecode interpreter and an *object space* which implements operations on objects. PyPy comes with experimental object spaces augmenting the standard one through delegation: * an experimental object space that does extensive tracing of bytecode and object operations; * the 'thunk' object space that implements lazy values and a 'become' operation that can exchange object identities. These spaces already give a glimpse in the flexibility potential of PyPy. See demo/fibonacci.py and demo/sharedref.py for examples about the 'thunk' object space. * The 0.6 release also contains a snapshot of our translation-efforts to lower level languages. For that we have developed an annotator which is capable of infering type information across our code base. The annotator right now is already capable of successfully type annotating basically *all* of PyPy code-base, and is included with 0.6. * From type annotated code, low-level code needs to be generated. Backends for various targets (C, LLVM,...) are included; they are all somehow incomplete and have been and are quite in flux. What is shipped with 0.6 is able to deal with more or less small/medium examples. Ongoing work and near term goals - Generating low-level code is the main area we are hammering on in the next months; our plan is to produce a PyPy version in August/September that does not need to be interpreted by CPython anymore and will thus run considerably faster than the 0.6 preview release. PyPy has been a community effort from the start and it would not have got that far without the coding and feedback support from numerous people. Please feel free to give feedback and raise questions. contact points: http://codespeak.net/pypy/index.cgi?contact contributor list: http://codespeak.net/pypy/index.cgi?doc/contributor.html have fun, Armin Rigo, Samuele Pedroni, Holger Krekel, Christian Tismer, Carl Friedrich Bolz PyPy development and activities happen as an open source project and with the support of a consortium funded by a two year EU IST research grant. Here is a list of partners of the EU project: Heinrich-Heine University (Germany), AB Strakt (Sweden) merlinux GmbH (Germany), tismerysoft GmbH(Germany) Logilab Paris (France), DFKI GmbH (Germany) ChangeMaker (Sweden) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Is Python suitable for a huge, enterprise size app?
Dave Brueck wrote: Overall it's been such a positive experience for us that nobody in the company - from grunt testers up to the CTO - has any reservations about using Python in production anymore (even though initially they all did). All of the developers have previous experience with using Java in production systems, and none seriously consider it for new projects at all. -Dave Think there is still a lack of communicating success on that scale. If I think about serious IT magazines published in Germany ( e.g. Object Spectrum ), there are tons of experience reports about all kinds of enterprise systems, that were created and managed in Java/dotNET. There might be a slight progress if you review some of the talks on the next Europython conference: http://www.python-in-business.org/ep2005/alisttrack.chtml?track=692 But this is still internal from the fans of the language to other fans. Ciao, Kay -- http://mail.python.org/mailman/listinfo/python-list
[pysqlite] How do I use pysqlite in a multi-threading env.?
In my wxPython-app a part of it gathers data, when a button is pressed, and stores it into a db. The GUI part should display the stuff being stored in the db. When both parts work on the same connection, I get SQL statements in progress errors. Seems ok to me, you can't do that. So, next step: Both parts get a separate connection. Now I get Database locked errors. Hmm, yes, it's GUI stuff after all, being all in the same thread. So, next step: I put the data gathering part into a real thread, that's started, wehn the Scan button is pressed. This way the Database locked- errors should got away. But now I get SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 3576 and this is thread id 1040. Hmm, true, I want to display db content, that was stored by an other thread. But that's what multi-threading capabilities are for! I must be missing something here. Anyway, I'm a bit lost now, really. So, how are you doing such stuff with pysqlite? Kind regards Franz GEIGER -- http://mail.python.org/mailman/listinfo/python-list
PyGame and Rotozoom (Sorry if OT)
I'm not sure if this is off-topic, since it doesn't deal with Python itself, but here goes: I'm messing around with writing a simple game where the player (a crudely drawn smiley face) moves by rotating and moving back or forward (think Resident Evil, but from an always-above view). After much hacking, I have it working where left and right rotate the player sprite and up always moves the sprite whichever direction it's facing, while down is reverse. I'm using pygame.transform.RotoZoom(). My problem is that it doesn't rotate smoothly. When it rotates, the corners of the image (just a plain white background) look like they're hitting some barrier and making it move around. Think of an empty box turned diagonally (so that it looks like a diamond, with its open end facing you), and a cube in that box being turned while it's resting in the bottom corner. I want it to rotate smoothly around its center, it's it's not doing that. I'm guessing that it has something to do with me not setting up a Rect right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? Any advice would be greatly appreciated. And yes, I'm a rank PyGame newbie. Thanks, J. W. McCall -- http://mail.python.org/mailman/listinfo/python-list
Re: readline module and white-space
Take a look at readline.get_completer_delims() and readline.set_completer_delims(). -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Paul Rubin wrote: Send e-mail to [EMAIL PROTECTED] -- actually, you can have commit privs if you want. I think I'm going to enter an SF bug on the issue if there isn't already one. It's not obvious to me whether a reasonable fix is possible, but at least it should be tracked. The current behavior is weird and confusing. this has been reported before, and it won't get fixed (unless you're volunteering to add Python-compatible garbage collection to Tk, that is). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: [pysqlite] How do I use pysqlite in a multi-threading env.?
On Fri, May 20, 2005 at 08:42:54AM +0200, F. GEIGER wrote: In my wxPython-app a part of it gathers data, when a button is pressed, and stores it into a db. The GUI part should display the stuff being stored in the db. When both parts work on the same connection, I get SQL statements in progress errors. Seems ok to me, you can't do that. You get that error message with which pysqlite call? So, next step: Both parts get a separate connection. Now I get Database locked errors. Hmm, yes, it's GUI stuff after all, being all in the same thread. One connection did not commit() or rollback() within the default timeout (5 seconds). SQLite is not a good solution if you need long transactions, because other SQLite connections are blocked, then. So, next step: I put the data gathering part into a real thread, that's started, wehn the Scan button is pressed. This way the Database locked- errors should got away. But now I get SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 3576 and this is thread id 1040. Hmm, true, I want to display db content, that was stored by an other thread. But that's what multi-threading capabilities are for! Yes, but pysqlite's threadsafety level is 1, that means you cannot share a connection object among multiple threads. In order to ensure that and to avoid that you get random and unexplainable crashes, I implemented this warning. I must be missing something here. Anyway, I'm a bit lost now, really. So, how are you doing such stuff with pysqlite? Use multiple connections and commit/rollback early. HTH, -- Gerhard -- Gerhard Häring - [EMAIL PROTECTED] - Python, web database development signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Mail System Error - Returned Mail
*** WARNING ** This message has been scanned by MDaemon AntiVirus and was found to contain infected attachment(s). Please review the list below. AttachmentVirus name Action taken -- Document.scr ??? Removed ** The original message was received at Fri, 20 May 2005 17:15:33 +0700 from indomaret.co.id [178.88.246.140] - The following addresses had permanent fatal errors - python-list@python.org -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL (HTTPS) with 2.4
That would be nice if something could be added to the distribution. In general, what needs to be done is as follows: #1: Connect to proxy host:port #2: Send CONNECT request with host:443 of secure url you want to tunnel to. Additional headers can be added depending on authorization needed for connection. #3: Once connection is established, setup a SSL handshake/connection via the proxy then start getting/sending data. I have steps #1 and #2 down and working with no problems, I keep getting hung up on step 3 and that is where the SSL Errors are occuring for me with squid etc. Bloke wrote: Ideally, we should aim at a 'fix' that can be included in the distribution. I am going to look at what communication goes on between the proxy server and a working browser by monitoring the traffic. From what i understand, the proxy needs to be told first to set up a secure connection with the web site, and only then do you pass the url to the proxy. Bloke -- Andrew Bushnell Lead Development Engineer Fluent Inc. 10 Cavendish Court Centerra Resource Park Lebanon, NH 03766 [EMAIL PROTECTED] Phone: 603-643-2600, ext. 757 Fax: 603-643-1721 www.fluent.com -- http://mail.python.org/mailman/listinfo/python-list
Re: XML Newbie needing some serious help..
On 19 May 2005 17:27:05 -0700, rh0dium [EMAIL PROTECTED] wrote: HI all, I am looking to parse a unix tool called lshw ( http://ezix.sourceforge.net/software/lshw.html ). Now this provides a nice XML output which looks similar to the bottom of this message.. That doesn't appear to be well-formed XML, which isn't a good start... -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: XML Newbie needing some serious help..
That doesn't appear to be well-formed XML, which isn't a good start... Indeed. rh0dium, you can't have two nodes elements at root level. If you use an enclosing element around the two nodes, your XML becomes well formed. Like this: ?xml version=1.0 standalone=yes ? root !-- generated by lshw-B.02.03 -- !-- GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-42) -- node id=cpu:0 claimed=true class=processor handle=DMI:0400 ... /node node id=cpu:1 disabled=true claimed=true class=processor handle=DMI:0401 ... /node /root Regards, Adriano. -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL and line drawing
Leonard J. Reder wrote: I am using PIL to annotate some images with lines. I could not find anyway to make the line that is drawn from the ImageDraw object thicker. Does anyone have a suggestion or solution for solving this without to much hacking? if you have 1.1.5, you can use the width option to control the line width. see: http://effbot.org/imagingbook/imagedraw.htm Thanks for any replies, tip: you may get quicker/better responses if you use the image-sig mailing list (if you're using a newsreader, point it to gmane.comp.python.image) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Shift-JIS to UTF-8 conversion
Hello, I think the answer is basically correct but shift-jis is not a standard part of Python 2.3. You will either need to use Python 2.4 where the cjkcodes are integrated or install them under Python 2.3. The link is http://cjkpython.i18n.org/ You then also need: import cjkcodecs.aliases Richard Jeff Epler wrote: I think you do something like this (untested): import codecs def transcode(infile, outfile, incoding=shift-jis, outcoding=utf-8): f = codecs.open(infile, rb, incoding) g = codecs.open(outfile, wb, outcoding) g.write(f.read()) # If the file is so large that it can't be read at once, do a loop which # reads and writes smaller chunks #while 1: #block = f.read(4096000) #if not block: break #g.write(block) f.close() g.close() Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Shift-JIS to UTF-8 conversion
PyTJ wrote: I need to convert a Japanese Shift-JIS CSV file to Unicode UTF-8. My machine is a Windows 98 english computer with Python 2.3.4 Any hints?. First, you need to install codecs to support japanese encodings. Python 2.3.* does not support SJIS by default. I'll give you two options. - Japanese Codecs http://www.python.jp/Zope/download/JapaneseCodecs http://ftp.python.jp/pub/JapaneseCodecs/JapaneseCodecs-1.4.10.win32-py2.3.exe - CJKCodecs http://cjkpython.i18n.org/ http://download.berlios.de/cjkpython/cjkcodecs-1.1.win32-py2.3.exe If you only need Japanese support, Japanese Codecs might be handy. On the other hand, CJKCodecs can handle much broader encodings. Aside from that, starting from 2.4, Python ships with CJKCodecs, so I'd recomment CJKCodecs without reservations. -- george -- http://mail.python.org/mailman/listinfo/python-list
MySQLdb and Unicode
Hi, I try to write unicode strings to a MySQL database via MySQLdb. According to the documentation I should pass 'utf-8' as keyword parameter to the connect method. But then I get the following error: Traceback (most recent call last): File C:\develop\SyynX\unicode_test.py, line 7, in ? con=MySQLdb.connect(host='localhost',db='unicode_test',unicode='utf-8') File C:\Python24\Lib\site-packages\MySQLdb\__init__.py, line 66, in Connect return Connection(*args, **kwargs) File C:\Python24\Lib\site-packages\MySQLdb\connections.py, line 134, in __init__ super(Connection, self).__init__(*args, **kwargs2) TypeError: 'unicode' is an invalid keyword argument for this function I'm using version 1.2 of MySQLdb. Any hint what I'm doing wrong? regards, Achim -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb and Unicode
Achim Domma (Procoders) wrote: Hi, I try to write unicode strings to a MySQL database via MySQLdb. According to the documentation I should pass 'utf-8' as keyword parameter to the connect method. But then I get the following error: (...) I'm using version 1.2 of MySQLdb. Any hint what I'm doing wrong? this is changed in 1.2, from the Connection class docstring: use_unicode ''If True, text-like columns are returned as unicode objects using the connection's character set. Otherwise, text-like columns are returned as strings. columns are returned as normal strings. Unicode objects will always be encoded to the connection's character set regardless of this setting.'' -- @prefix foaf: http://xmlns.com/foaf/0.1/ . #me a foaf:Person ; foaf:nick deelan ; foaf:weblog http://blog.deelan.com/ . -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGame and Rotozoom (Sorry if OT)
J. W. McCall wrote: I'm not sure if this is off-topic, since it doesn't deal with Python itself, but here goes: I'm messing around with writing a simple game where the player (a crudely drawn smiley face) moves by rotating and moving back or forward (think Resident Evil, but from an always-above view). After much hacking, I have it working where left and right rotate the player sprite and up always moves the sprite whichever direction it's facing, while down is reverse. I'm using pygame.transform.RotoZoom(). My problem is that it doesn't rotate smoothly. When it rotates, the corners of the image (just a plain white background) look like they're hitting some barrier and making it move around. Think of an empty box turned diagonally (so that it looks like a diamond, with its open end facing you), and a cube in that box being turned while it's resting in the bottom corner. I want it to rotate smoothly around its center, it's it's not doing that. I'm guessing that it has something to do with me not setting up a Rect right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? Any advice would be greatly appreciated. And yes, I'm a rank PyGame newbie. I'm not sure - haven't actually used rotozoom, but from the docs it returns a surface containing the rotated images. The problem with that is that a rotated surface wont fit in to the same area, so what you get back will be bigger than the original. If you want to draw it at the same position, move the rotated surface so that the centre point is the same as the original unrotated image. Creating a new sprite each time is probably quite inefficient. You might want to look at OpenGL, which is excellent for 2D and 3D games. HTH, Will McGugan -- http://www.willmcgugan.com .join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c in jvyy*jvyyzpthtna^pbz ] ) -- http://mail.python.org/mailman/listinfo/python-list
Cascading menus with Tk
Hi all, I am new to Tk, or Python GUI programming and I seem to be stuck. I have looked about for help with Tk GUIs, but everything seems so terse or incomplete?? I have been mostly using the Introduction to Tkinter by Fredrik Lundh (http://www.pythonware.com/library/tkinter/introduction/index.htm) What I am trying to do is add cascading menus to a Tk menu widget like: File New... --- Router --- Firewall Open Exit This seems simple enough, but I can't get it to work...the two add_cascade methods (shown below), if used, run an endless loop that is difficult to break: mainWindow = Tk() mainWindow.title(myApp) # create a menu menubar = Menu(mainWindow) mainWindow.config(menu=menubar) filemenu = Menu(menubar) menubar.add_cascade(label=File, menu=filemenu) filemenu.add_command(label=New...) filemenu.add_cascade(label=Router) filemenu.add_cascade(label=Firewall) filemenu.add_command(label=Open..., command = openFileDialog) filemenu.add_separator() filemenu.add_command(label=Exit, command = mainWindow.destroy) helpmenu = Menu(menubar) menubar.add_cascade(label=Help, menu=helpmenu) helpmenu.add_command(label=Online Help) helpmenu.add_command(label=Help on the web) helpmenu.add_separator() helpmenu.add_command(label=About..., command = openAboutBox) Any ideas?? Miki -- http://mail.python.org/mailman/listinfo/python-list
Re: cddb and mci produce an ImportError
flupke wrote: snip I finally succeeded in making a proper mci.dll that works. I will document what i did in the coming days and place it here. I developed the dll with DevC++. Anyway, it all works :) Benedict -- http://mail.python.org/mailman/listinfo/python-list
Re: OO design question / Transform object in place?
Dave Benjamin wrote: [EMAIL PROTECTED] wrote: Now suppose I set expression2 = Sum([a,-a]) and Sum.simplify() recognises that the two terms cancel and the Sum has value 0. Can I make expression2.simplify() transform expression2 from an instance of Sum to an instance of Number(0) **in place**? Is that possibe, or do I really have to write I think it's much better for simplify() to return a new object always, and leave the original object unmodified. You can still write: expression2 = expression2.simplify() Dave, A belated thank-you message for your reply to my posting. I took your advice, and made all the simplify methods return new objects and this has simplified my code structure a great deal (and any slow down in run time just doesn't matter!). Am I right that to make expression2.simplify() return a new object I will need use copy.copy a lot, as in: def simplify(self): newreturnvalue=copy.copy(self) # #now the code does lots of complicated things #to newreturnvalue object... # return newreturnvalue I have a nagging doubt as to whether this is what you meant, or if I've missed a trick again. Anyway, thanks again for your reply. Yours, Andy. if you don't care about the old value. expression2 = SimplifyFunction(expression2) This is another valid solution, but it's not an OO solution (you will need to use isinstance to write SimplifyFunction). and use the function return to set expression2 to be a Number(0) object, which is annoying for a variety of reasons! Have I made a mistake in the design? It's usually considered poor OO style to have an object change its class at runtime, although I'm sure you could do it in Python (__bases__ would be a place to start) if you really wanted. For what you're trying to do, I don't think it's necessary, though. Dave -- http://mail.python.org/mailman/listinfo/python-list
string formatting quirk?
Hi, ''%([]) doesn't raise exception but ''%('') does Can anyone explain me why?? rgds Anurag -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
I have read about parrot. How is that progressing? Stelios Xanthakis wrote: Hi. pyvm is a program which can run python 2.4 bytecode (the .pyc files). A demo pre-release is available at: http://students.ceid.upatras.gr/~sxanth/pyvm/ Facts about pyvm: - It's FAST. According to the cooked-bench benchmark suite it finishes in 55% of the time python takes;) - It's SMALL. Currently the source code is under 15k lines with the builtin modules. - It's new. Uses no code from CPython. - It's incomplete. Not even near the stability and quality of python. It needs A LOT of work before it can be compared to CPython. Moreover, at the time it lacks many things like closures, long numbers new style classes, etc. - It's incompatible with CPython. Not all programs run. - The C API is incompatible. You can't run C modules (a thin wrapper to make pyvm appear as libpython *could* be possible but not a goal AFAIC) - The demo is an x86/linux binary only. You shouldn't trust binaries, run it in a chrooted environment not as root! Hope it works! Cheers, Stelios -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing 2 similar strings?
On 20 May 2005 04:09:26 GMT, [EMAIL PROTECTED] (Patrick TJ McPhee) wrote: In article [EMAIL PROTECTED], John Machin [EMAIL PROTECTED] wrote: % None of the other approaches make the mistake of preserving the first % letter -- this alone is almost enough reason for jettisoning soundex. Metaphone does, at least in the case of Aaron and Erin. You're quite correct; moreover NYSIIS does that too. Dunno what came over me, must be gamma rays or something :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Cascading menus with Tk
michelle wrote: What I am trying to do is add cascading menus to a Tk menu widget like: File New... --- Router --- Firewall Open Exit Just add the submenu with the Router and Firewall entries to the filemenu in the same way you added the submenu with the New, Open, and Exit entries to the menu bar: mainWindow = Tk() mainWindow.title(myApp) # create a menu menubar = Menu(mainWindow) mainWindow.config(menu=menubar) filemenu = Menu(menubar) menubar.add_cascade(label=File, menu=filemenu) new_menu = Menu(filemenu) new_menu.add_command(label=Router) new_menu.add_command(label=Firewall) filemenu.add_cascade(label=New..., menu=new_menu) filemenu.add_command(label=Open..., command = openFileDialog) filemenu.add_separator() filemenu.add_command(label=Exit, command = mainWindow.destroy) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: string formatting quirk?
[EMAIL PROTECTED] wrote: ''%([]) doesn't raise exception but ''%('') does Can anyone explain me why?? That is a side-effect of duck-typing. The duck-type of an empty list is indistinguishable from that of an empty dictionary. Not testing the exact type here achieves consistency with the behaviour of custom dictionaries, e. g: class List(list): ... def __getitem__(self, index): ... return list.__getitem__(self, int(index)) ... %(0)s % List([42]) '42' %(1)s %(0)s % List([42, 24]) '24 42' % List([]) '' Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
Sorry, scratch that P.S.! The act of hitting Send seems to be a great way of realising one's mistakes. Of course you need colnr - m for those times when m is set to 26. Remembered that when I wrote it, forgot it 2 paragraphs later! -- http://mail.python.org/mailman/listinfo/python-list
a re problem
p.sub('','a\nbc') 'abc' p.sub('','%s') % a\nbc 'a\nbc' is it anyone got some idea why it happen? -- http://mail.python.org/mailman/listinfo/python-list
Re: a re problem
cheng wrote: p.sub('','%s') % a\nbc 'a\nbc' is it anyone got some idea why it happen? Make that p.sub('','%s' % a\nbc) Regards /Mikael Olofsson Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE]) Linköpings universitet --- E-Mail: [EMAIL PROTECTED] WWW: http://www.dtr.isy.liu.se/en/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 --- Linköpings kammarkör: www.kammarkoren.com Vi söker tenorer och basar! -- http://mail.python.org/mailman/listinfo/python-list
Re: a re problem
cheng [EMAIL PROTECTED] wrote: p.sub('','a\nbc') 'abc' p.sub('','%s') % a\nbc 'a\nbc' is it anyone got some idea why it happen? p.sub('', 'a\nbc') Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'p' is not defined import re p = re.compile(\n*) p.sub(, a\nbc) 'abc' p.sub(, %s) '%s' /F -- http://mail.python.org/mailman/listinfo/python-list
Re: a re problem
thx for help :) -- http://mail.python.org/mailman/listinfo/python-list
circular imports
I'm working with a large code base that I'm slowly trying to fix unpythonic features of. One feature I'm trying to fix is the use of: # how things are now sys.path.append('/general/path/aaa/bbb') # lots of lines like this to specific dirs import foo Insead I'd rather have PYTHONPATH already include '/general/path/' and then just use: # how I'd like them to be from aaa.bbb import foo So I thought I'd just add the necessary __init__.py files and then things would just work. Unfortunately trying this exposed a large number of circular imports which now cause the files to fail to load. Any ideas why the sys.path.append method has no problem with circular imports whereas doing thing the right way chokes. thanks, dustin -- http://mail.python.org/mailman/listinfo/python-list
How come print cannot be assigned to a variable?
Hi all, In Python, some functions can be assigned to variables like this: length=len Why is it that print cannot be assigned to a variable like this? (A syntax error is declared.) Thanks, Vaibhav -- http://mail.python.org/mailman/listinfo/python-list
Re: How come print cannot be assigned to a variable?
print is a statement, not a function. Read Guido's words on that: http://www.python.org/search/hypermail/python-1992/0112.html Regards. Adriano. -- http://mail.python.org/mailman/listinfo/python-list
dealing with MAC address
Hello, I am trying to fill a packet with source and destination mac address. The first 6 bytes hold the destination mac address and the next six bytes hold the source mac address. In the code i am filling in the first six bytes to broadcast address for the destination. # fill in the destination address data = array('B', '\0' * 512) for i in range(6): data[i] = 0xFF How do i fill in a command line passed mac address for source mac address. The first six bytes of data[i] should contain destination mac and the next six bytes of data[i] should contain the source mac address. Thanks, Ashton -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
Jason Drew wrote: ##def tuple2coord(tupl): [snip] ##rowfromzero, colfromzero = tupl Just a side note here that if you want a better function signature, you might consider writing this as: tuple2coord((rowfromzero, colfromzero)): ... Note that the docstrings are nicer this way: py def tuple2coord(tupl): ... x, y = tupl ... py help(tuple2coord) Help on function tuple2coord in module __main__: tuple2coord(tupl) py def tuple2coord((x, y)): ... pass ... py help(tuple2coord) Help on function tuple2coord in module __main__: tuple2coord((x, y)) STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: new release of RUR-PLE available
Michael Hoffman wrote: André Roberge wrote: Version 0.8.6a is now available. You might see a bit more interest if you briefly explain what RUR-PLE is, and where to find it. Oops.. sorry about that. RUR - a Python Learning Environment. Its purpose is to provide an environment where people with no prior experience can learn computer programming (using Python of course!). RUR-PLE currently requires that both Python and wxPython be installed. More information can be found at http://rur-ple.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Cascading menus with Tk
Martin Franklin wrote: michelle wrote: Hi all, I am new to Tk, or Python GUI programming and I seem to be stuck. I have looked about for help with Tk GUIs, but everything seems so terse or incomplete?? I have been mostly using the Introduction to Tkinter by Fredrik Lundh (http://www.pythonware.com/library/tkinter/introduction/index.htm) What I am trying to do is add cascading menus to a Tk menu widget like: File New... --- Router --- Firewall Open Exit This seems simple enough, but I can't get it to work...the two add_cascade methods (shown below), if used, run an endless loop that is difficult to break: mainWindow = Tk() mainWindow.title(myApp) # create a menu menubar = Menu(mainWindow) mainWindow.config(menu=menubar) filemenu = Menu(menubar) menubar.add_cascade(label=File, menu=filemenu) filemenu.add_command(label=New...) I think you want these two options to be in a cascading menu like so: newmenu = Menu(filemenu) filemenu.add_cascade(label=New..., menu=newmenu) newmenu.add_command(label=Router) newmenu.add_command(label=Firewall) filemenu.add_cascade(label=Router) filemenu.add_cascade(label=Firewall) filemenu.add_command(label=Open..., command = openFileDialog) filemenu.add_separator() filemenu.add_command(label=Exit, command = mainWindow.destroy) helpmenu = Menu(menubar) menubar.add_cascade(label=Help, menu=helpmenu) helpmenu.add_command(label=Online Help) helpmenu.add_command(label=Help on the web) helpmenu.add_separator() helpmenu.add_command(label=About..., command = openAboutBox) Any ideas?? Miki Martin Thank you, your code worked perfectly Miki -- http://mail.python.org/mailman/listinfo/python-list
Re: Twisted an several CPUs
Paul Rubin wrote: Jp Calderone [EMAIL PROTECTED] writes: Distributing load across multiple machines scales better than distributing it over multiple CPUs in a single machine. If you have serious scalability requirements, SMP is a minor step in the wrong direction (unless you're talking about something like 128-way SMP on a supercomputer :) See PoSH: http://poshmodule.sourceforge.net/ The performance gain from multiple CPU's and shared memory is quite real. I've been wanting for quite a long time to hack up a web server that uses this stuff. OOooh that looks interesting - thanks for posting that :) Michael. -- [EMAIL PROTECTED] British Broadcasting Corporation, Research and Development Kingswood Warren, Surrey KT20 6NP This message (and any attachments) may contain personal views which are not the views of the BBC unless specifically stated. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to receive events (eg. user mouse clicks) from IE
Thanks for the response again. The solution is pretty close but not yet complete This is what I observed. a) I tried to use the delay mechanism as suggested below ie. ie.Navigate('www.google.com') while ie.ReadyState !- 4 time.sleep(0.5) d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) IE *fails* to load the webpage b) Then I changed the delay to a specified time interval eg ie.Navigate('www.google.com') time.sleep(60) #wait for a minute d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) IE loads the web page *after* 60 seconds c) Then I used raw_input() eg ie.Navigate('www.google.com') raw_input() d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) IE now loads the webpage and prompts the user. If I click on the web page *before* clicking ok on the raw_input prompt - then it correctly invokes the Doc_Events method Ononactivate method. From these observations, it seems that there is some kind of a race condition / timing issue happening. Can you please comment (or maybe point me to other sources of info that I can investigate). I am running Python 2.3 on Windows 2k machine. Roger Upole wrote: Usually you get that error if you try to access the Document object before the page has loaded. Try adding a delay after ie.Navigate, something like while ie.ReadyState4: time.sleep(0.5) There are some constants that show up in win32com.client.constants that represent the ReadyState's, but I can't remember the names offhand. The only real reference for the Html objects (other than reading the generated module) is MSDN. Google turned this up: http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/htmlanchorevents/htmlanchorevents.asp Roger [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks for your prompt responses and the code. However, when I run the code I get com error d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) File C:\Python23\lib\site-packages\win32com\client\__init__.py, line 199, in __getattr__ return getattr(self._obj_, attr) File C:\Python23\lib\site-packages\win32com\client\__init__.py, line 455, in __getattr__ return self._ApplyTypes_(*args) File C:\Python23\lib\site-packages\win32com\client\__init__.py, line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) I am a newbie to python(started coding a few months ago). This appears to be a fairly common error when COM objects are not hooked up properly. Though I have not been able to find a solution or the reason for this. Thanks again for the explanation.All the information that I had acquired now seems to fall into place. I was not aware about doc_mod.HTMLAnchorEvents. Where can I find more documentation about this? Roger Upole wrote: Here's a few more lines that hook the document's onactivate event. import win32com.client ie_mod=win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-C05BAE0B}' ,0, 1, 1) doc_mod=win32com.client.gencache.EnsureModule('{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}' ,0 ,4, 0) class IE_Events(ie_mod.DWebBrowserEvents2): def OnNavigateComplete2(self, pDisp, URL): print 'OnNavigateComplete2:', URL class Doc_Events(doc_mod.HTMLAnchorEvents): def Ononactivate(self): print 'onactivate', self.activeElement.outerHTML ie=win32com.client.DispatchWithEvents('InternetExplorer.Application',IE_Events) ie.Visible=1 ie.Navigate('http://www.google.com') d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) Roger [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi Thanks for the response and for the code. However, I want to trap events like mouse click on the HTML document loaded by the web browser control. The code mentioned below provides events from the web browser control. I need to find out on which particular HTML tag did the user click for example. How do I find that out? There should be some way to refer to a document from a given web browser control and start receiving events from it Roger Upole wrote: The two you'll need to run makepy for are Microsoft Internet Controls and Microsoft HTML object Library. If you run them manually, you should be able to look at the generated code to get the guids. Here's a minimal example: import win32com.client ie_mod=win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-C05BAE0B}',0, 1, 1) class IE_Events(ie_mod.DWebBrowserEvents2): def OnNavigateComplete2(self, pDisp, URL): print 'OnNavigateComplete2:', URL ie=win32com.client.DispatchWithEvents('InternetExplorer.Application',IE_Events) ie.Visible=1 ie.Navigate('http://www.google.com') hth
Re: PIL and line drawing
Fredrik Lundh [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Leonard J. Reder wrote: I am using PIL to annotate some images with lines. I could not find anyway to make the line that is drawn from the ImageDraw object thicker. Does anyone have a suggestion or solution for solving this without to much hacking? if you have 1.1.5, you can use the width option to control the line width. see: I'm glad to see that addition. I was surprised to see that 'width' is actually doubled in the resulting line, though. I suppose the code adds and subtracts the specified width from the specified coordinate point(?). I'd love to see width added to arc, circles, etc., though if it is, I'd much prefer that it not be centered on the coordinate point, but added only to the outer edge (or subtracted from the inner edge); it would make placement much easier, I'd think. At the moment, whenever I need to generate thick-lined circles and rectangles, I have to create a second image of the desired color, then another mask image to contain a black rectangle (say) of the required outer size, then within that a white rectangle of the inner size, then use that mask to paste the color onto the original image. The results are satisfactory, but the method seems clunky at best. Maybe there's a better way. Even if this were the exact method used, I'd rather see it automated in C than manually done in Python. http://effbot.org/imagingbook/imagedraw.htm Thanks for any replies, tip: you may get quicker/better responses if you use the image-sig mailing list (if you're using a newsreader, point it to gmane.comp.python.image) -- rzed -- http://mail.python.org/mailman/listinfo/python-list
Re: python24.zip
Robin Becker wrote: Firstly should python start up with non-existent entries on the path? Yes, this is by design. Secondly is this entry be the default for some other kind of python installation? Yes. People can package everything they want in python24.zip (including site.py). This can only work if python24.zip is already on the path (and I believe it will always be sought in the directory where python24.dll lives). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: circular imports
[EMAIL PROTECTED] wrote: So I thought I'd just add the necessary __init__.py files and then things would just work. Unfortunately trying this exposed a large number of circular imports which now cause the files to fail to load. You didn't describe you you created the necessary __init__.py files. If they are not empty, there is a good chance that you made some error in creating these files. What is the error that you get with the circular imports? Any ideas why the sys.path.append method has no problem with circular imports whereas doing thing the right way chokes. One reason is that there could be duplicate module names, e.g. overlaps with the standard library. When you fully-qualified the modules, you actually changed the program, which would now import the user-provided modules instead of the predefined ones. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: dealing with MAC address
On 2005-05-20, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How do i fill in a command line passed mac address for source mac address. The first six bytes of data[i] should contain destination mac and the next six bytes of data[i] should contain the source mac address. Use the struct module. -- Grant Edwards grante Yow! MMM-MM!! So THIS is at BIO-NEBULATION! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How come print cannot be assigned to a variable?
Thank You Adriano. You were a huge help. Vaibhav -- http://mail.python.org/mailman/listinfo/python-list
embedded function body
Hi, I need to embed an user-supplied python function body in a C program. That is, the user has no control over the function definition: def afunction(): here goes user code Now, the problem is that I can't just append the supplied string, because I need to properly indent it which isn't trivial - just adding a tab in front of every line won't do. I'm considering two approaches: 1) write an indent function which is more aware of python syntax; 2) use the python lexxer and work with parse trees. I've done some experiments with 2). The idea was to parse the following program: def afunction(): pass and the user supplied string (as a complete program) separately, then replace the suite node in the function definition with one including the statements from the user program. I've got something that seems to work (but getting allocation/deallocation right requires some work), but it seems to me it's a bit awkward. Is the PyNode_* interface public and stable? Is it ok to use it? Any advice? Am I missing something? Should I try approach 1)? TIA, .TM. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. Funny that Pythonwin's argument-prompter (or whatever that feature is called) doesn't seem to like it. E.g. if I have def f(tupl): print tupl Then at the Pythonwin prompt when I type f( I correctly get (tupl) in the argument list pop-up box. But if I have def f((a, b)): print a, b then when I type f( I just get (.0) in the argument list pop-up box. Or with def f(p, q, (a, b)): pass Pythonwin prompts with (p, q, .4) However in each case the help() function correctly lists all the arguments. Strange. I'll check if it's a known feature. This is with PythonWin 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32. -- http://mail.python.org/mailman/listinfo/python-list
Re: circular imports
All of the __init__.py files are empty and I don't know of any overlapping of names. Like I said this is code that works fine, I'm just trying to clean up some things as I go. Here are my working examples: x1.py == # how things work in our code now: # called with home/dlee/test/module python aaa/x1.py import sys sys.path.append('/home/dlee/test/module') import x2 def goo(): print 'hi from goo' if __name__ == '__main__': x2.foo() x2.py == import sys sys.path.append('/home/dlee/test/module') import x1 def foo(): print 'entered foo' x1.goo() y1.py == # this works but is not quite what I want # called with PYTHONPATH=$PYTHONPATH:/home/dlee/test/module python aaa/y1.py import aaa.y2 def goo(): print 'hi from goo' if __name__ == '__main__': aaa.y2.foo() y2.py == import aaa.y1 def foo(): print 'entered foo' aaa.y1.goo() z1.py == # how I'd like things to work, but is failing for me # called with PYTHONPATH=$PYTHONPATH:/home/dlee/test/module python aaa/z1.py from aaa import z2 def goo(): print 'hi from goo' if __name__ == '__main__': z2.foo() z2.py == om aaa import z1 def foo(): print 'entered foo' z1.goo() w1.py == # this would also be acceptible # called with PYTHONPATH=$PYTHONPATH:/home/dlee/test/module python aaa/w1.py import aaa.w2 as w2 def goo(): print 'hi from goo' if __name__ == '__main__': w2.foo() w2.py == import aaa.w1 as w1 def foo(): print 'entered foo' w1.goo() -- http://mail.python.org/mailman/listinfo/python-list
Memory errors with large zip files
Is there a limitation with python's zipfile utility that limits the size of a file that can be extracted? I'm currently trying to extract 125MB zip files with files that are uncompressed to 1GB and am receiving memory errors. Indeed my ram gets maxed during extraction and then the script quits. Is there a way to spool to disk on the fly, or is necessary that python opens the entire file before writing? The code below iterates through a directory of zip files and extracts them (thanks John!), however for testing I've just been using one file: zipnames = [x for x in glob.glob('*.zip') if isfile(x)] for zipname in zipnames: zf =zipfile.ZipFile (zipname, 'r') for zfilename in zf.namelist(): newFile = open ( zfilename, wb) newFile.write (zf.read (zfilename)) newFile.close() zf.close() Any suggestions or comments on how I might be able to work with zip files of this size would be very helpful. Best regards, Lorn -- http://mail.python.org/mailman/listinfo/python-list
Re: OO design question / Transform object in place?
[EMAIL PROTECTED] wrote: Dave Benjamin wrote: I think it's much better for simplify() to return a new object and leave the original object unmodified. You can still write: expression2 = expression2.simplify() A belated thank-you message for your reply to my posting. I took your advice, and made all the simplify methods return new objects and this has simplified my code structure a great deal (and any slow down in run time just doesn't matter!). No problem. Glad it helped. =) Am I right that to make expression2.simplify() return a new object I will need use copy.copy a lot, as in: def simplify(self): newreturnvalue=copy.copy(self) # #now the code does lots of complicated things #to newreturnvalue object... # return newreturnvalue You could use copy.copy(), as long as you want a shallow copy and you don't want to change from one class to another. However, it may be to your advantage to use the constructor of one or more classes to build the result; this allows you to conditionally pick the result object's class. Also, there may be situations where an object can't be simplified, in which case you can just return self, and avoid copying entirely. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert from numbers to letters
On 20 May 2005 10:07:55 -0700, Jason Drew [EMAIL PROTECTED] wrote: Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. Funny that Pythonwin's argument-prompter (or whatever that feature is called) doesn't seem to like it. E.g. if I have def f(tupl): print tupl Then at the Pythonwin prompt when I type f( I correctly get (tupl) in the argument list pop-up box. But if I have def f((a, b)): print a, b then when I type f( I just get (.0) in the argument list pop-up box. Or with def f(p, q, (a, b)): pass Pythonwin prompts with (p, q, .4) However in each case the help() function correctly lists all the arguments. Strange. I'll check if it's a known feature. That sounds like a bug in pythonwin autocomplete. Tuple unpacking in function arguments is definitely a known feature, there were some recent (fairly extensive) clp threads about it.[1] I wish people would use it more, I think it's an awesome feature when properly used. I like it especially for signatures like def change_coord((x, y)). It was one of those features, for me, where I just tried it without knowing of its existence, assuming it would work, and I was pleasantly surprised that it did. Peace Bill Mill bill.mill at gmail.com [1] http://tinyurl.com/89zar I think there was another about ways to improve tuple unpacking, but I didn't find it in a brief search. This is with PythonWin 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)] on win32. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Sure it does not. As well as C, unless you instaead of malloc use low level os-dependant APIs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in Elementtree/Expat
Most examples in the book do not include such a declaration and yet are properly rendered by Internet Explorer. Is it mandatory and why is it that Expat crashes on it? It's not mandatory but it's probably good practice to make the document self-contained. The xlink prefix is defined in the DTD but Expat, as a nonvalidating parser, won't fetch it. Important clarification: The decision whether or not to read the external DTD subset is separate from the decision whether or not to validate. Expat does not validate, but it does read the external subset, if you tell it to. There are other uses for reading the external subset, such as entity resolution. And you can have validation constructs in the internal DTD subset (IOW right in the XML source file itself), and expat will not do anything with them because it does not validate. This may seem a subtle distinction, but it lies behind a lot of user confusion in practice. The XML WG really should have simplified such matters (IIRC SGML compatability was a big obstruction to doing so). -- Uche http://uche.ogbuji.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing 2 similar strings?
Dennis Lee Bieber wrote: On Wed, 18 May 2005 20:03:53 -0500, Ed Morton [EMAIL PROTECTED] declaimed the following in comp.lang.python: Fantastic test data set. I know how to pronounce McPherson but I'd never have guessed that Mousaferiadis sounds like it. I suppose non-Celts probably wouldn't be able to guess how Dalziell, Drumnadrochit, Culzean, Ceilidh, or Concobarh are pronounced either. Since soundex is initial letter (consonant?) and a code for the next three syllables (or close to it), really long multi-syllabic names are effectively truncated... Howe'er... When Maire Brennan releases an album as Moya, following sister's Enya (Eithne, as I seem to recall reading)... I'd not attempt to pronounce most of the names you supply... Dalziell doesn't look Celtic... Culzean almost looks Aztec/Mayan... Ceilidh = kay-lee? Okay, I think I can manage bain sidhe and uisge (after too much of the latter, I'll be seeing the former) Well, as an Englishman who has spent a good deal of time in Scotland I'd essay the following. If there are any Scots reading they can chastise me with glee for my presumption. Dalziell: Da'y yell Drumnadrochit: Dru'mnadro'ckit (but the Scots would insist you use a gutteral for the ch, I'm not sure how to render that phonetically. It's a bit like the sound made before spitting, or the G in Guido in Dutch :-). Culzean:Ka La'ne Ceilidh:Ca'yli (once had a border collie called Ceilidh). Concobarh: (is this the same as 'Conchobar'?) Co'nnahwar promoting-scottish-english-unity-ly y'rs - steve -- Steve Holden+1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing 2 similar strings?
Chris Croughton wrote: On Thu, 19 May 2005 06:38:59 +1000, John Machin [EMAIL PROTECTED] wrote: On Wed, 18 May 2005 15:06:53 -0500, Ed Morton [EMAIL PROTECTED] wrote: William Park wrote: How do you compare 2 strings, and determine how much they are close to each other? Eg. aqwerty qwertyb are similar to each other, except for first/last char. But, how do I quantify that? However you like is probably the right answer, but one way might be to compare their soundex encoding (http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?soundex) and figure out percentage difference based on comparing the numeric part. Fantastic suggestion. Here's a tiny piece of real-life test data: compare the surnames Mousaferiadis and McPherson. I remember a word processor, MultiMate, which used Soundex to do matching for its suggestions for spelling correction. One of my cow-orkers typed the word 'agains' -- it was supposed to be 'against' but 'again' would also have been a sensible suggestion. MultiMate, however, suggested neither of those reasonable words, it did suggest iguanas amd Utahns... (I wonder what it does with Talliafero and Tolliver, and with Featherstone-Howe and Fanshaw...) The answer to the OP, which someone just pointed out to me on comp.programming, is edit distance or Levenshtein Distance[1]. A google search on either produces some good descriptions in the first few links, including http://www.merriampark.com/ld.htm which has not only a description of the algorithm but also source code in Java, C++ and Visual Basic (no Awk, thought there are links to pages with implementations in Perl, Python, Delphi and many more)... [1] I would have spelt it 'Levenstein', and pronounced it 'Levenshtein' in Schwaebisch (south German) fashion, but apparently the author of the algorithm was one Vladimir I. Levenshtein and that is how he is credited on the IEEE site. There are also a number of Google hits under the 'stein' spelling, though... Chris C And what's the Levenshtein distance between levenshtein and levenstein? Ironic if it were large ... regards Steve -- Steve Holden+1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
buffer_info error
Hello, buffer_info is giving the following error: AttributeError: 'str' object has not attribute 'buffer_info' Here's the code snippet... dest = '' src = '0123' data = array('B', '\0' * 256) data1 = ''.join([dest, src] print data1 0123 print data.buffer_info()[0]... works print data1.buffer_info()[0]error This output is a string and hence i believe i get the above error. Any ideas? Thanks, -Ashton -- http://mail.python.org/mailman/listinfo/python-list
Re: circular imports
[EMAIL PROTECTED] wrote: I'm working with a large code base that I'm slowly trying to fix unpythonic features of. [...] Insead I'd rather have PYTHONPATH already include '/general/path/' and then just use: One option you might not have considered, which I find more pythonic than environment variables, is to use .pth files as documented at the top of the site.py module in the standard library (or in the online docs for site). You can also sometimes remove even more problems by using a sitecustomize.py file in addition to the .pth files. (Also in the docs, I believe, under site.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
appending key-value pairs to a dict
I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Many thanks, rbt -- http://mail.python.org/mailman/listinfo/python-list
Difficulty installing PyXml.
Hello, I have python installed under a different directory (/images/QA/QATools12/lib/python2.1), and I'm now trying to install PyXml. It gives me the following error: - python setup.py buildTraceback (most recent call last): File "setup.py", line 127, in ? config_h_vars = parse_config_h(open(config_h))IOError: [Errno 2] No such file or directory: /images/QA/QATools12/include/python2.1/config.h' Is there any way to circumvent this? I guess, there is some error in my distutils package, but I really need a way to get around this. I need PyXml before I can use Soapy. Thanks, Amit. -- http://mail.python.org/mailman/listinfo/python-list
Re: buffer_info error
[EMAIL PROTECTED] wrote: data = array('B', '\0' * 256) data1 = ''.join([dest, src] print data.buffer_info()[0]... works print data1.buffer_info()[0]error This output is a string and hence i believe i get the above error. Any ideas? Yes, you are entirely correct. (Integers don't have buffer_info attributes either, and for that matter strings don't have an attribute called fribble_frabble, in case you were thinking of trying that. ;-) (That's a facetious reply, yes, because you gave no indication what you were trying to accomplish. It's really hard to tell what you expected versus what you got, and why you got that is completely obvious to all of us, who can't read your mind.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Whereas with a list you would call append in the loop, with a dictionary you simply use an indexed-assignment type of access: mydict = {} for filename in some_list_of_filenames: hash = sha.sha(open(filename).read()).hexdigest() # or whatever mydict[filename] = hash -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Dave Brueck [EMAIL PROTECTED] writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's protocol modules - partly because we had to implement our own HTTP libraries for performance and scalability reasons anyway, and partly because we had trouble figuring out e.g. all the ins and outs of urllib/urllib2/httplib. What do you use for HTTPS? And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies). I'm not trying to be contentious here, just mentioning a couple further cases of where problems aren't visible from far away but are there when you look close. -- http://mail.python.org/mailman/listinfo/python-list
Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Like so: d = {} for filename in files: d[sha_func(filename)] = filename Or like so: d = dict([(sha_func(filename), filename) for filename in files]) -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing 2 similar strings?
Steve (is this the same as 'Conchobar'?) No, that's a trendy pub in Key West... wink Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Fredrik Lundh [EMAIL PROTECTED] writes: this has been reported before, and it won't get fixed (unless you're volunteering to add Python-compatible garbage collection to Tk, that is). Yeah, I think I understand what the issue is. I can think of some kludgy possible fixes but I assume they've been thought about already and rejected. The workaround of making the application save an extra reference isn't too bad, but all relevant docs that say anything about these images should mention the requirement emphatically. -- http://mail.python.org/mailman/listinfo/python-list
Re: appending key-value pairs to a dict
On Friday 20 May 2005 01:04 pm, rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Many thanks, rbt Simple assignment. adict[filename] = an_sha_hash -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
From the call hook, how do I know more precisely what is called?
Hi, I wrote a trace function using the profiling and tracing hooks provided by the python interpreter. The Python interpreter reports the calls occuring in the source program to my trace function. How can I know whether the call happened is a function call or method call and if it is a method call what is its self object and/or class is?. I receive a frame object from the interpreter for every call. Thanks, Vijay. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGame and Rotozoom (Sorry if OT)
On 2005-05-20, J. W. McCall [EMAIL PROTECTED] wrote: I'm not sure if this is off-topic, since it doesn't deal with Python itself, but here goes: I'm messing around with writing a simple game where the player (a crudely drawn smiley face) moves by rotating and moving back or forward (think Resident Evil, but from an always-above view). After much hacking, I have it working where left and right rotate the player sprite and up always moves the sprite whichever direction it's facing, while down is reverse. I'm using pygame.transform.RotoZoom(). My problem is that it doesn't rotate smoothly. When it rotates, the corners of the image (just a plain white background) look like they're hitting some barrier and making it move around. Think of an empty box turned diagonally (so that it looks like a diamond, with its open end facing you), and a cube in that box being turned while it's resting in the bottom corner. I want it to rotate smoothly around its center, it's it's not doing that. I'm guessing that it has something to do with me not setting up a Rect right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? Any advice would be greatly appreciated. And yes, I'm a rank PyGame newbie. You might want to try pygsear: http://www.nongnu.org/pygsear/ It has a RotatedImage class which takes care of rotating things for you. See the examples roti.py and wings.py for some use of rotated image sprites. -- http://mail.python.org/mailman/listinfo/python-list
Re: buffer_info error
On 20 May 2005 13:18:33 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: i am filling in a packet with source and destination address and using the buffer_info call to pass on the address to an underlying low level call. The src and dest are strings, but buffer_info expects an array. How do i deal with this? What's the low-level call you're invoking? Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: appending key-value pairs to a dict
rbt [EMAIL PROTECTED] wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. You just assign values to keys. If the key doesn't exist, it's created automagically. You want something like this: shaDict = {} for fileName in fileNameList: hash = generateShaHash (fileName) shaDict[hash] = fileName -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Paul Rubin wrote: Dave Brueck [EMAIL PROTECTED] writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's protocol modules - partly because we had to implement our own HTTP libraries for performance and scalability reasons anyway, and partly because we had trouble figuring out e.g. all the ins and outs of urllib/urllib2/httplib. What do you use for HTTPS? Hi Paul, m2crypto (plus some patches to make asynchronous SSL do what we needed). And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies). Are you referring to the use of pickle for cookie serialization? In any case, we didn't use Cookie.py from the stdlib (on the servers, nearly everything related to URLs HTTP was custom-built, with the exception of urlparse, for the aforemenioned reasons). -Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Process monitoring
gsteff wrote: Hey, I'm working on a Python program that will launch some other non-Python process using os.spawn (in the os.P_NOWAIT mode) and then basically wait for it to finish (while doing some other stuff in the interim). Normally, the new process will signal that it's done by writing to a file, but I'd like to also find out if the new process died unexpectedly. Anyone know any preferrable ways to do this? Greg Steffensen If you're using 2.4, have a look at the subprocess module. J -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
C programs also can be disassembled. Serious people do not consider braking the machine code harder byte-code. -- http://mail.python.org/mailman/listinfo/python-list
[ann] first release of PyPy
Welcome to PyPy 0.6 *The PyPy Development Team is happy to announce the first public release of PyPy after two years of spare-time and half a year of EU funded development. The 0.6 release is eminently a preview release.* What it is and where to start - Getting started:http://codespeak.net/pypy/index.cgi?doc/getting_started.html PyPy Documentation: http://codespeak.net/pypy/index.cgi?doc PyPy Homepage: http://codespeak.net/pypy/ PyPy is a MIT-licensed reimplementation of Python written in Python itself. The long term goals are an implementation that is flexible and easy to experiment with and retarget to different platforms (also non-C ones) and such that high performance can be achieved through high-level implementations of dynamic optimisation techniques. The interpreter and object model implementations shipped with 0.6 can be run on top of CPython and implement the core language features of Python as of CPython 2.3. PyPy passes around 90% of the Python language regression tests that do not depend deeply on C-extensions. Some of that functionality is still made available by PyPy piggy-backing on the host CPython interpreter. Double interpretation and abstractions in the code-base make it so that PyPy running on CPython is quite slow (around 2000x slower than CPython ), this is expected. This release is intended for people that want to look and get a feel into what we are doing, playing with interpreter and perusing the codebase. Possibly to join in the fun and efforts. Interesting bits and highlights - The release is also a snap-shot of our ongoing efforts towards low-level translation and experimenting with unique features. * By default, PyPy is a Python version that works completely with new-style-classes semantics. However, support for old-style classes is still available. Implementations, mostly as user-level code, of their metaclass and instance object are included and can be re-made the default with the ``--oldstyle`` option. * In PyPy, bytecode interpretation and object manipulations are well separated between a bytecode interpreter and an *object space* which implements operations on objects. PyPy comes with experimental object spaces augmenting the standard one through delegation: * an experimental object space that does extensive tracing of bytecode and object operations; * the 'thunk' object space that implements lazy values and a 'become' operation that can exchange object identities. These spaces already give a glimpse in the flexibility potential of PyPy. See demo/fibonacci.py and demo/sharedref.py for examples about the 'thunk' object space. * The 0.6 release also contains a snapshot of our translation-efforts to lower level languages. For that we have developed an annotator which is capable of infering type information across our code base. The annotator right now is already capable of successfully type annotating basically *all* of PyPy code-base, and is included with 0.6. * From type annotated code, low-level code needs to be generated. Backends for various targets (C, LLVM,...) are included; they are all somehow incomplete and have been and are quite in flux. What is shipped with 0.6 is able to deal with more or less small/medium examples. Ongoing work and near term goals - Generating low-level code is the main area we are hammering on in the next months; our plan is to produce a PyPy version in August/September that does not need to be interpreted by CPython anymore and will thus run considerably faster than the 0.6 preview release. PyPy has been a community effort from the start and it would not have got that far without the coding and feedback support from numerous people. Please feel free to give feedback and raise questions. contact points: http://codespeak.net/pypy/index.cgi?contact contributor list: http://codespeak.net/pypy/index.cgi?doc/contributor.html have fun, Armin Rigo, Samuele Pedroni, Holger Krekel, Christian Tismer, Carl Friedrich Bolz PyPy development and activities happen as an open source project and with the support of a consortium funded by a two year EU IST research grant. Here is a list of partners of the EU project: Heinrich-Heine University (Germany), AB Strakt (Sweden) merlinux GmbH (Germany), tismerysoft GmbH(Germany) Logilab Paris (France), DFKI GmbH (Germany) ChangeMaker (Sweden) -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments
import sys try: arg1 = sys.argv[1] except IndexError: print This script takes an argument, you boob! sys.exit(1) OR, way better: See the optparse module. On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote: I'm sure this is obvious, but how the heck do pass an argument(s) to a python script from the command line? Thanks, Jeff Elkins -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: first release of PyPy
holger krekel wrote: Welcome to PyPy 0.6 *The PyPy Development Team is happy to announce the first public release of PyPy after two years of spare-time and half a year of EU funded development. The 0.6 release is eminently a preview release.* Congratulation to You and Your team! PyPy is really awesome and if it succeeds in speed demands after the translation phase I believe that the project will shift the power within the Python community on the long run. There are moments I'm almost shocked about it and think about the fate of other programming programming languages like LISP. PyPy can be resolved to Python in Python but also Python multiplied/powered by itself which is much more triumphant. A short review of the 'thunks' objspace example gives me the impression that the language development process as we know it comes to an end and makes a kind of transition. This is both very exciting and dangerous, like every philosophical event. Regards, Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of Nested for loops
On 20 May 2005 15:35:10 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there a better way to code nested for loops as far as performance is concerned. what better way can we write to improve the speed. for example: N=1 for i in range(N): for j in range(N): do_job1 for j in range(N): do_job2 What do you see when you profile the code? Premature Optimization is the root of all manner of evil and all that good stuff. -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments
On Friday 20 May 2005 06:46 pm, James Stroud wrote: import sys try: arg1 = sys.argv[1] except IndexError: print This script takes an argument, you boob! sys.exit(1) OR, way better: See the optparse module. On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote: I'm sure this is obvious, but how the heck do pass an argument(s) to a python script from the command line? Thanks, Jeff Elkins Thanks! -- http://mail.python.org/mailman/listinfo/python-list
processing a large utf-8 file
Since the .encoding attribute of file objects are read-only, what is the proper way to process large utf-8 text files? I need bulk processing (i.e. in blocks - the file is ~ 1GB), but reading it in fixed blocks is bound to result in partially-read utf-8 characters at block boundaries. -- http://mail.python.org/mailman/listinfo/python-list
Re: processing a large utf-8 file
Ivan Voras wrote: Since the .encoding attribute of file objects are read-only, what is the proper way to process large utf-8 text files? You should use codecs.open, or codecs.getreader to get a StreamReader for UTF-8. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments
An even better way would be to use the optparse module.-- Daniel Bickettdbickett at gmail.comhttp://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Parsing bash_history and inputting into mysql (Intrusion Detection)
I have a seemingly tough assignment for my Senior Project. I need to develop an Intrusion Detection System. My approach is to parse the bash_history file of each user into a mysql database, assign a threshold for commands or sequences of commands and then alert the admin of nethin fishy is found. My advisor reccomended I use python for writing the scripts. I am absolutely new to python and have no prior experience in it. That said Could any one tell me how exactly to go abt all this? Any tools or code that would make my life easier? Suggestions (which modules to use etc) ? Cheers, Sreekanth -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of Nested for loops
You can use xrange(N) that way Python doesn't have to build the 1 item lists 2 times. Other than that one would need to know why you would call do_job1 and do_job2 1 times each inside a 1 iteration loop. Most VERY large performance gains are due to better algorithms not code optimization. Larry Bates [EMAIL PROTECTED] wrote: Is there a better way to code nested for loops as far as performance is concerned. what better way can we write to improve the speed. for example: N=1 for i in range(N): for j in range(N): do_job1 for j in range(N): do_job2 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to receive events (eg. user mouse clicks) from IE
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks for the response again. The solution is pretty close but not yet complete This is what I observed. a) I tried to use the delay mechanism as suggested below ie. ie.Navigate('www.google.com') while ie.ReadyState !- 4 time.sleep(0.5) d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) IE *fails* to load the webpage Thought this was quite curious so tried it myself (on Python 2.3 Win2k machine). Put in some timing conditions and the problem is not that it fails to load, but that it takes really long (min time during tests = 60 secs , maximum time 580 secs). Tried using just WithEvents, same problem. The problem seems to lie with the call to ie.ReadyState while trapping events. 2 things lead me to believe this... 1) Interrupting the Python code after the browser window opens, results in the window finishing and loading the URL immediately with no problems. 2) Running the code with just Dispatch (no events) and it works fine ( 1 sec). All I can think is that each call to ie.ReadyState triggers some internal event which hogs resources to process. It seems like the problem is with IE Events only... so a possible workaround (if all you need is the Doc events) is the following: - import win32com.client class Doc_Events: def Ononactivate(self): print 'onactivate:', doc.location.href def Ononclick(self): print 'onclick fired.' def Ononreadystatechange(self): print 'onreadystatechange:', doc.readyState ie = win32com.client.Dispatch(InternetExplorer.Application) ie.Visible = 1 ie.Navigate('http://www.google.com') while ie.ReadyState != 4: time.sleep(1) doc = ie.Document doc_events = win32com.client.WithEvents(doc, Doc_Events) # OR can use following: # doc = win32com.client.DispatchWithEvents(ie.Document, Doc_Events) while ie.ReadyState != 4 and doc.readyState != complete: # readystate is case sensitive and differs for ie (R) and doc (r) # ie.ReadyState: 0=uninitialised; 1=loading; 2=loaded; #3=interactive; 4=complete time.sleep(1) - HTH, -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.0.2 released
This is a minor bugfix release. Wiki, bugtracker, downloads at http://pysqlite.org/ If you missed 2.0.1, it fixed a bug that could happen if user-defined functions/aggregates were getting out of scope. It's a fatal bug that will crash your application if you encounter it. - Code changes to allow compilation on MacOS X Tiger - Fixed a few compilation warnings that appeared under GCC 4.0. - Refactored code so cursors are closed ASAP. This means that statements are now finalized as soon as the last row was fetched. In order to achieve this, pysqlite is always prefetching exactly one row. - Removed the type objects STRING, NUMBER, DATETIME, ... from the module, because pysqlite cannot deliver the type code anyway, so these type objects are useless, if not even confusing. -- Gerhard Häring - [EMAIL PROTECTED] - Python, web database development signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Can you introduce some book about python?
--- [EMAIL PROTECTED]: Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than Re: Contents of Python-list digest... Today's Topics: 1. Re: appending key-value pairs to a dict (Peter Hansen) 2. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 3. Re: appending key-value pairs to a dict (Brian Beck) 4. Re: Comparing 2 similar strings? (Skip Montanaro) 5. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 6. Re: buffer_info error ([EMAIL PROTECTED]) 7. Re: appending key-value pairs to a dict (James Stroud) 8. From the call hook, how do I know more precisely what is called? (Vijay Kumar) 9. Re: PyGame and Rotozoom (Sorry if OT) (Lee Harr) 10. Re: buffer_info error (Jp Calderone) 11. Re: appending key-value pairs to a dict (Roy Smith) 12. Re: Is Python suitable for a huge, enterprise size app? (Dave Brueck) 13. Re: Process monitoring (John Abel) : Peter Hansen [EMAIL PROTECTED] : python-list@python.org : Fri, 20 May 2005 16:12:17 -0400 : Re: appending key-value pairs to a dict rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Whereas with a list you would call append in the loop, with a dictionary you simply use an indexed-assignment type of access: mydict = {} for filename in some_list_of_filenames: hash = sha.sha(open(filename).read()).hexdigest() # or whatever mydict[filename] = hash -Peter : Paul Rubin http://[EMAIL PROTECTED] : python-list@python.org : 20 May 2005 13:12:50 -0700 : Re: Is Python suitable for a huge, enterprise size app? Dave Brueck [EMAIL PROTECTED] writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's protocol modules - partly because we had to implement our own HTTP libraries for performance and scalability reasons anyway, and partly because we had trouble figuring out e.g. all the ins and outs of urllib/urllib2/httplib. What do you use for HTTPS? And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies). I'm not trying to be contentious here, just mentioning a couple further cases of where problems aren't visible from far away but are there when you look close. : Brian Beck [EMAIL PROTECTED] : python-list@python.org : Fri, 20 May 2005 16:14:17 -0400 : Re: appending key-value pairs to a dict rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Like so: d = {} for filename in files: d[sha_func(filename)] = filename Or like so: d = dict([(sha_func(filename), filename) for filename in files]) -- Brian Beck Adventurer of the First Order : Skip Montanaro [EMAIL PROTECTED] : python-list@python.org : Steve Holden [EMAIL PROTECTED] : Fri, 20 May 2005 15:16:49 -0500 : Re: Comparing 2 similar strings? Steve (is this the same as 'Conchobar'?) No, that's a trendy pub in Key West... wink Skip : Paul Rubin http://[EMAIL PROTECTED] : python-list@python.org : 20 May 2005 13:15:48 -0700 : Re: Is Python suitable for a huge, enterprise size app? Fredrik Lundh [EMAIL PROTECTED] writes: this has been reported before, and it won't get fixed (unless you're volunteering to add Python-compatible garbage collection to Tk, that is). Yeah, I think I understand what the issue is. I can think of some kludgy possible fixes but I assume they've been thought about already and rejected. The workaround of making the application save an extra reference isn't too bad, but all relevant docs that say anything about these images should mention the requirement emphatically. : [EMAIL PROTECTED] [EMAIL PROTECTED] : python-list@python.org : 20 May 2005 13:18:33 -0700 : Re: buffer_info error i am filling in a packet with source and destination address and using the buffer_info call
Re: passing arguments
James Stroud wrote: import sys try: arg1 = sys.argv[1] except IndexError: print This script takes an argument, you boob! sys.exit(1) Also possible, to guarantee that exactly one argument was given: try: arg1, = sys.argv except ValueError: print This script takes an argument, you boob! sys.exit(1) If you want to get, say, 3 arguments, just change that line to: arg1, arg2, arg3 = sys.argv OR, way better: See the optparse module. Definitely. Though depending on what kind of arguments your script takes, you still may need to deal with the args that optparse returns. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
Dave Brueck [EMAIL PROTECTED] writes: What do you use for HTTPS? m2crypto (plus some patches to make asynchronous SSL do what we needed). That seems to be a nice piece of code, but it's still at version 0.13; if something goes wrong, are you sure you want to explain that you were using beta-test software to protect your customers' production financial transactions? There's also been some traffic on the python-crypto list about Zope encountering memory leaks with it. I haven't read the messages carefully though, so I'm not sure what the situation is. did you use the Cookie module in your HTTP servers?... Are you referring to the use of pickle for cookie serialization? Yes. -- http://mail.python.org/mailman/listinfo/python-list
count files in a directory
I assume that there's a better way than this to count the files in a directory recursively. Is there??? def count_em(valid_path): x = 0 for root, dirs, files in os.walk(valid_path): for f in files: x = x+1 print There are, x, files in this directory. return x rbt -- http://mail.python.org/mailman/listinfo/python-list
Re: appending key-value pairs to a dict
Peter Hansen wrote: rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's name and its sha hash into a dict on each loop. Whereas with a list you would call append in the loop, with a dictionary you simply use an indexed-assignment type of access: mydict = {} for filename in some_list_of_filenames: hash = sha.sha(open(filename).read()).hexdigest() # or whatever mydict[filename] = hash -Peter Thanks guys... that works great. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to config a comserver in a customize dll?
If you have a custom COM dll, you should just register it as normal. I'm not sure why you would want to register it as a python COM server. Unless you've duplicated the whole framework that allows com servers to be written in python ? Roger ÒÊÃÉɽÈË [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When i use the below code to create a comserver on Windows OS£¬i find that the com was configed in the file python23com.dll,why? if i want to config it in my customize dll,how should i do? thks class TestPythonCom: _public_methods_ = [ 'SplitString' ] _reg_progid_ = TestPythonCom.Application # NEVER copy the following ID # Use print pythoncom.CreateGuid() to make a new one. _reg_clsid_ = {93D78ABA-1F6C-4B1C-97C7-C3700511415A} def SplitString(self, val): return val == Posted via Newsfeeds.Com - Unlimited-Uncensored-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: count files in a directory
On Friday 20 May 2005 07:12 pm, rbt wrote: I assume that there's a better way than this to count the files in a directory recursively. Is there??? def count_em(valid_path): x = 0 for root, dirs, files in os.walk(valid_path): for f in files: x = x+1 print There are, x, files in this directory. return x rbt def count_em(valid_path): root, dirs, files = os.walk(valid_path) return len(files) -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: count files in a directory
Come to think of it file_count = len(os.walk(valid_path)[2]) -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing bash_history and inputting into mysql (Intrusion Detection)
[EMAIL PROTECTED] wrote: I have a seemingly tough assignment for my Senior Project. I need to develop an Intrusion Detection System. My approach is to parse the bash_history file of each user into a mysql database, assign a threshold for commands or sequences of commands and then alert the admin of nethin fishy is found. ~/.bash_history is written when Bash exits. Try history -c exit and see what happens. My advisor reccomended I use python for writing the scripts. I am absolutely new to python and have no prior experience in it. That said Could any one tell me how exactly to go abt all this? Any tools or code that would make my life easier? Suggestions (which modules to use etc) ? -- William Park [EMAIL PROTECTED], Toronto, Canada ThinFlash: Linux thin-client on USB key (flash) drive http://home.eol.ca/~parkw/thinflash.html -- http://mail.python.org/mailman/listinfo/python-list
Re: first release of PyPy
[EMAIL PROTECTED] wrote: Kay Schluehr wrote: holger krekel wrote: Welcome to PyPy 0.6 *The PyPy Development Team is happy to announce the first public release of PyPy after two years of spare-time and half a year of EU funded development. The 0.6 release is eminently a preview release.* Congratulation to You and Your team! PyPy is really awesome and if it succeeds in speed demands after the translation phase I believe that the project will shift the power within the Python community on the long run. Could you please explain this statement? Who will gain power, and who will lose it? The Python community will gain power, and nobody will loose some. The big win is that we gain a new flexibility that did not exist before, even if PyPy should completely miss its speed promises. Having an extremely flexible implementation in a very high-level language (which happens to be Python) enables possibilities which have not been seen, before. There is of course a chance for some community of C programmers to loose interest, if PyPy really gets as efficient as we hope for. But this is a) still a long, uncertain path and b) not a real danger, but more likely an advantage for the involved people. Are you suggesting that CPython and PyPy developers are competing? No idea how we could get onto this track. If there is a competition, then only if PyPy gets into a position where it is comparable with CPython. This is not the case, at least not in a well-ordered manner. It is not really faster, but it is definately much more flexible. Comparisons are not suitable at all, bcause there are too many qualities to compare about. And I see no point for any competition in any future. We all love Python. It is a language, and languages are communities. If a particular implementation gets more interest for some reasons, then because it ibetter s more efficient or more interesting, whatever reasoning gives it popularity. But we are all with Python! Surely we are comparing our performance with CPython's. This is not the real point. Note also, that many of the PyPy team members belong to CPython core developers, as well. This is not a competition, but a huge new branch, exploring what is doable and what not. You might also give our website a try which is quite informative and gives you an insight into what we are aiming for. http://codespeak.net/pypy PyPy is just a completely new approach to interpreted languages, almost based upon known compiler technology, but applying this in a consequent manner, that has no comparable prior example. I wish to repeat the congratulations to the team for the first release! --- ciao -- chris -- Christian Tismer :^) mailto:[EMAIL PROTECTED] tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/ 14109 Berlin : PGP key - http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: count files in a directory
Sorry, I've never used os.walk and didn't realize that it is a generator. This will work for your purposes (and seems pretty fast compared to the alternative): file_count = len(os.walk(valid_path).next()[2]) The alternative is: import os import os.path file_count = len([f for f in os.listdir('.') if os.path.isfile(f)]) On Friday 20 May 2005 08:08 pm, rbt wrote: James Stroud wrote: def count_em(valid_path): root, dirs, files = os.walk(valid_path) return len(files) Here's another Tback: Traceback (most recent call last): File C:\Program Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\Documents and Settings\rbt\Desktop\newa\replicate.py, line 62, in ? A = count_em(X) File C:\Documents and Settings\rbt\Desktop\newa\replicate.py, line 56, in count_em root, dirs, files = os.walk(valid_path) ValueError: need more than 2 values to unpack -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list