ANN: Tftpy 0.1 - Pure Python TFTP Library
Announcing new project, Tftpy, a Pure Python TFTP implementation. About Release 0.1: == This is an initial release in the spirit of release early, release often. Currently the sample client works, supporting RFC 1350. The server is not yet implemented, and RFC 2347 and 2348 support (variable block sizes) is underway, planned for 0.2. About Tftpy: Tftpy is a TFTP library for the Python programming language. It includes client and server classes, with sample implementations. Hooks are included for easy inclusion in a UI for populating progress indicators. It supports RFCs 1350, 2347 and 2348. This library was developed against Python 2.4.1. Project page: http://sourceforge.net/projects/tftpy/ License is the CNRI Python License. http://www.opensource.org/licenses/pythonpl.php -- Michael P. Soulier [EMAIL PROTECTED] Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. --Albert Einstein pgpAuHu4d8mIC.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: Urwid 0.9.7.1 - Console UI Library
Announcing Urwid 0.9.7.1 Urwid home page: http://excess.org/urwid/ Tarball: http://excess.org/urwid/urwid-0.9.7.1.tar.gz About this release: === This release fixes bugs introduced in the Padding and Overlay classes in the previous release. These bugs prevent the graph.py example program from running. New in this release: * Fixed bugs in Padding and Overlay widgets introduced in 0.9.7. About Urwid === Urwid is a console UI library for Python. It features fluid interface resizing, UTF-8 support, multiple text layouts, simple attribute markup, powerful scrolling list boxes and flexible interface design. Urwid is released under the GNU LGPL. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANNOUNCE: PyGObject 2.12.2
I am pleased to announce version 2.12.2 of the Python bindings for GObject. The new release is available from ftp.gnome.org as and its mirrors as soon as its synced correctly: http://download.gnome.org/sources/pygobject/2.12/ What's new since PyGObject 2.12.1: - Make PyGObject 64-bit safe for Python 2.5 (Gustavo) - All headers are now LGPL and not GPL (Johan) - Remove a couple of GCC warnings (Gustavo) - Revive distutils support (Cedric Gustin) - Emission hook reference count bugfix (Gustavo) - MSVC/ANSI C compilation fix (John Ehresman) - Bump Ctrl-C timeout handler from 100ms to 1000ms (Johan) Blurb: GObject is a object system library used by GTK+ and GStreamer. PyGObject provides a convenient wrapper for the GObject+ library for use in Python programs, and takes care of many of the boring details such as managing memory and type casting. When combined with PyGTK, PyORBit and gnome-python, it can be used to write full featured Gnome applications. Like the GObject library itself PyGObject is licensed under the GNU LGPL, so is suitable for use in both free software and proprietary applications. It is already in use in many applications ranging from small single purpose scripts up to large full featured applications. PyGObject requires GObject = 2.8.0 and Python = 2.3.5 to build. -- Johan Dahlin [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Dr. Dobb's Python-URL! - weekly Python news and links (Oct 4)
QOTW: If you want your objects to know their name, give them a name as an attribute. - Georg Brandl Unfortunately forty years of programming experience has taught me that there's an essentially infinite supply of mistakes to make ... your mistakes just get smarter most of the time. - Steve Holden timbot and other seniors explain several aspects of memory management applicable to a specific pathologic example ... [for which it's an advantage] to disable garbage collection: http://groups.google.com/group/comp.lang.python/browse_thread/thread/66ecc194fa8af1a1/ No, Ruby isn't more virtuously object-oriented than Python (although it *is* more Smalltalk-like). John Roth details the factual distinctions: http://groups.google.com/group/comp.lang.python/browse_thread/thread/25e108582b4a6db2/ Duncan Booth, effbot, Steve Holden, and others surpass Lewis Carroll in the care with which they distinguish a character, the name of the character, what it's called, ...: http://groups.google.com/group/comp.lang.python/browse_thread/thread/14885cf940d9e8b9/ Sybren Stuvel's article on Open Office and Python is important enough to merit correction: http://groups.google.com/group/comp.lang.python/browse_thread/thread/c7bee85c6af82777/ With a far different programming model, Python also can boss Excel around to the extent of inserting images: http://groups.google.com/group/comp.lang.python/browse_thread/thread/8a0a1165a9b844f5/ How do you realize the source for a class definition so it's useful, that is, effectively able for use in the future? James Stroud and Scott David Daniels tell their stories: http://groups.google.com/group/comp.lang.python/browse_thread/thread/99d80c18db6228cc/ WSGI has its own PEP, Wiki, high-profile introduction, ...: http://www.xml.com/pub/a/2006/09/27/introducing-wsgi-pythons-secret-web-weapon.html Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/python/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python
Re: PATCH: Speed up direct string concatenation by 20+%!
Larry Hastings wrote: John Machin wrote: try benchmarking this ... well style may not be the appropriate word Running this under Python 2.5 release: x = [] xappend = x.append for i in xrange(1000): xappend(a) y = .join(x) took 3281ms. Running this under my patched Python 2.5: x = xappend = x.__add__ for i in xrange(1000): xappend(a) y = .join(x) Don't you mean y = x[1] or something like that? y = .join(x) looks like a copy-paste error. Playing the devil's advocate here: 10M adds each of a single byte followed by 1 render doesn't seem very typical. How about 10 adds each of 10 bytes followed by a render, then repeat that 10 M times. Another question: How does this: buff = for datum in data: if buff: buff += | buff += str(datum) compare with buff = |.join(str(datum) for datum in data) ? Some of us have Windows boxes and don't have the necessary MS compiler. Is there any chance of someone making a 2.5+patch Windows binary? Cheers, John took 3343ms. /larry/ -- http://mail.python.org/mailman/listinfo/python-list
Re: saving an exception
Bryan wrote: i would like to save an exception and reraise it at a later time. something similar to this: exception = None def foo(): try: 1/0 except Exception, e: exception = e if exception: raise exception with the above code, i'm able to successfully raise the exception, but the line number of the exception is at the place of the explicit raise instead of the where the exception originally occurred. is there anyway to fix this? Sure: generate the stack trace when the real exception occurs. Check out sys.exc_info() and the traceback module. import sys import traceback exception = None def foo(): global exception try: 1/0 except Exception: # Build a new exception of the same type with the inner stack trace exctype = sys.exc_info()[0] exception = exctype('\nInner ' + traceback.format_exc().strip()) foo() if exception: raise exception # Output: Traceback (most recent call last): File foo.py, line 15, in module raise exception ZeroDivisionError: Inner Traceback (most recent call last): File foo.py, line 8, in foo 1/0 ZeroDivisionError: integer division or modulo by zero --Ben -- http://mail.python.org/mailman/listinfo/python-list
Thread hijack: [was Re: php and python: how to unpickle using PHP?]
Ted Zeng wrote: Hi, I store some test results into a database after I use python To pickle them (say, misfiles=['file1','file2']) Now I want to display the result on a web page which uses PHP. How could the web page unpickle the results and display them? Is there a PHP routine that can do unpickle ? Ted zeng Please don't generate a post by replying to somebody else's message and changing the subject and text: newsreader software will see your post as a part of the same thread and mix the two subjects, to everyone's confusion. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: app with standalone gui and web interface
Daniel Nogradi wrote: What would the simplest way to make an application that has both a web interface and runs from behind a web server but also can be used as a standalone app with a gui? More precisely is it possible to avoid creating an html/xml/whatever based web interface for the web version and separately creating a gui (wxpython for example) for the standalone version and instead create a graphical frontend at once that can be used for both? No. However, if you have a web interface there's nothing to stop you from providing that for local use as a desktop app as well as remote use: your app then just becomes a web shortcut to a locally-running server. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: saving an exception
Bryan wrote: hi, i would like to save an exception and reraise it at a later time. something similar to this: exception = None def foo(): try: 1/0 except Exception, e: exception = e if exception: raise exception i have a need to do this because in my example foo is a callback from c code which was originally called from python and i can't modify the c code. with the above code, i'm able to successfully raise the exception, but the line number of the exception is at the place of the explicit raise instead of the where the exception originally occurred. is there anyway to fix this? You can capture the trace at the time the original exception is raised, if that would help? I think the traceback module lets you do that. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets in python
What's your set-up and which cord are you pulling? Well i now i think the clue is in the OS, i have sniffed and it seems that Twisted have no magic. It is seems that i simply tested things in a wrong way - when i pulled cord from ethernet card windows determined that network lost and started to closing all sockets opened to that network (and so EINVAL or other OS error raised when twisted tryed to read wrom that socket), while the server did had a network - and it was right thing that server was thinking that socket is alive. -- http://mail.python.org/mailman/listinfo/python-list
Re: Determin network interface
Thanks a bunch! That is just what I was looking for ! Best regards Jakob Bryan Olson skrev: [EMAIL PROTECTED] wrote: Hi. How can I determin the hwaddr or ipaddress of the networkinterface that is used in an outgoing connection? Is sock_object.getsockname() enough? http://docs.python.org/lib/socket-objects.html -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: saving an exception
At Tuesday 3/10/2006 02:15, Bryan wrote: i would like to save an exception and reraise it at a later time. def foo(): Â Â try: Â Â Â Â 1/0 Â Â except Exception, e: Â Â Â Â exception = e if exception: raise exception with the above code, i'm able to successfully raise the exception, but the line number of the exception is at the place of the explicit raise instead of the where the exception originally occurred. Â is there anyway to fix this? The raise statement has 3 arguments, the third being the traceback (not used so much, except in cases like yours). You can get the values using sys.exc_info() (Don't store the traceback more than needed because it holds a reference to all previous stack frames...) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI - mod_python
[EMAIL PROTECTED] wrote: Hi, it is a kind of nooby question. Is there a way to transfer a CGI python script to mod_python without rewriting the code? Did you look in the mod_python documentation? http://www.modpython.org/live/current/doc-html/hand-cgi.html It certainly isn't the preferred way of using mod_python. You really should consider porting it properly to either mod_python or as someone else suggested, WSGI. Graham -- http://mail.python.org/mailman/listinfo/python-list
Re: switch user
Check out the os module, especially the os.getgid(), os.getuid(), os.setgid(), os.getuid(), methods. There are more , take at a look at Python documentation. You can start a script as root then change your priveleges with os.setgid() os.setuid() methods. Note: those methods operate with integer user and group IDs, not with user and group names. Hope that helps, -Nick Vatamaniuc [EMAIL PROTECTED] wrote: hi due to certain constraints, i will running a python script as root inside this script, also due to some constraints, i need to switch user to user1 to run the rest of the script...is there a way ?thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: postgresql database
Michele Simionato ha scritto: Paolo wrote: Ciao a tutti, sto cercando di implementare un applicazione che si interfaccia con postgresql(8.1), utilizzando Psycopg2, in ambiente windows (python versione 2.5). Ho installato Psycopg2 e provando solamente fare: import psycopg mi ritorna il seguente errore: import psycopg ImportError: No module named psycopg come mai? va settata qualche path oltre a quella di postgresql ? grazie dell'aiuto Well, if you are using Psycopg2, do import psycopg2 sure, I have mistaken to write the import, the problem was in the version of the driver. Thank you for tour fast answer. (and please use the italian mailing list for questions in Italian). sorry, but I thought to write in the italian mailing list. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: VIdeo Converence Software: Tk and thread synchronization
On Mon, 02 Oct 2006 14:42:15 +0200, Paolo Pantaleo [EMAIL PROTECTED] wrote: Hi, I am going on writing my video conference software. I wrote the video grab, code/decode, and netwoark (multicast) transport. I have one thread doing this: [thread 1] while True: for some times: my_socket.recv() #blocking here store data compute image #here we have a complete new image to display Now, I was thinking to display the image in a Tk window. But I think i will need a separate thread to run the mainloop() [thread 2], right? I don't know if tk likes to be run in anything else than the main thread; never tested it. If you can use the main thread for tk, you'll probably have far less problems. How can I signale to the Tk thread that a new image is ready to be shown? I was thinkin on using an event generated for the first (network) thread. But I don't know how to do it exactly. Any suggestion, please? Quite simple: in the tk thread, do: widget.bind('MyEvent', command) Then in the secondary thread, do: widget.event_generate('MyEvent', when='tail') 'MyEvent' can be anything, as long as you surround it with (these are custom events in tk). Don't forget to put the when='tail' in the event_generate call, or your binding may get called immediatly in the current thread. What if I access to Tk object form thread 1, is Tk thread safe? General answer: no, it isn't. The only thing that seems to work everytime on tk widgets from secondary threads is generating events as above. If you try to do anything else, you may experience deadlocks or even crashes. HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Re: VIdeo Converence Software: Tk and thread synchronization
Eric Brunel [EMAIL PROTECTED] writes: General answer: no, it isn't. The only thing that seems to work everytime on tk widgets from secondary threads is generating events as above. I wouldn't bet on even that always being safe. If you try to do anything else, you may experience deadlocks or even crashes. The way I do it is use a .after event in the main tkinter loop to check a queue every 20 msec or so. Other threads send commands through the queue. I usually pass commands as tuples (func, *args, **kw) so that the .after handler simply calls the func on the args. -- http://mail.python.org/mailman/listinfo/python-list
How Build VTK for Python 2.5 under Windows?
Hello, I'm running on Windows and I want to test VTK but I don't understand how build it Somebody can help me to build VTK for Python 2.5 under Windows? (or Python 2.43 if python 2.5 is a problem) I have no C compiler but I can install one if it's free. Thank you Seb -- http://mail.python.org/mailman/listinfo/python-list
I need Cryptogrphy in Python please .
Looking around for a Cryptography tool kit, the best recommendations I found about was for pyCrypto. I try to install it unsuccessfully in my windowsXP SP2 with python 2.4.3 and I get the following message : C:\Python24\pycrypto-2.0.1python setup.py build running build running build_py running build_ext error: The .NET Framework SDK needs to be installed before building extensions f or Python. I have installed .NET framework latest release. Unfortunately the pyCrypto project looks abandoned , I couldn't find an active mailing list and the last release are a couple of year old. Can some one guide me how to fix the problem above or point me to another Cyrptography library that I can use easily ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with an array problem.
Dennis Lee Bieber [EMAIL PROTECTED] wrote: Of course, there is also the confusion between type cast and type conversion -- at least, for me... cast taking the bit-pattern of a value in one type and interpreting the same bit-pattern as if it were a different type conversiontaking the value of a bit-pattern in one type and converting it to the bit pattern of the equivalent value in another type From where have you learned those definitions? If it's from C, then you have read the wrong books. A cast in C is a type conversion, with the same semantics as you write under conversion above. The C standard (ISO/IEC 9899:1999) says: 6.5.4 Cast operators [...] Semantics Preceding an expression by a parenthesized type name converts the value of the expression to the named type. This construction is called a cast. A cast that specifies no conversion has no effect on the type or value of an expression. (A cast that specifies no conversion refers to when you cast from one type to the same type, e.g. '(int)x' if x is of the type 'int'.) You may also try this program: #include stdio.h #include string.h int main(void) { /* Assumption: sizeof(float)==sizeof(int). This is the most * common case on modern computers. */ float f = -17.0; int i = -23; float fjunk; int ijunk; printf(Cast: %d %10.6f\n, (int)f, (float)i); memcpy(fjunk, i, sizeof i); memcpy(ijunk, f, sizeof f); printf(Bitcopy: %d %10.6f\n, ijunk, fjunk); return 0; } If a cast had been what you believed, both printf() statements above would give the same output. Unless your C compiler uses some really strange floating point representation, they will print rather different things. The first one must print Cast: -17 -23.00 showing very clearly that a cast is a type conversion. The second printf() will print some seemingly random numbers, showing that those bit-patterns will be interpreted very differently when interpreted as another type. What you might have been confused by, is dereferencing a casted pointer. Add the following statement: printf(Pointer cast: %d %10.6f\n, *(int*)f, *(float*)i); to the program. It should output the same numbers as the Bitcopy printf(). But what is cast here is the *address* of the variables, not the actual contents of them. It is the *dereferencing* of those casted pointers that interpret the bit patterns in the variables as if they were another type, not the casting itself. -- Thomas Bellman, Lysator Computer Club, Linköping University, Sweden I don't think [that word] means what you! bellman @ lysator.liu.se think it means. -- The Princess Bride! Make Love -- Nicht Wahr! -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
NicolasG [EMAIL PROTECTED] writes: Can some one guide me how to fix the problem above or point me to another Cyrptography library that I can use easily ? There are several. What do you want to do with it? -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
NicolasG wrote: I have installed .NET framework latest release. The SDK is different from the framework. ;) Can some one guide me how to fix the problem above or point me to another Cyrptography library that I can use easily ? Prebuilt binaries: http://www.voidspace.org.uk/python/modules.shtml#pycrypto Ps. The project still looks active to me, and has an active mailing list: http://www.amk.ca/python/code/crypto.html Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets in python
OneMustFall a écrit : What's your set-up and which cord are you pulling? Well i now i think the clue is in the OS, i have sniffed and it seems that Twisted have no magic. It is seems that i simply tested things in a wrong way - when i pulled cord from ethernet card windows determined that network lost and started to closing all sockets opened to that network (and so EINVAL or other OS error raised when twisted tryed to read wrom that socket), while the server did had a network - and it was right thing that server was thinking that socket is alive. Stupid Windows behaviour btw! I hate that, it makes testing code stability for temporary network lags much much harder to do. And don't get me started on when we reboot the switch which causes all open sockets on my computer to fail, even though the reboot only takes a few seconds and though the internet connection doesn't change. -- http://mail.python.org/mailman/listinfo/python-list
Python to use a non open source bug tracker?
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list
Re: app with standalone gui and web interface
Hi Daniel. What would the simplest way to make an application that has both a web interface and runs from behind a web server but also can be used as a standalone app with a gui? More precisely is it possible to avoid creating an html/xml/whatever based web interface for the web version and separately creating a gui (wxpython for example) for the standalone version and instead create a graphical frontend at once that can be used for both? I was experimenting with something roughly similar a couple of years ago. You might find it interesting. What I did may or may not work in your case. It depends on what you want to be able to do in the application. I built an application that consisted of some server side Java/JSPs that gave out XML. I used two stylesheets to transform the data into either HTML (for the web version) or another XML-format called wxWML (for the wxPython version). Desktop users accessed the application via a custom webbrowser that translates the wxWML to wxPython code which is executed to generate the GUI. This way, anyone with the wxBrowser installed could access the application as if it was a desktop app. But you should know that this was an experiment. We ended up not using it because it felt weird and because there was not much extra gain to be had from the desktop part. You should also know that the wxBrowser is a HUGE security hole which is a good reason not to use it. You can still download the code I wrote and a tutorial PDF from http://www.pulp.se/wx/ but I haven't touched it since last summer so I'm not sure it works with the latest version of wxPython. Also, I just noted that the example URL that I point to on that page doesn't work because I've moved my hosting since then, but that can be fixed. Good luck Johan Lindberg [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Overriding builtin getattr method
Hello guys, I have data stored in the database which has special characters like , etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like lt; gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database. For doing this I thought of overriding the __builtin__.__getattr__ method. I am wondering if there is any other way of achieving this. I have loads of files that get the attribute values of objects stored in the database and I do not want to manually change the way of DB access in those files. I rather prefer a centralized way to achieve this. Good inputs are always appreciated. :-) Raja -- http://mail.python.org/mailman/listinfo/python-list
Re: Overriding builtin getattr method
Correction: I meant __builtin__.getattr method and not the other one I mentioned. :-) Thanks Raja Raja Raman Sundararajan skrev: Hello guys, I have data stored in the database which has special characters like , etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like lt; gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database. For doing this I thought of overriding the __builtin__.__getattr__ method. I am wondering if there is any other way of achieving this. I have loads of files that get the attribute values of objects stored in the database and I do not want to manually change the way of DB access in those files. I rather prefer a centralized way to achieve this. Good inputs are always appreciated. :-) Raja -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Giovanni Bajo wrote: Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? No. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple but fast 2D lib for drawing pixels
Thanks Dave for this tip, this is excellent, exactly what I have been looking for! I'm using it already :-) Kind Regards, Peter [EMAIL PROTECTED] wrote: On Oct 1, 2006, at 6:28 PM, Peter Mexbacher wrote: Hello, we want to teach absolute programming newbies a first language, so they can start programming simple scientific models. We thought Python would make a good choice for a first language; but where pretty stumped when we found out that there is no simple way to draw pixels to a screen. (This is needed for fractals, agent-based models etc - like Conways Game of Life) Our requirements: -) easy to learn (newbs!) -) not too slow (after all, the models should simulate something) -) python :-) Any ideas? Best Regards, Peter You might check out John Zelle's Python book - he uses a simple graphics library on top of Tk (which Python comes with). You can find information on his book and the graphics.py file he uses at: http://mcsp.wartburg.edu/zelle/python/ It certainly meets your easy to learn and Python requirements - and of course speed is subjective so it may or may not be fast enough for you. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Giovanni Bajo wrote: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? not necessarily (and good support for data export is high on the requirements list), but for those of us who's been following the committee's work, there has indeed been a disturbing amount of free as in - oh shiny! from the very beginning. however, note that the committee do realize that using a Python- powered tool for Python is a good thing in itself; they are asking for volunteers that can keep a roundup instance running, and fix any issues that arises. python.org has plenty of hardware, but not enough manpower to do everything that could be done. see brett's post for details. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
I have made a site using Karrigell as a web server and I want to provide cryptography services to the visitors. They should wirte their text on the site and be able choose different encryption algorithms to apply on the text . MonkeeSage wrote: NicolasG wrote: I have installed .NET framework latest release. The SDK is different from the framework. ;) How can I fix this ? Can some one guide me how to fix the problem above or point me to another Cyrptography library that I can use easily ? Prebuilt binaries: http://www.voidspace.org.uk/python/modules.shtml#pycrypto I need the modules source to use it with my web server. Ps. The project still looks active to me, and has an active mailing list: http://www.amk.ca/python/code/crypto.html The last messages in the mailing list was on august (only one message) and the author does said that he does not reply to the this list , he point if anyone have an issue to use the bug trucker at sourceforge which looks not helpful ... cheers.. Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
NicolasG [EMAIL PROTECTED] writes: I have made a site using Karrigell as a web server and I want to provide cryptography services to the visitors. They should wirte their text on the site and be able choose different encryption algorithms to apply on the text . Um, why? Just as an exercise? If that's the case, you might enjoy implementing the algorithms in Python. They'd be slow but that might not matter. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Giovanni Bajo [EMAIL PROTECTED] writes: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? Sounds crazy, what's wrong with bugzilla? -- http://mail.python.org/mailman/listinfo/python-list
Re: Overriding builtin getattr method
At Tuesday 3/10/2006 05:24, Raja Raman Sundararajan wrote: Hello guys, I have data stored in the database which has special characters like , etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like lt; gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database. For doing this I thought of overriding the __builtin__.__getattr__ method. Not very reasonable on the source object itself. Escaping is a *presentation* requirement and should be managed at that level. For example, in a PageTemplate, using tal:content or tal:attribute does the right escaping. I am wondering if there is any other way of achieving this. I have loads of files that get the attribute values of objects stored in the database and I do not want to manually change the way of DB access in those files. I rather prefer a centralized way to achieve this. If your data contains a '', that's OK, it's the real contents and should remain that way. If you have to build an HTML page, escape those characters at *that* stage. If you have to write a CSV file, perhaps a '' is irrelevant but a ',' is problematic. For some Windows text controls you have to escape '' characters. None of these operations should make you to change your data, or the way you access your data. You invoke them at the presentation stage, depending on the final target. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Robert Kern wrote: Does this smell Bitkeeper fiasco to anyone else than me? No. that's just not true. lots of people have voiced concerns over using closed-sourced stuff originally designed for enterprise-level Java users for an application domain where Python has several widely used agile alternatives to chose from. if they hadn't done so, there probably wouldn't have been an evaluation period in the first place. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Overriding builtin getattr method
I have data stored in the database which has special characters like , etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like lt; gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database. For doing this I thought of overriding the __builtin__.__getattr__ method. I am wondering if there is any other way of achieving this. I have loads of files that get the attribute values of objects stored in the database and I do not want to manually change the way of DB access in those files. I rather prefer a centralized way to achieve this. The centralized approach to this is certainly not achieved by overloading getattr alone - because even if it was possible to do so (which it isn't), the implementation needed a way to know when to use escaping or not. Which would be signaled by some means, e.g. a thread-local variable or even a global (shudder). This signal gets set in the code that decides that it wants the data escaped - or not. And thus the code looks like this: needs_escaping() work_with_objects() no_escaping_anymore() But that is fragile, think of work_with_objects() throwing an exception and the no_escaping_anymore() isn't called again. So the better approach is to gather the data as it is, and when you transform it to something that requires escaping, do it there. That means: the way to do it is to use one of the gazillion web templating systems that already do this escaping for you. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: loop beats generator expr creating large dict!?
George Young wrote: ... I am puzzled that creating large dicts with an explicit iterable of key,value pairs seems to be slow. I thought to save time by doing: palettes = dict((w,set(w)) for w in words) instead of: palettes={} for w in words: palettes[w]=set(w) In the generator case, you are first creating a tuple, and then assigning the first element of the tuple as the key and the second element as the value in the dictionary. In the loop, you are directly setting the key and value in the dictionary. Essentially by doing the generator (or comprehension), you are packing and unpacking the key, value pairs for each word in your initial list, all of which will have an overhead. -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
NicolasG wrote: I need the modules source to use it with my web server. I thought you were trying to compile and install the pyCrypto extension? If that is the case, then download the installer from the page I linked to. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Ctypes and freeing memory
Hi everybody, I am currently playing around with ctypes and a C library (libWand from ImageMagick), and as I want to easily deploy it on Mac, Linux and Windows, I prefer a ctypes solution over a C module. At least on windows, I would have resource problems to compile the C module. So, ctypes is the perfect choice for me. But I am currently encountering a pattern inside the C library, that has to be used to free memory. Coding in C I have to do the following char *description; long severity; description = MagickGetException(wand, severity); /* do something with the description: print it, log it, ... */ description = (char *) MagickRelinquishMemory(description); exit(-1); /* or something else what I want to after an exception occured */ So, this looks easy and is sensible from C's point of view. Now I try to translate this to Python and ctypes. dll.MagickGetException.argtypes = [c_long, POINTER(c_long)] dll.MagickGetException.restype = c_char_p severity = c_long() description = dll.MagickGetException(byref(severity)) # So far so good. The above works like a charm, but the problem follows now # ctypes already converted the char * for description to a String object. # That means description has arrived in an area under Python's control. # these definitions are the easy part dll.MagickRelinquishMemory.argtypes = [c_void_p] dll.MagickRelinquishMemory.restype = c_char_p # but this obviously must cause problems and causes problems dll.MagickRelinquishMemory(description) So, my question is, how do I deal with this situation? Can I ignore the call to MagickRelinquishMemory, cause Python takes care of the resources already? Or is it impossible to use it at all, and I have to think about a different solution? Best regards, Oliver -- Oliver Andrich [EMAIL PROTECTED] --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Howto pass Array/Hash into Function
Hi, How can I pass Array, Hash, and a plain variable in to a function at the same time. I come from Perl. Where as you probably know it is done like this: sub myfunc { my ($plain_var, $hash_ref,$arref) = @_; # Do sth with those variables return; } I wonder how can that be done in Python. Regards, Edward WIJAYA SINGAPORE Institute For Infocomm Research - Disclaimer - This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto pass Array/Hash into Function
Wijaya Edward wrote: I wonder how can that be done in Python. def myfunc(plain_var, hash_ref, arref): # Do sth with those variables return Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto pass Array/Hash into Function
MonkeeSage wrote: Wijaya Edward wrote: I wonder how can that be done in Python. def myfunc(plain_var, hash_ref, arref): # Do sth with those variables return At the risk of being a jerk (sorry, I'm really just curious): Why isn't that obvious? wildemar (sorry) -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto pass Array/Hash into Function
Wildemar Wildenburger wrote: MonkeeSage wrote: Wijaya Edward wrote: I wonder how can that be done in Python. def myfunc(plain_var, hash_ref, arref): # Do sth with those variables return At the risk of being a jerk (sorry, I'm really just curious): Why isn't that obvious? wildemar (sorry) I wondered that too and wasn't even going to answer, but then I thought mabye the question was meant to be more general, like what is the syntax for passing objects to functions in python? Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto pass Array/Hash into Function
At Tuesday 3/10/2006 06:05, Wijaya Edward wrote: How can I pass Array, Hash, and a plain variable in to a function at the same time. I come from Perl. Where as you probably know it is done like this: sub myfunc { my ($plain_var, $hash_ref,$arref) = @_; # Do sth with those variables return; } In Python your functions have formal arguments: def myfunc(plain_var, some_dict, some_list): # ... return You also have positional and keyword arguments, and default values. Read the Python tutorial http://www.python.org/doc/current/tut/tut.html Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI - mod_python
[EMAIL PROTECTED] wrote: it is a kind of nooby question. Is there a way to transfer a CGI python script to mod_python without rewriting the code? Had you used WebStack [1] to begin with, this migration would involve changing a few lines of glue code. However, as others have pointed out, WSGI may be an appropriate API to target for a modest rewrite of the code, given substantial resemblances to aspects of the CGI API. Paul [1] http://www.python.org/pypi/WebStack -- http://mail.python.org/mailman/listinfo/python-list
Re: app with standalone gui and web interface
What would the simplest way to make an application that has both a web interface and runs from behind a web server but also can be used as a standalone app with a gui? More precisely is it possible to avoid creating an html/xml/whatever based web interface for the web version and separately creating a gui (wxpython for example) for the standalone version and instead create a graphical frontend at once that can be used for both? I was experimenting with something roughly similar a couple of years ago. You might find it interesting. What I did may or may not work in your case. It depends on what you want to be able to do in the application. I built an application that consisted of some server side Java/JSPs that gave out XML. I used two stylesheets to transform the data into either HTML (for the web version) or another XML-format called wxWML (for the wxPython version). Desktop users accessed the application via a custom webbrowser that translates the wxWML to wxPython code which is executed to generate the GUI. This way, anyone with the wxBrowser installed could access the application as if it was a desktop app. But you should know that this was an experiment. We ended up not using it because it felt weird and because there was not much extra gain to be had from the desktop part. You should also know that the wxBrowser is a HUGE security hole which is a good reason not to use it. You can still download the code I wrote and a tutorial PDF from http://www.pulp.se/wx/ but I haven't touched it since last summer so I'm not sure it works with the latest version of wxPython. Also, I just noted that the example URL that I point to on that page doesn't work because I've moved my hosting since then, but that can be fixed. Thanks for the suggestions, I'll look into both methods. Having a local webserver seems pretty easy and convenient. Johan, your way of doing it resembles XUL somewhat, although I can't say I fully understand XUL I just took a look some days ago. Let me see if I understand your approach: If you want to have something very dynamical you do it the way you described with the wxwml source getting parsed, converted to wxpython and then run by python all at once. At the same time the webserver can fetch the same wxwml source, convert it into html/xml and send that to the web client. Now if one wants to bypass wxbrowser and the real time conversion to wxpython, then, sacrificing some level of dynamicness, why not convert the wxwml source 'statically' into wxpython, bundle that as an app and at the same time convert it also to xml/html 'statically' and have that served by a webserver. In this way any time the gui changes one needs to go through both convertions once, bundle the desktop app again, update the webserver but there won't be any security whole or any magic that is not pure python or not pure html/xml. Does this sound reasonable or am I misunderstanding something? In fact something like that is the thing I'm looking for, some language that can specify a gui and can be used to generate 'statically' both wxpython source (or some other widget set) or html/xml source. -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI - mod_python
In article [EMAIL PROTECTED], Paul Boddie wrote: it is a kind of nooby question. Is there a way to transfer a CGI python script to mod_python without rewriting the code? Had you used WebStack [1] to begin with, this migration would involve changing a few lines of glue code. Or Jonpy ;-) http://jonpy.sf.net/ -- http://mail.python.org/mailman/listinfo/python-list
Artificial Mind - Part One - Basic Architecture and Cognitive Structure is now available
It's a dream of human beings to build machines that can think and behave like human beings. The most important part of of such a machine is an artificial mind that can emulate the cognitive processing of human mind. This book, Next Generation Artificial Intelligence, Artificial Mind - Part One - Basic Architecture and Cognitive Structure introduces a basic artificial mind architecture and computational model for cognitive processing. Inside the book, three important cognitive process modeling components, mental objects network (MON), associative-learning mechanisms and a concept formation principle are introduced. Based on the architecture and the computational model, one can develop his own model of artificial mind according to his own specific requirements. The first edition of Artificial Mind - Part One is now available for purchase from the author's personal web site. The price of the e-book is USD7.00 (seven US dollars). An evaluation edition of this e-book is also available for download from the web site. The author's personal web site: http://www.geocities.com/tomwingmak/ -- http://mail.python.org/mailman/listinfo/python-list
Raw strings and escaping
Hi, I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. ..although writing this I think I have solved my own problem. Is \' the only thing escaped in a raw string so you can place ' in a raw string? Although I thought the correct thing in that case would be; rawstring=rrawstring'with single-quote This email is confidential and may be privileged. If you are not the intended recipient please notify the sender immediately and delete the email from your computer. You should not copy the email, use it for any purpose or disclose its contents to any other person. Please note that any views or opinions presented in this email may be personal to the author and do not necessarily represent the views or opinions of Digica. It is the responsibility of the recipient to check this email for the presence of viruses. Digica accepts no liability for any damage caused by any virus transmitted by this email. UK: Phoenix House, Colliers Way, Nottingham, NG8 6AT UK Reception Tel: + 44 (0) 115 977 1177 Support Centre: 0845 607 7070 Fax: + 44 (0) 115 977 7000 http://www.digica.com SOUTH AFRICA: Building 3, Parc du Cap, Mispel Road, Bellville, 7535, South Africa Tel: + 27 (0) 21 957 4900 Fax: + 27 (0) 21 948 3135 http://www.digica.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Paul Rubin wrote: Giovanni Bajo [EMAIL PROTECTED] writes: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? Sounds crazy, what's wrong with bugzilla? Much the same as is wrong with the existing SourceForge system, I'd say. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Best way to handle large lists?
I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] Thanks. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
Matthew Warren wrote in news:mailman.1152.1159872720.10491.python- [EMAIL PROTECTED] in comp.lang.python: I would expect this to work, rawstring=r'some things\new things\some other things\' It in the docs: url:http://docs.python.org/ref/strings.html#l2h-14 ... Specifically, a raw string cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the string, not as a line continuation. Rob. -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
Matthew Warren [EMAIL PROTECTED] wrote: I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. ..although writing this I think I have solved my own problem. Is \' the only thing escaped in a raw string so you can place ' in a raw string? Although I thought the correct thing in that case would be; rawstring=rrawstring'with single-quote You cannot end *any* string literal with an odd number of backslash characters. The r prefix changes how the escape sequences are interpreted after the string literal has been parsed, it doesn't change how the literal itself is actually parsed. See the Python Reference Manual, 2.4.1: When an r or R prefix is present, a character following a backslash is included in the string without change, and all backslashes are left in the string. For example, the string literal r\n consists of two characters: a backslash and a lowercase n. String quotes can be escaped with a backslash, but the backslash remains in the string; for example, r\ is a valid string literal consisting of two characters: a backslash and a double quote; r\ is not a valid string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw string cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the string, not as a line continuation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Chaz Ginger [EMAIL PROTECTED] wrote: I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] How about: smallSet = set(smallList) something = [ i for i in bigList if i not in smallSet ] Use timeit.py on some representative data to see what difference that makes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Chaz Ginger [EMAIL PROTECTED] writes: I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] diff = list(set(bigList) - set(smallList)) Note that doesn't get you the elements in any particular order. -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
In article [EMAIL PROTECTED], Matthew Warren wrote: I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. String constants in Python are weird - raw strings doubly so. In a raw string, backslashes are not special - unless followed by a quote character, when they simultaneously escape the quote and also insert a literal backslash. I presume there was originally some reason for this bizarre behaviour - it'd be interesting to know what it is/was, if anyone knows? -- http://mail.python.org/mailman/listinfo/python-list
Re: app with standalone gui and web interface
Johan, your way of doing it resembles XUL somewhat, although I can't say I fully understand XUL I just took a look some days ago. Let me see if I understand your approach: Yes it's a lot like XUL, but there are some major differences. The most important one is that, at least back then, you had to use JavaScript. Also, XUL had (has) a much more limited set of widgets and you can't escape the surrounding Browser. If you want to have something very dynamical you do it the way you described with the wxwml source getting parsed, converted to wxpython and then run by python all at once. At the same time the webserver can fetch the same wxwml source, convert it into html/xml and send that to the web client. Now if one wants to bypass wxbrowser and the real time conversion to wxpython, then, sacrificing some level of dynamicness, why not convert the wxwml source 'statically' into wxpython, bundle that as an app and at the same time convert it also to xml/html 'statically' and have that served by a webserver. In this way any time the gui changes one needs to go through both convertions once, bundle the desktop app again, update the webserver but there won't be any security whole or any magic that is not pure python or not pure html/xml. Does this sound reasonable or am I misunderstanding something? In fact something like that is the thing I'm looking for, some language that can specify a gui and can be used to generate 'statically' both wxpython source (or some other widget set) or html/xml source. Ok, there are ways to do that... sort of. You could modify or extend the wxBrowser to do this but you should really have a look at extending XRC (have a look at XRCed which comes with wxPython if you don't know what it is). Even though it doesn't do *everything* you want it's a good place to start. An XRC-file is an XML-specification of a wx GUI which can be loaded by a wxApp to generate a static GUI. However, if you want any sort of functionality to go with your program you're going to have to find a way to also include the equivalent of HTML script-tags that you can hook into wx event-handlers. I don't think XRC has that. Also, last time I looked, XRC is very sensitive so if you do change the format here and there to include other stuff, make sure to remove it before you try to parse it in the wxApp (it complains otherwise, or at least it used to). The wxBrowser does all of this for you, but at run time, there's currently no way of packaging it all up in one big XML file that could be saved as wxPython source. But it's sure doable. I don't know which is easier but either way, I'm guessing that you're going to have to write some code of your own. If you decide to extend/modify the wxBrowser, let me know, I might be able to help you out. BR Johan Lindberg [EMAIL PROTECTED] PS You should also ask around at the wxPython-users list (http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/wxPython-users). -- http://mail.python.org/mailman/listinfo/python-list
Re: app with standalone gui and web interface
I agree with Steve and I would advise to use an Ajax toolkit (such as JQuery for example) which will help to make your UI act as a desktop application (and even better if you are creative). Olive. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Giovanni Bajo wrote: Does this smell Bitkeeper fiasco to anyone else than me? I can't understand why people waste time arguing this stuff. Use whatever tool is best at it's job... if it's not written in Python it doesn't mean that Python is not good for the task, only that there hasn't been any Python programmer that applied himself to the problem hard enough. And i dunno what the case against Trac is (it looks a fine tool for my small projects) but probably it's not good enough for python.org And BTW BitKeeper failed because Linus wanted to stop Tridge reverse engineering BitKeeper, not because BK wasn't good. Lorenzo -- http://mail.python.org/mailman/listinfo/python-list
py2app console
Hello, Does anyone know of the most straightforward way to get rid of the intensely annoying console window that py2app feels so compelled to create? On a related but less important note, why would anyone want that stupid window in the first place? James -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
Jon Ribbens [EMAIL PROTECTED] wrote: I presume there was originally some reason for this bizarre behaviour - it'd be interesting to know what it is/was, if anyone knows? See the FAQ for the explanation: http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-strings-end-with-a-backslash The idea is that if you use raw strings for regular expressions you can write things like: pattern = r'[\']' if the raw string simply ignored the backslash altogether it would be much harder to write regular expressions that contain both sorts of quotes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Chaz Ginger írta: I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] Thanks. Chaz Hi ! If you have big list, you can use dbm like databases. They are very quick. BSDDB, flashdb, etc. See SleepyCat, or see python help. In is very slow in large datasets, but bsddb is use hash values, so it is very quick. The SleepyCat database have many extras, you can set the cache size and many other parameters. Or if you don't like dbm style databases, you can use SQLite. Also quick, you can use SQL commands. A little slower than bsddb, but it is like SQL server. You can improve the speed with special parameters. dd -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Steve Holden [EMAIL PROTECTED] writes: Paul Rubin wrote: Giovanni Bajo [EMAIL PROTECTED] writes: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? Sounds crazy, what's wrong with bugzilla? Much the same as is wrong with the existing SourceForge system, I'd say. The existing SourceForge system runs on non-free software, which is a significant differentiator from Bugzilla. I would be greatly dismayed to see the PSF choosing to move critical Python development data into a non-free system. I hope this recommendation from the PSF infrastructure committee is rejected. -- \ There is no reason anyone would want a computer in their | `\ home. -- Ken Olson, president, chairman and founder of | _o__)Digital Equipment Corp., 1977 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Manipulate PDFs
Hi Everyone, am a developer using Zope and wanted to know if any of you have ever implemented a pdf generating/creating system using python? This just means mostly manipulating pdfs (create and/or edit) via web. If you guys have any suggestions or recommendations please post, thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Paul Rubin wrote: Giovanni Bajo [EMAIL PROTECTED] writes: Does this smell Bitkeeper fiasco to anyone else than me? I probably said as much before, possibly to the distaste of some individuals. Still, the BitKeeper story should serve as a reminder about relinquishing control of infrastructure to some seemingly benevolent third party with their own separate interests. It should especially be a reminder to those who deem Torvalds-style overt pragmatism to be virtuous in the face of supposedly ideological realism. Of course, there's presumably a huge gulf between the vendor in this case and the vendor in the BitKeeper case, especially with respect to draconian non-compete clauses and threats to sue one's own customers. However, it's certainly not some kind of heresy to at least question the wisdom of moving community resources and services around in such a way. After all, this situation has been brought about because of a dependence on a supposedly unreliable commercial third party. Sounds crazy, what's wrong with bugzilla? Well, Bugzilla is a bit of a monster. ;-) Seriously, having installed it, it seems like a relic of the early CGI period with a bunch of files that you're supposed to throw in a CGI directory before performing .htaccess surgery, which they admittedly do for you if you choose to trust that particular method of deployment. Contrast that with various other common Web applications which only put actual CGI programs within the CGI directory, making the whole deployment much cleaner and easier to troubleshoot/maintain, and you can see that there's a serious need for some repackaging work. Sure, there are scripts to help check dependencies, which meant a trip to CPAN (not as joyous as its advocates would have you believe), and there is a nice configuration system in Bugzilla's own Web interface which helps you finish the job off (providing you don't forget something in the 16 pages of settings), but there's always this nasty suspicion that something somewhere probably isn't configured properly. Finally, on the subject of the inner workings of Bugzilla, one is presented with the amusement of diving into Perl to fix stuff: something that not everyone is enthusiastic about. As for Bugzilla's interface, it is telling that some open source projects actually put a layer on top of Bugzilla in order to avoid the complexity of the search interface, although it must be said that recent versions don't seem to immediately throw up the page with 40 or so controls on it, just to search for a bug. That said, the fact that many open source projects continue to use Bugzilla would suggest that they're either not interested in or aware of alternatives (quite possible), or they're reasonably happy with it (also quite possible). Paul -- http://mail.python.org/mailman/listinfo/python-list
py_s60 HELP
Hello, I using py_s60 for calling from my program to phone,but I have one problem. When I want run py_s60 with python 2.4: FIRST ERROR: import telephone Traceback (most recent call last): File pyshell#2, line 1, in -toplevel- if e32.s60_version_info=(3,0): AttributeError: 'module' object has no attribute 's60_version_info' SECOND ERROR: import telephone Traceback (most recent call last): File pyshell#5, line 1, in -toplevel- import _telephone ImportError: No module named _telephone ...I was search everywhere for that module but I can't find it THANKS FOR HELP! -- http://mail.python.org/mailman/listinfo/python-list
was python implemented as a object oriented langage at the beginning ?
Hello,I heard a lot of people from the Ruby community claiming that Python, like Perl, was a scripting langagethat was changed aftewards to be object compatible, and that was making it not as good as Ruby, object-oriented from the begenning. Is that true ?Thanks for your answersBertrand -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto pass Array/Hash into Function
MonkeeSage wrote: Wildemar Wildenburger wrote: MonkeeSage wrote: Wijaya Edward wrote: I wonder how can that be done in Python. def myfunc(plain_var, hash_ref, arref): # Do sth with those variables return At the risk of being a jerk (sorry, I'm really just curious): Why isn't that obvious? wildemar (sorry) I wondered that too and wasn't even going to answer, but then I thought mabye the question was meant to be more general, like what is the syntax for passing objects to functions in python? It wouldn't be obvious to someone who learned Perl as their first programming language because Perl chose to ignore the otherwise almost universal convention that formal parameters determine the arguments that a function or procedure can be calles with. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Hi, On 10/3/06, Giovanni Bajo [EMAIL PROTECTED] wrote: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? No, this doesn't smell like the BK fiasco, it is just the decision to use a certain tool. But it is easy to change or influence this recommondation. Step up as an admin for Roundup. :) Best regards, Oliver -- Oliver Andrich [EMAIL PROTECTED] --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: py2app console
James Stroud wrote: Hello, Does anyone know of the most straightforward way to get rid of the intensely annoying console window that py2app feels so compelled to create? On a related but less important note, why would anyone want that stupid window in the first place? James I should mention that this is the ridiculously pointless Tcl shell created when deploying a TkAqua application with py2app. Surely there has to be a better place to practice one's Tcl programming than from the console window of a bundled application that would otherwise be fit for end-users--except for the stupid Tcl console that no one will bother to use but is just frickin' desktop clutter. ## This is not the stdout console of the shell terminal, etc. ## James -- http://mail.python.org/mailman/listinfo/python-list
Re: Overriding builtin getattr method
Hello Gabriel Genellina and Diez B. Roggisch, Thanks for sharing your opinions. I agree with Gabriel when he talks about the separation between the presentation and the DB level access and the drawbacks of introducing character manipulation. The problem that I am facing right now is that the presentation layer uses several different page rendering machines (about 12). Some of them use the escaping techniques that presents browser reserved characters to be unrunnable , we just some examples, so far so great. But the other presentation layer engines(about 9) used are basic (optimized for fast rendering) and do not use such filtering/encoding mechanisms. Since the amount of files that is used by the basic rendering machines are quite high, I am forced to fix the problem in a much lower level. I have found a work around for it...since the pages presented by the basic rendering machines knows about objects fetched from the DB and the type of request(which presentation engine to use) generated, I collect information about these in a struct. This struct also contains information about the level of encoding needed. I overrode __getattribute__ method (which is always called when one fetches an attribute of an object) in the base class and introduced encoding level in the class. The __getattribute__ then checks for the level of encoding needed depending on the infor from the struct and returns the encoded data to the presentation layer when needed. The business object or the functional layer is unaffected as the default value returned by the __getattribute__ is the unencoded data from the DB. Raja Diez B. Roggisch skrev: I have data stored in the database which has special characters like , etc. Case 1: Whenever I wanted to present the output to a browser I need to escape these special characters into the browser equivalent like lt; gt; etc.( for example by using the cgi module) Case 2: Whenever I wanted to present the output to some client other than a browser, I wanted to present the data as it is stored in the database. For doing this I thought of overriding the __builtin__.__getattr__ method. I am wondering if there is any other way of achieving this. I have loads of files that get the attribute values of objects stored in the database and I do not want to manually change the way of DB access in those files. I rather prefer a centralized way to achieve this. The centralized approach to this is certainly not achieved by overloading getattr alone - because even if it was possible to do so (which it isn't), the implementation needed a way to know when to use escaping or not. Which would be signaled by some means, e.g. a thread-local variable or even a global (shudder). This signal gets set in the code that decides that it wants the data escaped - or not. And thus the code looks like this: needs_escaping() work_with_objects() no_escaping_anymore() But that is fragile, think of work_with_objects() throwing an exception and the no_escaping_anymore() isn't called again. So the better approach is to gather the data as it is, and when you transform it to something that requires escaping, do it there. That means: the way to do it is to use one of the gazillion web templating systems that already do this escaping for you. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Artificial Mind - Part One - Basic Architecture and Cognitive Structure is now available
tommak wrote: It's a dream of human beings to build machines that can think and behave like human beings. The most important part of of such a machine is an artificial mind that can emulate the cognitive processing of human mind. This book, Next Generation Artificial Intelligence, Artificial Mind - Part One - Basic Architecture and Cognitive Structure introduces a basic artificial mind architecture and computational model for cognitive processing. Inside the book, three important cognitive process modeling components, mental objects network (MON), associative-learning mechanisms and a concept formation principle are introduced. Based on the architecture and the computational model, one can develop his own model of artificial mind according to his own specific requirements. The first edition of Artificial Mind - Part One is now available for purchase from the author's personal web site. The price of the e-book is USD7.00 (seven US dollars). An evaluation edition of this e-book is also available for download from the web site. The author's personal web site: http://www.geocities.com/tomwingmak/ I'm afraid you'll have to do a bit better than this feeble spam to persuade us that it wasn't written by the author of the work in question. regards Steve PS Python Web Programming is still available through all good bookstores ;) -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
Matthew Warren wrote: I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. raw string literals are parsed in exactly the same way as ordinary string literals; it's just the mapping from the string literal to the contents of the string object that differs. see the documentation for details. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: was python implemented as a object oriented langage at the beginning ?
Bertrand Ballis wrote: I heard a lot of people from the Ruby community claiming that Python, like Perl, was a scripting langage that was changed aftewards to be object compatible, and that was making it not as good as Ruby, object-oriented from the begenning. Is that true ? nope. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
[EMAIL PROTECTED] wrote: Giovanni Bajo wrote: Does this smell Bitkeeper fiasco to anyone else than me? I can't understand why people waste time arguing this stuff. Because people care about it, I guess. Use whatever tool is best at it's job... if it's not written in Python it doesn't mean that Python is not good for the task, only that there hasn't been any Python programmer that applied himself to the problem hard enough. And i dunno what the case against Trac is (it looks a fine tool for my small projects) but probably it's not good enough for python.org Perhaps, although I imagine that Trac would have a lot more uptake if it handled more than just Subversion repositories. I don't know whether Trac is monolithic or not, but there is a need for a wider range of modular tools operating in the following areas: * Web-based source code browsing and searching for many repository types; perhaps one per type, all providing a similar interface. Currently, there's ViewVC which does CVS and Subversion browsing (and limited searching), LXR which does CVS, Subversion and Git searching (with arguably more limited browsing), OpenGrok which seems to provide CVS, Subversion, RCS and SCCS browsing and searching. Perhaps ViewVC just needs more attention. * Issue tracking: a huge area in which Trac, Bugzilla, Roundup and a bunch of proprietary tools exist. * Documentation or content management: whilst arguably non-essential to the management of a software project, I can see the benefit of integrating documentation with the source code browser, especially. And it's convenient if providing a service to users as well as developers if things like downloadable files can be managed in a way that is compatible with the rest of the solution. * Mailing list management/administration, feeds, summaries, reports. I did briefly look at Trac to see whether I could hack in a WebStack backend, and I'd do the same for ViewVC if I had the time, mostly because such projects already duplicate a lot of effort just to permit the deployment of the software on incompatible server solutions. There's certainly a lot these solutions could learn from each other and from lesser known solutions. And BTW BitKeeper failed because Linus wanted to stop Tridge reverse engineering BitKeeper, not because BK wasn't good. That's a simplistic view of the situation. The BitKeeper vendor imposes a non-compete clause on its users, which is in itself pretty scandalous, and the various attempts to accomplish independent interoperability with the BitKeeper service led to its proprietor packing up his toys and going home. You might believe that having some opportunistic company narrowly define what you can and cannot do, despite a fairly loose relationship based on you just using their stuff in your workplace, to be acceptable as long as you get to use such nice stuff. Others, however, consider implications wider than whether something is technically good, including whether or not something brings with it all sorts of unacceptable restrictions on personal freedoms. Considered through such broader criteria, one can assert that BitKeeper certainly wasn't good at all. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
On Tue, 03 Oct 2006 08:19:10 GMT, Giovanni Bajo [EMAIL PROTECTED] wrote: ... using a non open source tracker (called JIRA - never heard before of course) for Python itself. Other projects do use it; see http://wiki.apache.org/general/ApacheJira for a partial list, and a link to the Apache Software Foundation's issue trackers. Does this smell Bitkeeper fiasco to anyone else than me? The committee did expect this recommendation to be controversial. :) --amk -- http://mail.python.org/mailman/listinfo/python-list
anyone make any non-wx python plugins for boa-constructor
I was looking at vpython and it would seem to be an easy thing to add to boa-constuctors classes but I am not sure if that is possible within the boa-constructor interface. Is it possible to do without combining it with wxwindows?? Is there any examples besides the simple one that comes with the software?? I haven't seen any in google. http://www.dexrow.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Ben Finney [EMAIL PROTECTED] writes: The existing SourceForge system runs on non-free software, which is a significant differentiator from Bugzilla. The SourceForge software, at least in some versions, is free software. See for example http://savannah.gnu.org for an instantiation, which may be a fork. I never followed the saga much. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Giovanni Bajo schrieb: I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the PSF infrastracture committee, after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell Bitkeeper fiasco to anyone else than me? It's significantly different from the Bitkeeper fiasco in two important ways: 1. Bitkeeper is a source revisioning system, so it is similar to CVS and Subversion. This project here is just the bug tracker, which is of lesser importance. If we move to a different one some day, a certain amount of data lossage might be acceptable (e.g. we now likely lose the history of status changes and file attachments on each report). An export of all data is high on the requirements list, as Fredrik points out. 2. None of these systems require a specialized client. A plain web browser will do. IIRC, non-availibility of the Bitkeeper client (or: re-engineering of the existing one) was what really caused the fiasco. The same fiasco is not possible for the bug tracker. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Ben Finney schrieb: I would be greatly dismayed to see the PSF choosing to move critical Python development data into a non-free system. Then volunteer to help operating the Roundup installation. It will become reality if there are enough volunteers to keep it running. I hope this recommendation from the PSF infrastructure committee is rejected. That is very very unlikely. Who would reject it, and why? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw strings and escaping
In article [EMAIL PROTECTED], Duncan Booth wrote: I presume there was originally some reason for this bizarre behaviour - it'd be interesting to know what it is/was, if anyone knows? See the FAQ for the explanation: http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-strings-end-with-a-backslash The idea is that if you use raw strings for regular expressions you can write things like: pattern = r'[\']' if the raw string simply ignored the backslash altogether it would be much harder to write regular expressions that contain both sorts of quotes. Well, hardly *much* harder: pattern = rfoo Personally, I think that raw strings behaving as they do is unexpected, unintuitive and unnecessary, but it's obviously too late to change it now anyway ;-) I think standard strings accepting backslash followed by an unexpected character is also a mistake, but again it's too late to fix now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Paul Rubin schrieb: Sounds crazy, what's wrong with bugzilla? Nobody offers to operate it: that's wrong. We put out a call for trackers, and nobody (niemand, nirgendwo) was willing to setup a bugzilla installation, work on an SF data import, and offered to operate this installation for the period of testing. In addition, people expressed deep dislike of Bugzilla in the early discussions. Some people just hate it, maybe more so than the SF tracker. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: was python implemented as a object oriented langage at the beginning ?
Bertrand Ballis wrote: I heard a lot of people from the Ruby community claiming that Python, like Perl, was a scripting langage that was changed aftewards to be object compatible, and that was making it not as good as Ruby, object-oriented from the begenning. Sounds like a bunch of hooey on both counts (alot of people claiming and python not OO). The python object system is closer to C++, ruby's is closer to SmallTalk; but they are both OO (i.e., everything is an object), and support all the OOP distinctives (i.e., encapsulation, abstraction, c) -- just because a language doesn't implement OO in the exact same way as another doesn't mean it isn't OO -- it just means it's a different language. Sounds like mabye you heard a few ruby zealots who didn't know what they were talking about. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: I need Cryptogrphy in Python please .
NicolasG wrote: Looking around for a Cryptography tool kit, the best recommendations I found about was for pyCrypto. I try to install it unsuccessfully in my windowsXP SP2 with python 2.4.3 and I get the following message : C:\Python24\pycrypto-2.0.1python setup.py build running build running build_py running build_ext error: The .NET Framework SDK needs to be installed before building extensions f or Python. I have installed .NET framework latest release. Unfortunately the pyCrypto project looks abandoned , I couldn't find an active mailing list and the last release are a couple of year old. Can some one guide me how to fix the problem above or point me to another Cyrptography library that I can use easily ? Thanks. I use pycrypto under *nix and Windows. Under windows, I compile it with VC++ 2003 without any problem. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: loop beats generator expr creating large dict!?
Does George's example raise the question: why do dictionaries not implement efficient creation for two common cases? - Making a dict from two sequences of the same length. - Making a dict from a sequence and a function (as in George's example in this thread). The current situation is: use a loop because the obvious generator approach is not efficient. Something seems wrong here... Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
excepthook doesn't give exact line number
Hi, I'm wondering if anyone can please help me on figuring out a better way of doing an excepthook. I have a script which is using an excepthook to catch any uncaught exceptions - there usually aren't any except when I am messing with the code, like right now :-) The problem is that the excepthook gives the line of the topmost called function rather that the actual line that generated the error the way you get it with a normal traceback. import sys, traceback def myexcepthook(type,value,tb): do something exception_message = ( \nLine no %s: %s - %s\n \nStack Trace:\n\n%s\n % (tb.tb_lineno,type,value,str(traceback.print_exc(2))) ) send me an email etc sys.excepthook = myexcepthook now do some work So the tb object that is passed into the function gives the tb.tb_lineno as a line right near the end where the original topmost called function happens. This is a bit useless to me since I don't want to go looking for the exception manually through the entire code. As you can see from my example, I have already used the traceback module which I usually use to give the normal traceback printout via traceback.print_exc(). Here it doesn't seem to work, it always give None, likely because the excepthook has taken it or something. Any guiding wisdom from the masters out there? Much appreciated, thanks for reading. -h -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: loop beats generator expr creating large dict!?
David Isaac wrote: The current situation is: use a loop because the obvious generator approach is not efficient. not efficient compared to what ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How Build VTK for Python 2.5 under Windows?
I've install MS Visual C++ toolkit 2003 and cmake but I don't really know how it work. there's somebody who can compile VTK for python 2.5 under windows for me ? thank you (And sorry for my english, I'm French) Seb Sébastien Ramage wrote: Hello, I'm running on Windows and I want to test VTK but I don't understand how build it Somebody can help me to build VTK for Python 2.5 under Windows? (or Python 2.43 if python 2.5 is a problem) I have no C compiler but I can install one if it's free. Thank you Seb -- http://mail.python.org/mailman/listinfo/python-list
Python components
Hello group!We know that Python have many components not too knowledge.I think that I'm looking for one of them.I need embed a good document editor ( as Word or Writer ) in my small python application, for document editing. It's to lawyers make important documents and control them using the application, that's the reason why need be a good editor (edit tables, border, paragraphs etc).I had though about anything that embed the Microsoft word/Open Office Writer in application, but now i think kinda impossible. So, maybe exist some component for a rich editing documents.Do anyone know any?I'm using pyGTK, but dont care if it use any other grafic tool.ThanksJorge -- http://mail.python.org/mailman/listinfo/python-list
Re: Manipulate PDFs
On 10/3/06, Weko Altamirano [EMAIL PROTECTED] wrote: Hi Everyone, am a developer using Zope and wanted to know if any of you have ever implemented a pdf generating/creating system using python? This just means mostly manipulating pdfs (create and/or edit) via web. If you guys have any suggestions or recommendations please post, thanks. Does ReportLab do the trick for you? -- Cheers, Simon B, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Operator += works once, fails if called again
John Machin wrote: Frederic Rentsch wrote: Hi all, I have a class Time_Series derived from list. It lists days and contains a dictionary of various Lists also derived from list which contain values related to said days. (e.g. Stock quotes, volumes traded, etc.) I defined an operator += which works just fine, but only once. If I repeat the operation, it fails and leaves me utterly mystified and crushed. Craving to be uncrushed by a superior intelligence. Frederic --- A test: [perfection snipped] Perfect! TS1 += TS2# Second call Traceback (most recent call last): File pyshell#311, line 1, in -toplevel- TS += TS2 File c:\i\sony\fre\src\python\TIME_SERIES_7.py, line 1314, in __iadd__ return self.__add__ (other) File c:\i\sony\fre\src\python\TIME_SERIES_7.py, line 1273, in __add__ Sum = copy.deepcopy (self) File C:\PYTHON24\lib\copy.py, line 188, in deepcopy y = _reconstruct(x, rv, 1, memo) File C:\PYTHON24\lib\copy.py, line 335, in _reconstruct state = deepcopy(state, memo) File C:\PYTHON24\lib\copy.py, line 161, in deepcopy y = copier(x, memo) File C:\PYTHON24\lib\copy.py, line 252, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File C:\PYTHON24\lib\copy.py, line 161, in deepcopy y = copier(x, memo) File C:\PYTHON24\lib\copy.py, line 252, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File C:\PYTHON24\lib\copy.py, line 188, in deepcopy y = _reconstruct(x, rv, 1, memo) File C:\PYTHON24\lib\copy.py, line 335, in _reconstruct state = deepcopy(state, memo) File C:\PYTHON24\lib\copy.py, line 161, in deepcopy y = copier(x, memo) File C:\PYTHON24\lib\copy.py, line 252, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File C:\PYTHON24\lib\copy.py, line 188, in deepcopy y = _reconstruct(x, rv, 1, memo) File C:\PYTHON24\lib\copy.py, line 320, in _reconstruct y = callable(*args) File C:\PYTHON24\lib\copy_reg.py, line 92, in __newobj__ Oho! What's it doing there, in copy_reg.py? Something has stashed away a reference to copy_reg.__newobj__, and the stasher is *not* the copy module return cls.__new__(cls, *args) TypeError: instancemethod expected at least 2 arguments, got 0 From a quick browse through the code for copy.py and copy_reg.py [Isn't open source a wonderful thing?], I'm guessing: (1) The cls is *your* class. You can confirm that with a debugger (or by hacking in a print statement!). (2) You may need to read this in the copy docs: Classes can use the same interfaces to control copying that they use to control pickling. See the description of module pickle for information on these methods. The copy module does not use the copy_reg registration module. (3) You may need to read this in the pickle docs: New-style types can provide a __getnewargs__() method that is used for protocol 2. Implementing this method is needed if the type establishes some internal invariants when the instance is created, or if the memory allocation is affected by the values passed to the __new__() method for the type (as it is for tuples and strings). Instances of a new-style type C are created using obj = C.__new__(C, *args) where args is the result of calling __getnewargs__() on the original object; if there is no __getnewargs__(), an empty tuple is assumed. (4) You may need to debug your pickling/unpickling before you debug your deepcopying. (5) Look at function _copy_inst at line 134 in copy.py -- work out what it will do with your class instance, depending on what __magic__ method(s) you have implemented. Hope some of this helps, John John, Thank you very much for your suggestions. I followed them one by one and in the end found the cause of the problem to be a circular reference. Some species of contained Lists need a reference to the containing Time_Series and that circular reference trips up deepcopy. Supposedly I can define my own __deepcopy__, but didn't understand whose method it is supposed to be. Time_Series.__deepcopy__ () doesn't make sens, nor does it work. Time_Series should be the argument of the method not the owner. Anyway, I managed without deepcopy making a new instance and loading it as I would, if it were the first one. Thanks again Frederic -- http://mail.python.org/mailman/listinfo/python-list
Newbie question: python doesn't search the cwd for my module
Hello AllI want to import a module I wrote to use it in a script. But, it is not in the same directory as the script I want to import it into. So my solution is to put the following piece of code in the script:import osos.chdir(the direcotry where the module is kept)import the moduleThis generates an error: 'ImportError: no module named the module'If I do the exact same code in interactive mode, using ipython it works fine, but when I try it in a script I get the error. I've even used os.listdir() after changing the directory to confirm that the module is in the cwd (and it is).Where am I going wrong?(I use windows XP, and enthought edition python2.4)ThanksIzak Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail.-- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
I don't know enough about Python internals, but the suggested solutions all seem to involve scanning bigList. Can this presumably linear operation be avoided by using dict or similar to find all occurrences of smallist items in biglist and then deleting those occurrences? Bill Williams In article [EMAIL PROTECTED], Chaz Ginger [EMAIL PROTECTED] wrote: I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] Thanks. Chaz -- http://mail.python.org/mailman/listinfo/python-list
RE: Howto pass Array/Hash into Function
Thanks for your understanding Steve. Furthermore, my related concern is how does Python actually deal with 'reference' in Perl. But now, it is clear to me now that Python simply treats them as object. Regards, Edward WIJAYA SINGAPORE From: [EMAIL PROTECTED] on behalf of Steve Holden Sent: Tue 10/3/2006 8:08 PM To: python-list@python.org Subject: Re: Howto pass Array/Hash into Function It wouldn't be obvious to someone who learned Perl as their first programming language because Perl chose to ignore the otherwise almost universal convention that formal parameters determine the arguments that a function or procedure can be calles with. regards Steve Institute For Infocomm Research - Disclaimer - This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
I don't know much about the python internals either, so this may be the blind leading the blind, but aren't dicts much slower to work with than lists and therefore wouldn't your suggestion to use dicts be much slower? I think it's something to do with the comparative overhead of using keys in dicts rather than using positional indexes in lists/arrays... At least that is what I thought. Can anyone confirm this? -h Hari Sekhon Bill Williams wrote: I don't know enough about Python internals, but the suggested solutions all seem to involve scanning bigList. Can this presumably linear operation be avoided by using dict or similar to find all occurrences of smallist items in biglist and then deleting those occurrences? Bill Williams In article [EMAIL PROTECTED], Chaz Ginger [EMAIL PROTECTED] wrote: I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] Thanks. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: python doesn't search the cwd for my module
izak marais [EMAIL PROTECTED] writes: I want to import a module I wrote to use it in a script. But, it is not in the same directory as the script I want to import it into. I can think of two sensible solutions. One is to change the 'sys.path' list to include the directory where you want Python to look for your module. This has the advantage that it will work on all current versions of Python. It has the disadvantage that modules with the same name in different directories are not easy to differentiate. import sys sys.path.append(/path/to/the/directory) import spam The other way is to use absolute imports to be specific about where the module should be imported from. This has the advantage that at most one module will match the requested name for a given import. It has the disadvantage of being a fairly new feature, introduced in Python 2.5. from __future__ import absolute_import from ...path.to.the.directory import spam See here for more information on absolute imports: URL:http://docs.python.org/whatsnew/pep-328.html URL:http://www.python.org/peps/pep-0328.html -- \ I believe in making the world safe for our children, but not | `\our children's children, because I don't think children should | _o__) be having sex. -- Jack Handey | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Ctypes and freeing memory
On 10/3/06, Oliver Andrich [EMAIL PROTECTED] wrote: Hi everybody, I am currently playing around with ctypes and a C library (libWand from ImageMagick), and as I want to easily deploy it on Mac, Linux and Windows, I prefer a ctypes solution over a C module. At least on windows, I would have resource problems to compile the C module. So, ctypes is the perfect choice for me. But I am currently encountering a pattern inside the C library, that has to be used to free memory. Coding in C I have to do the following char *description; long severity; description = MagickGetException(wand, severity); /* do something with the description: print it, log it, ... */ description = (char *) MagickRelinquishMemory(description); exit(-1); /* or something else what I want to after an exception occured */ So, this looks easy and is sensible from C's point of view. Now I try to translate this to Python and ctypes. dll.MagickGetException.argtypes = [c_long, POINTER(c_long)] dll.MagickGetException.restype = c_char_p severity = c_long() description = dll.MagickGetException(byref(severity)) # So far so good. The above works like a charm, but the problem follows now # ctypes already converted the char * for description to a String object. # That means description has arrived in an area under Python's control. # these definitions are the easy part dll.MagickRelinquishMemory.argtypes = [c_void_p] dll.MagickRelinquishMemory.restype = c_char_p # but this obviously must cause problems and causes problems dll.MagickRelinquishMemory(description) So, my question is, how do I deal with this situation? Can I ignore the call to MagickRelinquishMemory, cause Python takes care of the resources already? Or is it impossible to use it at all, and I have to think about a different solution? Not a ctypes expert but I can pretty much guaranteee that Python won't correctly release that memory by itself. Are you sure that description is actually a string object? By my recollection it should be a c_char_p object, and if you pass it to MagickRelinquishMemory ctypes should do the right thing. If it doesn't, then you can use a more literal translation of the C code, and use a c_void_p instead, using ctypes.string_at(description) to get a string out of the buffer. Best regards, Oliver -- Oliver Andrich [EMAIL PROTECTED] --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Instantiating an object when the type is only known at runtime
Hi, I am trying to replace the eval() in the following code: def myfunc(type, table): module = __import__(type) type = 'module' + '.' + type obj = eval(type) return obj(row[table.c.name], row[table.c.handle]) I am out of ideas. Any hints? Thanks, -Samuel -- http://mail.python.org/mailman/listinfo/python-list
Re: Making sure script only runs once instance at a time.
MonkeeSage wrote: Eric S. Johansson wrote: the problem with this solution is that it does not handle the read nonexclusive/write exclusive locking model. In this model, reads don't block, they only register that the request is in process. writes lock request block until all outstanding reads have completed. When there is a write lock waiting, all subsequent reads lock requests block until the write has completed. I should have said lock file -- I'm not trying to do file locking for concurrent access to a file; I'm trying to provide a lock file to determine if an instance of a process is already spawned. That difference was clear to me and I appreciate your comment clarifying the issue further. I was trying to point out how there are more models of locking that we could use in Python than the single point lock as you had described. Unfortunately, most system locks are hard to get right and difficult to test so you're never quite sure until something breaks and then you know you did it wrong. I really should grab the code you pasted and use it as a rewrite for portalocker. Someday. sigh --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Bill Williams enlightened us with: I don't know enough about Python internals, but the suggested solutions all seem to involve scanning bigList. Can this presumably linear operation be avoided by using dict or similar to find all occurrences of smallist items in biglist and then deleting those occurrences? And how would that beat O(n)? Every element of bigList has to be scanned at one point, either to compare it to every earlier element in bigList and eliminate it, or to compare it to every element in smallList. Run benchmarks on the suggestions, and see which is fastest for yourself. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list