Re: Python! Is! Truly! Amazing!
"Erik Bethke" <[EMAIL PROTECTED]> writes: > I have NEVER experienced this kind of programming joy. Yep, I feel the same way since learning Python. It's really a productive and pleasant language. Congratulations on all your game successes! -- http://mail.python.org/mailman/listinfo/python-list
XPath and XQuery in Python?
Could someone help me get started using XPath or XQuery in Python? I'm overwhelmed by all the various options and am lacking guidance on what the simplest way to go is. What library do I need to enable three line Python programs to extract data with XPath expressions? I have this problem a lot with Python and XML. Even with Uche's excellent yearly roundups I have a hard time finding how to do fancy things with XML in Python. I think it's a bit like web server frameworks in Python - too many choices. http://www.xml.com/pub/a/2004/10/13/py-xml.html -- http://mail.python.org/mailman/listinfo/python-list
Re: XPath and XQuery in Python?
Nelson Minar <[EMAIL PROTECTED]> writes: > Could someone help me get started using XPath or XQuery in Python? I figured this out. Thanks for the help, John! Examples below. I used this exercise as an opportunity to get something off my chest about XML and Python - it's kind of a mess! More here: http://www.nelson.monkey.org/~nelson/weblog/tech/python/xpath.html Here are my samples, in three libraries: # PyXML from xml.dom.ext.reader import Sax2 from xml import xpath doc = Sax2.FromXmlFile('foo.opml').documentElement for url in xpath.Evaluate('//@xmlUrl', doc): print url.value # libxml2 import libxml2 doc = libxml2.parseFile('foo.opml') for url in doc.xpathEval('//@xmlUrl'): print url.content # ElementTree from elementtree import ElementTree tree = ElementTree.parse("foo.opml") for outline in tree.findall("//outline"): print outline.get('xmlUrl') Please see my blog entry for more commentary http://www.nelson.monkey.org/~nelson/weblog/tech/python/xpath.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SOAP
Peter Schaefer <[EMAIL PROTECTED]> writes: > Is SOAPy still the way to go, or are there better methods? SOAPy hasn't been maintained in awhile. The two contemporary options are ZSI or SOAPpy, both at http://pywebsvcs.sourceforge.net/ ZSI seems to have more serious development now, but neither is perfect. You should consider doing a document/literal service instead of rpc/encoded, the old way. Unfortunately in my experience doc/lit doesn't work as well with Python, but it's a better way of doing things. The ZSI guys are working at it. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is print? A function?
Frans Englich <[EMAIL PROTECTED]> writes: > The reason I thinks about this is I need to implement a debug print for my > program; very simple, a function/print statement that conditionally prints > its message whether a bool is true. Not overly complex. As several folks have said, print is a statement, and Python doesn't really let you add statements to the language. You said you wanted to build a simple debugging function, so maybe this doesn't fit the bill, but for bigger pieces of code Python has a nice logging library. It's something like log4j or java.util.logging. http://www.python.org/doc/2.4/lib/module-logging.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Where are list methods documented?
You're not the only one with a hard time finding the list documentation. It's even crazier for string docs. If you want to see how to strip strings in Python you have to go to the library docs, then click "sequence types" (betcha don't think of strings as sequences), then scroll to the bottom, then click "String Methods", then scroll to find "strip()". This makes perfect sense if you understand that strings are "mutable sequences". But if you're coming from (say) Perl and are looking for the quick way to work with strings, it's pretty deeply buried. A simple internal link or two would help a lot. Say, something in "built-in functions" which says "see also..." -- http://mail.python.org/mailman/listinfo/python-list
Re: time.clock() or time.time()
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I'm trying to benchmark some function calls for Zope project Other folks have explained time() vs. clock(), so I'll leave that. But rather than roll your own timer functions, consider using timeit. -- http://mail.python.org/mailman/listinfo/python-list