Re: multiple inheritance of a dynamic list of classes?
[EMAIL PROTECTED] wrote: Thanks both for suggestions. I still think that using inheritance is somehow cleanest in this case (I always hear the mantra avoid multiple inheritance!, but this is one of the cases it seems to make a lot of sense to me), but it's nice food for thought/code anyway. Avoid inheritance would be almost as justified :-) Problems that may arise with this case of multiple inheritance: - If you need initializers, ensure that they are all invoked - What would you do about name clashes? To avoid them your plugins need to know about each other. - State (instance attributes) is shared among all your plugins. Since you call all base classes Commands, Python's double-underscore hack won't work. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5
[EMAIL PROTECTED] wrote: On Feb 11, 4:24 am, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 11, 1:35?am, Steve Holden [EMAIL PROTECTED] wrote: [...] By the way, on the sci.math newsgroup I promote Python every chance I get. One fellow thanked me profusely for recommending Python GMPY and asked for some help with a program he was having problems with. We worked it out fine but his problem made me suspect there may be more bugs in GMPY. What's my motivation for tracking them down? The satisfaction of a job well done? What's my motivation for acting as a director of the Python Software Foundation when I get accusations of irresponsibility? I apologize. But I hope you see how this appears from the outside, that the PSF doesn't give a rat's ass about Windows users with AOL addresses. Sure, that's wrong, but calling people who bring up these points whiny leeches doesn't do anything to dispell that notion. The AOL address is nothing to do with it. Accusations of whiny leeching tend to be made at people whose attitudes aren't constructive and who express their complaints in ways that seem to imply an expectation of some kind of right to dictate to open source developers. Anyway, thanks for taking the time to help maintain gmpy. Thanks, I try to help as much as I can. I'm a little sensitive about gmpy because without it, I would have to abandon Python and I don't want to abandon Python. This thread is starting to make me think that there's a case to be made for somehow providing supported build facilities for third-party extension modules. And the untouchables would greatly appreciate it. We're all Python users. There are no untouchables. But in the open source world you tend to have to take ownership of the problems that are important to you. Since you say you couldn't get the attention of gmpy's developers you might need to think about trying to join the team ... This wouldn't be a simple project, but since there's a Windows buildbot for Python there's no reason why the same couldn't be done for extensions. I'll raise this with the PSF and see what the response is: then your carping will at least have had some positive effect ;-) Stick with it, and let's try to make things better. Ok. On a point of information, as it happens there's a Board meeting today and I have tabled the topic for discussion. Unfortunately I can't guarantee to attend the meeting (I am moving from the UK to the USA this week) but I will try to do so, and will attempt to report back to c.l.py within a week. regards Steve PS: Couldn't send this yesterday, or attend the meeting, because BT Internet termined my DSL service early, mau God rot their profits and drive them into bankruptcy. I'll report back once I found out how the discussions went. -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: Testers please
martien friedeman wrote: I have written this tool that allows you to look at runtime data and code at the same time. And now I need people to test it. The easiest way to see what I mean is to look at some videos: http://codeinvestigator.googlepages.com/codeinvestigator_videos It requires Apache and Sqlite. It works for me with a Firefox browser on Linux. Great idea ! Especially for newbies, so you've to make sure it's always in the first starters package. As most modern code-editors, already support context sensitive popup's, can't you make a module that can be added to any editor ? a few other suggestions - for large datasets, display only the corner values - for loops, also only display the corner values - to decrease datasize enormuous, limit the functionality to a piece of code selected by the user - get rid of Apache and SQLite, too complicated for newbies keep on the good work, cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
Grant Edwards kirjoitti: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. Just let the registered .PDF viewer do it for you. os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system() That doesn't work either: $ ls -l user.pdf -rw--- 1 grante users 35640 2005-11-21 14:33 user.pdf $ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type help, copyright, credits or license for more information. import os os.system('user.pdf') sh: user.pdf: command not found 32512 Works fine on my system. You linux guys just have it hard. The op said windows. The posting to which you replied specified Linux. I can't answer for ubuntu linux but maybe you can help there? I don't see how. Pdf files just aren't executable. On Windows, this (where fileName is xyz.PDF, for example): webbrowser.open(r'file://' + fileName) starts Acrobat Reader with the document read in. I have no idea why, because Acrobat Reader sure ain't my browser;) Maybe someone could try this out on Linux. Cheers, Jussi -- http://mail.python.org/mailman/listinfo/python-list
Templates for epydoc
Hello, I am looking for a good css template to be used with epydoc . Google did not help. Any links would be helpful. - Suresh -- http://mail.python.org/mailman/listinfo/python-list
hi all
I get an error while I try to call python through VB. The error is Error 429: Active X cant create object Pls anybody help me to call python through VB. Thanks and Regards. Sandeep Patil HCL Technologies Expecting the world to treat you fairly coz you are a gud person, is like expecting the Lion not to attack you as you are a Vegetarian. DISCLAIMER: --- The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any mail and attachments please check them for viruses and defect. - http://mail.python.org/mailman/listinfo/python-list
Re: WindowsNT user authentication
On 12 Feb, 16:53, Tim Golden [EMAIL PROTECTED] wrote: billie wrote: Do you got any idea about how getting user's home directory? The answer to that is unfortunately slightly complicated, because Windows has no such thing as a user's home directory or, if you prefer, it has several such things. If you want, you can let Python make the decision, by calling os.path.expanduser on ~ which, in my case, correctly gives h:\ which is my domain home directory. Obviously this is not necessarily the same as my Documents and Settings directory, which can also be considered a home directory. That you can get by querying the shell: code from win32com.shell import shell, shellcon idlist = shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_PERSONAL) documents_and_settings = shell.SHGetPathFromIDList (idlist) print documents_and_settings /code In my case they are the same but that will depend on your setup. I know in the past at least one of these has defaulted to c:\ Alternatives (which in my case amount to the same thing) include using the HOMEDRIVE / HOMEPATH / HOMESHARE environment vars: code import os drive = os.environ.get (HOMEDRIVE, ) path = os.environ.get (HOMEPATH, ) share = os.environ.get (HOMESHARE, ) print drive+path print share /code I haven't bothered to look, but I think this latter is how the expanduser function works things out. YMMV TJG Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: searching a list of lists as a two-dimensional array?
John Machin [EMAIL PROTECTED] wrote: Now for the algorithm: all of that testing to see if you are about to sail off the end of the world is a bit ugly and slow. You can use bit- bashing, as Paul suggested, even though it's on Steven D'Aprano's list of 6 deadly sins :-) Thou shallt not bit - bash What are the other five? - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter and Tile
Eric Brunel [EMAIL PROTECTED] wrote: FYI, changes done in tcl/tk are usually quite rapidly integrated in Tkinter. For example, for the panedwindow widget, introduced in tk8.4 (first version out in the end of 2002), a Tkinter wrapper was available in Python 2.3 (first version out mid-2003). So I don't doubt that the Tile extension package will be integrated in Tkinter, as soon as it is available in an official tcl/tk release. Do you imagine that the bizarre behaviour of ButtonRelease will be fixed too? - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Optimization of Python software: real-time audiocontroller
Jean-Paul Calderone [EMAIL PROTECTED] wrote: Yep. There are even some existing Python applications which deal with sound and manage to work with ~20ms samples. I agree. Python is not *that* slow... I have written serial port communications that send and catch one character at a time (raw, unbuffered i/o) - and they seem to work well at 38400 baud, sending and receiving almost four characters a millisecond, continuously, back to back, without any stress So to get there every twenty millis should not be a problem, unless the machine is a real dog. (i.e. older than seven years) Would not try to handle individual samples at 44 KiloHerz in python though... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: how to compare...
On Feb 13, 5:03 am, jairodsl [EMAIL PROTECTED] wrote: Hello everybody ! I have two list, they are, S1=['A','B','C','D','E'], and S2=['F','G','H','I','J'], but i have to compare both in this way: A vs J A vs I, B vs J A vs H, B vs I, C vs J A vs G, B vs H, C vs I, D vs J A vs F, B vs G, C vs H, D vs I, E vs J B vs F, C vs G, D vs H, E vs I C vs F, D vs G, E vs H D vs F, E vs G E vs F Could someone give me any idea how to compare(or print) both list in this way ??? Thanks a lot !!! jDSL def interleave( X, Y ): for i in range(1, len(Y)+1): yield zip(X, Y[-i:]) for j in range(1, len(X)): yield zip(X[j:], Y) x = ['A', 'B', 'C', 'D', 'E'] y = ['F', 'G', 'H', 'I', 'J'] for seq in interleave(x, y): print seq [('A', 'J')] [('A', 'I'), ('B', 'J')] [('A', 'H'), ('B', 'I'), ('C', 'J')] [('A', 'G'), ('B', 'H'), ('C', 'I'), ('D', 'J')] [('A', 'F'), ('B', 'G'), ('C', 'H'), ('D', 'I'), ('E', 'J')] [('B', 'F'), ('C', 'G'), ('D', 'H'), ('E', 'I')] [('C', 'F'), ('D', 'G'), ('E', 'H')] [('D', 'F'), ('E', 'G')] [('E', 'F')] Regards Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: searching a list of lists as a two-dimensional array?
On Feb 13, 4:57 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: John Machin [EMAIL PROTECTED] wrote: Now for the algorithm: all of that testing to see if you are about to sail off the end of the world is a bit ugly and slow. You can use bit- bashing, as Paul suggested, even though it's on Steven D'Aprano's list of 6 deadly sins :-) Thou shallt not bit - bash What are the other five? ... regexes have their place, together with pointer arithmetic, bit manipulations, reverse polish notation and goto. The problem is when people use them inappropriately ... The sixth is never mentioned. Aliter: I can't count. Believe whichever hypothesis you like :-) -- http://mail.python.org/mailman/listinfo/python-list
Announcing Elixir!
Today, we are pleased to announce the release of Elixir (http://elixir.ematia.de), a declarative mapper for SQLAlchemy. Elixir is the successor to ActiveMapper and TurboEntity, and is a collaboration between Daniel Haus, Jonathan LaCour and Gaëtan de Menten. Elixir's website provides installation instructions, a tutorial, extensive documentation, and more. The eventual goal of Elixir is to become an official SQLAlchemy extension after some time soliciting feedback, bug reports, and testing from users. Daniel Haus http://www.danielhaus.de Gaëtan de Menten http://openhex.com Jonathan LaCour http://cleverdevil.org -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance of a dynamic list of classes?
On 13 Feb, 09:14, Peter Otten [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Thanks both for suggestions. I still think that using inheritance is somehow cleanest in this case (I always hear the mantra avoid multiple inheritance!, but this is one of the cases it seems to make a lot of sense to me), but it's nice food for thought/code anyway. Avoid inheritance would be almost as justified :-) Why? Problems that may arise with this case of multiple inheritance: - If you need initializers, ensure that they are all invoked Yes, I figured it out. This should be easy in this case. - What would you do about name clashes? To avoid them your plugins need to know about each other. Yes, I know, but I can't see any simple solution to this (if you can, please share it with me!). The cmd module works by interpreting any method starting with do_ as a command, so do_blah becomes the blah command. If two people write a do_blah command, and both plugins are used, I see no easy way to solve the issue (apart rewriting a cmd module). Perhaps there can be some previous sanity check in each modules dict to see if there are obvious namespace clashings, and in this case issue a warning. I don't know. - State (instance attributes) is shared among all your plugins. Since you call all base classes Commands, Python's double-underscore hack won't work. What double-underscore hack are you referring to? (sigh, my python limits are all arising...) I can call all base classes PluginNameCommand, however, this wouldn't break the thing (I'm still at the very early planning stage) and would maybe work. m. -- http://mail.python.org/mailman/listinfo/python-list
Re: c++ for python programmers
On Feb 12, 7:00 pm, Thomas Nelson [EMAIL PROTECTED] wrote: I realize I'm approaching this backwards from the direction most people go, but does anyone know of a good c/c++ introduction for python programmers? I don't think there's any book catering specifically for people coming from dynamically typed languages. If you want a crash course try Accelerated C++, by Koenig Moo; if you want something more gentle, that may also serve as a reference, go for C++ Primer, by Lippman, Lajoie Moo. Both books from Addison Wesley. As for something freely available people speak well of Bruce Eckel's Thinking in C++, but I haven't read it: http://www.mindview.net/ Books/TICPP/ThinkingInCPP2e.html Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
On 12 fév, 15:59, Stef Mientki [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 9 fév, 14:06, Stef Mientki [EMAIL PROTECTED] wrote: will explain the rest Delphi is a (dying) proprietary, MS-Windows-only[1] software relying on a low-level language. Well it may be dying, but for the moment it beats Python with a factor of 10, when it comes to user (the majority of PC users) friendly GUI ;-) Would you mind explaining yourself and backing your above assertion ? Like, ie, on which points does Delphi beats Python wrt/ GUIs, what special magic would make so that GUIs designed with Delphi would be more user-friendly, and where does this factor 10 comes from ? Maybe I should have written it in quotes factor of 10 ;-) But here are a few points - in Delphi the GUI design itself is done in a graphical environment, Ever heard of Glade, wxGlade, QTDesigner etc ? Please stop confusing language, GUI Toolkit, and GUI Designer... making it much easier and faster making it much easier to get a quick prototype. Then, hacking the source may become *much* more easy and faster... (my experience with other windows clickodromes). - auto-scaling of components on a form is very easy (so if the user changes form size ..) And ? - even making everything on a form movable by the end-user is just 1 mouse-click I wouldn't like to make everything movable by the end-user... - using the designers style, or the user style is just 1 click - very good feedback, so creating interactive graphs is very easy, cross-hair, slopes, region of interest etc. - a very huge collection of controls is standard available - print / clipboard / export to almost any graphical file format, just 1 line of code but to be honest ... ... I never even tried to write a GUI in Python, ... Seems quite obvious. ... just looked at others examples, ... and still not seen what I can perform in Delphi ;-) IOW, you assert things just based on your experience with Delphi and your lack of experience with any of the major GUI toolkits availables from Python. To be true, I don't know if any of these toolkits (GTK, wxWindows, QT) and their GUIDesigners have the features you like in Delphi. What I know is that: 1/ these three toolkits have everything *needed* to write serious GUI apps 2/ they are all (more or less) portable 3/ the first two are free software 4/ they are all (more or less) language-independant So talking about GUIs, I think we're really far from a factor of 10. It may be possible that Delphi has a better GUI *designer* than some other GUI toolkits, but that's far from being a major concern as far a I'm concerned - I wouldn't choose my tools based only on this consideration. -- http://mail.python.org/mailman/listinfo/python-list
Re: Testers please
On Feb 13, 1:38 am, martien friedeman [EMAIL PROTECTED] wrote: I have written this tool that allows you to look at runtime data and code at the same time. And now I need people to test it. The easiest way to see what I mean is to look at some videos:http://codeinvestigator.googlepages.com/codeinvestigator_videos It requires Apache and Sqlite. It works for me with a Firefox browser on Linux. I'm absolutely stunned. This is a great idea, especially because we all hate learning other people's code, and this makes the process so much easier. Got some exams coming up this week, but I'll do some testing in the weekend. I'd like to suggest one thing though. When evaluating conditional statements, it would be very useful to see what else meant in terms of the statement itself, for example: if foo == 1: # Instead of showing true this would show foo == 1 elif foo == 2: # This would show foo == 2 else: # Instead of showing false. Here comes the tricky part. This should show the opposite of foo == 1, as well as the following elif statements. So in this case, the tab could show not (foo == 1) | (foo == 2). The reason for why showing the negated else in the header (looking for a better word, this refers to the header shown when you click something) would be helpful is because it helps keep track of what statements are being evaluated, since False gives no information on what statment is being tested and if the code is long, you have to scroll way up to take a look at the if statement, so it will help a lot with complex code. While this is not hard to implement (unless I'm missing something), the implementation has some problems, because conditional statements can become very long, the else statement's tab could show an exceptionally long statement whereas showing just False keeps it at a fair length. I might be missing something in this suggestion though - if so, please set me straight. At any rate, I think you've done a great job on this. When I get around to testing it this weekend I'll post the results on the project's SourceForge forums. Regards, Friðrik Már -- http://mail.python.org/mailman/listinfo/python-list
Re: favourite editor
A beta version of PyScripter with remote debugging is actually out. See http://pyscripter.googlepages.com/ and http:// pyscripter.googlepages.com/remotepythonengines for details. Ο/Η Stef Mientki έγραψε: azrael wrote: I expirienced some big craches. tra running some aplication vith using Vpython. when you close the vpython window, pyscripter also crashes. sometimes im writing some code and suddenly get about 300 error messages without running anything. I like pyscripter, but sometimes it drives me crazy did you read the help file: if you use a GUI platform (e.g. tknter, wxpython etc.). As the help file says under the topic known issues you should not run or debug such scripts internally. Instead use the Run, External Run command. and form the author of PyScripter jan-2007: I hope that such problems will be resolved when I release the remote debugging facility, which should happen quite soon. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Vim scripting with python
J. Clifford Dyer wrote: Stuart D. Gathman wrote: On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote: Does anyone have any advice, and more genraly how to script Vim with Python ? :py import sys :py print sys.version :help :py I know I can put some python functions inside my vimrc file like this : function! My_function() python EOF import vim, string ...blablabla EOF endfunction but I would like to use external .py files. :py import myfile Use :py inside your vimrc - don't run python externally. Which versions of vim is this valid for? I tried :py print 'Hello', and got E319: Sorry, the command is not available in this version It's valid for vim 5.0 and later (all official vim releases since March 1998). You have to make sure python support is enabled at build time with --enable-pythoninterp or other configure options that turn it on (check for +python in the output of :ver to see if a precompiled binary includes python support). -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
On Feb 13, 7:44 pm, Jussi Salmela [EMAIL PROTECTED] wrote: Grant Edwards kirjoitti: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. Just let the registered .PDF viewer do it for you. os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system() That doesn't work either: $ ls -l user.pdf -rw--- 1 grante users 35640 2005-11-21 14:33 user.pdf $ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type help, copyright, credits or license for more information. import os os.system('user.pdf') sh: user.pdf: command not found 32512 Works fine on my system. You linux guys just have it hard. The op said windows. The posting to which you replied specified Linux. I can't answer for ubuntu linux but maybe you can help there? I don't see how. Pdf files just aren't executable. On Windows, this (where fileName is xyz.PDF, for example): webbrowser.open(r'file://' + fileName) starts Acrobat Reader with the document read in. I have no idea why, because Acrobat Reader sure ain't my browser;) Maybe someone could try this out on Linux. Cheers, Jussi Works on Ubuntu -- this opens a tab in my browser and then launches Document Viewer to view the PDF. [EMAIL PROTECTED]:~$ python Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2 Type help, copyright, credits or license for more information. import webbrowser webbrowser.open(r'file:///home/peter/appa.pdf') -- http://mail.python.org/mailman/listinfo/python-list
Re: c++ for python programmers
On 2007-02-12, Thomas Nelson [EMAIL PROTECTED] wrote: I realize I'm approaching this backwards from the direction most people go, but does anyone know of a good c/c++ introduction for python programmers? To become productive in C++ in a short time, especially with a Python background, I highly recommend Koenig Moo _Accelerated C++_. It's not enough C++ to join a C++ team at a professional development house (of course no book can provide that), but it's all the best bits. If you get through that, then proceed directly to the source, Stroustrup _The C++ Programming language_. -- Neil Cerutti You only get a once-in-a-lifetime opportunity so many times. --Ike Taylor -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance of a dynamic list of classes?
[EMAIL PROTECTED] wrote: On 13 Feb, 09:14, Peter Otten [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Thanks both for suggestions. I still think that using inheritance is somehow cleanest in this case (I always hear the mantra avoid multiple inheritance!, but this is one of the cases it seems to make a lot of sense to me), but it's nice food for thought/code anyway. Avoid inheritance would be almost as justified :-) Why? Well, what problems ocurring with class A: pass class B: pass class C(A, B): pass could be avoided by writing class A: pass class B(A): pass class C(B): pass instead? Classes have to be designed for subclassing, so essentially you get two interfaces, one for subclasses and one for client code instead of just the latter. A more relevant mantra governing inheritance is Flat is better than nested. Problems that may arise with this case of multiple inheritance: - If you need initializers, ensure that they are all invoked Yes, I figured it out. This should be easy in this case. - What would you do about name clashes? To avoid them your plugins need to know about each other. Yes, I know, but I can't see any simple solution to this (if you can, please share it with me!). The cmd module works by interpreting any method starting with do_ as a command, so do_blah becomes the blah command. If two people write a do_blah command, and both plugins are used, I see no easy way to solve the issue (apart rewriting a cmd module). Perhaps there can be some previous sanity check in each modules dict to see if there are obvious namespace clashings, and in this case issue a warning. I don't know. - State (instance attributes) is shared among all your plugins. Since you call all base classes Commands, Python's double-underscore hack won't work. What double-underscore hack are you referring to? (sigh, my python limits are all arising...) I can call all base classes PluginNameCommand, however, this wouldn't break the thing (I'm still at the very early planning stage) and would maybe work. If you use attributes starting with two underscores inside a method, Python transparently prepends them with the class name. This allows to you to use the same variable name in two base classes and reduces coupling: class A: ... def set_a(self, v): self.__value = v ... class B: ... def set_b(self, v): self.__value = v ... class C(A, B): pass ... c = C() c.set_a(alpha); c.set_b(beta) vars(c) {'_A__value': 'alpha', '_B__value': 'beta'} But if two classes with the same name use the private variable, the mechanism fails: OldA = A class A: ... def set_b(self, v): self.__value = v ... class C(A, OldA): pass ... c = C() c.set_a(alpha); c.set_b(beta) vars(c) {'_A__value': 'beta'} Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: how to compare...
On Feb 13, 4:30 am, Gerard Flanagan [EMAIL PROTECTED] wrote: On Feb 13, 5:03 am, jairodsl [EMAIL PROTECTED] wrote: Hello everybody ! I have two list, they are, S1=['A','B','C','D','E'], and S2=['F','G','H','I','J'], but i have to compare both in this way: A vs J A vs I, B vs J A vs H, B vs I, C vs J A vs G, B vs H, C vs I, D vs J A vs F, B vs G, C vs H, D vs I, E vs J B vs F, C vs G, D vs H, E vs I C vs F, D vs G, E vs H D vs F, E vs G E vs F Could someone give me any idea how to compare(or print) both list in this way ??? Thanks a lot !!! jDSL def interleave( X, Y ): for i in range(1, len(Y)+1): yield zip(X, Y[-i:]) for j in range(1, len(X)): yield zip(X[j:], Y) x = ['A', 'B', 'C', 'D', 'E'] y = ['F', 'G', 'H', 'I', 'J'] for seq in interleave(x, y): print seq [('A', 'J')] [('A', 'I'), ('B', 'J')] [('A', 'H'), ('B', 'I'), ('C', 'J')] [('A', 'G'), ('B', 'H'), ('C', 'I'), ('D', 'J')] [('A', 'F'), ('B', 'G'), ('C', 'H'), ('D', 'I'), ('E', 'J')] [('B', 'F'), ('C', 'G'), ('D', 'H'), ('E', 'I')] [('C', 'F'), ('D', 'G'), ('E', 'H')] [('D', 'F'), ('E', 'G')] [('E', 'F')] Regards Gerard Thank you very much for all your answers. jDSL -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance of a dynamic list of classes?
On 2007-02-13, Peter Otten [EMAIL PROTECTED] wrote: Well, what problems ocurring with class A: pass class B: pass class C(A, B): pass could be avoided by writing class A: pass class B(A): pass class C(B): pass instead? With multiple inheritance, the choice of algorithm for Method Resolution Ordering isn't obvious or trivial. As I understand it, Python got it wrong for quite some time, allowing bad hierarchies to compile, i.e., classes for which the properties of local precedence ordering and monotonicity did not hold. URL:http://www.python.org/download/releases/2.3/mro/ -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: searching a list of lists as a two-dimensional array?
John Machin [EMAIL PROTECTED] wrote: On Feb 13, 4:57 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: John Machin [EMAIL PROTECTED] wrote: Now for the algorithm: all of that testing to see if you are about to sail off the end of the world is a bit ugly and slow. You can use bit- bashing, as Paul suggested, even though it's on Steven D'Aprano's list of 6 deadly sins :-) Thou shallt not bit - bash What are the other five? ... regexes have their place, together with pointer arithmetic, bit manipulations, reverse polish notation and goto. The problem is when people use them inappropriately ... I find this unsatisfactory - I was hoping for a five commandment style of thing, setting out proper prohibitions against evil stuff. It seems that I am a closet fundamentalist. A sixth, btw is: Thou shallt not use globals. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Download parts not whole file in ones
Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ---CODE--- import urllib # the heavy file to download f = urllib.urlopen(http://da.wikipedia.org/wiki/Wiki;) # This was supposed to print the file while it downloads while 1: print f.read(100) ---/CODE--- In my example it just download the whole file, and then print it. Any suggestions? Regards Andreas -- http://mail.python.org/mailman/listinfo/python-list
Regex highlight html
Hey, I want to write a function that highlights html code. I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions just like this: img scr=test.png alt=test pic height=100 width=100 a href=#test/a to this: img scr=test.png alt=test pic height=100 width=100 a href=#test/a Just example colors - not so pretty :) Any suggestions? Andreas -- http://mail.python.org/mailman/listinfo/python-list
Lazy container
Hi everyone, I'm trying to write a Container which should mimic a list. Basically, the container pulls items on the fly from an unspecified source through a function and returns an instance of a given class over the pulled item. That is: class lazy(object): def __getitem__(self,index): return Foo(f(index)) lc = lazy() Here I see a problem: two consecutive accesses to lc for the same index would retrieve two different instances of Foo. In some scenarios this is not desirable since one wants to have all the accessors to share the same instance for the same index so as to reduce memory consumption. So, I thought to use an internal dictionary of all the Foo instances given away so far. Something like: class lazy(object): def __init__(self): self.cache = {} def __getitem__(self,index): if not self.cache.has_key(index): value = Foo(f(index)) # MISS self.cache[index] = value else: # HIT value = self.cache[index] return value This is acceptable as it reduces the number of instances living in the system at any given time. The problem with this implementation is that the cache never decreases in length as Foo instances are no longer referenced by the lc accessor since they're all referenced by the internal cache. There are scenarios in which f() retrieves items from a very huge source (i.e. a database) and threads sharing the lazing container and consuming Foo instances to use them for a very short time and then discardi them: after a while you'll eventually end up having a whole copy of the source in memory, which is unacceptable. One solution may be to use gc.get_referrers() to search the cache for unused instances every time we have a cache miss so as to see if we could discard some instance before inserting the new one in the cache. But this comes at a cost. May be someone has faced this problem before and came up with some obscure language feature to solve this elegantly :D Thanks for your replies. Cristiano -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex highlight html
Hey, I want to write a function that highlights html code. I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions just like this: img scr="test.png" alt="test pic" height="100" width="100" a href=""test/a to this: img scr="test.png" alt="test pic" height="100" width="100" a href="#"test/a Just example colors - not so pretty :) Any suggestions? Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: favourite editor
I'm very happy with eclipse and its python module called pydev. It's a little slow because it parse continuously the code (P4 2.0Ghz required), but give nice realtime info by underlining syntax error or unknown variable (very very useful when miss spelling a variable or a function :-) On 11 fév, 05:41, azrael [EMAIL PROTECTED] wrote: Since i'm new on this forum, and first time meeting a python comunity, i wanted to ask you for your python editors. Im looking for some good python editor, with integrated run function, without having to set it up manualy like komodo. I found the pyscripter, and it has all i need, but it's unsatble. bloated. it crashes when i close an yplication window run by python from pyscripter. please. tell me a good one with buil in run (-very important) and nice gui. if possible to suport projects, code highlighting, code completition, class browser, python comand line (), traceback. I didn't take a look on vista (and i dont want to), but i hope they improved the notepad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lazy container
Cristiano Paris [EMAIL PROTECTED] wrote: May be someone has faced this problem before and came up with some obscure language feature to solve this elegantly :D Yes. Try using weak references. Specifically a weakref.WeakValueDictionary should meet your needs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lazy container
Duncan Booth wrote: ... Yes. Try using weak references. Specifically a weakref.WeakValueDictionary should meet your needs. :D Thank you. Cristiano -- http://mail.python.org/mailman/listinfo/python-list
Re: Lazy container
Cristiano Paris wrote: I'm trying to write a Container which should mimic a list. Basically, the container pulls items on the fly from an unspecified source through a function and returns an instance of a given class over the pulled item. That is: class lazy(object): def __getitem__(self,index): return Foo(f(index)) lc = lazy() Here I see a problem: two consecutive accesses to lc for the same index would retrieve two different instances of Foo. In some scenarios this is not desirable since one wants to have all the accessors to share the same instance for the same index so as to reduce memory consumption. So, I thought to use an internal dictionary of all the Foo instances given away so far. Something like: The problem with this implementation is that the cache never decreases in length as Foo instances are no longer referenced by the lc accessor since they're all referenced by the internal cache. You want a WeakValueDictionary: http://docs.python.org/lib/module-weakref.html Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: favourite editor
You could try SPE, but that's really unstable, and no help manual to read ;-) But, there is a tutorial on SPE here: www.serpia.org/spe regards, Dimitri -- --- You can't have everything. Where would you put it? -- Steven Wright --- please visit www.serpia.org -- http://mail.python.org/mailman/listinfo/python-list
float print formatting
Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Thanks, hg -- http://mail.python.org/mailman/listinfo/python-list
Re: Mulig SPAM: float print formatting
hg skrev: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Thanks, hg Try this: a = 45.45 # the floating number print some text, print a, print some text again or just this: print some text, print 45.45, print some text again Hope it helped :D Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
On 2007-02-13, hg [EMAIL PROTECTED] wrote: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Yes. How wide (total) is 0.00, compared to 00.00? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
Neil Cerutti wrote: On 2007-02-13, hg [EMAIL PROTECTED] wrote: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Yes. How wide (total) is 0.00, compared to 00.00? -- Neil Cerutti I do not get it s = '%02.02f' % 0.0 s '0.00' len(s) 4 -- http://mail.python.org/mailman/listinfo/python-list
Re: Mulig SPAM: float print formatting
NOSPAM plz wrote: hg skrev: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Thanks, hg Try this: a = 45.45 # the floating number print some text, print a, print some text again or just this: print some text, print 45.45, print some text again Hope it helped :D Andreas Sorry, must be very slow or not enough coffee yet ... my purpose is to display a justified report, so I format my floats into strings which I next draw in a bitmap. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
hg wrote: Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? The first integer specifies the total width: %05.2f % 0 '00.00' Peter -- http://mail.python.org/mailman/listinfo/python-list
Segmentation faults using threads
Dear ng, I use the thread module (not threading) for a client/server app where I distribute large amounts of pickled data over ssh tunnels. Now I get regular Segmentation Faults during high load episodes. I use a semaphore to have pickle/unpickle run nonthreaded, but I still get frequent nondeterministic segmentation faults. Since there is no traceback after a sf, I have no clue what exactly happened, and debugging a multithreaded app is no fun anyway :( Can someone recommend me how to get extra info during such a crash? Or any other opinion on where the problem might lie? Thanks a lot, Mathias -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
Stef Mientki wrote: [EMAIL PROTECTED] wrote: On 9 fév, 14:06, Stef Mientki [EMAIL PROTECTED] wrote: will explain the rest Delphi is a (dying) proprietary, MS-Windows-only[1] software relying on a low-level language. Well it may be dying, but for the moment it beats Python with a factor of 10, when it comes to user (the majority of PC users) friendly GUI ;-) Would you mind explaining yourself and backing your above assertion ? Like, ie, on which points does Delphi beats Python wrt/ GUIs, what special magic would make so that GUIs designed with Delphi would be more user-friendly, and where does this factor 10 comes from ? Maybe I should have written it in quotes factor of 10 ;-) But here are a few points - in Delphi the GUI design itself is done in a graphical environment, making it much easier and faster - auto-scaling of components on a form is very easy (so if the user changes form size ..) - even making everything on a form movable by the end-user is just 1 mouse-click - using the designers style, or the user style is just 1 click - very good feedback, so creating interactive graphs is very easy, cross-hair, slopes, region of interest etc. - a very huge collection of controls is standard available - print / clipboard / export to almost any graphical file format, just 1 line of code but to be honest ... ... I never even tried to write a GUI in Python, ... ... just looked at others examples, ... and still not seen what I can perform in Delphi ;-) cheers, Stef Mientki Good luck... There is dabo which is a tool on top of wxwidgets: http://dabodev.com/ Uwe -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
Peter Otten wrote: hg wrote: Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? The first integer specifies the total width: %05.2f % 0 '00.00' Peter Many thanks ! hg -- http://mail.python.org/mailman/listinfo/python-list
_ssl.pyd is buggy?
Hello, I wrote a small program that uses xmlrpc over https. It should work as a win32 application and as a win32 service too. There is a file called Processor.py that contains the main thread of the program. It is called from two files: win32_Application.py and win32_Service.py. The application works perfectly. The service does not. I can start it from the services mmc console, but it does not created logfiles, and does nothing. It cannot be stopped and I have to kill pythonservice.exe. The event log shows this: Information: The AmazonOfferDownloaderService service has started. Application error: Faulty application: python.exe, version: 0.0.0.0, faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87. Is it possible that my _ssl.pyd is faulty? Please help me. Python version: 2.4.3 (#69, Mar 29 2006) Windows version: Windows XP Professional, service pack 2, Hungarian (I translated the above messages from the event log) Thanks, Laszlo Here is the code for the application: import thread,threading,time from Processor import * from servicelog import * from win32_Config import * stopped = threading.Event() stopped.clear() processor = Processor(stopped) thread.start_new_thread(processor.Process,()) logger = getLogger('win32_Application') logger.info(Staring as application. Please press CTRL+C to stop service.) while 1: try: time.sleep(1) except: break logger.info(Stopping application + SERVICE_NAME) stopped.set() while not processor.stopped.isSet(): logger.debug(Waiting for the processor to finish...) time.sleep(1) logger.info(Application stopped.) Here is the code for the service: from win32_Config import * from Processor import * from servicelog import * import win32serviceutil, win32service import pywintypes, win32con, winerror from win32event import * from win32file import * from win32pipe import * from win32api import * from ntsecuritycon import * import traceback import thread,threading class Service(win32serviceutil.ServiceFramework): _svc_name_ = SERVICE_NAME _svc_display_name_ = SERVICE_DISPLAY def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.stopped = threading.Event() self.stopped.clear() self.logger = getLogger(SERVICE_NAME) def SvcStop(self): self.logger.info(Got SvcStop, trying to stop service...) self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.stopped.set() def SvcDoRun(self): Write an event log record - in debug mode we will also see this message printed. try: import servicemanager servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) self.logger.info(Started.) self.logger.debug(Creating processor instance) processor = Processor(self.stopped) self.logger.debug(Starting processor thread) thread.start_new_thread(processor.Process,()) self.logger.debug(Waiting for the processor thread to finish) self.stopped.wait() self.logger.debug(Stopping) time.sleep(1) while not processor.stopped.isSet(): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000) time.sleep(5) servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, ) ) self.logger.info(Stopped) except: self.logger.error('',exc_info = sys.exc_info()) if __name__=='__main__': win32serviceutil.HandleCommandLine(Service) -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
On Feb 12, 4:56 pm, Larry Bates [EMAIL PROTECTED] wrote: krishnakant Mane wrote: hello all, I am stuck with a strange requirement. I need a library that can help me display a pdf file as a report and also want a way to print the same pdf file in a platform independent way. if that's not possible then I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. the problem is that I want to display reports in my application. the user should be able to view the formatted report on screen and at his choice click the print button on the screen to send it to the printer. I have reportlab installed and that is sufficient to generate pdf reports. but I still can't fine the way to display it directly and print it directly. Please help me. Krishnakant. Just let the registered .PDF viewer do it for you. os.start('myfile.pdf') Launches whatever is registered as .PDF viewer and user can then print, save, zoom, etc. on their own. -Larry os.startfile('pathToTheFile') should work. Under Library Reference- os - Process Management -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
On 2007-02-13, hg [EMAIL PROTECTED] wrote: Neil Cerutti wrote: On 2007-02-13, hg [EMAIL PROTECTED] wrote: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Any clue ? Yes. How wide (total) is 0.00, compared to 00.00? -- Neil Cerutti I do not get it s = '%02.02f' % 0.0 The first number after the percent is the minimum width specifier for the ENTIRE field. s '0.00' len(s) 4 It is the MINIMUM width specifier for the entire field. -- Neil Cerutti The eighth-graders will be presenting Shakespeare's Hamlet in the church basement on Friday at 7 p.m. The congregation is invited to attend this tragedy. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
Neil Cerutti wrote: The eighth-graders will be presenting Shakespeare's Hamlet in the church basement on Friday at 7 p.m. The congregation is invited to attend this tragedy. --Church Bulletin Blooper ;-) I like that ! hg -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
On 2007-02-11, krishnakant Mane [EMAIL PROTECTED] wrote: hello all, I am stuck with a strange requirement. I need a library that can help me display a pdf file as a report and also want a way to print the same pdf file in a platform independent way. if that's not possible then I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. the problem is that I want to display reports in my application. the user should be able to view the formatted report on screen and at his choice click the print button on the screen to send it to the printer. I have reportlab installed and that is sufficient to generate pdf reports. but I still can't fine the way to display it directly and print it directly. Please help me. Krishnakant. I think the best way to handle this under a unix like system is by using the mailcap module, something like the following: import mailcap import os mc = mailcap.getcaps() cmd = mailcap.findmatch(mc, 'image/pdf' , filename='/tmp/dummy')[0] os.system(cmd) -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
On 2007-02-13, hg [EMAIL PROTECTED] wrote: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 ^^ That's the specifierfor how many total columns you want to use (including the decimal point and all digits to either side). Any clue ? %05.02f % 0.0 '00.00' -- Grant Edwards grante Yow! Yow!! Janitor at trapped in sewer uses ESP visi.comto find decayed burger!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Mulig SPAM: float print formatting
On 2007-02-13, hg [EMAIL PROTECTED] wrote: NOSPAM plz wrote: Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 Try this: a = 45.45 # the floating number print some text, print a, print some text again Sorry, must be very slow or not enough coffee yet... Don't worry. I do know what you did wrong and how to fix it, and I have absolutely no idea what NOSPAM plz is trying to say either. -- Grant Edwards grante Yow! I'm in a twist at contest!! I'm in a visi.combathtub! It's on Mars!! I'm in tip-top condition! -- http://mail.python.org/mailman/listinfo/python-list
Re: float print formatting
Grant Edwards wrote: On 2007-02-13, hg [EMAIL PROTECTED] wrote: Hi, Considering the float 0.0, I would like to print 00.00. I tried '%02.02f' % 0.0 ... but I get 0.00 ^^ That's the specifierfor how many total columns you want to use (including the decimal point and all digits to either side). Any clue ? %05.02f % 0.0 '00.00' -- Grant Edwards grante Yow! Yow!! Janitor at trapped in sewer uses ESP visi.comto find decayed burger!! Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about Class
En Tue, 13 Feb 2007 03:56:21 -0300, [EMAIL PROTECTED] escribió: I'm reading the book of Dive into Python and got these code pieces: class UserDict: def __init__(self, dict=None): self.data = {} if dict is not None: self.update(dict) My question is,for the statement of: if dict is not None: self.update(dict) Why it's not this one below? if dict is not None: self.data.update(dict) Thanks. The idea behind that class is to act as-if it were a real dictionary. Dicts have an update method, and UserDict should too. But it's not listed in the book (should appear a few lines below that code); this is a possible implementation: def update(self, other): for key in other.keys(): self.data[key] = other[key] Given this method, __init__ works fine. Using self.data.update(dict) is OK if the dict argument is a real dictionary, but not if it's another UserDict. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about Class
[quote]The idea behind that class is to act as-if it were a real dictionary. Dicts have an update method, and UserDict should too. But it's not listed in the book (should appear a few lines below that code); this is a possible implementation: def update(self, other): for key in other.keys(): self.data[key] = other[key] Given this method, __init__ works fine. Using self.data.update(dict) is OK if the dict argument is a real dictionary, but not if it's another UserDict.[/quote] Thank you. But I'm still confused that what's the real dictionary?I can't know this point.Please help and thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance of a dynamic list of classes?
On 13 Feb, 12:46, Peter Otten [EMAIL PROTECTED] wrote: Well, what problems ocurring with class A: pass class B: pass class C(A, B): pass could be avoided by writing class A: pass class B(A): pass class C(B): pass instead? Classes have to be designed for subclassing, so essentially you get two interfaces, one for subclasses and one for client code instead of just the latter. A more relevant mantra governing inheritance is Flat is better than nested. I am truly getting lost. Are you saying that doing A--B(A)--C(B) is better than C(A,B)? And isn't the former thing nested? Or are you saying that C(A,B) is better than A,B(A),C(B)? And in both cases:why? And why classes have to be designed for subclassing? I often do classes that are not thought to be subclassed. If you use attributes starting with two underscores inside a method, Python transparently prepends them with the class name. This allows to you to use the same variable name in two base classes and reduces coupling: Wow, I didn't know it. Thanks a lot. But if two classes with the same name use the private variable, the mechanism fails: Of course.I'll remember it. m. -- http://mail.python.org/mailman/listinfo/python-list
Freeze packaging for Debian
How is Freeze--freeze.py URL: http://wiki.python.org/moin/Freeze --packaged for Debian? *Is* it packaged for Debian? -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
I'm using Suse Linux which has five program that will open a pdf file from a shell command line. Acrobat Reader is one of the five. A right button click on the file should give a list of programs that will open a PDF file. Im using a KDE desktop Open a shell, add the path to the directory where the PDF file lives, and on the command line type; xpdf myfile.pdf ## may also work on a Gnome ## Desktop or any of these for the KDE desktop; kpdf myfile.pdf Kghostview myfile.pdf konqueror myfile.pdf ## my browser + myfile. Acrobat Reader is also listed on my system. It open files as adobe reader using the mouse to open a pdf file but not from the command line with an arg, and I haven't spent the time to figgure out why. You will have to import os and some combination of any of the exec.. args, or the popen, spawn, or system modules. os.execvep() ## or others like execl, execle os.spawnv(), os.spawnve(), os.popen() hope this give some direction. jim-on-linux On Tuesday 13 February 2007 03:44, Jussi Salmela wrote: Grant Edwards kirjoitti: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: On 2007-02-12, Larry Bates [EMAIL PROTECTED] wrote: I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. Just let the registered .PDF viewer do it for you. os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system() That doesn't work either: $ ls -l user.pdf -rw--- 1 grante users 35640 2005-11-21 14:33 user.pdf $ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type help, copyright, credits or license for more information. import os os.system('user.pdf') sh: user.pdf: command not found 32512 Works fine on my system. You linux guys just have it hard. The op said windows. The posting to which you replied specified Linux. I can't answer for ubuntu linux but maybe you can help there? I don't see how. Pdf files just aren't executable. On Windows, this (where fileName is xyz.PDF, for example): webbrowser.open(r'file://' + fileName) starts Acrobat Reader with the document read in. I have no idea why, because Acrobat Reader sure ain't my browser;) Maybe someone could try this out on Linux. Cheers, Jussi -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
Laszlo Nagy wrote: Hello, I wrote a small program that uses xmlrpc over https. It should work as a win32 application and as a win32 service too. There is a file called Processor.py that contains the main thread of the program. It is called from two files: win32_Application.py and win32_Service.py. The application works perfectly. The service does not. I can start it from the services mmc console, but it does not created logfiles, and does nothing. It cannot be stopped and I have to kill pythonservice.exe. The event log shows this: Information: The AmazonOfferDownloaderService service has started. Application error: Faulty application: python.exe, version: 0.0.0.0, faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87. Is it possible that my _ssl.pyd is faulty? Please help me. Python version: 2.4.3 (#69, Mar 29 2006) Windows version: Windows XP Professional, service pack 2, Hungarian (I translated the above messages from the event log) Thanks, Laszlo Here is the code for the application: import thread,threading,time from Processor import * from servicelog import * from win32_Config import * stopped = threading.Event() stopped.clear() processor = Processor(stopped) thread.start_new_thread(processor.Process,()) logger = getLogger('win32_Application') logger.info(Staring as application. Please press CTRL+C to stop service.) while 1: try: time.sleep(1) except: break logger.info(Stopping application + SERVICE_NAME) stopped.set() while not processor.stopped.isSet(): logger.debug(Waiting for the processor to finish...) time.sleep(1) logger.info(Application stopped.) Here is the code for the service: from win32_Config import * from Processor import * from servicelog import * import win32serviceutil, win32service import pywintypes, win32con, winerror from win32event import * from win32file import * from win32pipe import * from win32api import * from ntsecuritycon import * import traceback import thread,threading class Service(win32serviceutil.ServiceFramework): _svc_name_ = SERVICE_NAME _svc_display_name_ = SERVICE_DISPLAY def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.stopped = threading.Event() self.stopped.clear() self.logger = getLogger(SERVICE_NAME) def SvcStop(self): self.logger.info(Got SvcStop, trying to stop service...) self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.stopped.set() def SvcDoRun(self): Write an event log record - in debug mode we will also see this message printed. try: import servicemanager servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) self.logger.info(Started.) self.logger.debug(Creating processor instance) processor = Processor(self.stopped) self.logger.debug(Starting processor thread) thread.start_new_thread(processor.Process,()) self.logger.debug(Waiting for the processor thread to finish) self.stopped.wait() self.logger.debug(Stopping) time.sleep(1) while not processor.stopped.isSet(): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000) time.sleep(5) servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, ) ) self.logger.info(Stopped) except: self.logger.error('',exc_info = sys.exc_info()) if __name__=='__main__': win32serviceutil.HandleCommandLine(Service) I was using _ssl.pyd to upload files to DAV server over ssl and found it to be a problem. I upgraded to Python 2.5 and the problem was fixed. I don't know if it is the same problem that is affecting you, but I couldn't get it to work on 2.4. FYI, Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex highlight html
En Tue, 13 Feb 2007 10:13:26 -0300, NOSPAM plz [EMAIL PROTECTED] escribió: I want to write a function that highlights html code. Well, it's already done, you have Pygments http://pygments.pocoo.org/ and SilverCity http://silvercity.sourceforge.net/ I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions Ouch... Read some previous posts on why it's not a good idea to use regexps for parsing html code. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Freeze packaging for Debian
On 13 Feb, 16:48, [EMAIL PROTECTED] (Cameron Laird) wrote: How is Freeze--freeze.py URL:http://wiki.python.org/moin/Freeze--packaged for Debian? *Is* it packaged for Debian? A search for freeze.py in package contents conducted from the Debian packages page [1] indicates that the file in question is provided by the examples package for each particular version of Python: so the python2.4-examples package would provide the file for a Python 2.4 installation, for example. Doing dpkg -S freeze.py yields python2.4- examples as the package responsible on my Kubuntu system. Paul [1] http://www.debian.org/distrib/packages (also http://packages.debian.org/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about Class
En Tue, 13 Feb 2007 13:01:59 -0300, [EMAIL PROTECTED] escribió: But I'm still confused that what's the real dictionary?I can't know this point.Please help and thanks again. I'm talking about a Python dictionary (a real one, as opposed to UserDict, which is a fake dictionary; it looks and acts like a dictionary but it's not). py from UserDict import UserDict py d = {a: 1, b: 2, c: 3} # This is a real dictionary # I create an UserDict instance, its initial contents come from a dictionary py ud1 = UserDict(d) py ud1 {'b': 2, 'a': 1, 'c': 3} # Now I create a second UserDict instance, its initial contents come from the UserDict instance py ud2 = UserDict(ud1) py ud2 {'b': 2, 'a': 1, 'c': 3} -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: c++ for python programmers
On Tue, 13 Feb 2007 06:35:36 +1100, andrew clarke [EMAIL PROTECTED] wrote: On Mon, Feb 12, 2007 at 10:00:51AM -0800, Thomas Nelson wrote: I realize I'm approaching this backwards from the direction most people go, but does anyone know of a good c/c++ introduction for python programmers? Thomas, I sent you a message off-list but it bounced due to your mailbox being full. Short answer: Subscribe to the c-prog@yahoogroups.com mailing list and ask your C/C++ questions there. Why on earth should he do that, seeing that he seems to post here over Usenet? There are plenty of Usenet groups for both languages. For C++, there are comp.lang.c++ and comp.lang.c++.moderated. Reading the second one has been both useful and enjoyable for me. And to echo what someone else wrote: please don't use the term C/C++. It makes about the same sense as Perl/Python (or Python/Perl). /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Testers please
it would be nice when someone would paste some instructions or tutorial how to bound it all together. where to paste the file. a dummy tutorial if possible. -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
I was using _ssl.pyd to upload files to DAV server over ssl and found it to be a problem. I upgraded to Python 2.5 and the problem was fixed. I don't know if it is the same problem that is affecting you, but I couldn't get it to work on 2.4. FYI, Larry I just installed Python 2.5 and now I do not get the error message in the event log. But the service still cannot be stopped and does not log anything. I'm using the logging module and RotatingFileHandler, so the service should start logging into a new file immediately after startup. According to the event log, the service is started, but it does nothing. If I start the same program as an application, it works fine. The program only uses the standard lib. Any ideas, what can be the problem? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation faults using threads
I use the thread module (not threading) for a client/server app where I distribute large amounts of pickled data over ssh tunnels. Now I get regular Segmentation Faults during high load episodes. I use a semaphore to have pickle/unpickle run nonthreaded, but I still get frequent nondeterministic segmentation faults. Since there is no traceback after a sf, I have no clue what exactly happened, and debugging a multithreaded app is no fun anyway :( Can someone recommend me how to get extra info during such a crash? Or any other opinion on where the problem might lie? Hi, it would be helpful if you posted a minimalistic code snippet which showed the problem you describe. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: c++ for python programmers
On Mon, 12 Feb 2007 19:10:02 +0100, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: Thomas Nelson schrieb: [top posting fixed] I realize I'm approaching this backwards from the direction most people go, but does anyone know of a good c/c++ introduction for python programmers? Learning C++ is not worth is in my opinion, since you can get the OOP power from Python and use C if you need speed... Well, C++ is a better language than C in many ways. So, if he needs to learn one of them, why does it have to be C? Another reason some people choose C++ over Python for some tasks is that they feel that larger programs benefit from strong, static type checking. I like both ways, but depending on the task, one or the other is better. And then there's always the my boss told me reason, which seems to apply to the OP. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Download parts not whole file in ones
On Feb 13, 8:09 am, NOSPAM plz [EMAIL PROTECTED] wrote: Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ---CODE--- import urllib # the heavy file to download f = urllib.urlopen(http://da.wikipedia.org/wiki/Wiki;) # This was supposed to print the file while it downloads while 1: print f.read(100) ---/CODE--- In my example it just download the whole file, and then print it. Any suggestions? Regards Andreas That's because urllib.urlopen() is not a low enough level function to allow what you want, it will simply open the . Take a look inside of urllib.py and maybe you'll find a way to subclass the urllopen() function to do what you want. Cheers, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Scripting Visio using Python
I would like to create some additional shapes in Microsoft Visio using the Python language. It would appear that Visio can use any CLR language. Has anyone done this? Can I use the Python package from python.org, or must I use IronPython? -- http://mail.python.org/mailman/listinfo/python-list
Re: Download parts not whole file in ones
On Feb 13, 12:51 pm, Jordan [EMAIL PROTECTED] wrote: On Feb 13, 8:09 am, NOSPAM plz [EMAIL PROTECTED] wrote: Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ---CODE--- import urllib # the heavy file to download f = urllib.urlopen(http://da.wikipedia.org/wiki/Wiki;) # This was supposed to print the file while it downloads while 1: print f.read(100) ---/CODE--- In my example it just download the whole file, and then print it. Any suggestions? Regards Andreas That's because urllib.urlopen() is not a low enough level function to allow what you want, it will simply open the . Take a look inside of urllib.py and maybe you'll find a way to subclass the urllopen() function to do what you want. Cheers, Jordan Sorry, my previous msg got mangled. I meant to say that urllib.urlopen() will simply open the webpage, you can't interrupt it to print out what's already been downloaded. -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
Dennis Lee Bieber kirjoitti: On Tue, 13 Feb 2007 08:44:18 GMT, Jussi Salmela [EMAIL PROTECTED] declaimed the following in comp.lang.python: On Windows, this (where fileName is xyz.PDF, for example): webbrowser.open(r'file://' + fileName) starts Acrobat Reader with the document read in. I have no idea why, because Acrobat Reader sure ain't my browser;) Most likely Adobe installed the Acrobat plug-in for the browser... The browser identifies the file as PDF and passes it to the plug-in for rendering. I can read PDFs with the browser if I open them in there. But as I was trying to tell the line above starts the Acrobat Reader EXE in its own window. The mechanism is probably caused by something I must have done/installed, but I don't know what. Anyway: it works just as I want although this may not be the general behaviour. (OS: Win XP SP2, Python 2.4.3) Cheers, Jussi -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation faults using threads
Hi, it would be helpful if you posted a minimalistic code snippet which showed the problem you describe. Daniel I wish I could! If I knew exactly where the effect takes place I could probably circumvent it. All I know know is that it happens under high load and with a lot of waitstates I can reduce the propability of crashing. So there must be some race condition somewhere I think. Is there a way to analyze where the crash took place? I guess I can have a core dumped and somehow analyze it, but that's probably very hard to do. Would a profiler work which records the function call structure? Does someone have experience with threading in python - are there non-threadsafe functions I should know about? Thanks, Mathias -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation faults using threads
Daniel Nogradi wrote: I use the thread module (not threading) for a client/server app where I distribute large amounts of pickled data over ssh tunnels. What module are you using for SSH? What's in your program that isn't pure Python? The problem is probably in some non-Python component; you shouldn't be able to force a memory protection error from within Python code. Also note that the marshal module may be unsafe. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation faults using threads
John Nagle wrote: Daniel Nogradi wrote: I use the thread module (not threading) for a client/server app where I distribute large amounts of pickled data over ssh tunnels. What module are you using for SSH? What's in your program that isn't pure Python? The problem is probably in some non-Python component; you shouldn't be able to force a memory protection error from within Python code. Also note that the marshal module may be unsafe. John Nagle I'm using os.popen2() to pipe into an ssh session via stdin/stdout. That's probably not the elegant way... Other modules: scipy 0.3.2 (with Numeric 24.2) and python 2.4 Does pickle/cPickle count as part of the marshal module? Mathias -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex highlight html
Gabriel Genellina skrev: En Tue, 13 Feb 2007 10:13:26 -0300, NOSPAM plz [EMAIL PROTECTED] escribió: I want to write a function that highlights html code. Well, it's already done, you have Pygments http://pygments.pocoo.org/ and SilverCity http://silvercity.sourceforge.net/ I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions Ouch... Read some previous posts on why it's not a good idea to use regexps for parsing html code. Thanks just what i needed :D! -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation faults using threads
PS: setting sys.setcheckinterval(1) reduces the probablilty of a failure as well, but definetely at a performance cost. -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
En Tue, 13 Feb 2007 14:40:20 -0300, Laszlo Nagy [EMAIL PROTECTED] escribió: I just installed Python 2.5 and now I do not get the error message in the event log. But the service still cannot be stopped and does not log anything. I'm using the logging module and RotatingFileHandler, so the service should start logging into a new file immediately after startup. According to the event log, the service is started, but it does nothing. If I start the same program as an application, it works fine. The program only uses the standard lib. Any ideas, what can be the problem? Services usually run under the LOCAL_SERVICE account, which is rather limited on what it is allowed to do (It has no access to network shares, by example). Perhaps this is afecting your program. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Fast constant functions for Py2.5's defaultdict()
FWIW, here are three ways of writing constant functions for collections.defaultdict(): d = defaultdict(int) # slowest way; works only for zero d = defaultdict(lambda: 0) # faster way; works for any constant d = defaultdict(itertools.repeat(0).next)# fastest way; works for any constant Another approach is to use the __missing__ method for dictionary subclasses: class zerodict (dict): def __missing__ (self, key): return 0 # fast on initial miss, but slow on non-misses; works for any constant The itertools.repeat(const).next approach wins on speed and flexibility. Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
Services usually run under the LOCAL_SERVICE account, which is rather limited on what it is allowed to do (It has no access to network shares, by example). Perhaps this is afecting your program. I'm sorry, it is not. My service only uses the standard output, writes into different files and uses the http and https protocol. It does not use microsoft networking, only TCP/IP. It is actually a spider that downloads information from some web sites. The most strange thing is that the main thread is enclosed in a try - except statement, and it should log all exceptions into a file. The file is even not created, and I see no way to debug it. Can a python win32 service program be debugged? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
En Tue, 13 Feb 2007 16:49:10 -0300, Laszlo Nagy [EMAIL PROTECTED] escribió: Services usually run under the LOCAL_SERVICE account, which is rather limited on what it is allowed to do (It has no access to network shares, by example). Perhaps this is afecting your program. I'm sorry, it is not. My service only uses the standard output, writes into different files and uses the http and https protocol. It does not use microsoft networking, only TCP/IP. It is actually a spider that downloads information from some web sites. The most strange thing is that the main thread is enclosed in a try - except statement, and it should log all exceptions into a file. The file is even not created, and I see no way to debug it. Can a python win32 service program be debugged? Do you catch all exceptions on your working thread too? You didn't post that code. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: New Pythin user looking foe some good examples to study
http://www.daniweb.com/code/python.html http://www.pythonchallenge.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: New Pythin user looking foe some good examples to study
yeah! i also think cookbook is easy to read and code is very practical. On 2/12/07, Larry Bates [EMAIL PROTECTED] wrote: Johnny Garcia wrote: I have just discovered Python and am familiarizing myself with the syntax but I have always found that code examples where the best way for me to learn. Can anyone point me to a site with some good open source functioning python applications? I would appreciate any help. Also, does anyone know of any good Linux or python user groups in the orange county, California area? Pick up a copy of Python Cookbook from O'Reilly. -Larry -- http://mail.python.org/mailman/listinfo/python-list -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) -- http://mail.python.org/mailman/listinfo/python-list
Click event with python
I am creating an alternative mouse device(like wiimote), i use Xlib to move mouse, but now I need also to create the right and left click event, I can use already Xlib or there is another library that make it? It is possibile beacuse the wiimote code click also(I tryed to understand that code but it is too complicated!). -- http://mail.python.org/mailman/listinfo/python-list
Undo os.remove
Hi. I just used os.remove to get rid of some files -- unfortunately, I realized afterward that I didn't really want to get rid of them. It isn't life-or-death, here, but is there any way for me to get these files back? - Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Undo os.remove
[EMAIL PROTECTED] writes: Hi. I just used os.remove to get rid of some files -- unfortunately, I realized afterward that I didn't really want to get rid of them. It isn't life-or-death, here, but is there any way for me to get these files back? Try a websearch for file recovery utilities, nothing to do with Python especially. Directory Snoop by Kent Briggs is supposedly pretty good if you run Windoze. One thing you should do is shut off your computer right away if it's the same one where you deleted those files. If the freed disk sectors get re-used by other files they are unrecoverable, and Windows is always doing stuff that eats up disk sectors. Use a different computer to search for recovery programs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Testers please
Thanks for getting involved. And kind remarks. The labeling of 'false' and 'true' is just for shortness sake. The condition itself could be quite a mess and span several lines. You mentioned that. The only reason I like to display it, is to show whether a block of coding, the colored bit, is performed or not. Without that you would find out anyway; nothing becomes underlined when you move your mouse in that area: Nothing in that area is interactive. Because nothing happened there. Even when the condition itself shows on the tab, not just the outcome, the user would still need to scroll up to that tab if it was not visible. The user interface is in HTML, maybe a tooltip when one moves the cursor over a colored condition block could show up that shows the condition and its value. I hate them tooltips though. They make the whole interface so jumpy. More work in that area needed then. -- http://mail.python.org/mailman/listinfo/python-list
Re: Scripting Visio using Python
On Feb 13, 6:52 pm, Paul Watson [EMAIL PROTECTED] wrote: I would like to create some additional shapes in Microsoft Visio using the Python language. It would appear that Visio can use any CLR language. Has anyone done this? Can I use the Python package from python.org, or must I use IronPython? Don't know how to do that, but I suggest you post your question on the IronPython list: http://groups.google.com/group/ironpy?lnk=li Python is not a .NET language, IronPython is. HTH, -- Marcel -- http://mail.python.org/mailman/listinfo/python-list
Re: Undo os.remove
[EMAIL PROTECTED] writes: Hi. I just used os.remove to get rid of some files -- unfortunately, I realized afterward that I didn't really want to get rid of them. It isn't life-or-death, here, but is there any way for me to get these files back? Since 'os.remove' delegates the actual removal to your operating system, it's a matter of whether your operating system has a way to get those files back. Most operating systems don't have a simple bring this file back system call (the way they have a remove this file system call), so Python can't provide such an interface. But your operating system might provide a way. -- \ Reichel's Law: A body on vacation tends to remain on vacation | `\ unless acted upon by an outside force. -- Carol Reichel | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
RE: Testers please
cool product, I'll test depending on schedule at the time. one (more) suggestion (from those of us who arn't doing the work ;) is to put this in eclipse, rather than apache, since many developers work with it. Please no IDE wars, I like emacs too, but when I'm trying to teach to newbies I use elcipse. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of martien friedeman Sent: Monday, February 12, 2007 8:38 PM To: python-list@python.org Subject: Testers please I have written this tool that allows you to look at runtime data and code at the same time. And now I need people to test it. The easiest way to see what I mean is to look at some videos: http://codeinvestigator.googlepages.com/codeinvestigator_videos It requires Apache and Sqlite. It works for me with a Firefox browser on Linux. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance of a dynamic list of classes?
[EMAIL PROTECTED] a écrit : Hi, (snip) - is there a better way than using multiple inheritance to plug-in dynamically commands in a Cmd command line? Yes : use composition + delegation. Python makes it easy: #foo.py class Commands(object): def do_this(self,args): ... def do_that(self,args): ... #bar.py class Commands(object): def do_what(self, args): ... I've seen I can do it by explicitely import them and using multiple inheritance: class MyCli(cmd.Cmd): def __init__(self, *plugins): self.plugins = plugins self._cache = {} def __getattr__(self, name): try: return self._cache[name] except KeyError: for plugin in self.plugins: attr = getattr(plugin, name, None) if attr is not None: self._cache[name] = attr return attr my_cli = MyCli(foo.Command(), bar.Command()) -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
Laszlo Nagy wrote: Hello, I wrote a small program that uses xmlrpc over https. It should work as a win32 application and as a win32 service too. There is a file called Processor.py that contains the main thread of the program. It is called from two files: win32_Application.py and win32_Service.py. The application works perfectly. The service does not. I can start it from the services mmc console, but it does not created logfiles, and does nothing. It cannot be stopped and I have to kill pythonservice.exe. The event log shows this: Information: The AmazonOfferDownloaderService service has started. Application error: Faulty application: python.exe, version: 0.0.0.0, faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87. Is it possible that my _ssl.pyd is faulty? Please help me. Python version: 2.4.3 (#69, Mar 29 2006) Windows version: Windows XP Professional, service pack 2, Hungarian (I translated the above messages from the event log) Thanks, Laszlo Here is the code for the application: import thread,threading,time from Processor import * from servicelog import * from win32_Config import * stopped = threading.Event() stopped.clear() processor = Processor(stopped) thread.start_new_thread(processor.Process,()) logger = getLogger('win32_Application') logger.info(Staring as application. Please press CTRL+C to stop service.) while 1: try: time.sleep(1) except: break logger.info(Stopping application + SERVICE_NAME) stopped.set() while not processor.stopped.isSet(): logger.debug(Waiting for the processor to finish...) time.sleep(1) logger.info(Application stopped.) Here is the code for the service: from win32_Config import * from Processor import * from servicelog import * import win32serviceutil, win32service import pywintypes, win32con, winerror from win32event import * from win32file import * from win32pipe import * from win32api import * from ntsecuritycon import * import traceback import thread,threading class Service(win32serviceutil.ServiceFramework): _svc_name_ = SERVICE_NAME _svc_display_name_ = SERVICE_DISPLAY def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.stopped = threading.Event() self.stopped.clear() self.logger = getLogger(SERVICE_NAME) def SvcStop(self): self.logger.info(Got SvcStop, trying to stop service...) self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.stopped.set() def SvcDoRun(self): Write an event log record - in debug mode we will also see this message printed. try: import servicemanager servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) self.logger.info(Started.) self.logger.debug(Creating processor instance) processor = Processor(self.stopped) self.logger.debug(Starting processor thread) thread.start_new_thread(processor.Process,()) self.logger.debug(Waiting for the processor thread to finish) self.stopped.wait() self.logger.debug(Stopping) time.sleep(1) while not processor.stopped.isSet(): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000) time.sleep(5) servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, ) ) self.logger.info(Stopped) except: self.logger.error('',exc_info = sys.exc_info()) if __name__=='__main__': win32serviceutil.HandleCommandLine(Service) I see some problems. You don't use time sleep in services. You wait for a stop signal and if you don't get it by the time you reach your timeout, you loop. I'm not sure what you are trying to accomplish with the threading module, but you should start with a simple service first. I don't think you will need the threading at all. Here is a skeleton that might help: class Service(win32serviceutil.ServiceFramework): def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.timeout=5000 # 5000 milliseconds or 5 seconds #- # Create an event which we will use to wait on. # The service stop request will set this event. #- self.hWaitStop=win32event.CreateEvent(None, 0, 0, None) return def SvcStop(self):
Tkinter: how; newbie
can someone explain me this code? from Tkinter import * root = Tk() def callback(event): print clicked at, event.x, event.y frame = Frame(root, width=100, height=100) frame.bind(Button-1, callback) frame.pack() root.mainloop() well, my problem is at frame.bind(,Button-1, callback) callback function prints event.x and event.y. How the callback function get this two number when it has only one argument (event) Why its not: def callback(x, y): print x, y Im new to gui programming Sorry for bad eng! Thanks for replay! -- http://mail.python.org/mailman/listinfo/python-list
Re: Testers please
Thanks Stef! I looked at that area of storing large structures. That would seriously make the whole thing much more complicated. Say you have object 'foo' and it has lots of attributes. If you're only accessing foo.length in the statement 'if foo.length 12:' why should I store everything about foo? Its 'length' is the only attribute accessed, therefore I only store its 'length'. And therefore you can not click on 'foo', only on 'length'. No video shows such an example though. On the other hand if you had the statement 'if foo:' then 'foo' would be able to be clicked, and it would say '__main__.Foo instance ... etc. The usual. No attributes though. The interface is web based; I was going to make it as universal as possible. The web server is required to do the Ajax thing and display pages. Makes it harder to install too, unfortunately. The size of the 'recording' is a major drawback, it was clearly not meant to record the processing of millions of records. I need to find a way to specify the area in the code that needs recording. Thanks for the suggestions. -- http://mail.python.org/mailman/listinfo/python-list
Re: What does del actually do?
John Nagle a écrit : The Python reference manual says, for del, Rather that spelling it out in full details, here are some hints. That's not too helpful. In particular, when del is applied to a class object, what happens? Are all the instance attributes deleted from the object? It would have been simpler to just test: class Ghost(object): ... def __init__(self, name): ... self.name = name ... say = whoo ... def greetings(self): ... print %s from %s %s \ ... %(self.say, self.__class__.__name__, self.name) ... g1 = Ghost(Albert) g2 = Ghost(Ivan) g1.greetings() whoo from Ghost Albert del Ghost g1.greetings() whoo from Ghost Albert g1.__class__ class '__main__.Ghost' the del statement remove a name from the current namespace. period. It's also used for removing keys from dicts. Is behavior the same for both old and new classes? Should it be different ? I'm trying to break cycles to fix some memory usage problems. GC and/or Weakrefs should do. -- http://mail.python.org/mailman/listinfo/python-list
Re: c++ for python programmers
On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn [EMAIL PROTECTED] wrote: Well, C++ is a better language than C in many ways. So, if he needs to learn one of them, why does it have to be C? Another reason some people choose C++ over Python for some tasks is that they feel that larger programs benefit from strong, static type checking. I like both ways, but depending on the task, one or the other is better. C++ is -not- strongly typed. You can cast anything to void *, and manipulate it in ways unimaginable. Plus there's the whole mess that is pointer arithmetic and a weak typesystem... Disclaimer: I am unashamedly in the C++ Is Evil camp, and wholly believe that if you want proper strong, static type checking, use Haskell, or if you want proper, complete object-orientation (C++'s primitive types compromise its object system's integrity, and I believe I've already discussed casting and pointers), use Python, and if you want under-the-hood pointer-fu, use C. --Sam -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: how; newbie
How the callback function get this two number when it has only one argument (event)? It has one argument, event, which is an instance of a class that has both x and y attributes. print clicked at, event.x, event.y It doesn't accept the coordinates as separate parameters because every event binding uses that same signature, even ones for which coordinates might not make any sense. I recommend you look over the python tutorial: http://docs.python.org/tut/ -- http://mail.python.org/mailman/listinfo/python-list
Comparing lists ...
I would like to know if it is possible, and how to do this with Python: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ lets call this function check(a, b) and define a few lists: l0 = [1, 2, 3, 4] l1 = [1, 2, 3, 4] l2 = l0 I want it to have the following behaviour: check(l1, l0) False check(l2, l0) True check(l1, l2) False Any idea how to do this with Python? -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: how; newbie
Matimus wrote: How the callback function get this two number when it has only one argument (event)? It has one argument, event, which is an instance of a class that has both x and y attributes. print clicked at, event.x, event.y It doesn't accept the coordinates as separate parameters because every event binding uses that same signature, even ones for which coordinates might not make any sense. I recommend you look over the python tutorial: http://docs.python.org/tut/ that was fast, thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing lists ...
Loic wrote: I would like to know if it is possible, and how to do this with Python: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ lets call this function check(a, b) and define a few lists: l0 = [1, 2, 3, 4] l1 = [1, 2, 3, 4] l2 = l0 I want it to have the following behaviour: check(l1, l0) False check(l2, l0) True check(l1, l2) False Any idea how to do this with Python? Use is. E.g.: l0 is l1 James -- http://mail.python.org/mailman/listinfo/python-list
Re: _ssl.pyd is buggy?
Something I always found useful is to use the win32traceutil to set up the trace debugging tool. You can then see the output in the pythonwin trace collector tool. This is very useful for Python services and COM servers. Best of luck, Giles -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing lists ...
Loic [EMAIL PROTECTED] writes: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ Use the is keyword. print (l1 is l2) print (l0 is l2) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: how; newbie
On Tuesday 13 February 2007 18:02, Gigs_ wrote: can someone explain me this code? from Tkinter import * root = Tk() def callback(event): print clicked at, event.x, event.y frame = Frame(root, width=100, height=100) frame.bind(Button-1, callback) frame.pack() root.mainloop() if you live on longititude 32, wrere is that? If you live on latitude 40 and longitiude 32 I can find that location. Your mouse is pointing to x, and y, which is simply a location on the screen. well, my problem is at frame.bind(,Button-1, callback) callback function prints event.x and event.y. How the callback function get this two number when it has only one argument (event) Why its not: def callback(x, y): print x, y Im new to gui programming Sorry for bad eng! Thanks for replay! -- http://mail.python.org/mailman/listinfo/python-list