ANN: pywinauto 0.3.0 released - now localization proof
Hi, The 0.3.0 release of pywinauto is now available. pywinauto is a set of open-source (LGPL) modules for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from 0.2.5: 0.3.0 Added Application data - now useful for localization testing -- 20-Mar-2006 * Added automatic Application data collection which can be used when running the same test on a different spoken language version. Support is still preliminary and is expected to change. Please treat as early Alpha. If you have a different language version of Windows then you can try this out by running the notepad_fast.py example with the langauge argument e.g. :: examples\notepad_fast.py language This will load the application data from the supplied file notepad_fast.pkl and use it for finding the right menu items and controls to select. * Test implementation to make it easier to start using an application. Previously you needed to write code like :: app = Application().connect_(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) 1st change was to implement static methods ``start()`` and ``connect()``. These methods return a new Application instance so the above code becomes:: app = Application.connect(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) I also wanted to make it easier to start working with a simple application - that may or may not have only one dialog. To make this situation easier I made ``window_()`` not throw if the application has not been ``start()ed`` or ``connect()ed`` first. This leads to simpler code like:: app = Application() app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) What happens here is that when you execute any of Application.window_(), Application.__getattr__() or Application.__getitem__() when the application hasn't been connected or started. It looks for the window that best matches your specification and connects the application to that process. This is extra functionality - existing connect_() and start_() methods still exist * Fixed HwndWrapper.SetFocus() so that it would work even if the window was not in the foreground. (it now makes the window foreground as well as giving it focus). This overcomes a restriction in Windows where you can only change the foreground window if you own the foreground window. * Changed some 2.4'isms that an anonymous commenter left on my blog :-) with these changes pywinauto should run on Python 2.3 (though I haven't done extensive testing). * Commented out controls.common_controls.TabControlWrapper.GetTabState() and TabStates() as these did not seem to be returning valid values anyway. * Fixed documentation issues were parts of the documentation were not getting generated to the HTML files. * Fixed issue where MenuSelect would sometimes not work as expected. Some Menu actions require that the window that owns the menu be active. Added a call to SetFocus() before selecting a menu item to ensure that the window was active. * Fixed Bug 1452832 where clipboard was not closed in clipboard.GetData() * Added more unit tests now up to 248 from 207 If you want to follow this project then please sign up to the mailing list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users Thanks Mark Mark Mc Mahon Manchester, NH 03110, USA PA HREF=http://sourceforge.net/projects/pywinauto;pywinauto 0.3.0/A Simple Windows GUI automation with Python. (20-Mar-06) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Nuxeo Calendar Server released in version 2
Nuxeo Calendar Server released in version 2 --- Nuxeo releases version 2 of it's calendar products for Python and Zope, updating to the latest technology frameworks. Nuxeo proudly presents version 2 of its calendar framework. The calendar framework is a set of advanced, flexible calendar components for Python and Zope. CalCore is a calendar component for Python. It allows the Python developer do write advanced calendar applications either using their own event storage or integrating with external calendar servers. Features of the CalCore include among others: * Support for making private calendars, shared calendars, resource booking and more, * invitation workflow, * iCalendar import and export, * meeting support, including helper functions to look for free time, * recurring event support, * etc. CalZope is the Zope module that provides a web user interface for CalCore. Features include: * an internationalized web user interface, * integration with iCalendar clients (Apple iCal, Mozilla Sunbird, ...) using the iCalendar and http, * an advanced meeting helper that allows you to search for free time amongst the invited users, * etc. The changes between version 1 and version 2 have been mostly in CalZope, where we now have started using more of the techniques available through the tighter integration of Zope 3s component architecture in Zope 2. * Local utilities instead of portal tools, providing for an easier installation and greater portability to various non-CMF frameworks, such as Silva and Zope 3. * zope.i18n for internationalization providing translations of CalZope without additional tools such as Localizer or PTS. CalZope will in a standard Zope now be automaticaly translated into english, french and more, and you can easily add your own translations. * Install script, so you can easily try CalZope out in a pure Zope environment. * And of course, various minor bugfixes. For CPS users, all these modules are a part of the CPSGroupware bundle, together with the CPSMailAccess webmail client. For more functional and technical information, see the Calendar Server web site: http://www.cps-project.org/sections/projects/calendar_server CalCore v2 can be downloaded here: http://www.cps-project.org/static/misc/CalCore-bundle-2.0.1.tgz CalZope v2 can be downloaded here: http://www.cps-project.org/static/misc/CalZope-bundle-2.2.2.tgz CPSGroupware 1.9.0 for CPS 3.4.0 can be downloaded here: http://www.cps-project.org/static/misc/CPSGroupware-1.9.0-1.tgz If you'd like to help with development or porting to other platforms, please join the cps-devel mailing list at http://lists.nuxeo.com/mailman/listinfo/cps-devel Enjoy, S. -- Stefane Fermigier - CEO, Nuxeo SAS - http://www.nuxeo.com/en/ Open Source ECM provider - http://www.cps-project.org Free soft. developer - http://blogs.nuxeo.com/sections/blogs/fermigier -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
How to fork or spawn processes to second processor ?
Hi everybody, how can I spawn or fork a second process onto the second processor of my dual core server ? Is there a possibility to determin the processor on which a process shall run ? Thanks in advance Bernd -- http://mail.python.org/mailman/listinfo/python-list
Error sending message [1142852913051.1792.rpppl] from [randpoly.com]
[00] V-POP3bounce: [EMAIL PROTECTED];Error=[550 Error: Invalid Attachment] [01] Error sending message [1142852913051.1792.rpppl] from [randpoly.com]. ID:SF1F0 Mail From: python-list@python.org Rcpt To: [EMAIL PROTECTED] Server:relaymaster.rapidns.com [209.120.245.170] [02] The reason of the delivery failure was: 550 Error: Invalid Attachment [05] Here is listed the initial part of the message: Received: from python.org (192.168.0.24:4203) by smtp.randpoly.com with [V-POP3Mail (Win32/Ix86) ESMTP Server] id SF1F0 for [EMAIL PROTECTED] from python-list@python.org; Mon, 20 Mar 2006 16:38:28 +0530 From: python-list@python.org To: [EMAIL PROTECTED] Subject: Good day Date: Mon, 20 Mar 2006 16:50:20 +0530 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000_0012_F35E4AFF.7BDAC5B9 X-Priority: 3 X-MSMail-Priority: Normal -- http://mail.python.org/mailman/listinfo/python-list
Re: ** Operator
Christoph Zwerschke wrote: Kent Johnson wrote: The way to make this change happen is to submit a bug report with your suggested change. See the link at the bottom of the above page to find out how. I know, but I wanted to see at least one person assenting before doing so. Anyway, I took your words as assent and filed a bug report now ;-) ... which was promptly rejected. Seems like the Gods of Python don't want newbies to understand the manuals too easily, so they can have their fun ranting why they did not RTFM, when they come here and ask silly questions. ;-) -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: How to fork or spawn processes to second processor ?
Sabre wrote: how can I spawn or fork a second process onto the second processor of my dual core server ? Is there a possibility to determin the processor on which a process shall run ? Hi, from your post it's not clear why you would want to do that or which operating system you are using. Normally, you can expect any decent multi-processor operating system to distribute the load nicely over all available processors. Relying on that might help you. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Become another user
Hello, [Disclaimer: This might really be a Unix question ?!] I have written a cgi-script in python - it works reasonably well. The script is invoked by the apache web server and runs as user 'wwwrun'. During the execution of the script I want to save some files, as the script is run bu user 'wwwrun' that is also the resulting ownership of the files created. Since I don't have root access on the server these files create some hassle. Hence my question is whether it is possible (from the the python script) to change identity 'wwwrun' - 'myuser' during execution? Best Regards Joakim Hove -- Joakim Hove hove AT ntnu.no/ Tlf: +47 (55 5)8 27 13/ Stabburveien 18 Fax: +47 (55 5)8 94 40 / N-5231 Paradis http://www.ift.uib.no/~hove// 55 91 28 18 / 92 68 57 04 -- http://mail.python.org/mailman/listinfo/python-list
Re: user-supplied locals dict for function execution?
Lonnie Princehouse wrote: Beautiful is better than ugly. Explicit is better than implicit. Err... I see no contradiction nor conflict here. What to do when explicit is ugly and implicit is beautiful? Depends on your understanding of explicit/implicit. Side effects on globals or automatic type conversion à la PHP are implicit. Passing args and getting results back or requiring explicit conversion are explicit. Abstracting implementation details is a somewhat different topic IMHO. May I had : Simple is better than complex. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. and of course : Namespaces are one honking great idea -- let's do more of those! You know, the whole is greater than the sum of the parts and all that kind of things !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing parameters to VB
koia [EMAIL PROTECTED] wrote: Hi, I am using win32com for the Python interface to my Excel shreadsheets. When I turn on Macro recordiong in Excel while filling a rectangle with text information, a part of the VB code produced is the following: With Selection.Characters(Start:=1, Length:=11).Font .Name = Arial .FontStyle = Normal .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic What is the syntax for passing the parameters Start:=1, Length:=11 to VB from a Python function, if I want to control these properties of the text in the Excel spreadsheet? If you check the object model documentation, you'll find that Start and Length are the only two parameters to Characters, so Characters(1,11) should work. However, in a few minutes of experimentation, I was unable to get Characters to accept any parameters from Python. I can set the whole cell to bold by this: xl = win32com.client.Dispatch(Excel.Application) wb = xl.ActiveWorkbook ws = wb.Worksheets(1) r = ws.Range(A1) r.Characters.Font.Bold = True -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Become another user
Look at the os module: http://docs.python.org/lib/os-file-dir.html This has various functions you may find useful depending on how you want to go about it, such as chmod and chown. Cheers, -- Ant... -- http://mail.python.org/mailman/listinfo/python-list
Re: How to recgonize an USB device in FreeBSD?
Geoffery [EMAIL PROTECTED] wrote: I want to use Python to develop a software.Now, I have a question. How to recgonize USB device in FreeBSD? Presumably, with a device driver, which will not be written in Python. And , Is there any module that I can use? Could you be a bit more specific? -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 Schedule
Looks like some good new stuff coming along. Does anyone know what's happened to the path PEP (http://www.python.org/doc/peps/pep-0355/) - I thought I'd seen somewhere that that was originally planned for 2.5... -- Ant... -- http://mail.python.org/mailman/listinfo/python-list
Re: ** Operator
Ron Adam wrote: I agree and think the for language lawyers should be changed to something that encourages people to read it instead of encouraging them to avoid it. Maybe: The Python language structure for everyone. If it's hard to read and understand, then that can and should be fixed. Hm, actually that was not my point. I think the writers of the Language Reference already did a very good job. The precise and authoritative language reference covering all the subtleties and special cases will never be fun to read. You would rather learn the use of the keywords and the basic rules and magic attributes of the language from a good tutorial or handbook, and look up the Language Reference really seldomly. You can program quite well in Python without ever having looked into the official Language Reference. Newbies should not think they need to read it in order to start programming. However, it is different with the Lib Reference. This is used on a daily basis, you will often look into it, Python users are accustomed to it, and it should invite readers to really browse and read and learn more about the power of the batteries included. My point was that since users are more accustomed to and prefer to use the Lib reference as their first source of information rather than the Language reference, it should not be reluctant to mention some things which strictly speaking belong to the Language Reference. In some cases, it can also point to the Lanugage Reference for the details (and it does so already). -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: whats your favourite object relational mapper?
Jonathan Ellis wrote: Steve Holden wrote: I think describing this as Ian saying the code in its current form is a dead end is to read rather more into the words than is actually there. Well, that may be. However, given that the 0.x code is so crufty that the v2 refactor is a multi-day (-week, now) process that merits a new project name, and there are enough architecture warts that it's not worth it to keep v2 backwards compatible, I'm not sure what requirements of being a dead end are missing here. :) I suppose that in one sense no OSS project is a dead end since you can always pick up the pieces yourself, but it's clear the 0.x series is not a place to expect much in the way of new developments from its author. Sure, we can agree on that. I though you meant to imply that Ian was abandoning the concepts behind SQLObject rather that the somewhat crufty initial implementation. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
should os.walk return a list instead of a tuple?
Hello, os.walk doc: http://www.python.org/doc/2.4/lib/os-file-dir.html#l2h-1625 When walking top to bottom, it allows you to choose the directories you want to visit dynamically by changing the second parameter of the tuple (a list of directories). However, since it is a tuple, you cannot use filter on it, since it would mean reassigning it: for dir_tuple in os.walk('/home'): dir_tuple[1]=filter(lambda x: not x.startswith('.'), dir_tuple[1]) #do not show hidden files print dir_tuple #just print the directory and its contents in the simplest possible way If os.walk did return a list of three items instead of a tuple, that would become possible. It would also not break old code like for dirpath, dirnames, filenames in os.walk(somedir): do something. Since assigning a list to a tuple is valid python code. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: user-supplied locals dict for function execution?
Lonnie Princehouse wrote: Beautiful is better than ugly. Explicit is better than implicit. Err... I see no contradiction nor conflict here. What to do when explicit is ugly and implicit is beautiful? Aye, there's the rub. ;-) Realise that sometimes explicitly ugly can be implicitly beautiful, and you will become enlightened. could-that-be-the-sound-of-one-hand-clapping-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Spidering Hacks for Python, not Perl
Enigma Curry wrote: I've been looking for similar stuff recently. I haven't found much, but this is the list of links I've come across so far: Harvest Man - http://harvestman.freezope.org/ Mechanize - http://wwwsearch.sourceforge.net/mechanize/ Beautiful Soup - http://www.crummy.com/software/BeautifulSoup/ (Neither Beautiful Soup, nor Mechanize are complete crawlers but probably have a lot of the nuts and bolts) If anyone is aware of a book or other documentation like the OP would like, I would be pleased to see it as well. Don't forget webchecker and websucker in the Python distribution Tools folder. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to recgonize an USB device in FreeBSD?
I want to add some applications to Freevo. Let Freevo recgonize the USB device is the one. Thank u for your answer. -- http://mail.python.org/mailman/listinfo/python-list
Re: should os.walk return a list instead of a tuple?
Ministeyr wrote: When walking top to bottom, it allows you to choose the directories you want to visit dynamically by changing the second parameter of the tuple (a list of directories). However, since it is a tuple, you cannot use filter on it, since it would mean reassigning it: for dir_tuple in os.walk('/home'): dir_tuple[1]=filter(lambda x: not x.startswith('.'), dir_tuple[1]) #do not show hidden files print dir_tuple #just print the directory and its contents in the simplest possible way If os.walk did return a list of three items instead of a tuple, that would become possible. But you don't need to assign to it, you simply need to mutate it: for dir, subdirs, files in os.walk('/home'): subdirs[:] = [d for d in subdirs if not d.startswith('.')] print dir, subdirs, files (and if you are desparate to use filter+lambda that works as well.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
[EMAIL PROTECTED] wrote: After the basic fact of generating the exclusion - a considerable achievement - the program should be interactive. What if the target set has thousands or millions of elements? There should be a loop-like way ('do' in Haskell, for example) to peel off the elements one-by-one and then terminate. Um...interactivity is a bit tricky in Prolog ;) As Geoffrey pointed out in his posting, the solutions are generated effectively one at a time. Following is a typical example of using the generator: generate_member( X, ... ), do_something_with( X ), fail. The underlying semantics is, roughly, 1) bind X, 2) do_something_with( X ), 3) fail, meaning reject this binding of X and backtrack. In this particular case, backtracking is tantamount to going back to 1). You can regard ( generate_member( X, ... ) ... fail ) as the equivalent of a loop construct, and do_something_with( X ) as the loop body. At any given time that the goal is being evaluated, there is only one binding for X in effect. On a side note, Haskell's do notation isn't really about loops. If you're referring to Tomasz's code, it's rather mapM_ that can sort of be thought of as looping through the list of values returned by generateNotMatching :) Cheers, Dinko -- http://mail.python.org/mailman/listinfo/python-list
Re: How to recgonize an USB device in FreeBSD?
Geoffery wrote: I want to add some applications to Freevo. Let Freevo recgonize the USB device is the one. Thank u for your answer. Have a look at 'man 5 usbd.conf' -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
Dinko Tenev wrote: Speculation: the time for building-up a smart structure to speed-up enumeration, together with the time for enumerating the set using that structure, should sum up to roughly Theta( n*|S^n| ), even with a really smart algorithm. OK, maybe not. This might be the worst case, looking at S^n - W only, but it's not quite clear what worst case means in the context of concrete implementations. Surely, one can clog the program with zillions of wildcards to test, so we can produce an arbitrarily bad case :) -- but such a case is obviously of little or no practical importance. It appears that, to make any sensible statements about performance in the relevant cases, we have to take into account the size of the pattern set used to specify W as well. [...] here's another speculation: such structure would likely take up Theta( |S^n| ) space in memory, in the worst case. ...and similarly for worst case here. Cheers, Dinko -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
http://www.doxdesk.com/img/software/py/icons.png Neat! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list
TaskQueue
I would like to get feedback on an idea I had for simplifying the use of queues with daemon consumer threads Sometimes, I launch one or more consumer threads that wait for a task to enter a queue and then work on the task. A recurring problem is that I sometimes need to know if all of the tasks have been completed so I can exit or do something with the result. If each thread only does a single task, I can use t.join() to wait until the task is done. However, if the thread stays alive and waits for more Queue entries, then there doesn't seem to be a good way to tell when all the processing is done. So, the idea is to create a subclass of Queue that increments a counter when objects are enqueued, that provides a method for worker threads to decrement the counter when the work is done, and that offers a blocking join() method that waits until the counter is zero. There's are working implementation at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475160 Here is an example: def worker(): while 1: task = q.get() do_work(task) q.task_done() # setup queue and launch worker threads q = Queue() for i in range(num_worker_threads): Thread(target=worker).start() # load the tasks for elem in tasklist: q.put(elem) # block until they are done q.join() # process with other stuff . . . There are some competing approaches. One is to attach sentinel objects to the end of the line as a way for consumer threads to know that they should shut down. Then a regular t.join() can be used to block until the consumers threads have shut-down. This approach is straight-forward, but it depends on 1) complicating the consumer logic to include sentinel detection and thread shut-down, 2) complicating the producer logic to append one sentinel for each consumer when the data stream is done, 3) actually knowing when the data stream is done. The latter is a problem in one of my programs because the consumer sometimes uses a divide-and-conquer approach, resulting in two new subtasks being loaded to the queue. IOW, the only way to know when all the inputs have been handled is to have the queue empty and all consumers inactive (i.e. processing complete). def worker(): while 1: task = q.get() if task is None: # check for sentinel return do_work(task) # setup queue and launch worker threads q = Queue() threads = [] for i in range(num_worker_threads): t = Thread(target=worker) threads.append(t) t.start() # load the tasks for elem in tasklist: q.put(elem) for i in range(num_worker_threads): q.put(None)# load sentinels # block until they are done for t in threads: t.join() # process with other stuff . . . Another approach is to set-up a second queue for results. Each consumer loads a result when it is done with processing an input. The producer or main thread then becomes responsible for matching all inputs to the corresponding results. This isn't complicated in-practice but it isn't pretty either: def worker(): while 1: task = tasks_in.get() do_work(task) tasks_out.put(None) # enqueue a None result when done with task # setup queues and launch worker threads tasks_in = Queue() tasks_out = Queue() for i in range(num_worker_threads): Thread(target=worker).start() # load the tasks n = len(tasklist) for elem in tasklist: tasks_in.put(elem) # block until they are done for i in range(n): tasks_out.get() # process with other stuff . . . This approach becomes messier if the task loading occurs at multiple points inside a more complex producer function. Also, it doesn't work well with the worker thread divide-and-conquer situation discussed above. -- http://mail.python.org/mailman/listinfo/python-list
Re: TaskQueue
Raymond Hettinger: There are some competing approaches. One is to attach sentinel objects to the end of the line as a way for consumer threads to know that they should shut down. Then a regular t.join() can be used to block until the consumers threads have shut-down. This approach is straight-forward, but it depends on 1) complicating the consumer logic to include sentinel detection and thread shut-down, Writing this observation was way more complicated than writing the code that's required to implement it :-) if task is None: break I use 'None' as the sentinel. This is a larger snippet from my own threadpool with the context of this code: def run(self): while True: task = self.workQueue.get() if task is None: break try: task.do() except: task.unhandledException() self.resultQueue.put(task) 2) complicating the producer logic to append one sentinel for each consumer when the data stream is done for i in range(self.numberOfThreads): self.workQueue.put(None) Again, more characters in your observation than in the code. 3) actually knowing when the data stream is done. def doingWork(self): return self.numberOfTasks 0 Which is possible because of: def putTask(self,task): self.workQueue.put(task) self.numberOfTasks += 1 def getTask(self): task = self.resultQueue.get() self.numberOfTasks -= 1 return task -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list
[CODE] - Python Newcomer Starting with Coding
Where can I find practical coding examples for real life coding problems? Something like a categorized solution guide? - My current problem: * create a folder * seems to be: os.mkdir(path) * obtain the path of a python package * copy the content of the package folder to the created folder alternatively (which would possibly preserve the file-attributes) * obtain the path of a python package * copy the content of the package folder to the destination folder, whlist giving a new name. I've looked in the Python 2.4 documentation, but the resulting possibilities are too much. Any suggestions welcome. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Become another user
Look at the os module: http://docs.python.org/lib/os-file-dir.html This has various functions you may find useful depending on how you want to go about it, such as chmod and chown. Correct me if I'm wrong, but doesn't this also require having a little chat with the admin to set things up so the server has permission to give away files to Joakim? Say, putting them in a common group or something? Just making the files world readable may not be the best option (which I believe is the only option otherwise). Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
Superb! How about getting them in the 2.5 release? Part of the reason why I am asking is that I am not sure what I have to do to get Win XP to use these instead of the one coming with 2.4.2. Cheers, EuGeNe -- http://mail.python.org/mailman/listinfo/python-list
Re: Python compiler
Rc wrote: But ,my question is when I start Python it is a Dos Window that opened.I think it is not possible on a XP computer? The Windows NT family, including XP, is not based on MS DOS. It still has a text more interface, and it is much better than DOS ever was. You can start that by clicking on the Start button, selecting 'run' and typing cmd.exe and pressing ENTER. You don't need that--but as you gain experience, you might start to prefer it... The keyboard is much faster than the mouse... The standard Python installer contains a graphical development environment called IDLE. Have a look at Danny Yoo's tutorial http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ Good Luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: why isn't Unicode the default encoding?
In article [EMAIL PROTECTED], Martin v. Löwis wrote: In any case, it doesn't matter what encoding the document is in: read(2) always returns two bytes. It returns *up to* two bytes. Sorry to be picky but I think it's relevant to the topic because it illustrates how it's difficult to change the definition of file.read() to return characters instead of bytes (if the file is ready to read, there will always be one or more bytes available (or EOF), but there won't always be one or more characters available). -- http://mail.python.org/mailman/listinfo/python-list
Re: [CODE] - Python Newcomer Starting with Coding
Ilias Lazaridis wrote: Where can I find practical coding examples for real life coding problems? Probably in real life code ?-) Something like a categorized solution guide? Look for the Python cookbook (google is your friend). - My current problem: * create a folder * seems to be: os.mkdir(path) I wouldn't even count this as a coding problem, except perhaps for a total CS newbie. * obtain the path of a python package import package print package.__file__ * copy the content of the package folder to the created folder import shutil help(shutil.copytree) (snip) I've looked in the Python 2.4 documentation, but the resulting possibilities are too much. ??? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: should os.walk return a list instead of a tuple?
Ministeyr wrote: Hello, os.walk doc: http://www.python.org/doc/2.4/lib/os-file-dir.html#l2h-1625 When walking top to bottom, it allows you to choose the directories you want to visit dynamically by changing the second parameter of the tuple (a list of directories). However, since it is a tuple, you cannot use filter on it, since it would mean reassigning it: for dir_tuple in os.walk('/home'): dir_tuple[1]=filter(lambda x: not x.startswith('.'), dir_tuple[1]) #do not show hidden files print dir_tuple#just print the directory and its contents in the simplest possible way Ok, you are missing 2 points here : 1/ multiple assignment. Python allows you to do things like: a, b, c = (1, 2, 3) So the canonical use of os.walk is: for dirpath, subdirs, files in os.walk(path): ... 2/ what's mutable and what is not: a tuple is immutable, but a list is not. The fact that the list is actually an element of a tuple doesn't make it immutable: t = ('A', [1, 2, 3]) t ('A', [1, 2, 3]) t[1] [1, 2, 3] # this will work t[1].append(4) t ('A', [1, 2, 3, 4]) # this won't work t[1] = [] Traceback (most recent call last): File stdin, line 1, in ? TypeError: object does not support item assignment HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
This is strange... I've been trying to access this site since yesterday, but I couldn't (Firefox can't stabilish connection with server www.doxdesk.com). However, I seem to be the only one with this problem... -- http://mail.python.org/mailman/listinfo/python-list
recursive map on nested list
Hello, I'd like to apply a function to elements of a nested list and wondered if there is anything more idiomatic and/or shorter than this recursive way: def recur_map(f, data): ... if isinstance(data, list): ... mapped_list = [] ... for i in data: ... mapped_list.append(recur_map(f, i)) ... return mapped_list ... else: ... return f(data) ... recur_map(lambda x: x*2, [[1, 2], 3, 4, [5, 6, [7, 8]]]) [[2, 4], 6, 8, [10, 12, [14, 16]]] Thanks, alex -- http://mail.python.org/mailman/listinfo/python-list
Nuxeo Calendar Server released in version 2
Nuxeo Calendar Server released in version 2 --- Nuxeo releases version 2 of it's calendar products for Python and Zope, updating to the latest technology frameworks. Nuxeo proudly presents version 2 of its calendar framework. The calendar framework is a set of advanced, flexible calendar components for Python and Zope. CalCore is a calendar component for Python. It allows the Python developer do write advanced calendar applications either using their own event storage or integrating with external calendar servers. Features of the CalCore include among others: * Support for making private calendars, shared calendars, resource booking and more, * invitation workflow, * iCalendar import and export, * meeting support, including helper functions to look for free time, * recurring event support, * etc. CalZope is the Zope module that provides a web user interface for CalCore. Features include: * an internationalized web user interface, * integration with iCalendar clients (Apple iCal, Mozilla Sunbird, ...) using the iCalendar and http, * an advanced meeting helper that allows you to search for free time amongst the invited users, * etc. The changes between version 1 and version 2 have been mostly in CalZope, where we now have started using more of the techniques available through the tighter integration of Zope 3s component architecture in Zope 2. * Local utilities instead of portal tools, providing for an easier installation and greater portability to various non-CMF frameworks, such as Silva and Zope 3. * zope.i18n for internationalization providing translations of CalZope without additional tools such as Localizer or PTS. CalZope will in a standard Zope now be automaticaly translated into english, french and more, and you can easily add your own translations. * Install script, so you can easily try CalZope out in a pure Zope environment. * And of course, various minor bugfixes. For CPS users, all these modules are a part of the CPSGroupware bundle, together with the CPSMailAccess webmail client. For more functional and technical information, see the Calendar Server web site: http://www.cps-project.org/sections/projects/calendar_server CalCore v2 can be downloaded here: http://www.cps-project.org/static/misc/CalCore-bundle-2.0.1.tgz CalZope v2 can be downloaded here: http://www.cps-project.org/static/misc/CalZope-bundle-2.2.2.tgz CPSGroupware 1.9.0 for CPS 3.4.0 can be downloaded here: http://www.cps-project.org/static/misc/CPSGroupware-1.9.0-1.tgz If you'd like to help with development or porting to other platforms, please join the cps-devel mailing list at http://lists.nuxeo.com/mailman/listinfo/cps-devel Enjoy, S. -- Stefane Fermigier - CEO, Nuxeo SAS - http://www.nuxeo.com/en/ Open Source ECM provider - http://www.cps-project.org Free soft. developer - http://blogs.nuxeo.com/sections/blogs/fermigier -- http://mail.python.org/mailman/listinfo/python-list
Re: TaskQueue
Raymond Hettinger wrote: I would like to get feedback on an idea I had for simplifying the use of queues with daemon consumer threads Sometimes, I launch one or more consumer threads that wait for a task to enter a queue and then work on the task. A recurring problem is that I sometimes need to know if all of the tasks have been completed so I can exit or do something with the result. If each thread only does a single task, I can use t.join() to wait until the task is done. However, if the thread stays alive and waits for more Queue entries, then there doesn't seem to be a good way to tell when all the processing is done. Hmm. How about this: the Producer can cause an exception to be raised in any Consumers waiting on the Queue, or vice-versa. I remember encountering a similar problem when writing a slide viewer that prefetched and slides. I wanted to have the ability to terminate the slide show early. But what you have is five slides sitting in the Queue when the user quits (the UI was in the consumer thread, of course). Now how do you signal the Producer thread to exit? It seemed to me that allowing one thread to raise an exception in another was the most straightforward way to do this. (In my case is was the Consumer raising it in the Producer.) I briefly considered a subclass of Queue to implement it, but it was too difficult a thing that I would have wanted to work on at that point in time. I implemented some workaround that I don't remember, and forgot about the issue until your post. But yeah, something like an InterruptableQueue might be a nice thing to have. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
TKinter problem
To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder. My code writes to a text file 'table.txt', and 'table.txt' is displayed in the GUI. The user can generate new data at the click of a button which re-writes 'table.txt', but I can only add the new table to the GUI window rather than 'update' the existing one. Any assistance would be much appreciated, Regards, Christian Wood. Part III Aerospace Engineering University of Southampton, UK. ## from Tkinter import * #Tkinter User Interface class MoC: def __init__(self, master): frame = Frame(master, width=600, height=800, bd=1) frame.pack() #Button frame iframe4 = Frame(frame, bd=2, relief=SUNKEN) #Using this button below, I want to update the text box in iframe5. Button(iframe4, text='Display table.txt', command=self.DisplayUpdate).pack(side=LEFT, padx=5) Button(iframe4, text='Quit', command=self.quit).pack(side=LEFT, padx=5) iframe4.pack(expand=1, fill=X, pady=10, padx=5) #Text box frame iframe5 = Frame(frame, bd=2, relief=SUNKEN) text=Text(iframe5, height=10, width =70) fd = open('table.txt') #table.txt must be in the same folder lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) #Command definitions def quit(self): root.destroy() def DisplayUpdate(self): #The command definition used to update the display. #Could I insert a line here to remove the existing frame/text box first? = iframe5 = Frame(root, bd=2, relief=SUNKEN) text = Text(iframe5, height=10, width =70) fd = open('table.txt') lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) root = Tk() root.option_add('*font', ('arial', 10)) all = MoC(root) root.title('2D Method of Characteristics') root.update root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
Luis M. González wrote: This is strange... I've been trying to access this site since yesterday, but I couldn't (Firefox can't stabilish connection with server www.doxdesk.com). However, I seem to be the only one with this problem... You could try using a proxy (one of the anonymous proxies would do the job). Tim Parkin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python compiler
Rc wrote: DaveM [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] On Thu, 16 Mar 2006 13:34:14 +0100, Méta-MCI [EMAIL PROTECTED] wrote: Après, vous pourrez aussi fréquenter le newsgroup : fr.comp.lang.python qui a l'avantage d'être en français. But perhaps he's a Flemish speaker - are you trying to start a riot? DaveM Yes,I'm a Flemish speaker, I have been to school in the evening to study Englisch and also now for the last year I'm study French. To improve my English it's maybe good to work with English newsgroupes. Maybe... I'm not looking for a riot,because I don't understand the word. This one was for Michel (Meta-MCI), not for you. And the french for riot is émeute. By the way, in case to learn Python,they Who ?-) told me it's the most esay language to start. Well, it was, some years ago. It's still pretty easy to get started with, but there are more and more advanced features, and lot of subtle details that are quite obvious when you're a seasonned pro, but certainly not for a newbie programmer. But still, Python is certainly one of the most easy languages for beginners - far easier than C , far more funny than Java, far more usable than VB. Also - and that can really make a difference - the community is usually really helpful and well-mannered. But ,my question is when I start Python it is a Dos Window that opened. Yes, that's the Python interactive shell - a command line utility. If you want a GUI, try IDLE, that should be installed with Python. Also, and IIRC, giving your python source files the .pyw extension should avoid the the opening of a dos window when you try to execute the file. A couple of resources you may find useful when you'll be done with the official tutorial: http://www.ibiblio.org/obp/thinkCSpy/ (tutorial for CS newbies) http://www.diveintopython.org (more advanced python tutorial) and of course the tutor maling list: http://mail.python.org/mailman/listinfo/tutor HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: [CODE] - Python Newcomer Starting with Coding
On 21/03/06, Ilias Lazaridis [EMAIL PROTECTED] wrote: Where can I find practical coding examples for real life coding problems? Something like a categorized solution guide? This sounds quite a lot like PLEAC. It certainly contains a lot that you would find useful. http://pleac.sourceforge.net/pleac_python/index.html Also, try using the python-tutor list. It's a lot more helpful for questions like these. My current problem: * create a folder * seems to be: os.mkdir(path) Try using the Path module. It makes all that stuff much easier: http://www.jorendorff.com/articles/python/path/ Ed -- http://mail.python.org/mailman/listinfo/python-list
Re: Spidering Hacks for Python, not Perl
Duncan Booth wrote: Enigma Curry wrote: I've been looking for similar stuff recently. I haven't found much, but this is the list of links I've come across so far: http://awaretek.com/nowak/mygale.html http://cheeseshop.python.org/pypi/spider.py/0.5 http://sig.levillage.org/?p=599 http://www.robertblum.com/articles/2005/11/21/challenge-map-i-python-web-scraping http://www.rexx.com/~dkuhlman/quixote_htmlscraping.html http://sig.levillage.org/?p=588 http://sourceforge.net/projects/goog-kongulo/ -- http://mail.python.org/mailman/listinfo/python-list
Convert (sorted) list of dics to nested list ?
Hi - I want to take something like ... lstIn = [] lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 10, 'LEA_AUTOID': 1000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2003}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3002}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3003}) lstIn.append({'COM_AUTOID': 2, 'PRG_AUTOID': 110, 'LEA_AUTOID': 4000}) ... and produce something like ... sampleOut = [[1,[10,1000]],[1,[11,[2000,2001,2003]]],[1,[12,[3000,3001,3002,3003]]],[2,[110,4000]] Well I've now been around the block a few times with this one and I'm still frowning !! In the process my code has become uglier and uglier - I'm sure there must be quite an elegant way of dealing with it - could anyone give me a push in the right direction ? Just to provide some motivation here - I should just say that this is cut down test case - the real problem involves creating a Javascript structure which in turn defines a three level menu. The resulting JS will be something like this, I think you can see how the nested loops get into it.: var MENU_ITEMS = [ { pos:'relative', leveloff:[b,a], itemoff:[d,c], size:[e,f], ... }, { ...Item 1... }, { ...Item 2... , sub:[ { ...level format... }, { ...Item 1... }, { ...Item 2... }, { ...Item 3... , sub:[ { ...level format... }, { ...Item 1... }, { ...Item 2... }, { ...Item 3... }, { ...Item 4... } ] }, { ...Item 4... }, ] }, { ...Item 3... } ]; Interested to hear of any smart/elegant ideas. thanks Richard. -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
3KWA skrev: Superb! How about getting them in the 2.5 release? Part of the reason why I am asking is that I am not sure what I have to do to get Win XP to use these instead of the one coming with 2.4.2. That`s easy: control panel Folder options File Types *scroll to py file* advanced change icon and youre done. -- http://mail.python.org/mailman/listinfo/python-list
Re: TaskQueue
Rene Pijlman wrote: 2) complicating the producer logic to append one sentinel for each consumer when the data stream is done for i in range(self.numberOfThreads): self.workQueue.put(None) Or, you could just put one sentinel in the Queue, and subclass the Queue's _get method not to take the sentinel out. It might help keep bookkeeping down (and it seems Raymond was in a situation where keeping track of threads wasn't so easy). BTW, for sentinels, I recommend creating one using: sentinel = object() Because, although it's not applicable to your example, sometimes None is an object you want to pass through. (I think Alex Martelli came up with that one.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Spidering Hacks for Python, not Perl
gene tani wrote: Duncan Booth wrote: Enigma Curry wrote: a couple more http://cheeseshop.python.org/pypi/Orchid/1.0 http://cheeseshop.python.org/pypi/webstemmer/0.5.0 -- http://mail.python.org/mailman/listinfo/python-list
Re: recursive map on nested list
I think for most purposes a program like this is short enough: def recur_map2(fun, data): if hasattr(data, __iter__): return [recur_map2(fun, elem) for elem in data] else: return fun(data) data = [set([1, 2]), [3], 4, [5, {6:4}, [7, 8]]] print recur_map2(lambda x: x*2, data) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: what's the general way of separating classes?
Ben Cartwright wrote: Er? Surely you've used C#'s using statement? Well yes, but really that's very different. 'Using' statements are solely for the purpose of convenience so you don't have to qualify classes with namespaces. They aren't necessary to actually *use* those classes. (The true 'include' functionality comes in the References, which are shared across all files on account of them being compiled together.) You can just refer to the classes from any other file. Iff they're in the same namespace. You can have multiple namespaces in the same .NET assembly, you know. Yes, true. I was just thinking of a program all contained in one namespace. -- http://mail.python.org/mailman/listinfo/python-list
Re: TaskQueue
Carl Banks wrote: But yeah, something like an InterruptableQueue might be a nice thing to have. Ok, I see now that InterruptableQueue wouldn't help the OP, though it would have helped me in my situation, so it'd still be a good idea. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert (sorted) list of dics to nested list ?
[EMAIL PROTECTED] wrote: Hi - I want to take something like ... lstIn = [] lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 10, 'LEA_AUTOID': 1000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2003}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3002}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3003}) lstIn.append({'COM_AUTOID': 2, 'PRG_AUTOID': 110, 'LEA_AUTOID': 4000}) ... and produce something like ... sampleOut = [[1,[10,1000]],[1,[11,[2000,2001,2003]]],[1,[12,[3000,3001,3002,3003]]],[2,[110,4000]] Well I've now been around the block a few times with this one and I'm still frowning !! In the process my code has become uglier and uglier - I'm sure there must be quite an elegant way of dealing with it - could anyone give me a push in the right direction ? Just to provide some motivation here - I should just say that this is cut down test case - the real problem involves creating a Javascript structure which in turn defines a three level menu. The resulting JS will be something like this, I think you can see how the nested loops get into it.: var MENU_ITEMS = [ { pos:'relative', leveloff:[b,a], itemoff:[d,c], size:[e,f], ... }, { ...Item 1... }, { ...Item 2... , sub:[ { ...level format... }, { ...Item 1... }, { ...Item 2... }, { ...Item 3... , sub:[ { ...level format... }, { ...Item 1... }, { ...Item 2... }, { ...Item 3... }, { ...Item 4... } ] }, { ...Item 4... }, ] }, { ...Item 3... } ]; Interested to hear of any smart/elegant ideas. thanks Richard. Might not be 'elegant', but at least it works. -Larry lstIn = [] lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 10, 'LEA_AUTOID': 1000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2003}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3002}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 12, 'LEA_AUTOID': 3003}) lstIn.append({'COM_AUTOID': 2, 'PRG_AUTOID': 110, 'LEA_AUTOID': 4000}) c=COM_AUTOID p=PRG_AUTOID l=LEA_AUTOID lastc=None lastp=None sampleOut=[] for entry in lstIn: C=entry[c] P=entry[p] L=entry[l] if C != lastc or P != lastp: sampleOut.append([C,[P,L]]) else: sampleOut[-1:][0][1].append(L) lastc=C lastp=P print sampleOut=, sampleOut -- http://mail.python.org/mailman/listinfo/python-list
Module import information
List: Is it possible to determine the name of the module that invoked import from within the imported module? Thanks, Eric -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: pywinauto 0.3.0 released - now localization proof
[EMAIL PROTECTED] wrote: ANN: pywinauto 0.3.0 released - now localization proof Hi, The 0.3.0 release of pywinauto is now available. pywinauto is a set of open-source (LGPL) modules for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from 0.2.5: 0.3.0 Added Application data - now useful for localization testing -- 20-Mar-2006 * Added automatic Application data collection which can be used when running the same test on a different spoken language version. Support is still preliminary and is expected to change. Please treat as early Alpha. If you have a different language version of Windows then you can try this out by running the notepad_fast.py example with the langauge argument e.g. :: examples\notepad_fast.py language This will load the application data from the supplied file notepad_fast.pkl and use it for finding the right menu items and controls to select. * Test implementation to make it easier to start using an application. Previously you needed to write code like :: app = Application().connect_(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) 1st change was to implement static methods ``start()`` and ``connect()``. These methods return a new Application instance so the above code becomes:: app = Application.connect(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) I also wanted to make it easier to start working with a simple application - that may or may not have only one dialog. To make this situation easier I made ``window_()`` not throw if the application has not been ``start()ed`` or ``connect()ed`` first. This leads to simpler code like:: app = Application() app.Find.Close.Click() app.NotePad.MenuSelect(File-Exit) What happens here is that when you execute any of Application.window_(), Application.__getattr__() or Application.__getitem__() when the application hasn't been connected or started. It looks for the window that best matches your specification and connects the application to that process. This is extra functionality - existing connect_() and start_() methods still exist * Fixed HwndWrapper.SetFocus() so that it would work even if the window was not in the foreground. (it now makes the window foreground as well as giving it focus). This overcomes a restriction in Windows where you can only change the foreground window if you own the foreground window. * Changed some 2.4'isms that an anonymous commenter left on my blog :-) with these changes pywinauto should run on Python 2.3 (though I haven't done extensive testing). * Commented out controls.common_controls.TabControlWrapper.GetTabState() and TabStates() as these did not seem to be returning valid values anyway. * Fixed documentation issues were parts of the documentation were not getting generated to the HTML files. * Fixed issue where MenuSelect would sometimes not work as expected. Some Menu actions require that the window that owns the menu be active. Added a call to SetFocus() before selecting a menu item to ensure that the window was active. * Fixed Bug 1452832 where clipboard was not closed in clipboard.GetData() * Added more unit tests now up to 248 from 207 If you want to follow this project then please sign up to the mailing list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users Thanks Mark i just tried the notepad demo and it's very nice. the only thing was in the demo it shows one Click() method to close the notepadabout dialog. but for me on windows xp media edition, it took two Click() methods. the first click clearly had the button depressed and the second click released the button back up. is this a bug in 0.3.0? or is it the new way of doing it... two clicks for each button? also, i would be really nice if the FAQ mentioned where you could get free or opensourced spy utilities so you could spy on controls and get their id values or internal names. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: Module import information
Eric White wrote: Is it possible to determine the name of the module that invoked import from within the imported module? Almost anything is possible in Python. On the other hand, some things are probably impractical, and others ill-advised. Perhaps you can describe your requirements, *why* you want to do this, to provide some context for the answers. Also, consider that the effect of the import statement is different after the first import. When an already-imported module is imported by another module (i.e. the second time import xxx is executed for your module), the code is not reloaded from the .pyc file, but instead a reference is retrieved from sys.modules where it was cached when the first import was executed. What are you expecting to happen in that case? -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: recursive map on nested list
Uglier than yours, but down to two lines: def recur_map(f, data): return [ not hasattr(x, __iter__) and f(x) or recur_map(f, x) for x in data ] -- http://mail.python.org/mailman/listinfo/python-list
Encoding newlines in XML?
*argh!* I hate XML! There, now that that's off my chest... I am trying to save Python code as attributes of an XML tag with xml.dom.minidom machinery. The code, predicatbly enough, contains newlines. If I do nothing to my program text, upon output I get XML which looks like this: SomeTag text=def _f(): return 3 / When that is later parsed, the newlines are replaced by spaces. That's clearly no good. I verified manually that if I changed the above to SomeTag text=def _f():#10;return 3#10;/ when read in, the entities are replaced by newlines and the function is restored to its normal indented, multiline self. No problem, I thought, just update the call the setAttribute() on the node: node.setAttribute(key, str(val).replace(\n, #10;)) Alas, that leaves me with this tag: SomeTag text=def _f():amp;#10;return 3amp;#10;/ which doesn't work for obvious reasons. Is there a way to achieve XML attribute newline nirvana? Please show me the path to enlightenment. Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: TKinter problem
C D Wood wrote: To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder. My code writes to a text file 'table.txt', and 'table.txt' is displayed in the GUI. The user can generate new data at the click of a button which re-writes 'table.txt', but I can only add the new table to the GUI window rather than 'update' the existing one. Any assistance would be much appreciated, Regards, Christian Wood. Part III Aerospace Engineering University of Southampton, UK. ## from Tkinter import * #Tkinter User Interface class MoC: def __init__(self, master): frame = Frame(master, width=600, height=800, bd=1) frame.pack() #Button frame iframe4 = Frame(frame, bd=2, relief=SUNKEN) #Using this button below, I want to update the text box in iframe5. Button(iframe4, text='Display table.txt', command=self.DisplayUpdate).pack(side=LEFT, padx=5) Button(iframe4, text='Quit', command=self.quit).pack(side=LEFT, padx=5) iframe4.pack(expand=1, fill=X, pady=10, padx=5) #Text box frame iframe5 = Frame(frame, bd=2, relief=SUNKEN) text=Text(iframe5, height=10, width =70) fd = open('table.txt') #table.txt must be in the same folder lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) #Command definitions def quit(self): root.destroy() def DisplayUpdate(self): #The command definition used to update the display. #Could I insert a line here to remove the existing frame/text box first? = iframe5 = Frame(root, bd=2, relief=SUNKEN) text = Text(iframe5, height=10, width =70) fd = open('table.txt') lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) root = Tk() root.option_add('*font', ('arial', 10)) all = MoC(root) root.title('2D Method of Characteristics') root.update root.mainloop() What you want probably looks like this: from Tkinter import * class MoC: def __init__(self, master): frame = Frame(master, width=600, height=800, bd=1) frame.pack() iframe4 = Frame(frame, bd=2, relief=SUNKEN) Button(iframe4, text='Display table.txt', command=self.DisplayUpdate).pack(side=LEFT, padx=5) Button(iframe4, text='Quit', command=self._quit).pack(side=LEFT, padx=5) iframe4.pack(expand=1, fill=X, pady=10, padx=5) iframe5 = Frame(frame, bd=2, relief=SUNKEN) self.text=Text(iframe5, height=10, width =70) # read the file in the update function; create Text Scrollbar only once self.text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=self.text.yview) sb.pack(side=RIGHT, fill=Y) self.text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) self.DisplayUpdate() def _quit(self): # quit is a keyword in python 2.4 IDE root.destroy() def DisplayUpdate(self): fd = open('table.txt') lines = fd.read() fd.close() self.text.config(state=NORMAL) self.text.delete(1.0, END) self.text.insert(END, lines) self.text.config(state=DISABLED) # previous 4 lines are to make the text READONLY, see more in: # http://www.pythonware.com/library/tkinter/introduction/x8309-patterns.htm root = Tk() root.option_add('*font', ('arial', 10)) all = MoC(root) root.title('2D Method of Characteristics') root.update root.mainloop() ezd -- http://mail.python.org/mailman/listinfo/python-list
python on blackberry?
i use a blackberry as my pda, and was wondering fi there was anything going on in the python world for blackberry.. i googled a bit, but it seems like most of the area is untapped.. anyone else have anything they know about? thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
It's easier than that in this case. Just unpack the icons in yout Python directory over the top of the existing ones. The change should get picked up the next time you log on. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list
How can I compare if 2 files has duplicate entries in python?
I am new to python. How can I compare if 2 files has duplicate entries in python? Is there an example for that? What if the files are big and I don't want to read the whole file in memory. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: user-supplied locals dict for function execution?
Lonnie Princehouse wrote: Occaisionally, the first two lines of The Zen of Python conflict with one another. An API I'm working on involves a custom namespace implementation using dictionaries, and I want a pretty syntax for initializing the custom namespaces. The fact that these namespaces are implemented as dictionaries is an implementation detail, and I don't want the users to access them directly. I find the implicit update syntax to be much cleaner: This can be easier achieved with a custom metaclass: class MetaNamespace(type): ... def __new__(metaclass, name, bases, dict): ... try: ... Namespace ... except NameError: ... return type.__new__(metaclass, name, bases, dict) ... dict.pop('__module__', None) ... return dict ... class Namespace(object): ... __metaclass__ = MetaNamespace ... Now whenever you want to create your dictionary you simply declare a class that inherits from Namespace: class MyNamespace(Namespace): ... x = 5 ... y = 'spam' ... z = 'eggs' ... print sorted(MyNamespace.items()) [('x', 5), ('y', 'spam'), ('z', 'eggs')] Ziga -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style Python icons
Thanks a lot! (Still think 2.5 could have spunky new icons:) EuGeNe -- http://mail.python.org/mailman/listinfo/python-list
Command line arguments question (Windows XP)
Hi, I run simple script # u.py import sys print 'args',sys.argv in Command Prompt window, with 2 command lines on 2 PCs: # Case (1L): C:\tmp u.py a b c args ['C:\\tmp\\u.py'] # Case (1D): C:\tmp u.py a b c args ['C:\\tmp\\u.py', 'a', 'b', 'c'] # Cases (2L) (2D): C:\tmp C:\Python24\python u.py a b c args ['u.py', 'a', 'b', 'c'] How to explain this ? Particularly case (1L) without arguments. Both PCs have Python 2.4.2 and Windows XP SP2. The only difference I see is XP 'Home Edition' on Desktop (D) and XP 'Professional' on Laptop (L). Eugene -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I use a conditional in a variable declaration?
Ron Adam [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I want the equivalent of this: if a == yes: answer = go ahead else: answer = stop in [a] more compact form: I sometimes find it useful to do: answers = {True: go ahead, False: stop} answer = answers[a == yes] In this particular case, you can get it even more compact as answer = {yes: go ahead}.get(a, stop) but that's sacrificing elegance and readability for bytes. When I find myself with code like the OP's, I usually rewrite as: answer = stop if a == yes: answer = go ahead -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: ** Operator
Christoph Zwerschke wrote: Christoph Zwerschke wrote: Kent Johnson wrote: The way to make this change happen is to submit a bug report with your suggested change. See the link at the bottom of the above page to find out how. I know, but I wanted to see at least one person assenting before doing so. Anyway, I took your words as assent and filed a bug report now ;-) ... which was promptly rejected. ... but now it has been checked in by somebody else anyway. The Python gods sometimes move in mysterious ways ;-) -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding newlines in XML?
[EMAIL PROTECTED] wrote: *argh!* I hate XML! There, now that that's off my chest... I think, rather, that you hate XML libraries. Which is perfectly understandable. I am trying to save Python code as attributes of an XML tag with xml.dom.minidom machinery. The code, predicatbly enough, contains newlines. If I do nothing to my program text, upon output I get XML which looks like this: SomeTag text=def _f(): return 3 / When that is later parsed, the newlines are replaced by spaces. That's clearly no good. I verified manually that if I changed the above to SomeTag text=def _f():#10;return 3#10;/ when read in, the entities are replaced by newlines and the function is restored to its normal indented, multiline self. Other libraries seem to get this right. In [89]: from lxml import etree In [90]: e = etree.Element('SomeTag', text=def _f():\n return 3\n) In [93]: e.attrib Out[93]: {'text': 'def _f():\n return 3\n'} In [94]: etree.dump(e) SomeTag text=def _f():#10; return 3#10;/ In [96]: etree.dump(etree.XML('SomeTag text=def _f():#10; return 3#10;/')) SomeTag text=def _f():#10; return 3#10;/ I'll bet good money that ElementTree also gets this right. -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
RE: Command line arguments question (Windows XP)
[ezd] | # u.py | import sys | print 'args',sys.argv | | in Command Prompt window, with 2 command lines on 2 PCs: | | # Case (1L): | C:\tmp u.py a b c | args ['C:\\tmp\\u.py'] | | # Case (1D): | C:\tmp u.py a b c | args ['C:\\tmp\\u.py', 'a', 'b', 'c'] Almost certainly means that the association between .py files and the python executable has been set up differently. Try typing (as the command shell): assoc .py = .py=Python.File ftype Python.File = python.file=C:\Python24\python.exe %1 %* Now if they don't look like that, in particular if the second one looks like this: python.file=C:\Python24\python.exe %1 then the extra parameters (everything after the script filename) won'e get passed along to the interpreter. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Can XML-RPC performance be improved?
I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction). And this is using SGMLOP for parsing -- I dread to think what it would be like with a slower parser. Anyone (Fredrik?) got any good ideas for tackling this problem? -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: user-supplied locals dict for function execution?
Lonnie Princehouse [EMAIL PROTECTED] wrote: ... @namespace # indicates function should be executed in namespace def initialize_namespace(): x = 5 # versus the alternative __namespace__ = { 'x' : 5, } Hm, what about: ns = namespace(x=5) and perhaps later ns.update(y=6) if you need to add a name to ns? You can start with 'namespace=dict' (in whatever ubernamespace you'd define your @namespace decorator above) and change it later in any way you wish -- and it's vastly less blackmagical, too. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I compare if 2 files has duplicate entries in python?
[EMAIL PROTECTED] wrote: I am new to python. How can I compare if 2 files has duplicate entries in python? Is there an example for that? What if the files are big and I don't want to read the whole file in memory. Thank you. You need to supply more info. If you just want to determine if two files are exactly alike you can just calculate the md5 checksum or each file. If they are different, the files are different. See: http://docs.python.org/lib/module-md5.html If you want to compare files line by line see following: http://docs.python.org/lib/module-difflib.html -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction). And this is using SGMLOP for parsing -- I dread to think what it would be like with a slower parser. Anyone (Fredrik?) got any good ideas for tackling this problem? CORBA. Or TCP/IP directly. I know that isn't really the answer you're looking for - but there is an overhead parsing XML, and that can't go away. From what I read at SGMLOP's site I doub't that you can get much faster - because speed comes with sacrificing standard compliancy, which it already seems to do. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Module import information
Peter: Thanks for the reply. Consider the following situation: A set of variable names is defined along with a list of possible values for each. A second set of variable names is defined along with an _expression_ for generating a value for each. For each possible permutation of variables from the first set, a python script is created that contains commands that initialize the variable set with the permuted values. A second python script is created that contains commands for connecting to a database and storing the values of the second set of variables after running the associated _expression_ for each. We would like to be able to use the scripts above to drive a python script containing a system of equations specified at run time and to store the results. This master script contains the following calls: import somemodule # do stuff ... # initialize permuted variables somemodule.init() # do more stuff ... # store results somemodule.save() # do more stuff ... Etc. We would like for the call to init to initialize variables in the context of the master script. To do this inside somemodule we use the sys.modules dictionary to find a reference to the master module by name and initialize variables at this reference. What I would like to know if it is arbitrarily possible to walk the import hierarchy from any point. It is not apparent that python's optimization of subsequent imports of the same module is relavent.On 3/21/06, Peter Hansen [EMAIL PROTECTED] wrote:Eric White wrote: Is it possible to determine the name of the module that invoked import from within the imported module?Almost anything is possible in Python.On the other hand, some thingsare probably impractical, and others ill-advised.Perhaps you candescribe your requirements, *why* you want to do this, to provide some context for the answers.Also, consider that the effect of the import statement is differentafter the first import.When an already-imported module is imported byanother module (i.e. the second time import xxx is executed for your module), the code is not reloaded from the .pyc file, but instead areference is retrieved from sys.modules where it was cached when thefirst import was executed.What are you expecting to happen in that case? -Peter--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Perhaps there's a hardware solution? Could you run more servers in parallel? Or have some sort of load distribution system? (Just some generic server tips, I don't know much about XML-RPC) -Greg On 3/21/06, Diez B. Roggisch [EMAIL PROTECTED] wrote: Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction). And this is using SGMLOP for parsing -- I dread to think what it would be like with a slower parser. Anyone (Fredrik?) got any good ideas for tackling this problem? CORBA. Or TCP/IP directly. I know that isn't really the answer you're looking for - but there is an overhead parsing XML, and that can't go away. From what I read at SGMLOP's site I doub't that you can get much faster - because speed comes with sacrificing standard compliancy, which it already seems to do. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list -- Gregory Piñero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) -- http://mail.python.org/mailman/listinfo/python-list
creating website script in Myghty
I'm learning Myghty from few weeks and now I'm making a simple forum script ;) and I have problem finding few things in python that I need: - how to strip all HTML tags leaving the text / strip all code (python/other) from a string? - how to highlight a python/html/other code (result in HTML code)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding newlines in XML?
Robert Kern wrote: Other libraries seem to get this right. In [89]: from lxml import etree In [90]: e = etree.Element('SomeTag', text=def _f():\n return 3\n) In [93]: e.attrib Out[93]: {'text': 'def _f():\n return 3\n'} In [94]: etree.dump(e) SomeTag text=def _f():#10; return 3#10;/ In [96]: etree.dump(etree.XML('SomeTag text=def _f():#10; return 3#10;/')) SomeTag text=def _f():#10; return 3#10;/ I'll bet good money that ElementTree also gets this right. well, not quite: import cElementTree as ET e = ET.Element('SomeTag', text=def _f():\n return 3\n) e Element 'SomeTag' at 0091A320 e.attrib {'text': 'def _f():\n return 3\n'} ET.tostring(e) 'SomeTag text=def _f():\n return 3\n /' ET.tostring(ET.XML(ET.tostring(e))) 'SomeTag text=def _f(): return 3 /' ET.tostring(ET.XML(ET.tostring(e).replace(\n, #10;))) 'SomeTag text=def _f():\n return 3\n /' I don't recommend putting non-trivial formatted stuff in attributes (the resulting files look really messy, and not all parsers support it), but the serializer should be fixed. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: TaskQueue
Carl Banks: Rene Pijlman: for i in range(self.numberOfThreads): self.workQueue.put(None) Or, you could just put one sentinel in the Queue, and subclass the Queue's _get method not to take the sentinel out. Ah yes, clever trick. But you'd have to worry about thread-safety of your subclass though. BTW, for sentinels, I recommend creating one using: sentinel = object() Because, although it's not applicable to your example, sometimes None is an object you want to pass through. (I think Alex Martelli came up with that one.) You mean this post, I guess: http://mail.python.org/pipermail/python-list/2004-October/244750.html I dunno, but I cannot think of a better way to say this has no possible use than to pass None. Place yourself in the position of someone who doesn't know exactly what object() is and who encounters it in the code. I've just spent 5 minutes trying to find some reference information and I gave up (object is a lousy search word). -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I compare if 2 files has duplicate entries in python?
[EMAIL PROTECTED]: I am new to python. How can I compare if 2 files has duplicate entries in python? What is an 'entry'? -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Sion Arrowsmith: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML http://xmlsucks.org/ Anyone got any good ideas for tackling this problem? cPickle. http://docs.python.org/lib/module-cPickle.html -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime iso8601 string input
aurora I agree. I just keep rewriting the parse method again and again. aurora def parse_iso8601_date(s): aurora Parse date in iso8601 format e.g. 2003-09-15T10:34:54 and aurora returns a datetime object. aurora ... Why not dt = datetime.datetime(*time.strptime(s, %Y-%m-%dT%H:%M:%S)[0:6]) ? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction). And this is using SGMLOP for parsing -- I dread to think what it would be like with a slower parser. Anyone (Fredrik?) got any good ideas for tackling this problem? the cElementTree unmarshaller on this page http://effbot.org/zone/element-iterparse.htm#incremental-decoding is a bit faster than the one in xmlrpclib. (to get more performance, you probably need a library that allows you to register decoders on the C level.) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Sion Arrowsmith wrote: shovel huge amounts of data That right there basically takes XML-RPC off the table as a viable solution. No matter how much fine tuning you try large amounts of data don't bode well using XML-RPC. The other posted alternatives are certainly worth a shot. From CORBA to cPickle to even a basic TCP socket connection would be more efficient. I have used XML-RPC for very small recordset transfers but I wouldn't use it for anything large. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating website script in Myghty
piotr maliñski wrote: I'm learning Myghty from few weeks and now I'm making a simple forum script ;) and I have problem finding few things in python that I need: - how to strip all HTML tags leaving the text http://effbot.org/zone/re-sub.htm#strip-html might be helpful. strip all code (python/other) from a string? not sure what this means. - how to highlight a python/html/other code (result in HTML code)? http://www.google.com/search?q=colorize+python /F -- http://mail.python.org/mailman/listinfo/python-list
Installing PyExcelerator to write Excel files from Python
I downloaded PyExcelerator.zip as I need to write some data into Excel files, and tried unsuccessfully to install it. I unzipped the files into C:/Python24/Lib/site-packages/PyExcelerator, and in a python command line window typed os.chdir(C:/Python24/Lib/site-packages/PyExcelerator) followed by python ./setup.py install exactly as stated in README.txt. However all I get is a SyntaxError. I then tried various combinations - with and without enclosing quotes, with and without ./, and in all cases I get a SyntaxError. Has anyone installed this program successfully? If so, what's the magic ingredient for a successful install? Thanks in advance Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyExcelerator to write Excel files from Python
[EMAIL PROTECTED] wrote: I downloaded PyExcelerator.zip as I need to write some data into Excel files, and tried unsuccessfully to install it. I unzipped the files into C:/Python24/Lib/site-packages/PyExcelerator, and in a python command line window typed os.chdir(C:/Python24/Lib/site-packages/PyExcelerator) followed by python ./setup.py install exactly as stated in README.txt. However all I get is a SyntaxError. I then tried various combinations - with and without enclosing quotes, with and without ./, and in all cases I get a SyntaxError. Has anyone installed this program successfully? If so, what's the magic ingredient for a successful install? use a windows *command interpreter* window, instead of typing windows commands into a Python interpreter. (if you cannot find it in your start menu, select run... and run the cmd command). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction). And this is using SGMLOP for parsing -- I dread to think what it would be like with a slower parser. Anyone (Fredrik?) got any good ideas for tackling this problem? CORBA. Or TCP/IP directly. snip Beware, CORBA marshaling/unmarshaling can be similarly deadly, especially if you are passing Any's and have to marshal complex type codes. But if you are just sending arrays of octets, or strings of chars, then CORBA marshal/unmarshal will be quite fast. Of course, something will have to convert that array to meaningful data *somewhere*! You can't really eliminate software complexity, you can only move it around. (not original, I'm quoting Chris Stone, founder of the OMG. Also from Chris Stone - I finally came up with a good definition for middleware. Middleware is the software nobody wants to pay for.) -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Diez Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML ... Diez CORBA. Or TCP/IP directly. I know that isn't really the answer Diez you're looking for - but there is an overhead parsing XML, and Diez that can't go away. Ah, but if both ends of the pipe happen to be running Python, you can cheat. ;-) Run your list through marshal.dumps() before passing it to xmlrpclib, then undo the marshalling on the other end. biglist = [abc] * 50 biglist = [biglist] * 50 import xmlrpclib import marshal x = xmlrpclib.dumps((biglist,)) len(x) 92331 x.count() 10310 y = xmlrpclib.dumps((marshal.dumps(biglist),)) len(y) 20324 y.count() 8 If you can swing it, I'd be willing to bet you a beer your XML parsing time will all but disappear. If you're not using xmlrpclib with some sort of C helper (like sgmlop), try that as well. Big difference parsing XML in C and Python. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: ** Operator
... which was promptly rejected. ... but now it has been checked in by somebody else anyway. The Python gods sometimes move in mysterious ways ;-) The tracker item reviewers are people, including me, with different knowledge, viewpoints and experiences, who sometimes disagree. -- http://mail.python.org/mailman/listinfo/python-list
Re: Module import information
Eric White wrote: Peter: Thanks for the reply. Consider the following situation: A set of variable names is defined along with a list of possible values for each. A second set of variable names is defined along with an expression for generating a value for each. For each possible permutation of variables from the first set, a python script is created that contains commands that initialize the variable set with the permuted values. A second python script is created that contains commands for connecting to a database and storing the values of the second set of variables after running the associated expression for each. We would like to be able to use the scripts above to drive a python script containing a system of equations specified at run time and to store the results. This master script contains the following calls: import somemodule # do stuff ... # initialize permuted variables somemodule.init() # do more stuff ... # store results somemodule.save() # do more stuff ... Etc. We would like for the call to init to initialize variables in the context of the master script. To do this inside somemodule we use the sys.modules dictionary to find a reference to the master module by name and initialize variables at this reference. What I would like to know if it is arbitrarily possible to walk the import hierarchy from any point. It is not apparent that python's optimization of subsequent imports of the same module is relavent. It seems to me that you could achieve the same end by accessing the calling stack frame inside the calls to your somemodule.functions(). Whether this is acceptable or not (and whether you are prepared to put up with the necessary voodoo) is another question. However, this would lead to atrocious coupling in your program. It's the kind of thing people used to use Fortran common blocks for, for goodness sake! The point Peter was trying to make about the distinction between first import of a module and subsequent ones is, I suspect, quite relevant, as you made it appear that you wanted to rely on code executed *during the import* to distinguish its importer. Clearly this would only be possible on the first import, as subsequent imports wouldn't execute the module's code. But now it appears that the import structure isn't really as relevant as the calling relationships anyway, no? Or am I misunderstanding your intent? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
should os.walk return a list instead of a tuple?
Seems i forgot about the [:] notation. Thanks for the help. -- http://mail.python.org/mailman/listinfo/python-list
Handling yes/no questions from the User
I'm writing a scipt that need to interact with the user. Lets say I have the: Do you want to continue [Y|n] Where just pressing return means Yes (since its uppercase). Its easy to write a function for this, but perhaps something like this already exists. Could someone point me to a class that handles this kind of user interaction? BR / Claes -- http://mail.python.org/mailman/listinfo/python-list
Re: [CODE] - Python Newcomer Starting with Coding
bruno at modulix wrote: Ilias Lazaridis wrote: Where can I find practical coding examples for real life coding problems? Probably in real life code ?-) Something like a categorized solution guide? Look for the Python cookbook (google is your friend). ... http://www.oreilly.com/catalog/pythoncook/ sorry, I've not clarified that I mean an free internet resource. * copy the content of the package folder to the created folder import shutil help(shutil.copytree) ... this one was helpfull. thanks a lot. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Design mini-lanugage for data input
Yes. But they have different motivations. The mini-language concept is to design an input format that is convenient for human editor and that is close to the semi-structured data source. I think the benefit from ease of editing and flexibility would justify writing a little parsing code. JSON is mainly designed for data exchange between programs. You can hand edit JSON data (as well as XML or Python statement) but it is not the most convenient. Just consider you don't have to enter two quotes for every string object is almost liberating. These quotes are only artifacts for structured data format. The idea to design a format convenient for human and let code to parse and built the data structure. wy Hmm, Do you know about JSON and YAML? http://en.wikipedia.org/wiki/JSON http://en.wikipedia.org/wiki/YAML They have the advantage of being maintained by a group of people and being available for a number of languages. (as well as NOT being XML :-) - Cheers, Paddy. -- http://paddy3118.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding newlines in XML?
Robert [EMAIL PROTECTED] wrote: *argh!* I hate XML! There, now that that's off my chest... Robert I think, rather, that you hate XML libraries. Well, I guess I don't mind XML as long as I don't have to look at it. XML-RPC is one example I'm perfectly happy with. You could call it Martian-RPC and I might not have known the difference. Still, I suspect you're correct that it's more the libraries than the ''s and ''s that give me fits. Robert Other libraries seem to get this right. Robert In [89]: from lxml import etree ... Thanks, an existence proof of a correct solution makes me less concerned about hacking around the current problem. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding newlines in XML?
Fredrik I don't recommend putting non-trivial formatted stuff in Fredrik attributes ... Yeah, I sort of knew that going in, but didn't want to make big changes to the code to do it in a cleaner fashion. I'll figure something out. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 Schedule
Ant [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Looks like some good new stuff coming along. Does anyone know what's happened to the path PEP (http://www.python.org/doc/peps/pep-0355/) - I thought I'd seen somewhere that that was originally planned for 2.5... It is still being discussed and has not been accepted. Latest revision was just 2 weeks ago and open issues are at bottom. There is the broad problem that it mostly just rearranges existing functionality (even if for the better) and would create two ways to do everything it does, since the existing modules and functions could not disappear until 3.0. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: [CODE] - Python Newcomer Starting with Coding
Ed Singleton wrote: On 21/03/06, Ilias Lazaridis [EMAIL PROTECTED] wrote: Where can I find practical coding examples for real life coding problems? Something like a categorized solution guide? This sounds quite a lot like PLEAC. It certainly contains a lot that you would find useful. http://pleac.sourceforge.net/pleac_python/index.html yes, this looks like the resource I was looking for. Also, try using the python-tutor list. It's a lot more helpful for questions like these. I've subscribed via gmane's nntp: news://news.gmane.org:119/gmane.comp.python.tutor will take a close look to this list. My current problem: * create a folder * seems to be: os.mkdir(path) Try using the Path module. It makes all that stuff much easier: http://www.jorendorff.com/articles/python/path/ looks very intresting. for now I am limited to the standard library. but I will for sure take a deeper look in near future. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
gregarican wrote: Sion Arrowsmith wrote: shovel huge amounts of data That right there basically takes XML-RPC off the table as a viable solution. No matter how much fine tuning you try large amounts of data don't bode well using XML-RPC. The other posted alternatives are certainly worth a shot. From CORBA to cPickle to even a basic TCP socket connection would be more efficient. I have used XML-RPC for very small recordset transfers but I wouldn't use it for anything large. rant I am continually surprised that the industry as a whole has become so enamoured of XML that people persist in using it for tasks it was never designed nor intended to be used for. /rant I suppose there *was* a good reason for using XML-RPC in the first place? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [CODE] - Python Newcomer Starting with Coding
On Tue, 21 Mar 2006 20:05:48 +0200 in comp.lang.python, Ilias Lazaridis [EMAIL PROTECTED] wrote: bruno at modulix wrote: [...] Look for the Python cookbook (google is your friend). ... http://www.oreilly.com/catalog/pythoncook/ sorry, I've not clarified that I mean an free internet resource. Try the first hit from google rather than the third. http://aspn.activestate.com/ASPN/Python/Cookbook/ Regards, -=Dave -- Change is inevitable, progress is not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Design mini-lanugage for data input
P.S. Also it is a 'mini-language' because it is an ad-hoc design that is good enough and can be easily implemented for a given problem. This is oppose to a general purpose solution like XML that is one translation from the original data format and carries too much baggages. Just consider you don't have to enter two quotes for every string object is almost liberating. These quotes are only artifacts for structured data format. The idea to design a format convenient for human and let code to parse and built the data structure. wy -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Steve I suppose there *was* a good reason for using XML-RPC in the Steve first place? I don't know about the OP, but in my case it was a drop-dead simple cross-language RPC protocol. At one point Mojam's XML-RPC server talked to clients written in Python, Perl and Objective-C (via a Java bridge, no less). Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyExcelerator to write Excel files from Python
Thanks!!! I had a good laugh at myself after i got it working. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can XML-RPC performance be improved?
Skip wrote: I don't know about the OP, but in my case it was a drop-dead simple cross-language RPC protocol. Exactly. RPC implementations. Typically these are a quick do this with this sent from the client, with a brief okay, I did that, here's the result back from the server. Shovelling huge amounts of data using any XML encapsulation leads to a certain code smell at the very least. -- http://mail.python.org/mailman/listinfo/python-list