Fredericksburg VA ZPUG, tomorrow 7:30-9 PM: Jim Fulton's State of Zope
Sorry to all for the late notice. Tomorrow, March 8, from 7:30 to 9:00 PM, instead of the previously discussed presentations (IronPython and Twisted/Zope 3), Jim Fulton will present his State of Zope talk recently delivered at PyCon, and lead discussion afterwards. The meeting with have the usual selection of delicious food and carbonated beverages. General ZPUG information When: second Wednesday of every month, 7:30-9:00. Where: Zope Corporation offices. 513 Prince Edward Street; Fredericksburg, VA 22408 (tinyurl for map is http://tinyurl.com/duoab). Parking: Zope Corporation parking lot; entrance on Prince Edward Street. Topics: As desired (and offered) by participants, within the constraints of having to do with Python or Zope. Contact: Gary Poster ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Dr. Dobb's Python-URL! - weekly Python news and links (Mar 6)
QOTW: This PyCon has been better in so many respects than the three that preceded it. ... PyCon will continue to improve. - Steve Holden, chairman of PyCon 2003-2005 http://holdenweb.blogspot.com/ Design patterns are kind of like sarcasm: hard to use well, not always appropriate, and disgustingly bad when applied to problems they are not meant to solve. - ajones Most of most design patterns is to work around the fact that it's difficult in Java and C++ to do many things. - Roy Smith Alex Martelli, Duncan Booth, Steven D'Aprano, and Peter Hansen illustrate that, where a C programmer thinks of an inline assignment, a Pythoneer looks for an opportunity to define a generator--and so on: http://groups.google.com/group/comp.lang.python/browse_thread/thread/d5408fdddc9f1d51/ Even rawstrings can't be entirely raw. Blackbird, Steven D'Aprano, and Alex Martelli explain the principal subtlety of their interpretation: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e5136d32f4b5c2f9/ As you should have heard by now, Queue.Queue is often the best way to organize cooperation among threads: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e41fd02f36a5e207/ Remember that the Wiki has lots of information about PyCon2006, both in anticipation and reflection: http://wiki.python.org/moin/PyCon2006/Talks/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Cetus collects Python hyperlinks. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all The old Python To-Do List now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse http://python.sourceforge.net/peps/pep-0042.html The online Python Journal is posted at
ANN: webstring 0.1 released
This is the first public release of webstring. webstring is a web templating engine that allows programs to manipulate XML and HTML documents with standard Python sequence and string operators. It is designed for those whose preferred web template languages are Python and HTML (and XML for people who swing that way). webstring's design is inspired by PyMeld but with a stricter Python feel. Like PyMeld, it strictly seperates the view (XML/HTML) from the controller (Python). Web designers can rest easy knowing that they can devote more time to mastering the complexities of HTML while programmers can now spend their days writing controller logic. webstring was written as a wrapper for Fredrik Lundh's cElementTree package, so the cElementTree and ElementTree packages are required. It also requires Fredrik Lundh's elementtidy package for trying to make sense of HTML from off the beaten track. All of these packages are available for download at: http://effbot.org/downloads/ webstring is currently only known to work with Python 2.4. webstring's documentation at this point is found in its source code alongside its unit tests. The file is available for download from: http://prdownloads.sourceforge.net/psilib/webstring.py?download -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: PyGUI 1.6.1
PyGUI 1.6.1 is now available: http://www.cosc.canterbury.ac.nz/~greg/python_gui/ Bug fixes: - Mouse down event in a GLView caused a crash. - Canvas methods fill_poly() and stroke_poly() didn't work. Added a test for these. What is PyGUI? -- PyGUI is an experimental highly-Pythonic cross-platform GUI API. Implementations are currently available for MacOSX and Gtk. For a full description of the project goals, see the PyGUI web page at the above address. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
pywinauto 0.2.5 released
Hi, The 0.2.5 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: 0.2.5 More refactoring, more tests 07-Mar-2006 * Added wrapper classes for Menus and MenuItems this enabled cleaner interaction with Menu's. It also gives more functionality - you can now programmatically Click() on menus, and query if a menu item is checked or not. * Added application.WindowSpecification.Wait() and WaitNot() methods. These methods allow you to wait for a control to exist, be visible, be enabled, be ready (both enabled and visible!) or to wait for the control to not be in any of these states. WaitReady(), WaitNotEnabled(), WaitNotVisible() now use these methods. I was able to also add the missing methods WaitNotReady(), WaitEnabled(), WaitVisible(), WaitExists(), WaitnotExists(). Please use Wait() and WaitNot() as I have Deprecated these Wait* methods. * Slightly modified timeout waits for control resolution so that a timed function more accurately follows the timeout value specified. * Added application.Application.start() and connect() static methods. These methods are factory methods in that they will return an initialized Application instance. They work exactly the same as start_() and connect() as they are implemented in terms of those. from pywinauto.application import Application notepad = Application.start(notepad) same_notepad = Application.connect(path = notepad) * Updated the examples to follow changes to the code - and to make them a little more robust. * Added a new Controls Overview document page which lists all the actions on all controls. * Added more unit tests now up to 207 from 134 (added 68 tests) 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.2.5/A Simple Windows GUI automation with Python. (07-Mar-06) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: 2006 Python training courses, San Francisco
WE are giving 4 more Python training sessions (held near the San Francisco airport) for the remainder of this year. For the first time, there will be an advanced Python course available to the public. In fact, we've added the March intro course date for those prepping to take the advanced class in May. You may register for any of the 4 courses/dates below. (Intensive) Introduction to Python March 29-31, 2006 August 16-18, 2006 Advanced Python Programming May 17-19, 2006 November 8-10, 2006 LOCALS: it'll be at a hotel with BART and CalTrain access (San Bruno stations) VISITORS: free shuttle directly from the San Francisco airport, lots of free food and wireless DISCOUNTS available. for more info and details, go to http://cyberwebconsulting.com and click Python training. cheers, -wesley ps. a great big public THANKS to Rob Stephenson for putting together the short PodCast clip of one of our training sessions for your viewing pleasure on a video iPod or iTunes on your Mac! - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2006,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
BayPIGgies: March 9, 7:30pm (Google)
The next meeting of BayPIGgies will be Thurs, March 9 at 7:30pm at Google. This meeting features a PyCon report from Guido van Rossum and possibly others. BayPIGgies meetings alternate between IronPort (San Bruno, California) and Google (Mountain View, California). For more information and directions, see http://baypiggies.net/ Before the meeting, we sometimes meet at 6pm for dinner. Discussion of dinner plans is handled on the BayPIGgies mailing list. Advance notice: We need a speaker for April. Please e-mail [EMAIL PROTECTED] if you want to suggest an agenda (or volunteer to give a presentation). -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ 19. A language that doesn't affect the way you think about programming, is not worth knowing. --Alan Perlis -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: It is fun.the result of str.lower(str())
Sullivan WxPyQtKinter wrote: Guess what would be the result of these functions: str.lower('ASFA') str.join(str(),['1','1','1']) str.join('a','b') If you guess them correctly, please explain. I think it was because I've read the manuals. -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
kepioo schrieb: I currently have an xml input file containing lots of data. My objectiv is to write a script that reports in another xml file only the data I am interested in. Doing this is really easy using SAX. The input file is continuously updated. However, the other xml file should be updated only on request. Everytime we run the script, we track the new elements in the input file and report them in the output file. My idea was to : _ detect in the output file the last event reported _ read the input file from the end _ report all the new events ( since the last time the script was run). Question : IS it possible to read an XML file and process it from the end to the beginning, using SAX No. And in no other XML-related technology I know of. Generally speaking, I'd say your approach is inherently flawed. XML as a language requires well-formed documents to have exactly one root element. This makes it unsuitable for e.g. logging-files, as these have no explicit end - except the implicit last log-entry. So you will always have something like this: --- begin --- root entry/ entry/ --- end --- I don't know _what_ you do, but unless you always write the whole XML-file completely new, you can't possibly write that closing end-tag. So you end up with an malformed xml-document. Or you _do_ write all the file contents new each time - but then you'd be able to reverse the order of elements so that the last came first. But I doubt the latter, as it imposes a great performance-bottleneck with little gain. SAX won't puke on you for your file being malformed, as it only learns about that when it is to late. So - you might use it, as when that happens you are already finished with your actual task. But you will always have to parse it from the beginning, to catch the document header, and there is no fast-forward build into SAX. So - what are your options? - use seperate output files for each entry, that are well-formed in themselves. Beware if you've got plenty of them (few K to M) that some FS might not deal well with that - if you can keep the file open reading all the time (because you are kind of a background process), you can read the contents, create a buffer and search for start-tags in that yourself. Then you can snip out the necessary portions, complete them with a xml-header and feed them separately. - if you can't keep it open, you can simulate that using the seed-function Both the last options are somewhat cumbersome, as you have to do a lot of parsing yourself - the exact purpose one chose XML the first time... From that follows the last advice: - ditch XML. Either totally, or at least as format for the whole file. Instead, use some protocol like this: --- begin --- Chunk-Length: 100 ?xml version=1.0? root... ( a 100 byte size xml document) /root Chunk-Length: 200 ?xml version=1.0? root... ( a 200 byte size xml document) /root ... Then you can easily read through your document, skip unnecessary entries and extract the ones you want. Or, when keeping the file open, know exactly what to read for the next chunk. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and exit code on Windows
[EMAIL PROTECTED] wrote: On UNIX one can use popen* to get a pipe for reading, a pipe for writing, and the exit code of the child process via a call to close() on the last pipe. Is there any way, in principle, to simulate such behaviour on Windows? Some googling reveals that direct use of the popen* functions on Windows will not do the trick, but are there indirect ways? This is well-tested: def launch(cmd, split_lines=True): Launch a sub-process. Return its output (both stdout and stderr), optionally split by lines (if split_lines is True). Raise a LaunchError exception if the exit code of the process is non-zero (failure). if os.name not in ['nt', 'os2']: p = popen2.Popen4(cmd) p.tochild.close() if split_lines: out = p.fromchild.readlines() else: out = p.fromchild.read() ret = p.wait() if ret == 0: ret = None else: ret = 8 else: i,k = os.popen4(cmd) i.close() if split_lines: out = k.readlines() else: out = k.read() ret = k.close() if ret is None: return out raise LaunchError(ret, cmd, out) -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Here is my code ; why after the readline the port close? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: It is fun.the result of str.lower(str())
Sullivan WxPyQtKinter wrote: Guess what would be the result of these functions: s/functions/method calls/ str.lower('ASFA') = 'ASFA'.lower() = 'asfa' str.join(str(),['1','1','1']) = ''.join(['1','1','1']) = '111' str.join('a','b') = 'a'.join('b') = 'b' If you guess them correctly, No need to guess, there's this thing named the python interactive shell, you know... And it even has an integrated help system. please explain. Explain what ? It's all in the fine manual. * Klass() is a call to Klass's constructor and returns an instance of Klass. * Klass.method(klass_instance) is the same as klass_instance.method() * str is the builtin string class. * without any args, the str constructor returns an empty string * str.join() takes a sequence of strings and join'em with the target str instance as separator Now would you be kind enough to explain what's funny about all this ? -- 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: Checking function calls
James Stroud wrote: (snip) Since python is weakly typed, s/weakly/dynamically/ (snip) -- 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: Compile ui files from within Eclipse
Chuck wrote: Hello, I am new to the Eclipse IDE. I am using pydev plug-in to create python projects. Is there a way to create custom builders to build certain types of files? I have done this with other IDE's but can't seem to figure it out with Eclipse. I am trying to build *.ui files of a pydev project to create the corresponding py files. For example to do this the manual way I would: pyuic.exe c:\source.ui c:\dest.py Thanks. You can, just create an external tool. (menu: run external tools external tools). You can also add a keybinding to the last external tool launched. Cheers, Fabio -- Fabio Zadrozny -- Software Developer ESSS - Engineering Simulation and Scientific Software www.esss.com.br Pydev Extensions www.fabioz.com/pydev PyDev - Python Development Enviroment for Eclipse pydev.sf.net pydev.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: It is fun.the result of str.lower(str())
On Tue, 07 Mar 2006 10:23:59 +0100, rumours say that bruno at modulix [EMAIL PROTECTED] might have written: snip various python expressions Now would you be kind enough to explain what's funny about all this ? I would guess it's the statement: Funny, it works! -- TZOTZIOY, I speak England very best. Dear Paul, please stop spamming us. The Corinthians -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this not infinite?
John Salerno wrote: Kent Johnson wrote: This should be def __init__(self, etc): Base.__init__(self, etc...) It's a typo in the book. Thank goodness! At least I know my mind is heading in the right direction then... :) Which book? Many of the authors are here, and I don't recall seeing that one reported before. These things can sometimes be patched in an errata page for the book, or at least noted here for posterity in case anyone else tries searching. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
luca72 wrote: Here is my code ; why after the readline the port close? What is the line of code before the first one shown here? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. What's the next line of code after ser.readline()? -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
Hi Diez, thank you for your answer. Let me give you more background on the project. The input xml I am parsing is always well formed. It is coming out from another application that append to this xml. I didn't see the source code of the application, but i know that it is not re-writing the whole xml. I thinnk it is just removing the last root element, adding the new tags and writing again the /root tag. We don't want to create new output files for every entry ( each entry is an event, and we have approximativaly 5 events per minute). So I have to stick with this xml input file. I guess, i will parse it till I find the last reported event and update the output xml from there, reporting only the events I am interested inI hope SAX won't take too much time to do all this...(let's say 1 event = 10 tags, 5 events/minutes, xml file running for 1 month -- 5400 000 opening tags)... What do you think? -- http://mail.python.org/mailman/listinfo/python-list
Can anyone explain this behaviour (class attribute vs instance lookup)
Hi all,From what I understand about the lookup semantics of instances and classes, the following is expected: class A(object): pass... A.__module__ '__main__' A().__module__'__main__'IOW, if an attribute is not found in the instance, it is looked-up in class, and if found, returned. Then, I was pluzzed by this behaviour: A.__name__ 'A' A().__name__Traceback (most recent call last): File stdin, line 1, in ?AttributeError: 'A' object has no attribute '__name__'It seems that '__name__' is being treated differently somehow. I guess this involves the descriptor machinery, but I don't know the internals of the new-class completely to explain the above behaviour in detail. Can anyone explain precisely the above semantics? Best Regards,Nicodemus. -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
We don't want to create new output files for every entry ( each entry is an event, and we have approximativaly 5 events per minute). So I have to stick with this xml input file. Well, the overall amount of data won't change. But I can understand that decision. However, you might consider using a file per day/week. I guess, i will parse it till I find the last reported event and update the output xml from there, reporting only the events I am interested inI hope SAX won't take too much time to do all this...(let's say 1 event = 10 tags, 5 events/minutes, xml file running for 1 month -- 5400 000 opening tags)... Use my suggested approach 2 - that boils down to using seek and some hand-written parsing/buffering. A little bit nasty, but better than consuming all of that file through sax. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
kepioo wrote: The input xml I am parsing is always well formed. It is coming out from another application that append to this xml. I didn't see the source code of the application, but i know that it is not re-writing the whole xml. I thinnk it is just removing the last root element, adding the new tags and writing again the /root tag. If the writers had a clue, they probably just seek to the end of the file minus len('/root') (or whatever) and then overwrite with the new entry and another /root element. At least, that's what seemed like the obvious approach when I had to do this once. Not that this is particularly relevant to the problem. ;-) I guess, i will parse it till I find the last reported event and update the output xml from there, reporting only the events I am interested inI hope SAX won't take too much time to do all this...(let's say 1 event = 10 tags, 5 events/minutes, xml file running for 1 month -- 5400 000 opening tags)... What do you think? I think (guessing wildly) you probably have a fairly restricted number of possibilities being written to this file, possibly as simple as the somewhat stereotypical 'entry text=blah blah/' type of thing which I've seen lots of times. If so, you can simply treat this as a text file which you process manually, in whatever direct and crude fashion works best, such as by seeking 1000 chars back from the end (assuming new entries are always less than that length), scanning for the last entry string, and slicing and dicing till you find the stuff you need. In other words, screw SAX, just grab the data directly and forget about all those silly well-formed XML issues etc. Go for the simplest thing that could possibly work, and if you don't need the complexity of SAX, don't use it. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Webhosting python info
Hi, Is there a way in python to have all the modules/ packages availiable to me printed out, like phpinfo (http://uk2.php.net/phpinfo) on my webhosting. Cheers David -- http://mail.python.org/mailman/listinfo/python-list
Re: Peter Naur wins ACM Turing Award
Kay Schluehr wrote: Terry Reedy wrote: http://campus.acm.org/public/pressroom/press_releases/3_2006/turing_3_01_2006.cfm Peter Naur was co-developer of Backus/Naur grammar notation, co-author and editor of the Algol 60 specification, and co-developer of a successful Algol compiler. That's very fine. Peter Naur has to be honored before he dies and Algol gets forgotten forever. Sarkasm mode off. Is it just me who thinks that this grand-old-man gala should be cancelled and replaced by a fields medal mode where the jury has to prove that it is a little more up to date? Maybe being at age of 50 would be good upper limit ( our societies grow older ;) This mode would enable to honor Simon Peyton Jones and Philip Wadler for Haskell and introducing monads to Haskell before the language is phased out in 20+ years. Without detracting from the last sentence, I disagree. Peter Naur's honour is long overdue. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cryptographically random numbers
Bryan Olson wrote: Tuvas wrote: Ahh, you are correct, that is a large bug... How about this one? Much better. Do note the comments from Emile van Sebille and Paul Rubin. There are some minor style and efficiency points, but it looks reasonable. Incidentally, as of Python 2.4, the standard library offers random.SystemRandom, which will generate integers in any desired range using os.urandom as the entropy source. How can I generate a random string containing digits, symbols and letters? I will use this random string for the key of a cryptographic algorithm. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: New python.org website
Phoe6 wrote: beta.python.org evolved very nice and noticed today the new python.org website going live. There is a change in the look n feel, wherein it looks more official and maximum possible information about python is now directly accessible from the home page itself. Kudoes to the design team. Sigh! Another of these sites that all look the same, with two screenfuls of info on the home page that are going to be in the way of every returning user... Not to mention the dull color scheme and the unremarkable logo. I can't say I'm impressed. Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking function calls
Fredrik Tolf python-list@python.org wrote: If I have a variable which points to a function, can I check if certain argument list matches what the function wants before or when calling it? Currently, I'm trying to catch a TypeError when calling the function (since that is what is raised when trying to call it with an illegal list), but that has the rather undesirable side effect of also catching any TypeErrors raised inside the function. Is there a way to avoid that? The only way is to read the documentation for the function (or, the source code). Can you be a little more specific about what you're trying to do? Can you post your code? -- http://mail.python.org/mailman/listinfo/python-list
Getting File Permissions
Hi, For getting permissions of a file, the following script has been suggested in the same group import os, stat st = os.stat(myfile) mode = st[stat.ST_MODE] print mode is, octal(mode 0777) But while executing I am getting error message as follows Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'octal' is not defined Since I am new to python, can any one help me to solve this error? A bunch of thanks in advance. Hari -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting File Permissions
Hari wrote: Hi, For getting permissions of a file, the following script has been suggested in the same group import os, stat st = os.stat(myfile) mode = st[stat.ST_MODE] print mode is, octal(mode 0777) But while executing I am getting error message as follows Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'octal' is not defined The correct name is oct(). The docs on built-in functions are helpful here: http://docs.python.org/lib/built-in-funcs.html Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting File Permissions
Hari wrote: Hi, For getting permissions of a file, the following script has been suggested in the same group import os, stat st = os.stat(myfile) mode = st[stat.ST_MODE] print mode is, octal(mode 0777) But while executing I am getting error message as follows Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'octal' is not defined Since I am new to python, can any one help me to solve this error? A bunch of thanks in advance. Hari You can use oct instead of octal. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting File Permissions
Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'octal' is not defined Since I am new to python, can any one help me to solve this error? Looks like you just want the oct() function (not octal()) [x for x in dir(__builtins__) if x.lower().find(oct) != -1] ['oct'] The __builtins__ will tell you what functions python supports natively, and you can query against this list for patterns, as done above. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
def OnButton1Button(self, event): ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() no code before Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Simulation Programming Skills and Python
On Mon, 06 Mar 2006 10:48:46 -0500, Richard Blackwood wrote: Two, is Python a good language for simulation programming? Civilization 4 is (partly) written in Python. I suppose they thought Python was a good language for that. I said partly because as far as I know some code is C++ for speed reasons. -- USB Priests for only 10$ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Thanks for these suggestions. To be clear, we already have a Python 2.4 minimum requirement for other reasons, and we are looking for a long-term solution so that as Python advances, the scripting solution can keep up in a timely way. Since the Java code is for a very large, complex application, we need to bring Python to Java rather than Java to Python. We will take a look at some of the other ideas. -- http://mail.python.org/mailman/listinfo/python-list
CP4E? (was: Help - just a few lines of code needed)
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: There is some fine permutation code in the cookbook. Take a look at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 . You can easily code something like: . . . Unfortunately I am not able to program it myself, so I would appreciate if someone could write this piece of software, compile it (for DOS or Windows) and send the .exe file to: lory88 at gmail . com Meet us halfway, here. At least install Python. Also, it's a dangerous world out there. Don't run .exe s sent to you by people you don't know. All true. This situation rather intrigues me at what I'll call a managerial level. I'm sympathetic to the possibility that Lory might have a life where compilation and script-launching and our other commonplaces are very remote; I salute him or her for recognizing that string permutation is indeed a feasible goal for a simple .EXE. I know *I* sometimes am in the situation of not having a useful Windows installation of a C compiler, or adequate Java environment, or ..., and I lean on the kindnesss o strangers at least temporarily. At the same time, there's little incentive for comp.lang.python to take on the burden of application development for transients in Pythonia. Lory, we can walk you through the at least install Python part Mr. Zenger mentions above in ten minutes; truly, it'll take less time than it would to negotiate delivery of a special-purpose executable for you. I remain curious: how'd you come to Python for your need? Is there some particular reason--most likely, that you're a potential Python student yourself--that we should help you? Is there a reason--that this is an assignment you're to do on your own?--that we should *not*? -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking function calls
Roy Smith wrote: Fredrik Tolf python-list@python.org wrote: If I have a variable which points to a function, can I check if certain argument list matches what the function wants before or when calling it? Currently, I'm trying to catch a TypeError when calling the function (since that is what is raised when trying to call it with an illegal list), but that has the rather undesirable side effect of also catching any TypeErrors raised inside the function. Is there a way to avoid that? The only way is to read the documentation for the function (or, the source code). Can you be a little more specific about what you're trying to do? Can you post your code? if you know ahead of runtime which methods are at issue and what method signatures you want, multimethod decorators, maybe? http://www.artima.com/weblogs/viewpost.jsp?thread=101605 (read comments: PJE, ian bicking or you can arg-test inside the method, which isn't much fun http://www.python.org/doc/faq/programming.html#how-can-i-overload-constructors-or-methods-in-python -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck wrote: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? Any ideas? Jython would be a natural candidate, but it is stuck at Python 2.1 and seems to have an uncertain future. JPype or CORBA/ICE. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Cryptographically random numbers
from os import urandom def cstring(bytes): ret='' while(len(ret)bytes): c=os.urandom(1) if c'0' and c'z': ret=ret+c return ret That should do it, though I bet there might be a more efficient way. I don't know if that's the set of characters you want to use, but... If you want a better answer, you'd have to be more specific. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck [EMAIL PROTECTED] writes: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? Any ideas? Jython would be a natural candidate, but it is stuck at Python 2.1 and seems to have an uncertain future. Thanks in advance. If you need real CPython (e.g., need add-on libraries compiled in C), then XMLRPC is a clean way to make the connection. -- http://mail.python.org/mailman/listinfo/python-list
AES encryption
I have just finished a new function that will do AES128 encryption, which is the standard for private-key cryptology today. In fact, the NSA permitted AES to be used for classified documents in the USA, the first time a public algorithm has been given this honor (Secret and Top Secret documents can use AES as well, but must use a larger key (192 or 256 bits)) I've tested my function with a thousand random texts, it seems to return the same result as received every time. If you want to take a look, http://www.geocities.com/brp13/Python/index.html Note, I still wouldn't quite encrypt your credit card numbers, but, well, it does seem to be secure enough... I would like comments as to anything fairly simple I might be able to do to increase security. I've tested the algorithm about a thousand times, with no appearant failures, but, there still could be one that I haven't found yet, so... Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Difference between a library and a module...
OK this might seem like a retarded question, but what is the difference between a library and a module? If I do: import string am I importing a module or a library? And if i do string.replace() am I using a module or a function or a method or what? Sorry. -- http://mail.python.org/mailman/listinfo/python-list
What version of python is running a script
Hi, How can my script tell which version of python is running it? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
On 2006-03-07, luca72 [EMAIL PROTECTED] wrote: Here is my code; why after the readline the port close? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. Because the ser object is never used after that point, so it get's garbage collected and deleted. -- Grant Edwards grante Yow! for ARTIFICIAL at FLAVORING!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What version of python is running a script
import syssys.version yields something like:2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]On 3/7/06, Fernando RodrÃguez [EMAIL PROTECTED] wrote:Hi, How can my script tell which version of python is running it?Thanks--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between a library and a module...
I'm not 100% sure what is a library in python. Your example above is importing a module. Someone else can correct me, but I use libraries to refer to underlying c/c++ code that is required for the python modules to function. So in pure python you are really only dealing with modules. string.replace() I'm 90% sure is a function in the string module. However something like this: foo = bar foo.Capitalize() bar.capitalize is executing a method. Actually at this point string.replace() may be a method as well, I don't know for sure as I haven't inspected the string module's code. Read some intro to OOP, for a better understanding, but the main difference between a function and a method, is that a method is associated with some class or object. In Python it's really only objects (even class is an object) Hence when I created the string object foo, and executed Capitalize() it was a method on the string object. the same thing as a function might look something like: # defining a function def capitalize(inStr) #do stuff here to capitalize the string return outStr foo = capitalize(bar) hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: What version of python is running a script
Fernando RodrÃguez wrote: Hi, How can my script tell which version of python is running it? Thanks import sys # examine these variables sys.version_info sys.version -- http://mail.python.org/mailman/listinfo/python-list
Re: raw strings and \
Alex Martelli wrote: John Salerno [EMAIL PROTECTED] wrote: Alex Martelli wrote: Now get back to work on your new Nutshell book :-) Yep, good point!-) Are you working on a new edition? I didn't see any new Python books listed on O'Reilly's site through April, but I'd definitely be interested in new versions of the books I plan to get soon (Cookbook and Nutshell, for example, although I figure the Cookbook is fairly new at this point.) Yep, a 3rd edition of the Cookbook is not in the cards. A 2nd edition of the Nutshell is, and if all goes well should be out before the fall. Alex Awesome, can't wait! :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between a library and a module...
sophie_newbie wrote: OK this might seem like a retarded question, but what is the difference between a library and a module? If I do: import string am I importing a module or a library? I'm not a guru, but... I think that modules are things that live inside the Python language. In the above case, you are importing a Python module. I think that a library is something that resides on the file system and contains code. But it can be anything, and it exists outside a Python program. I have the feeling that a library is usually lives in compiled form, while a python module can be anything that can be 'import'-ed (py file, pyd file or an so file...) And if i do string.replace() am I using a module or a function or a method or what? What you call here is: string.replace. In the standard string module, replace is a function. But if string refers to a custom module, then string.replace could be a class or an object (or any callable) as well. By the way, modules are not callable at all. Methods can only be called with an object. Class methods can be called with a class. Well, a module is itself a special object, called the 'module object'. Module objects have no class, and they cannot be instantiated or called. http://docs.python.org/ref/types.html#l2h-105 I hope this helps. Laszlo -- http://mail.python.org/mailman/listinfo/python-list
inserting into a list
Let me apologize in advance for what I'm sure is an achingly simple question, but I just can't find the answer in either of my Python books. I've tried a few tests with the interactive prompt, but they don't work either. All I'm trying to do is insert an item into a list, like so: L = [1, 2, 4] and I want to insert the integer 3 into the position L[2], so that the list reads [1, 2, 3, 4] I've tried all kinds of combinations of slicing assignment, but I always get: TypeError: can only assign an iterable Can someone please embarrass me with the simple answer? :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Grant Edwards wrote: On 2006-03-07, luca72 [EMAIL PROTECTED] wrote: Here is my code; why after the readline the port close? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. Because the ser object is never used after that point, so it get's garbage collected and deleted. The ser name is still bound to the serial object, surely? 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
Dr. Dobb's Python-URL! - weekly Python news and links (Mar 6)
QOTW: This PyCon has been better in so many respects than the three that preceded it. ... PyCon will continue to improve. - Steve Holden, chairman of PyCon 2003-2005 http://holdenweb.blogspot.com/ Design patterns are kind of like sarcasm: hard to use well, not always appropriate, and disgustingly bad when applied to problems they are not meant to solve. - ajones Most of most design patterns is to work around the fact that it's difficult in Java and C++ to do many things. - Roy Smith Alex Martelli, Duncan Booth, Steven D'Aprano, and Peter Hansen illustrate that, where a C programmer thinks of an inline assignment, a Pythoneer looks for an opportunity to define a generator--and so on: http://groups.google.com/group/comp.lang.python/browse_thread/thread/d5408fdddc9f1d51/ Even rawstrings can't be entirely raw. Blackbird, Steven D'Aprano, and Alex Martelli explain the principal subtlety of their interpretation: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e5136d32f4b5c2f9/ As you should have heard by now, Queue.Queue is often the best way to organize cooperation among threads: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e41fd02f36a5e207/ Remember that the Wiki has lots of information about PyCon2006, both in anticipation and reflection: http://wiki.python.org/moin/PyCon2006/Talks/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Cetus collects Python hyperlinks. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all The old Python To-Do List now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse http://python.sourceforge.net/peps/pep-0042.html The online Python Journal is posted at
ANN: PyGUI 1.6.1
PyGUI 1.6.1 is now available: http://www.cosc.canterbury.ac.nz/~greg/python_gui/ Bug fixes: - Mouse down event in a GLView caused a crash. - Canvas methods fill_poly() and stroke_poly() didn't work. Added a test for these. What is PyGUI? -- PyGUI is an experimental highly-Pythonic cross-platform GUI API. Implementations are currently available for MacOSX and Gtk. For a full description of the project goals, see the PyGUI web page at the above address. -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
Thanks Diez for your suggestion, I'll look around to find out more about the seek function ( i learnt python 2 weeks ago and I do not have a programmer background, but so far, I am doing well). Peter, I cannot really process as your advice : it is not that stereotypical entrieswe built a data structure for the xml and we report various types of events, always under the same format but with different contents types. The script i am writing aims at picking only special events ( identified by a route tag and an information tag). Anyway, thank you for your advices!! -- http://mail.python.org/mailman/listinfo/python-list
Re: generators shared among threads
[EMAIL PROTECTED] wrote: Thanks for the great advice, Alex. Here is a subclass that seems to work: You're welcome! from Queue import Queue from itertools import count class reentrantQueue(Queue): def _init(self, maxsize): self.maxsize = 0 self.queue = [] # so we don't have to override put() self.counter = count() def _empty(self): return False def _get(self): return self.counter.next() def next(self): return self.get() def __iter__(self): return self You may also want to override _put to raise an exception, just to avoid accidental misuse, though I agree it's marginal. Also, I'd use maxsize (if provided and 0) as the upperbound for the counting; not sure that's necessary but it seems pretty natural to raise StopIteration (rather than returning the counter's value) if the counter reaches that maxsize. Last, I'm not sure I'd think of this as a reentrantQueue, so much as a ReentrantCounter;-). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
On Tuesday 07 March 2006 16:18, John Salerno wrote: Let me apologize in advance for what I'm sure is an achingly simple question, but I just can't find the answer in either of my Python books. I've tried a few tests with the interactive prompt, but they don't work either. All I'm trying to do is insert an item into a list, like so: L = [1, 2, 4] and I want to insert the integer 3 into the position L[2], so that the list reads [1, 2, 3, 4] Either L[2:2]=[3] or L.insert(2,3) Kindly Christoph -- ~ ~ .signature [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
John Salerno wrote: Let me apologize in advance for what I'm sure is an achingly simple question, but I just can't find the answer in either of my Python books. I've tried a few tests with the interactive prompt, but they don't work either. All I'm trying to do is insert an item into a list, like so: L = [1, 2, 4] and I want to insert the integer 3 into the position L[2], so that the list reads [1, 2, 3, 4] I've tried all kinds of combinations of slicing assignment, but I always get: TypeError: can only assign an iterable Can someone please embarrass me with the simple answer? :) l = [1,2,3] l.insert(2, 10) l [1, 2, 10, 3] Embarrasing enough? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
On 2006-03-07, Steve Holden [EMAIL PROTECTED] wrote: Here is my code; why after the readline the port close? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. Because the ser object is never used after that point, so it get's garbage collected and deleted. The ser name is still bound to the serial object, surely? I don't see any references to ser after the call to ser.readline(). Do you? ;) I was trying to make the point [again] that it's impossible to to tell what's going on because the OP refuses to post enough of his code to allow meaningful analysis. He's been told at least three times in as many postings that he needs to post a complete example that demonstrates the problem he's trying to solve, but he refuses. I've explained multiple times that the excerpts he's posting aren't sufficient. He persists in posting small snippets of mostly-irrelevant code with no context. I give up. I have a feeling I'm just annoying the mule at this point. -- Grant Edwards grante Yow! It don't mean a at THING if you ain't got visi.comthat SWING!! -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
from the Library Reference:s.insert(i, x) same as s[i:i] = [x] (5)On 3/7/06, John Salerno [EMAIL PROTECTED] wrote:Let me apologize in advance for what I'm sure is an achingly simple question, but I just can't find the answer in either of my Python books.I've tried a few tests with the interactive prompt, but they don't workeither.All I'm trying to do is insert an item into a list, like so: L = [1, 2, 4]and I want to insert the integer 3 into the position L[2], so that thelist reads [1, 2, 3, 4]I've tried all kinds of combinations of slicing assignment, but I alwaysget: TypeError: can only assign an iterableCan someone please embarrass me with the simple answer?:)--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference between a library and a module...
sophie_newbie wrote: OK this might seem like a retarded question, Better to look like an ignorant than to stay one !-) but what is the difference between a library and a module? Python only defines 'modules' and 'packages'. A module can technically be any python source file, but usually refers to a python source file that defines symbols (variables, constants, functions, classes...) and is meant to be imported (vs. a 'script', which is meant to be executed). A package is a kind of a super-module - a collection of modules and packages -. To make a package, just put your modules in a folder and add a __init__.py file (which can be empty, the mere existence of this file is enough to turn your folder into a python package) 'librairy' is a non python-specific, more or less formal term that refers to a collection of functions, classes, variables etc... (just like a (real) library is a collection of books). In Python, 'library' can apply either to an external system lib (.dll on Windows, .so on *n*x), a collection of packages and modules, a single package, or even a single module... If I do: import string am I importing a module or a library? Could be a module, a package, or a module wrapping an external lib (AFAIK, the string module is a wrapper around a system lib). The term 'module' refers in fact to two things: the physical python source file, and the python object created from it by an import statement. When importing a package, Python creates in the current namespace a module object[1] from the __init__.py file. Any symbol defined in the __init__.py will become available as an attribute of the module object. Of course, if the __init__.py is empty, this won't give you much !-) And if i do string.replace() am I using a module or a function or a method or what? In this case : string.replace() is the function 'replace' defined in the module 'string'. More generally: when you import a module (or package FWIW, cf above), Python creates a module object. Symbols defined in the (physical) module become attributes of the (object) module. Some of these attributes are 'callable' (functions, classes,... ). Sorry. Why ? 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: Pyserial again
Hello Grant and Hello Steve. Pls. don't kill me, but if you try the code above written you see that after the read the port close. My question is only: why it close without the close command? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
Terry Reedy wrote: I believe it is Guido's current view, perhaps Google's collective view, and a general *nix view that such increases can just as well come thru parallel processes. I believe one can run separate Python processes on separate cores just as well as one can run separate processes on separate chips or separate machines. Your view has also been presented and discussed on the pydev list. (But I am not one for thread versus process debate.) That's ok for me. I usually have lots of different things happening on the same computer, but for someone who writes an application and want to make his particular program faster, there is not a lot of support for building simple multi-process systems in Python. While multi-threading is nasty, it makes it possible to perform tasks in the same program in parallel. I could well imagine something similar to Twisted, where the different tasks handled by the event loop were dispatched to parallel execution on different cores/CPUs by some clever mechanism under the hood. If the typical CPU in X years from now is a 5GHz processor with 16 cores, we probably want a single Python program to be able to use more than one core for CPU intensive tasks. At least if writing threaded applications becomes less error prone in competing languages, this might well be the weak point of Python in the future. Queue.Queue was added to help people write correct threaded programs. What I'm trying to say is that multi-threaded programming (in all languages) is difficult. If *other* languages manage to make it less difficult than today, they will achieve a convenient performance boost that Python can't compete with when the GIL prevents parallel execution of Python code. - For many years, CPU performance has increased year after year through higher and higher processor clock speeds. The number of instructions through a single processing pipeline per second has increased. This simple kind of speed increase is flattening out. The first 1GHz CPUs from Intel appeared about five years ago. At that time, CPU speed still doubled every 2 years. With that pace, we would have had 6GHz CPUs now. We don't! Perhaps someone will make some new invention and the race will be on again...but it's not the case right now. - The hardware trend right now, is to make CPUs allow more parallel execution. Today, double core CPU's are becoming common, and in a few years there will be many more cores on each CPU. - While most computers have a number of processes running in parallel, there is often one process / application that is performance critical on typical computers. - To utilize the performance in these multi-core processors, we need to use multi-threading, multiple processes or some other technology that executes code in parallel. - I think languages and application design patterns will evolve to better support this parallel execution. I guess it's only a few languages such as Erlang that support it well today. - If Python isn't to get far behind the competition, it has to manage this shift in how to utilize processor power. I don't know if this will happen through core language changes, or via some conveninent modules that makes fork/spawn/whatever and IPC much more convenient, or if there is something entirely different waiting around the corner. Something is needed I think. -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
Diez B. Roggisch wrote: l = [1,2,3] l.insert(2, 10) l [1, 2, 10, 3] Embarrasing enough? Actually, I was trying to figure it out with the slice technique instead. But yeah, as Christopher's example showed, it's not hard. But I didn't realize you had to assign a list item to the slice, so I was doing: L[2:2] = 3 among other things, but they all involved '= 3', not '= [3]' -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
Christoph Haas wrote: L[2:2]=[3] I'm still a little confused about this. If what I'm inserting is just an integer, why wouldn't L[2:2] = 3 work? What if you wanted to insert an actual list into that slot? Would you have to wrap it in double brackets? -- http://mail.python.org/mailman/listinfo/python-list
Re: What version of python is running a script
In article [EMAIL PROTECTED], Fernando RodrÃguez [EMAIL PROTECTED] wrote: Hi, How can my script tell which version of python is running it? . . . $ python Python 2.3.5 (#2, Aug 30 2005, 15:50:26) [GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2 Type help, copyright, credits or license for more information. import sys print sys.version 2.3.5 (#2, Aug 30 2005, 15:50:26) [GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] 'Does that make it clear? -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and exit code on Windows
Thanks for the reply Giovanni. Is this behaviour of the close method on Windows documented anywhere? Regards, Iker -- http://mail.python.org/mailman/listinfo/python-list
SOAPpy, WSDL and objects
Hi, I am trying to access a webservice which needs a login request of the following form: login request firstnameFirstName/firstname lastnameLastName/lastname /request /login I am trying to do this with the following code: from SOAPpy import WSDL server = WSDL.Proxy(m_url) request = {'firstname': FirstName, 'lastname': LastName} server.login(request) But this will be sending the following: login v1 firstnameFirstName/firstname lastnameLastName/lastname /v1 /login Basically, I need to know how to change the code so it generates 'request' instead of 'v1'. Have a nice evening! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python version of XMLUnit?
Kent Johnson wrote: I have found XMLUnit to be very helpful for testing Java and Jython code that generates XML. At its heart XMLUnit is an XML-aware diff - it parses expected and actual XML and pinpoints any differences. It is smart enough to ignore things like attribute order, different quoting and escaping styles, and insignificant whitespace. Now I am working on a CPython project and have a similar need. Is there any comparable tool for Python? Basically I'm looking for a tool to compare XML and show diffs in an intelligible fashion that is usable from Python unit tests (using py.test, if it matters). One possible approach is to use c14n to in effect normalize the XML so that you can use regular text compare. This is not as sophisticated as a full XML diff, but it's definitely a viable approach for testing. For those who migh tbe interested in that approach, learn more about c14n here: http://www.ibm.com/developerworks/xml/library/x-c14n/ It includes a brief example using the c14n module in PyXML http://pyxml.sourceforge.net/ I also recently checked in c14n capability for 4Suite. It offers the same level of coverage as PyXML's, but operates in streaming, rather than DOM mode. http://4suite.org/ 4Suite also contains in its test suite routines (TreeCompare) for comparing XMl and HTML while ignoring non-significant syntactic variations. Certainly full xmldiff is very useful. One nice thing about LogiLabs's app is that it can output XUpdate, which could be used with, say 4Suite's 4XUpdate to apply a patch to another document. -- Uche Ogbuji Fourthought, Inc. http://uche.ogbuji.nethttp://fourthought.com http://copia.ogbuji.net http://4Suite.org Articles: http://uche.ogbuji.net/tech/publications/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
1) Peter Hansen was asking you for the code AFTER the ser.readline() not BEFORE!! the code you have originally posted here 2) the best way how to examine if your code works is to try to write some simplest code as possible first (not buttons, not GUI etc..., just a simple code) (all this suggestions were already mentioned in one of your previous postings, see http://tinyurl.com/zz3s5) Regarding to your questions in this posting I think you can try something like: import serial ser=serial.Serial(0, 9600, 8, E, stopbits=2, timeout=1) while 1: print s.readline() In your original code you have posted here, you read one line from the serial port only. It means the code reads byte by byte from the serial port till the end of line byte ('\n') is recognized. Than the reading stops and after that the whole code is finished because no other code lines after the ser.readline(). If no data present on the serial port for longer than timeout defined, it will stop reading serial port and the code finishes as well. 3) please note, you can define serial port as following as well which is ,IMHO, more readable: ser=serial.Serial(0, 9600, 8, E, stopbits=2, timeout=1) (it was recommended to you in above mentioned posting as well) You can find plenty of examples on http://pyserial.sourceforge.net/ in the Examples paragraph. Try to study and search before you ask. HTH Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Ok you write that it close :Because the ser object is never used after that point, so it get's garbage collected and deleted. But for example if i make one button with the same caracteristic of the previous com port: def OnButton1Button(self, event): ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 But with a = textCtrl1GetValue() # i put here some different string to send ser.write (a) b = ser.readline() textCtrl2SetValue(b) why at any read the serial close, is possible to prevent the closure of the port? -- http://mail.python.org/mailman/listinfo/python-list
Distutils places 'extra_compile_args' in the wrong place?
I'm completely new to this, but trying to compile some code I've been given which uses the python Distutils stuff. I need to pass some compiler directives to gcc, and the documentation suggests that the parameteres 'extra_compile_args' can be used. However, this does so AFTER the rest of the arguments, including the -o output name and the sourcecode file name, so gcc ignores it (and tells me that it is doing so). How do I get my compiler directives passed correctly? How do I find the other directives that setup.py seems to put in by default? My current setup.py: --- setup (name = extension, description = Extension to Python, ext_modules = [Extension('PyHST_c', ['PyHST_c.c',c_hst_recon_1over.c,Vhst_fourier.c,Vhst_calculate_limits.c], define_macros=[('MACRO1','1'),('MACRO2',None)], extra_compile_args=['-TOOLATETOHAVEEFFECT'], libraries=['pthread','gcc','m']), ] ) --- Cheers, greg -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
John Salerno wrote: Christoph Haas wrote: L[2:2]=[3] I'm still a little confused about this. If what I'm inserting is just an integer, why wouldn't L[2:2] = 3 work? Because a slice represents a list - even if it is a one-elemented one. So, replacing it you need another list. What if you wanted to insert an actual list into that slot? Would you have to wrap it in double brackets? Why don't you just _try_ that? It would have been way faster than to ask questions you can easily answer yourself. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Peter Hansen was asking you for the code AFTER the ser.readline() not BEFORE!! the code you have originally posted here OK IS MY MISTAKE; EXCUSE. I have read the example but if i ask is bucause i don't or maybe i don't understand the example Regaards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
John Salerno wrote: Christoph Haas wrote: L[2:2]=[3] [ ... ] What if you wanted to insert an actual list into that slot? Would you have to wrap it in double brackets? Yep. It's a strong-typing thing. Slices of lists are lists, and therefore what you assign to one has got to be a list, or convertible to a list (a tuple would work.) Python 2.4.2 (#1, Jan 23 2006, 21:24:54) [GCC 3.3.4] on linux2 Type help, copyright, credits or license for more information. a=[1,3,4] a[2:3] [4] a[2:2] [] a[1:1]=[2] a [1, 2, 3, 4] a[1:2] [2] Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
It makes sense because a slice IS a list, so you should assign a list to it. Yours is just a special case in which the target slice has a length of zero. It's still a list, just an empty one: L = [1,2,4] print L[2:2] [] As for your question, yes: L = [1,2,4] L[2:2] = [[3]] print L [1, 2, [3], 4] Cheers! :) -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
Diez B. Roggisch wrote: Why don't you just _try_ that? It would have been way faster than to ask questions you can easily answer yourself. I did try it, but I was still hoping for an explanation, which I've also gotten from you guys, some in nicer terms than others. -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
John Salerno wrote: Diez B. Roggisch wrote: Why don't you just _try_ that? It would have been way faster than to ask questions you can easily answer yourself. I did try it, but I was still hoping for an explanation, which I've also gotten from you guys, some in nicer terms than others. You got an explanation to your first question from me. But you obviously _didn't_ try your second one. Which would be a no-brainer as Warby's reply shows, and given that you already knew how to insert a single element list I consider it being not so nice of _you_ not to do so, but instead post before you tried. Diez -- http://mail.python.org/mailman/listinfo/python-list
Attaching files in windows using Python.
Hi all, I have to select a particular file (using the 'Browse') button in Windows. After this I need to populate the 'Open Dialogue Box' with the path of the file I need (I have the entier path of the file I need). Then I need to select the 'Open' Button. Only after this the file I want is attached. Any idea as to how this can be done using 'Win32 API's. While looking for the proper answer to this I found that 'Mark Hammond's' Python for Windows documentation is not detail enough. Any help in this regard would be much appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
Diez B. Roggisch wrote: John Salerno wrote: Diez B. Roggisch wrote: Why don't you just _try_ that? It would have been way faster than to ask questions you can easily answer yourself. I did try it, but I was still hoping for an explanation, which I've also gotten from you guys, some in nicer terms than others. You got an explanation to your first question from me. But you obviously _didn't_ try your second one. Which would be a no-brainer as Warby's reply shows, and given that you already knew how to insert a single element list I consider it being not so nice of _you_ not to do so, but instead post before you tried. Diez Actually, I did try the second one too, but I'm not trying to get into a fight here, so let's just forget it. I appreciate the fact that you responded at all, and with answers to my questions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
Indentation makes all kinds of inlined code extremely clumsy or practically impossible in Python. This is the only sensible argument against the indentation thing I've heard. Python squirms about being inlined in a presentation template. Making a direct competitor to PHP in pure Python is problematic. While there are workarounds which are not hard to envision, it seems like the right answer is not to inline small fragments of Python code in HTML, which is probably the wrong approach for any serious work anyway. This problem does, however, seem to interfere with adoption by beginning web programmers, who may conceivably end up in PHP or perhaps Perl Mason out of an ill-considered expedience. Why this should matter in this discussion, about scientific programming, escapes me though. When you say all kinds of inlined code, do you have any other examples besides HTML? mt -- http://mail.python.org/mailman/listinfo/python-list
os.execve(pth,args,env) and os.chroot(pth) = problems
Hello fellow python users, I've been working on a basic implementation of a privilege separated web server, and I've goto the point of running a basic cgi script. Basically when the execCGI function in my Unpriv.py program is called a few things should happen, it should fork (which it does), the stdout of the child should be redirected to a given pipe (which it does), and the script should execute using execve(which is has problems with). Also before the execCGI() fucntion is executed, a few important things happen in __init__: os.chroot('/var/www/webroot/') the path is web server root and os.setuid(33) where 33 is the uid of a user on my machine. It seems me that the os.chroot() call is messing up the os.execve() (which executes the cgi script). os.execve(pth, args, envVariables) is only executed if os.path.exists(pth) returns True. But when I run a CGI script that os.path.exists(pth) returns True for, then os.execve(pth) python throws back the error: File /***/***/***/Unpriv.py, line 201, in execCGI OSError: [Errno 2] No such file or directory However I don't see how this is possible if os.path.exists(pth) returns True, why is it os.execve() has problems finding it. I thought it might be a user permission problem, but I've run it without the chroot and with the setuid and it works fine. So I'm pretty sure its something to do with the chroot conflicting with the os.execve(). Also execution privileges for the script file are also checked before execution. Any insight would be greatly appreciated Here are the relevant functions of Unpriv.py class Unpriv(object): def __init__(self): pipes = sys.argv self.fromParent, self.toParent = os.pipe() # this is just how http requested are recieved from a privilege part and sent back os.dup2(int(pipes[2]), self. toParent) ##write os.dup2(int(pipes[1]), self.fromParent) ##read os.chroot('/var/www/webroot/') ##chrooting os.setuid(33) ##setuid def checkFileExists(self, pth):## just calls os.path.exists() return os.path.exists(pth) def execCGI(self, pth): ## x = pth.rfind('?') if x -1: path = pth[:x] query = pth[x+1:] query = query.replace('+', ' ') else: path = pth query = '' ##populate enviroment variables, not yet implemented envVariables = {} readEnd, writeEnd = os.pipe() parentStout = sys.stdout.fileno() args = [''] args.append(query) pid = os.fork() if pid == 0: ##child os.dup2(writeEnd, sys.stdout.fileno()) ##this works ## this is the problem! if self.checkFileExists(pth): os.execve(pth , args, envVariables) else: ## just some debug info for me. ## in fact part of pth is there ##however for some reason execve doesn't see print 'the directory listing is:', os.listdir(os.getcwd()) os._exit(0) else: #parent #read the output from the script scriptOutPut = os.read(readEnd, 10) #just some debug info for me print 'OUTPUT FROM SCRIPT EXECUTION: ' , scriptOutPut return scriptOutPut Please excuse any problems with the formatting. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
On 2006-03-07, luca72 [EMAIL PROTECTED] wrote: Hello Grant and Hello Steve. Pls. don't kill me, but if you try the code above written you see that after the read the port close. My question is only: why it close without the close command? I've answered that question TWICE. The ser object is getting garbage collected. That closes the port. -- Grant Edwards grante Yow! Yow! Are we laid at back yet? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
[luca] Here is my code; why after the readline the port close? ser = serial.Serial(0) [...] ser.readline() Why after this the port close. [Grant] Because the ser object is never used after that point, so it get's garbage collected and deleted. [Steve] The ser name is still bound to the serial object, surely? A piece of that code has been chopped off by someone's newsreader - it's the body of a method, and ser.readline() is the last line of that method. -- Richie Hindle [EMAIL PROTECTED] -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
On 2006-03-07, luca72 [EMAIL PROTECTED] wrote: Ok you write that it close :Because the ser object is never used after that point, so it get's garbage collected and deleted. Yes. But for example if i make one button with the same caracteristic of the previous com port: def OnButton1Button(self, event): ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 But with a = textCtrl1GetValue() # i put here some different string to send ser.write (a) b = ser.readline() textCtrl2SetValue(b) I have no idea what you mean by that. POST THE CODE. With both button handlers. I'm GUESSING (since you won't post enough code for me to actually figure it otu) that ser is local to your button handlers and it's going out of scope and getting deleted when the button handler returns. Do you understand what I wrote above? why at any read the serial close, is possible to prevent the closure of the port? Yes. Make sure the ser object doesn't get deleted. -- Grant Edwards grante Yow! A can of ASPARAGUS, at 73 pigeons, some LIVE ammo, visi.comand a FROZEN DAQUIRI!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Attaching files in windows using Python.
Hi all, I have got this far till now - import win32gui, struct, array, string OFN_ALLOWMULTISELECT=0x0200 OFN_EXPLORER=0x0008 def arrayToStrings(resultArray): return list-of-strings corresponding to a char array, where each string is terminated by \000, and the whole list by two adjacent \000 bytes astr=resultArray.tostring() manyStrings=[] # perhaps a loop of string.split would be faster... while len(astr) and astr[0]!='\000': i=astr.index('\000') manyStrings.append(astr[:i]) astr=astr[i+1:] return manyStrings def szFrom(anarray): return the string-pointer (sz) corresponding to a char array, 0 (null pointer) if no array if anarray: return anarray.buffer_info()[0] else: return 0 def arrayFrom(astring,additional=0): return a char array built from a string, plus 0 or more \000 bytes as filler if not astring: astring='' return array.array('c',astring+additional*'\000') def arrayMulti(stringlist): return a char array built from many strings, each separated by a \000 byte, and two \000's at the end return arrayFrom(string.join(stringlist,'\000'),2) def buildOfn(resultarray,filters=None,initdir=None,title=None, multisel=1,oldlook=0): build an OPENFILENAME struct as a string, with several options and a given result-array for the string[s] that will result from the GetOpenFileName call flags=OFN_EXPLORER if multisel: flags=flags|OFN_ALLOWMULTISELECT if oldlook: flags=flags~OFN_EXPLORER szfile,maxfile=resultarray.buffer_info() szfilter=szFrom(filters) szinitdir=szFrom(initdir) sztitle=szFrom(title) return struct.pack( 3i2P2iPiPi2PI2hPi2P, 76, 0, 0, # size, owner-hwnd, hinstance szfilter, 0, 0, 0, # filter, custom-filter, max-cust-filter,filter-index szfile, maxfile,# file, max-file 0, 0, # file-title, max-file-title szinitdir, sztitle, # initial-dir, dialog-title flags, 0, 0,# flags, file-offset, file-extension 0, # def-ext 0, 0, 0)# cust-data, func-hook, template-name def openNames(forsave=0,filters=None,initdir=None,title=None, initfile=None,multisel=1,oldlook=0): return a list of filenames for open or save, given interactively by the user through a common-dialog; if more than 1 string is returned, the first is the directory, followed by the filenames. resultBuffer=arrayFrom(initfile,8192) title=arrayFrom(title) initdir=arrayFrom(initdir) filters=arrayMulti(filters) ofn=buildOfn(resultBuffer,filters,initdir,title,multisel,oldlook) if forsave: isok=win32gui.GetSaveFileName(ofn) else: isok=win32gui.GetOpenFileName(ofn) if not isok: return [] return arrayToStrings(resultBuffer) def _test(): return openNames( filters=('Texts and scripts','*.txt;*.py','Py stuff','*.py*') ) if __name__=='__main__': print _test() But hear the Dialogue_box stops and waits for the user to select a file. But Since I have the entire path of the file, How do I pass it to the file name to populate the box automatically instead of the user manually selecting a file. Any further help will be appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by Method(function) of a module and method of a class/instance
Sullivan WxPyQtKinter: Why do the three expression yield the same result abc? Because all three converted ABC to lowercase, as per your request. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: AES encryption
Tuvas wrote: [...] I've tested my function with a thousand random texts, it seems to return the same result as received every time. Unfortunately, the results seem incorrect, self-consistent as they may be. The following will call your code, and check the results against 3 popular test vectors. --Bryan # Assert false if test fails test_key = ( 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x76, 0x2e, 0x71, 0x60, 0xf3, 0x8b, 0x4d, 0xa5, 0x6a, 0x78, 0x4d, 0x90, 0x45, 0x19, 0x0c, 0xfe) test_plaintext = ( 0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34) expected = ( (0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32), (0xf9, 0xfb, 0x29, 0xae, 0xfc, 0x38, 0x4a, 0x25, 0x03, 0x40, 0xd8, 0x33, 0xb8, 0x7e, 0xbc, 0x00), (0x1a, 0x6e, 0x6c, 0x2c, 0x66, 0x2e, 0x7d, 0xa6, 0x50, 0x1f, 0xfb, 0x62, 0xbc, 0x9e, 0x93, 0xf3)) key_sizes = (16, 24, 32) plaintext = s2num(''.join([chr(c) for c in test_plaintext])) for i in range(len(key_sizes)): key_size = key_sizes[i] key = s2num(''.join([chr(c) for c in test_key[:key_size]])) expected = s2num(''.join([chr(c) for c in expected[i]])) ciphertext = encryptb(plaintext, key) assert ciphertext == expected deciphertext = decryptb(ciphertext, key) assert deciphertext == plaintext -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile ui files from within Eclipse
Well, I tried that but there isnt a way to get the filename without the extension. For example, pyuic -o MyClass.py MyClass.ui Using the variables in the external tool config I dont see a way to get just the filename in order to create an output filename and pass it into the pyoic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Peter Naur wins ACM Turing Award
Colin J. Williams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: http://campus.acm.org/public/pressroom/press_releases/3_2006/turing_3_01_2006.cfm Peter Naur was co-developer of Backus/Naur grammar notation, co-author and editor of the Algol 60 specification, and co-developer of a successful Algol compiler. Peter Naur's honour is long overdue. That was my reaction also, tempered by three observations. 1. I do not have enough detailed knowledge of who invented what when to judge details of credit allocation. 2. The importance of Algol60 (and the impetus of the award) is not its usage in the 60s but the dominance of the family of languages it inspired, including, at least in some important parts, Python. But this has been a gradual development. So when did the award become 'due', to make it 'overdue' now? (I would say by 1990, at least.) 3. To call it overdue suggests that it should have been awarded before, *instead of* to someone else. But I am not about to suggest which of the previous (worthy, I am sure) recipients he should have been instead of ;-). Nobel's will specificed awards for the most important contribution in the previous year. The Nobel committees recognized that this is ludicrous in that recognition of importance can take decades. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a list
Warby wrote: It makes sense because a slice IS a list, so you should assign a list to it. Yours is just a special case in which the target slice has a length of zero. It's still a list, just an empty one: L = [1,2,4] print L[2:2] [] As for your question, yes: L = [1,2,4] L[2:2] = [[3]] print L [1, 2, [3], 4] Cheers! :) Thanks guys! What I wasn't realizing was that a slice is a list, so I needed a list. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: setting PYTHONPATH
On Sun, 5 Mar 2006 23:05:31 -0800 (PST) anushya beauty [EMAIL PROTECTED] wrote: Anybody, please help me to set PYTHONPATH to import my modules?. Where is sy.path set? In some python groups site, to import the user modules, they explained to create one __init__.py file in my module directory (this file should include __all__ variable, which refer to the modules that the user wants to import). How to set the __all__ var? PYTHONPATH is an environment variable. You set this however your operating system lets you do handle them. In Linux or Unix with csh/tcsh, this looks like: setenv PYTHONPATH /path/to/python/files in bash/sh it looks like: set PYTHONPATH=/path/to/python/files and I'm sure there's some way to do it in Windows and OS X. sys.path means the name path in the module sys So, in order to see that, you need to (from python): import sys sys.path sys.path ['', '/usr/lib/python23.zip', '/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2', ...] As you can see, it's a list. You can append to it, or more likely, prepend the directory you need. __all__ is a magic variable in the __init__.py (or any module) which you can set to define which names will be imported when you import from that module: If module foo.py contains: __all__ = ['a', 'b'] a = 1 b = 2 c = 3 then another module which imports from foo will get a and b, but not c: from foo import * a,b (1, 2) c Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'c' is not defined Meanwhile: __init__.py This is how you make a package out of a directory of python modules. Its namespace is the package-wide space. So you can control what modules are loaded with explicit commands, or you can leave it empty and then you will have to do explicit imports of sub-modules: spam/ __init__.py ham.py eggs.py requires explicit imports of ham and eggs modules: import spam import spam.ham import spam.eggs Although these things are all interesting, they are not closely related, and you haven't really said what your problem is, so I don't know which is going to be helpful to you. -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile ui files from within Eclipse
I guess I could prompt for input but was hoping to find a better way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Richie Hindle wrote: A piece of that code has been chopped off by someone's newsreader - it's the body of a method, and ser.readline() is the last line of that method. I'm pretty sure that's true. Technically, however, it's still a guess, though at this point one I'm sure we're all comfortable making. That's why I asked about code *after* that last line. He replied there was no code before, but I think we can be generous in interpreting that (through the language barrier) as no code after. Unfortunately, at this point we're getting into application design issues unless and until Luca can learn enough Python and other programming stuff to understand why ser is going out of scope because it's a local variable and is then being garbage collected. (Luca, if you're reading, you really either have to just do exactly what Grant tells you :-), or learn about these issues enough to understand. If you don't know about object construction and destruction, memory allocation and garbage collection, the concept of scope and the difference between things like local variables, global variables, and attributes, we're going to continue to have an exceptionally difficult and frustrating time helping you. Serial ports aren't trivial, and combining them with a GUI program written by a rookie is a pretty big order. You can learn enough to figure this out, but it will be lots of work and a challenge. If you're up to it, please go read that how to ask smart questions page thoroughly if you haven't already, realizing that we're not trying to be rude by asking you to read it, and pay attention when someone asks you to try out different things, such as posting a small program that reproduces the problem, or post all the code rather than just snippets. Good luck.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as an extension language
On Mon, 06 Mar 2006 12:20:32 +0100 Torsten Bronger [EMAIL PROTECTED] wrote: Sybren Stuvel [EMAIL PROTECTED] writes: Torsten Bronger enlightened us with: I already know how to do that in principle. My only concern is distributing the thing, especially for the Windows platform. Check out distutils and py2exe. I know that py2exe can convert a Python script into an EXE file, however, I have no Python script. I only have C++ source code, and I'd like to avoid saying, well, please install my little EXE and this 10MB Python MSI for scripting it. If your C++ file is so small, then maybe you should not embed a Python interpreter in it, but rather allow it to be compiled as a Python module. Just write a Pyrex or Python C/API wrapper for it, and include a build for the Python module. -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
ANN: 2006 Python training courses, San Francisco
WE are giving 4 more Python training sessions (held near the San Francisco airport) for the remainder of this year. For the first time, there will be an advanced Python course available to the public. In fact, we've added the March intro course date for those prepping to take the advanced class in May. You may register for any of the 4 courses/dates below. (Intensive) Introduction to Python March 29-31, 2006 August 16-18, 2006 Advanced Python Programming May 17-19, 2006 November 8-10, 2006 LOCALS: it'll be at a hotel with BART and CalTrain access (San Bruno stations) VISITORS: free shuttle directly from the San Francisco airport, lots of free food and wireless DISCOUNTS available. for more info and details, go to http://cyberwebconsulting.com and click Python training. cheers, -wesley ps. a great big public THANKS to Rob Stephenson for putting together the short PodCast clip of one of our training sessions for your viewing pleasure on a video iPod or iTunes on your Mac! - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2006,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX/Python : read an xml from the end to the top
kepioo wrote: Peter, I cannot really process as your advice : it is not that stereotypical entrieswe built a data structure for the xml and we report various types of events, always under the same format but with different contents types. The script i am writing aims at picking only special events ( identified by a route tag and an information tag). Can you post one or two small examples that show the range of possibilities? I still have this feeling there will be a simpler approach than really parsing the XML, but maybe I'm wrong. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: how about adding ping's uuid module to the standard lib ?
[Fredrik Lundh wrote] see subject and http://python.org/sf/1368955 comments ? +1, once it has been vetted a bit (as is being done on the tracker) Trent -- Trent Mick [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: generators shared among threads
Alex wrote: Last, I'm not sure I'd think of this as a reentrantQueue, so much as a ReentrantCounter;-). Of course! It must have been late when I named this class... I think I'll go change the name in my code right now. -- http://mail.python.org/mailman/listinfo/python-list
Re: processing the genetic code with python?
Thanks so much guys for you all your help. I've had a month to learn python and do this for my project, I had the basics down but just kept getting unstuck. I won't message again - promise! Hehehe, thanks again everyone. -- http://mail.python.org/mailman/listinfo/python-list
Re: Opening files without closing them
Robert Kern [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Paul Rubin wrote: Say that the open is inside the try block. If the file can't be opened, then 'open' raises an exception, 'f' doesn't get set, and then the 'finally' clause tries to close f. f might have been previously bound to some other file (which still has other handles alive) and so the wrong file gets closed. And even if 'f' wasn't bound to anything, you will get a NameError instead of the exception that you're really interested in seeing. Thanks to both of you. So in order to be thorough, should I be doing: try: f=open('file') except: IOError: print 'doesn't exist' so_something_else_instead() try: contents = f.read() finally: f.close() Thanks again. Louis -- http://mail.python.org/mailman/listinfo/python-list
Re: New python.org website
While the new one is much better than the old website, the logo strikes me as awful. I tried to suggest repurposing the much better PyCon logo, but it didn't raise the vast groundswell of support I wanted it to. But for whatever its worth I'll try again. My rant is here: http://tinyurl.com/rkq3s mt -- http://mail.python.org/mailman/listinfo/python-list
Re: New python.org website
I think the new site is great. I really don't understand all the nit picking that's going on from the armchair web designers. The new site is clean and professional. It needs to go live soon! -- http://mail.python.org/mailman/listinfo/python-list