[ANN] logilab-astng 0.16.1
Hi there ! I'm pleased to announce the 0.16.1 release of Logilab astng package. This release include some major bug fixes (pylint crashs, 2.5 compatibility) and have tests passing from python 2.3 to python 2.5 :). You're higly encouraged to upgrade if you're currently using the 0.16.0 release. What's new ? * python 2.5 support, patch provided by Marien Zwart * fix [Class|Module].block_range method (this fixes pylint's inline disabling of messages on classes/modules) * handle class.__bases__ and class.__mro__ (proper metaclass handling still needed though) * drop python2.2 support: remove code that was working around python2.2 * fixed generator expression scope bug * patch transformer to extract correct line information Home page - http://www.logilab.org/projects/astng Download ftp://ftp.logilab.org/pub/astng Mailing list mailto://[EMAIL PROTECTED] LOGILAB provides services in the fields of XML techniques and advanced computing (implementation of intelligent agents, knowledge management, natural language processing, statistical analysis, data mining, etc.), and also trainings on Python, XML, UML, Object Oriented design, design patterns use and other cutting edge topics. To know more about Logilab, visit http://www.logilab.com/. Logilab is also a strong supporter of the Free Software movement, and an active member of the Python and Debian communities. Logilab's open source projects can be found on http://www.logilab.org/. -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
[ANN] logilab-common 0.19.2
Hi there ! I'm pleased to announce the 0.19.2 release of Logilab common package. This release include some bug fixes and have tests passing from python 2.3 to python 2.5 :). You may be surprised by the version number since we have been missing public annoucements recently. To quote Alexandre, we got a bit sloppy in the public part of our release process, and the mails did not fly... Hopefuly we'll be better on this in a near future. Take a look at the change log to get information about what's changed in the recent discret versions. What's new ? * testlib: - fixed a bug in find_test making it returns some bad test names - new assertIsInstance method on TestCase * optik_ext: make it works if mx.DateTime is not installed, in which case the date type option won't be available * test fixes What is common ? logilab-common is a collection of low-level Python packages and modules, designed to ease: * handling command line options and configuration files * writing interactive command line tools * manipulation files and character strings * interfacing to OmniORB * generating of SQL queries * running unit tests * manipulating tree structures * accessing RDBMS (currently postgreSQL, mysql and sqlite) * generating text and HTML reports * logging ... Home page - http://www.logilab.org/projects/common Download ftp://ftp.logilab.org/pub/common Mailing list mailto://[EMAIL PROTECTED] LOGILAB provides services in the fields of XML techniques and advanced computing (implementation of intelligent agents, knowledge management, natural language processing, statistical analysis, data mining, etc.), and also trainings on Python, XML, UML, Object Oriented design, design patterns use and other cutting edge topics. To know more about Logilab, visit http://www.logilab.com/. Logilab is also a strong supporter of the Free Software movement, and an active member of the Python and Debian communities. Logilab's open source projects can be found on http://www.logilab.org/. -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
IMDbPY 2.7
IMDbPY 2.7 is available (tgz, deb, rpm, exe) from: http://imdbpy.sourceforge.net/ IMDbPY is a Python package useful to retrieve and manage the data of the IMDb movie database about both movies and people. With this release some major bugs were fixed, especially in the http and mobile data access systems; searches which return a lot of results are handled gracefully. Platform-independent and written in pure Python (and few C lines), it can retrieve data from both the IMDb's web server and a local copy of the whole database. IMDbPY package can be very easily used by programmers and developers to provide access to the IMDb's data to their programs. Some simple example scripts are included in the package; other IMDbPY-based programs are available from the home page. -- Davide Alberani [EMAIL PROTECTED] [PGP KeyID: 0x465BFD47] http://erlug.linux.it/~da/ -- 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 (Sep 27)
QOTW: It's not out of the kindness of our hearts that we help. Heck, I don't know what it is. Probably I just like reading my own drivel on the internet and occasionally helping others is a good excuse. - Neil Cerutti Well, if you're only watching mtv, it's easy to think that there's obviously not much demand fr country singers, blues musicians, British hard rock bands, or melodic death metal acts. - Fredrik Lundh std{in,out,err} are easier than people realize: http://groups.google.com/group/comp.lang.python/browse_thread/thread/1295fe27228f/ Skip, Amaury, and Bruno illustrate that, yes, there *is* a purpose to for's else: http://groups.google.com/group/comp.lang.python/browse_thread/thread/bc1d8038e65c449/ Thanks to Connelly Barnes for the autoimp module: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2478cc7e5bcc6c30/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/python/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python 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://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. [EMAIL PROTECTED] and [EMAIL PROTECTED] welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python
London Python Meetup, Wednesday the 4th of October
I'm organising another London Python meetup at The Stage Door, Waterloo, London SE1 8QA (see http://tinyurl.com/ko27s) for Wednesday the 4th of October, anytime after work. Hope to see you there! -- Cheers, Simon B, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
cx_Oracle 4.2.1
What is cx_Oracle? cx_Oracle is a Python extension module that allows access to Oracle and conforms to the Python database API 2.0 specifications with a few exceptions. Where do I get it? http://starship.python.net/crew/atuining What's new? 1) Added additional type (NCLOB) to handle CLOBs that use the national character set as requested by Chris Dunscombe. 2) Added support for returning cursors from functions as requested by DanielSteinmann. 3) Added support for getting/setting the get mode on session pools as requested by Anand Aiyer. 4) Added support for binding subclassed cursors. 5) Fixed binding of decimal objects with absolute values less than 0.1. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Pydev 1.2.4 Released
Pydev and Pydev Extensions 1.2.4 have been released Details on Pydev Extensions: http://www.fabioz.com/pydev Details on Pydev: http://pydev.sf.net Details on its development: http://pydev.blogspot.com Release Highlights in Pydev Extensions: - * Code analysis: analysis on imported modules do no longer give you errors on * classes that have __getattribute__ or __getattr__ overriden * assigns that are initially None * assigns to a function call and not a class definition * Completions for parameters in a context-insensitive way, looking for all the methods/attributes declared in classes available to the project (after 3 chars) Release Highlights in Pydev: -- * Completions for parameters based on the tokens that were defined for it in a given context * Removed the default PyLint options, because its command-line interface changed (that was crashing PyLint in newer versions) * Changed the grammar so that 'yield' is correctly parsed as an _expression_ * Giving better error message when external file is opened without any interpreter selected * Icons for the builtins gotten on large libraries (such as wx -- it was optimized not to do that before) * Adding jars relative to the project now works correctly * Patched (Kovan): The debugger is now able to get the variables in a context when handling negative payloads What is PyDev? --- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny -- Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: ctypes question about call by reference
At Sunday 24/9/2006 15:49, Lawrence Oluyede wrote: Is it at all possbile to use a struct without defining it with ctypes? If you want to use it you have to define it somewhere... If it's an opaque thing, totally managed by the external code, yes - treat it as a pointer. That is, if you never have to access its fields, or create/destroy it in the python code (using an external function would be ok). Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Lawrence D'Oliveiro wrote: yield dict(zip(Fields, NextRow)) the OP didn't ask for a field name = value mapping, though. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CTypes translation of (pv != NULL)
At Monday 25/9/2006 21:27, [EMAIL PROTECTED] wrote: Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in http://starship.python.net/crew/theller/ctypes/tutorial.html) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Fredrik Lundh wrote: the OP didn't ask for a field name = value mapping, though. footnote: but for those who want that, I strongly recommend using something like Greg Stein's dtuple module: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81252 http://www.lyra.org/greg/python/dtuple.py /F -- http://mail.python.org/mailman/listinfo/python-list
Query regarding grep!!
Hi, I saw in PEP4 of python 2.5 that grep module has gone obsolete in perl 2.5. But I am not able to find an alternative for that.My doubt is are the other forms of grep like egrep and ggrep be used instead? cheers, Spurthi __ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
At Monday 25/9/2006 11:08, Jon Ribbens wrote: What precisely do you think it would break? existing code, and existing tests. I'm sorry, that's not good enough. How, precisely, would it break existing code? Can you come up with an example, or even an explanation of how it *could* break existing code? FWIW, a *lot* of unit tests on *my* generated html code would break, and I imagine a *lot* of other people's code would break too. So changing the defaults is not a good idea. But if you want, import this on sitecustomize.py and pretend it said quote=True: import cgi cgi.escape.func_defaults = (True,) del cgi Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Query regarding grep!!
bhavya sg wrote: I saw in PEP4 of python 2.5 that grep module has gone obsolete in perl 2.5. But I am not able to find an alternative for that. the grep module has been deprecated for ages (it's been in the lib-old non-standard library since at least Python 2.1). The old grep module depends on the regex module, which has been deprecated since Python 1.6, and which was finally removed in Python 2.5. My doubt is are the other forms of grep like egrep and ggrep be used instead? there are no such modules in Python, afaik. (and that's a question, not a doubt, right?) if you have Python code that uses the grep module, you can replace it with something like: import re def simple_grep(filename, pattern): find = re.compile(pattern).search for index, line in open(filename): if find(line): print filename, index, line[:-1] where pattern is an RE-style pattern, not a REGEX-style pattern (see the RE documentation for details). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Timeline for Python?
From: Fredrik Lundh [EMAIL PROTECTED] Date: Sat, Sep 23 2006 12:03 pm i cover through 2.5, but also include stuff that have already been slated for 2.6 and 2.7. and what would that be? target versions in the PEP:s are usually just wild guesses... true, and it's obviously a *bad* idea to be wrong. i don't have easy access to where in the manuscript i've made such annotations, however, there are some minor things which i'm reasonably sure will be in 2.6: - 'as' becomes a keyword - catching of string exceptions generates a warning (in 2.5, raising of string exceptions generates a warning) - the 'with' statement, introduced under __future__ in 2.5, becomes standard - intra-package imports not using the relative import syntax will generate a warning i'm sure all you dev folks will let me know where i've hung myself. i can always make an errata correction on the book's website as with any other problems that people find. however, the main point of my reply is really that i've tried hard to make the book to be as version- independent as much as possible. the added bonus is for those who *are* locked into specific (pre- sumably older) versions to know about features that were added to, altered in, or removed from Python and for which releases those updates were first introduced to the public. cheers, -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Jon Ribbens wrote: In article [EMAIL PROTECTED], Brian Quinlan wrote: Now you're just being ridiculous. In this thread you have been rude, evasive, insulting, vague, hypocritical, and have failed to answer substantive points in favour of sarcastic and erroneous sniping - I'd suggest it's you that needs to worry about being taken seriously. Actually, at least in the context of this mailing list, Fredrik doesn't have to worry about that at all. Why? Because he is one of the most prolific contributers to the Python language and libraries I would have hoped that people don't treat that as a licence to be obnoxious, though. I am aware of Fredrik's history, which is why I was somewhat surprised and disappointed that he was being so rude and unpleasant in this thread. He is not living up to his reputation at all. Maybe he's having a bad day ;-) I generally find that Fredrik's rudeness quotient is satisfactorily biased towards discouraging ill-informed comment. As far as rudeness goes, I've found your approach to this discussion to be pretty obnoxious, and I'm generally know as someone with a high tolerance for idiotic behaviour. If your intention was to troll you could not have crafted your contributions in a better way. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Steve Holden wrote: When you use the DB API correctly and paramterise your queries you still need to quote wildcards in search arguments, but you absolutely shouldn't quote the other SQL specials. That's what parameterised queries are for on the first place... So you're suggesting I quote the wildcards, then rely on autoquoted parameters to handle the rest? Unfortunately, that's stupid mistake number 2. Ah, so your quoting function will deduce the context in which arguments intended for parameter substitution in the query will be used? Or are you suggesting that it's unwise to rely on autoquoted parameters? That could have a serious impact on the efficiency of some repeated queries. I find it difficult to take your argument seriously. Are you doing this just to be obnoxious, or do you have a genuine point to make? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Fredrik Lundh wrote: Max M wrote: It also makes the escaped html harder to read for standard cases. and slows things down a bit. (cgi.escape(s, True) is slower than cgi.escape(s), for reasons that are obvious for anyone who's looked at the code). What you're doing is adding to the reasons why the existing cgi.escape function is stupidly designed and implemented. The True case is by far the most common, so to make that the slow case, as well as being the non-default case, is doubly brain-dead. How exactly would you make s = s.replace('',quot;) faster than *not* doing the replacement? -- http://mail.python.org/mailman/listinfo/python-list
Re: accepts decorator
At Monday 25/9/2006 21:58, urielka wrote: i think i got what the * and ** mean. *args mean arguments that are assigned by position(that is why *arg is a tuple) **kwds mean arguments that are assigned using equals a=2,b=3 (that is why **kwds i a dict) but why self is in *args and other thing goes to **kwds? even if not assigned using equals For these elemental things you should start by reading the Python tutorial included with the documentation - it's easy. And for decorators, this is a good text http://www.phyast.pitt.edu/~micheles/python/documentation.html which supplements the Python docs. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: (cgi.escape(s, True) is slower than cgi.escape(s), for reasons that are obvious for anyone who's looked at the code). What you're doing is adding to the reasons why the existing cgi.escape function is stupidly designed and implemented. The True case is by far the most common, so to make that the slow case, as well as being the non-default case, is doubly brain-dead. It is slightly slower because it does more. Both cases are about 15 times faster than the regular expression implementation someone posted to this thread yesterday. -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: In message [EMAIL PROTECTED], Duncan Booth wrote: If I have a unicode string such as: u'\u201d' (right double quote), then I want that encoded in my html as '#8221;' (or rdquo; but the numeric form is better). Right-double-quote is not an HTML special, so there's no need to quote it. I'm only concerned here with characters that have special meanings in HTML markup. There is no need to quote or ' either except in particular situations. Would you care to suggest how you get a right double quote into any iso- 8859-1 encoded web page without quoting it? Even if the page is utf-8 encoded quoting it can be a good idea. There should be a one-stop shop where I can take my unicode text and convert it into something I can safely insert into a generated html page; at present I need to call both cgi.escape and s.encode to get the desired effect. What you're really asking for is a version of cgi.escape that a) fixes the bugs discussed in this thread, and b) copes with different encodings while doing so. To handle b), you would need to pass it some indication of what the encoding of the string is. In any case, converting a literal right-double-quote to #8221; is not relevant to the purpose of cgi.escape. You don't seem to understand about html entity escapes. #8221; is a valid way to express right double quote whatever the page encoding. There is no need to know the encoding of the page in order to escape entities, just escape anything which can be problematic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
In message [EMAIL PROTECTED], Fredrik Lundh wrote: Lawrence D'Oliveiro wrote: yield dict(zip(Fields, NextRow)) the OP didn't ask for a field name = value mapping, though. What other kind of mapping could you produce? -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend file type
abcd wrote: Any ideas what methods the stdout (and I guess stderr) of Popen objects from subprocess call? the external process only sees OS-level file handles (the number you get from the fileno() method on your file objects), not Python objects. no matter how you override things in your process, you cannot make your OS pretend that the other process is written in Python... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Paul Rubin wrote: Brian Quinlan [EMAIL PROTECTED] writes: o cgi.escape is not meant for serious web application development, What is it meant for then? Why should the library ever implement anything in a half-assed way unsuitable for serious application development, if it can supply a robust implementation instead? I'd have to dig through the revision history to be sure, but I imagine that cgi.escape was originally only used in the cgi module (and there only in it's various print_* functions). Then it started being used by other core Python modules e.g. cgitb, DocXMLRPCServer. The mistake, if there was one, was probably that escape wasn't spelled _escape and got documented in the LaTeX documentation system. All of this is just speculation though. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro wrote: Fredrik Lundh wrote: you're not the designer... I don't have to be. Whoever the designer was, they had not properly thought through the uses of this function. That's quite obvious already, to anybody who works with HTML a lot. So the function is broken and needs to be fixed. If you're worried about changing the semantics of a function that keeps the same cgi.escape name, then fine. We delete the existing function and add a new, properly-designed one. _That_ will be a wake-up call to all the users of the existing function to fix their code. Wow. Are you always that arrogant for things you know very little about, or just plain stupid ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Frank Millman wrote: Fredrik Lundh wrote: Frank Millman wrote: I am reminded of a spoof Latin motto from the days of my youth - NIL ILLEGITIMO CARBORUNDUM isn't that usually written Illegitimi non carborundum ? or is that just due to differences between british latin and american latin ? /F or my bad memory - my youth was a long time ago :-) You were lucky, you *had* a youth [... etc.] regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Jon Ribbens wrote: In article [EMAIL PROTECTED], Brian Quinlan wrote: A summary of this pointless argument: Your summary seems pretty reasonable, but please note that later on, the thread was not about cgi.escape escaping (or not) quote characters (as described in your summary), but about Fredrik arguing, somewhat incoherently, that it should have to take character encodings into consideration. And, of course, about you telling people that their explanations are not good enough :-) BTW, I am curious about how you do unit testing. The example that I used in my summary is a very common pattern but would break in cgi.escape changed it's semantics. What do you do instead? Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Makin search on the other site and getting data and writing in xml
Steven D'Aprano wrote: Google don't define automated queryit, and I don't think they can. the phrases they use are well understood in the SE business. that's good enough for everyone involved (including courts; see below). (What on earth is meta-searching? If you're going to use terms which don't have a commonly understood meaning, define what they mean.) http://en.wikipedia.org/wiki/Metasearch_engine If I want to search for foo, and I type foo into the Firefox search box, is that an automated query? nope. unless you're a robot. What if I type gg: foo into Konqueror's address bar, which expands to http://www.google.com/search?q=foo;? Is it okay if I type the URL by hand myself? nope. unless you're a robot. Can I use the browser to save the search page to a local HTML file? If Google says no, how can they possibly hope to stop me? what you do with the search results once you've gotten them is outside the scope of that clause. What if I type this command into my shell? elinks --dump http://www.google.com/search?q=foo; output.html What if I type wget http://www.google.com/search?q=foo; into the shell? Surely that's no more automated than typing foo into Google's search box. neither is automated, unless you're a robot. Where is the line I must not cross? letting a program generate search requests based on something other than human wants to find something and types some keywords into a prompt somewhere. And that, it seems to me, is what the Original Poster wanted. the OP wanted to read keywords from a text file generated in some unknown fashion. that's bot behaviour, not human behaviour. Of course, what I think isn't important. If Google wants to write legal contracts that won't stand up in court (speaking as somebody who isn't a lawyer and whose legal advice is worthless) well, here's some random guy who didn't understand the terms used in the contract isn't a valid defense in court; courts are more interested in whether people with experience from the relevant field can reasonably be expected to understand the contract. but this isn't about court cases, of course; it's about getting banned by Google for abusing their services. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
well, if you're only watching mtv, it's easy to think that there's obviously not much demand for country singers, blues musicians, British hard rock bands, or melodic death metal acts. These days its even hard to get the idea that there is a demand of boy bands, rnb, euro trash or any other popular music when watching it. But make sure you polish your mechanics degrees, there sure is to pimp something out there, and training a head-butt also will do you good... SCNR, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
In message [EMAIL PROTECTED], I wrote: In message [EMAIL PROTECTED], Fredrik Lundh wrote: Lawrence D'Oliveiro wrote: yield dict(zip(Fields, NextRow)) the OP didn't ask for a field name = value mapping, though. What other kind of mapping could you produce? All right, sorry, looks like they want to load the entire table into RAM and key it off the first field. Kind of defeats the point of having SQL, but there you go... -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Max M wrote: Lawrence is right that the escape method doesn't work the way he expects it to. Rewriting a library module simply because a developer is surprised is a *very* bad idea. I'm not surprised. Disappointed, yes. Verging on disgust at some comments in this thread, yes. But surprised is what a lot of users of the existing cgi.escape function are going to be when they discover their code isn't doing what they thought it was. Why should they be surprised? The documentation states clearly what cgi.escape() does (as does the docstring). Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Makin search on the other site and getting data and writing in xml
Steven D'Aprano wrote: On Mon, 25 Sep 2006 13:51:55 +0200, Fredrik Lundh wrote: http://www.google.com/terms_of_service.html You may not send automated queries of any sort to Google's system without express permission in advance from Google. I'm not just being a pedantic weasel here, but what's an automated query? Google's ToS is a legal document (maybe), and if both parties don't agree on the meanings of terms, well, then it is a lousy legal document and a recipe for trouble. Google don't define automated queryit, and I don't think they can. In fact, the closest they come to defining it is to list three things they want to prevent, NONE of which have anything to do with the distinction between automated and non-automated. The fact remains that Google can chop your searching ability off at the knees if *they* determine that you have broken the terms of service, so whether you agree or not becomes slightly academic. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
In message [EMAIL PROTECTED], Steve Holden wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Steve Holden wrote: When you use the DB API correctly and paramterise your queries you still need to quote wildcards in search arguments, but you absolutely shouldn't quote the other SQL specials. That's what parameterised queries are for on the first place... So you're suggesting I quote the wildcards, then rely on autoquoted parameters to handle the rest? Unfortunately, that's stupid mistake number 2. Ah, so your quoting function will deduce the context in which arguments intended for parameter substitution in the query will be used? Or are you suggesting that it's unwise to rely on autoquoted parameters? No, I'm saying it's _incorrect_ to use the existing autoquoting mechanism in combination with a separate function that escapes the wildcards. I previously described the two stupid mistakes that can arise from having a separate function for doing just the wildcard quoting: this is the second one. That could have a serious impact on the efficiency of some repeated queries. Correctness comes before efficiency. It's no point doing it quickly if you're doing it wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
In message [EMAIL PROTECTED], Georg Brandl wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Fredrik Lundh wrote: Lawrence D'Oliveiro wrote: Georg Brandl wrote: A function is broken if its implementation doesn't match the documentation. or if it doesn't match the designer's intent. cgi.escape is old enough that we would have noticed that, by now... _We_ certainly have noticed it. you're not the designer... I don't have to be. Whoever the designer was, they had not properly thought through the uses of this function. That's quite obvious already, to anybody who works with HTML a lot. So the function is broken and needs to be fixed. If you're worried about changing the semantics of a function that keeps the same cgi.escape name, then fine. We delete the existing function and add a new, properly-designed one. _That_ will be a wake-up call to all the users of the existing function to fix their code. What about the users who don't need to fix their code since it's working fine and flawlessly with the current cgi.escape? They're just lucky. I guess, that the bugs haven't bitten them--yet. -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Steve Holden wrote: Ah, so your quoting function will deduce the context in which arguments intended for parameter substitution in the query will be used? Or are you suggesting that it's unwise to rely on autoquoted parameters? That could have a serious impact on the efficiency of some repeated queries. but people wouldn't use Python if they cared about efficiency /F -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
In message [EMAIL PROTECTED], Gabriel G wrote: At Monday 25/9/2006 11:08, Jon Ribbens wrote: What precisely do you think it would break? existing code, and existing tests. I'm sorry, that's not good enough. How, precisely, would it break existing code? Can you come up with an example, or even an explanation of how it *could* break existing code? FWIW, a *lot* of unit tests on *my* generated html code would break... Why did you write your code that way? -- http://mail.python.org/mailman/listinfo/python-list
Re: accepts decorator
hehe i saw that,that is what made my understand it. the decorator now works. let say i have a function decorated with two decorators: @Accept(int,int) @OtherDecorator def myfunc(a,b): pass how can i make the two decorators into one(note:one get parameters and the other doesn`t) -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
In message [EMAIL PROTECTED], Georg Brandl wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Max M wrote: Lawrence is right that the escape method doesn't work the way he expects it to. Rewriting a library module simply because a developer is surprised is a *very* bad idea. I'm not surprised. Disappointed, yes. Verging on disgust at some comments in this thread, yes. But surprised is what a lot of users of the existing cgi.escape function are going to be when they discover their code isn't doing what they thought it was. Why should they be surprised? The documentation states clearly what cgi.escape() does (as does the docstring). Documentation frequently states stupid things. Doesn't mean it should be treated as sacrosanct. -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Fredrik Lundh wrote: Lawrence D'Oliveiro wrote: Georg Brandl wrote: A function is broken if its implementation doesn't match the documentation. or if it doesn't match the designer's intent. cgi.escape is old enough that we would have noticed that, by now... _We_ certainly have noticed it. you're not the designer... I don't have to be. Whoever the designer was, they had not properly thought through the uses of this function. That's quite obvious already, to anybody who works with HTML a lot. So the function is broken and needs to be fixed. If you're worried about changing the semantics of a function that keeps the same cgi.escape name, then fine. We delete the existing function and add a new, properly-designed one. _That_ will be a wake-up call to all the users of the existing function to fix their code. What about the users who don't need to fix their code since it's working fine and flawlessly with the current cgi.escape? Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run in background?
At Monday 25/9/2006 09:02, billie wrote: Hi all. I know that it's possible to automatically run a Python program in background by giving it the pyw extension. This is useful when I release a source ditribution of my program. How could it be possible to do the same thing with an .exe file compiled with py2exe extension? Do I have to write a batch script separately? I don't remember the details, but in your setup.py replace: console=myscript.py to windows=myscript.py (or maybe noconsole=myscript.py? I dont remember, but look at the distutils docs) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: QOTW (was Re: does anybody earn a living programming in python?)
Aahz enlightened us with: Fredrik Lundh [EMAIL PROTECTED] wrote: well, if you're only watching mtv, it's easy to think that there's obviously not much demand for country singers, blues musicians, British hard rock bands, or melodic death metal acts. Any other votes for this being QOTW? +1 here Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Lawrence D'Oliveiro wrote: Kind of defeats the point of having SQL, but there you go... there are plenty of reasons to use Python data structures instead of the SQL engine for data crunching. especially if you care about efficiency. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: SimpleXMLRPCServer and socket
Juju wrote: But I still have a little question : How can I do to know which method I should override to make the things work ? Usually, I look at python.org but in this case, I couldn't find what I was looking for. Finally, I had to look at the source files to under- stand what I should do. the SocketServer framework is a bit underdocumented, indeed. it would be a nice subject for an extended howto document, I think (cf. http://www.amk.ca/python/howto/ ). any volunteers ? on the other hand, the code is stable, and it's not going anywhere, so reading the source is perfectly okay. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE - Customizing output format
Ilias Lazaridis wrote: Ilias Lazaridis wrote: IDLE has an output format like this: object type 'object' type type 'type' object.__class__ type 'type' object.__bases__ How can I customize it to become like that: object type 'object' type type 'type' object.__class__ type 'type' object.__bases__ or that: object : type 'object' type : type 'type' object.__class__ : type 'type' object.__bases__ (preferably without modifying code) I assume this is not possible. I am wondering that other users are not annoyed by this reduced readability. I'm sure its quite unpopular to agree with you, but I do. I am tremendously annoyed the format of the interactive interpreter. Lovely would be output as you describe, but with the option, when selecting for copy-paste, to include the prompts and/or your suggested whitespace margin (e.g. select in doctest mode). James -- http://mail.python.org/mailman/listinfo/python-list
Re: SimpleXMLRPCServer and socket
Hi, 2006/9/25, Fredrik Lundh [EMAIL PROTECTED]: I don't have time to dig deeper into this right now, but this post might be helpful: http://article.gmane.org/gmane.comp.python.general/471411 I tried to override the verify_request method, it managed to get the ClientAddress, but in this method, the Server is not yet Multithreaded so I couldn't detect which ClientAddress correspond to which Thread. So I look more closely at the code (TCPServer, SimpleXMLRPCServer...) and I finally manage to do what I wanted to do, with overriding the finish_request method and storing the ClientAddresses in a dict (with the Thread ID as the key) : -- def finish_request(self, request, client_address): # Override the finish_request to collect the client address self.dictClientAddress[str(thread.get_ident())]=client_address SimpleXMLRPCServer.SimpleXMLRPCServer.finish_request(self, request, client_address) -- And now it works ! But I still have a little question : How can I do to know which method I should override to make the things work ? Usually, I look at python.org but in this case, I couldn't find what I was looking for. Finally, I had to look at the source files to understand what I should do. Thanks in advance... Ju (if not, follow up to c.l.python) cheers /F -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
At Monday 25/9/2006 20:09, walterbyrd wrote: I do. If so, I doubt there are many. That's why they get well paid :) (uhm, not really... :( ) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Query regarding grep!!
Of course you can always use grep as an external process (if the OS has it). For example: --- In [1]: import subprocess In [2]: out=subprocess.Popen( 'grep -i blah ./tmp/*', stdout=subprocess.PIPE, shell=True ).communicate()[0] In [3]: out Out[3]: './tmp/ex.tex:Blah blah blah...\n' --- -Nick V. bhavya sg wrote: Hi, I saw in PEP4 of python 2.5 that grep module has gone obsolete in perl 2.5. But I am not able to find an alternative for that.My doubt is are the other forms of grep like egrep and ggrep be used instead? cheers, Spurthi __ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
In message [EMAIL PROTECTED], Duncan Booth wrote: The spurious escaping of the apostrophe does no harm, but spuriously escaping a newline makes the select match the letter 'n' insteal of matching a newline. And how would you get my QuoteSQL routine, as written, to make the same mistake you did? -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend file type
abcd enlightened us with: Any suggestions on how to find out? I did try adding to MyFile def __call__(self, *args): print calling:, args return file.__call__(self, *args) but I never see that either. I don't know the answer to your problem, but I can explain why this doesn't work. __call__ is used when an instance if MyFile is called as if it were a function: mf = MyFile(blabla) mf() Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Lawrence D'Oliveiro wrote: What other kind of mapping could you produce? and here we go again. how about reading the code the OP posted, or the first few followups? /F -- http://mail.python.org/mailman/listinfo/python-list
Surprise using the 'is' operator
I thought the 'is' operator was used to identify identical objects, whereas the '==' operator checked equality. Well, I got a surprise here: IDLE 1.1.3 a = 10 b = a a is b True a == b True c = 10 a == c True a is c True I was NOT expecting the last statement to return True! What am I missing? Thanks Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: Makin search on the other site and getting data and writing in xml
GOOGLE IS NOT OUR SUBJECT ANY MORE. MY GOAL IS NOT MAKING SEARCH ON GOOGLE: MY GOAL IS MAKING A SEARCH ON www.onelook.com, for example -- http://mail.python.org/mailman/listinfo/python-list
[ANN] logilab-astng 0.16.1
Hi there ! I'm pleased to announce the 0.16.1 release of Logilab astng package. This release include some major bug fixes (pylint crashs, 2.5 compatibility) and have tests passing from python 2.3 to python 2.5 :). You're higly encouraged to upgrade if you're currently using the 0.16.0 release. What's new ? * python 2.5 support, patch provided by Marien Zwart * fix [Class|Module].block_range method (this fixes pylint's inline disabling of messages on classes/modules) * handle class.__bases__ and class.__mro__ (proper metaclass handling still needed though) * drop python2.2 support: remove code that was working around python2.2 * fixed generator expression scope bug * patch transformer to extract correct line information Home page - http://www.logilab.org/projects/astng Download ftp://ftp.logilab.org/pub/astng Mailing list mailto://[EMAIL PROTECTED] LOGILAB provides services in the fields of XML techniques and advanced computing (implementation of intelligent agents, knowledge management, natural language processing, statistical analysis, data mining, etc.), and also trainings on Python, XML, UML, Object Oriented design, design patterns use and other cutting edge topics. To know more about Logilab, visit http://www.logilab.com/. Logilab is also a strong supporter of the Free Software movement, and an active member of the Python and Debian communities. Logilab's open source projects can be found on http://www.logilab.org/. -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Sybren Stuvel wrote: I'm suggesting functions based on the role of the string they need to escape, not the characters in that string. 1) Quoting of wildcard strings for a query using LIKE etc. 2) Quoting of values for putting into queries. it's actually quite amusing that some people have such a hard time developing a conceptual model that actually matches the underlying architecture and the information model. and it's usually the same people that end up arguing for hypergeneralization. it's about data, folks, not syntax artifacts. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: I need some help with a regexp please
Dennis Lee Bieber wrote: On 25 Sep 2006 10:25:01 -0700, codefire [EMAIL PROTECTED] declaimed the following in comp.lang.python: Yes, I didn't make it clear in my original post - the purpose of the code was to learn something about regexps (I only started coding Python last week). In terms of learning a little more the example was successful. However, creating a full email validator is way beyond me - the rules are far too complex!! :) I've been doing small things in Python for over a decade now (starting with the Amiga port)... I still don't touch regular expressions... They may be fast, but to me they are just as much line noise as PERL... I can usually code a partial parser faster than try to figure out an RE. If I may add another thought along the same line: regular expressions seem to tend towards an art form, or an intellectual game. Many discussions revolving around regular expressions convey the impression that the challenge being pursued is finding a magic formula much more than solving a problem. In addition there seems to exist some code of honor which dictates that the magic formula must consist of one single expression that does it all. I suspect that the complexity of one single expression grows somehow exponentially with the number of functionalities it has to perform and at some point enters a gray zone of impending conceptual intractability where the quest for the magic formula becomes particularly fascinating. I also suspect that some problems are impossible to solve with a single expression and that no test of intractability exists other than giving up after so many hours of trying. With reference to the OP's question, what speaks against passing his texts through several simple expressions in succession? Speed of execution? Hardly. The speed penalty would not be perceptible. Conversely, in favor of multiple expressions speaks that they can be kept simple and that the performance of the entire set can be incrementally improved by adding another simple expression whenever an unexpected contingency occurs, as they may occur at any time with informal systems. One may not win a coding contest this way, but saving time isn't bad either, or is even better. Frederic -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
walterbyrd wrote: If so, I doubt there are many. My share of the waterfall :o) I do earn my (preposterously nice *wink*) salary from doing *all* major efforts, at the company I work for, in Python. Not only that, since I started out here some 5 years ago, nearly all software development of new thingys have moved to.. right! Python! That adds three more people. (We do use some Java for PDA's and also C++, the last just for maintenance of older SW) And even more, some of our PLC programmers use Python to auto-render PLC code for Siemens(!), significantly increasing their productivity in each and every project. So I guess you just have to listen in on the right frequencies *wink again* //M -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Lawrence D'Oliveiro enlightened us with: The trouble with this is that, instead of offering extra functionality, it leaves the door open to making two stupid mistakes: 2) quoting of wildcards BEFORE quoting of non-wildcards Why is this a stupid mistake in your view? Please explain this in detail, because I think it's a proper way of doing it. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a percent sign
In message [EMAIL PROTECTED], John Machin wrote: 1. Reasoning: How do you get a literal ' into an SQL string constant? How do you get a literal \ into a Python string constant? How do you get a literal $ into some *x shell command lines? Do you detect a pattern? None of which applies to escaping of % characters in format strings. -- http://mail.python.org/mailman/listinfo/python-list
Re: concat next line with previous
[EMAIL PROTECTED] enlightened us with: hi what is the python way to concat 2 lines eg concated = line1 + line2 Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Talking to marketing people about Python
Dennis Lee Bieber wrote: Unfortunately, if management goes further down the page, they find Ruby and D (when did that get out) both rated so many up arrows they had to use shorthand notation to represent 14 arrows... Yes, there is no doubt Ruby is gaining traction - mostly due to the success of Ruby on Rails. I was in the Ruby community in the very early days and it was like being in a quiet backwater. As soon as ROR came on the scene the whole thing just exploded. I chose Python over Ruby because it has more maturity and stability (in terms of the product). Python does the job and does it well and is steadily growing and improving. D has been around for several years at least. It doesn't really compete with Python though. But not sure if it would be suitable for the product mentioned at the start of this thread. Cheers, Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: where are isinstance types documented?
codefire wrote: Hi, I'm using the isinstance built-in function. I've found the docs for it, but there are no docs on the supported types. It supports *all* types. For example isinstance(a, int) works fine but isinstance(s, string) doesn't - because 'string is not known'. That's because there is no built-in type called string. I do know how to import the types module and then use defined types such as 'types.StringType' - but the documentation says that from 2.2 this is not the preferred way. So, where's the documentation for types I can use with isinstance, such as 'int'? This is must-read stuff, but doesn't give the actual type names: http://docs.python.org/ref/types.html What you are looking for is this: http://docs.python.org/lib/types.html which is also must-read, but you may find it faster to use the Who's your father? technique on a known instance: | type([]) | type 'list' | type('') | type 'str' | type(u'') | type 'unicode' | isinstance('foo', str) | True | isinstance('foo', unicode) | False Who's your grandfather? can be useful, too: | str.__mro__ | (type 'str', type 'basestring', type 'object') | isinstance('foo', basestring) | True | isinstance(u'u2', basestring) | True HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
In message [EMAIL PROTECTED], Fredrik Lundh wrote: Lawrence D'Oliveiro wrote: SQL databases like MySQL are _designed_ for efficiency. unlike the Python data types, you mean ? Did I say it was unlike anything? -- http://mail.python.org/mailman/listinfo/python-list
Re: Verify an e-mail-adress - syntax and dns
Steven D'Aprano a écrit : On Mon, 25 Sep 2006 16:11:38 +0200, Christophe wrote: This is useless AND annoying at the same time. But people like us don't screw up our email address in the first place, and if we do, we know how to fix it. Not everybody is like us. So you say that the better answer is not to teach them to be careful when they fill those forms. It's to annoy them and teach them to copypaste mistakes instead! Besides, what is so special with electronic forms that we have to go through all kind of tricks to make sure the user doesn't make mistakes when regular paper forms just assume the user will be careful when he fills it? Must be some kind of IQ draining field emited by all the computers which only computer experts are immune to :D -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
Lawrence D'Oliveiro wrote: SQL databases like MySQL are _designed_ for efficiency. unlike the Python data types, you mean ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a percent sign
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], John Machin wrote: 1. Reasoning: How do you get a literal ' into an SQL string constant? How do you get a literal \ into a Python string constant? How do you get a literal $ into some *x shell command lines? Do you detect a pattern? None of which applies to escaping of % characters in format strings. What I had in mind was: where surname = 'O''REILLY' install_dir = C:\\Python25 ... print The interest rate is %.2f%% p.a. % (rate * 100.0) the common pattern being that the problem character is doubled. -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprise using the 'is' operator
codefire a écrit : I thought the 'is' operator was used to identify identical objects, whereas the '==' operator checked equality. Well, I got a surprise here: IDLE 1.1.3 a = 10 b = a a is b True a == b True c = 10 a == c True a is c True I was NOT expecting the last statement to return True! The answer is : Why not? Does it even matter for integers? Never use is on integers, always == ( and on strings too for that matter ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprise using the 'is' operator
codefire wrote: I thought the 'is' operator was used to identify identical objects, whereas the '==' operator checked equality. Well, I got a surprise here: IDLE 1.1.3 a = 10 b = a a is b True a == b True c = 10 a == c True a is c True I was NOT expecting the last statement to return True! What am I missing? One of the most severely beaten dead horses of python - small integers are cached by the interpreter. Maybe. Thus the above results. Google for a bazillion discussions on this. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
In message [EMAIL PROTECTED], Sybren Stuvel wrote: Lawrence D'Oliveiro enlightened us with: The trouble with this is that, instead of offering extra functionality, it leaves the door open to making two stupid mistakes: 2) quoting of wildcards BEFORE quoting of non-wildcards Why is this a stupid mistake in your view? Please explain this in detail, because I think it's a proper way of doing it. Because quoting the wildcards introduces backslash specials before each wildcard. Quoting non-wildcards then causes those backslashes to be doubled, which means they escape themselves instead of the wildcards. -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
In article [EMAIL PROTECTED], Steve Holden wrote: I would have hoped that people don't treat that as a licence to be obnoxious, though. I am aware of Fredrik's history, which is why I was somewhat surprised and disappointed that he was being so rude and unpleasant in this thread. He is not living up to his reputation at all. Maybe he's having a bad day ;-) I generally find that Fredrik's rudeness quotient is satisfactorily biased towards discouraging ill-informed comment. It's a pity he's being rude when presented with well-informed comment then. As far as rudeness goes, I've found your approach to this discussion to be pretty obnoxious, and I'm generally know as someone with a high tolerance for idiotic behaviour. Why do you say that? I have confined myself to simple logical arguments, and been frankly very restrained when presented with rudeness and misunderstanding from other thread participants. In what way should I have modified my postings? -- http://mail.python.org/mailman/listinfo/python-list
Re: newbe's re question
[EMAIL PROTECTED] wrote: Frederic Rentsch wrote: [EMAIL PROTECTED] wrote: These are csound files. Csound recently added python as a scripting language and is allowing also allowing csound calls from outside of csound. The nice thing about csound is that instead of worrying about virus and large files it is an interpiter and all the files look somewhat like html. 4,000 virus free instruments for $20 is available at http://www.csounds.com and the csound programming book is also available. The downside is that csound is can be realy ugly looking (that is what I am trying to change) and it lets you write ugly looking song code that is almost unreadable at times (would look nice in a grid) snip snip snip snip snip . I was hoping to add and remove instruments.. although the other should go into my example file because it will come in handy at some point. It would also be cool to get a list of instruments along with any comment line if there is one into a grid but that is two different functions. http://www.dexrow.com Eric, Below the dotted line there are two functions. csound_filter () extracts and formats instrument blocks from csound files and writes the output to another file. (If called without an output file name, the output displays on the screen). The second function, make_instrument_dictionaries (), takes the file generated by the first function and makes two dictionaries. One of them lists instrument ids keyed on instrument description, the other one does it the other way around, listing descriptions by instrument id. Instrument ids are file name plus instrument number. You cannot depend on this system to function reliably, because it extracts information from comments. I took my data from ems.music.utexas.edu/program/mus329j/CSPrimer.pdf the author of which happens to lead his instrument blocks with a header made up of comment lines, the first of which characterizes the block. That first line I use to make the dictionaries. If your data doesn't follow this practice, then you may not get meaningful dictionaries and are in for some hacking. In any case, this doesn't look like a job that can be fully automated. But if you can build your data base with a manageable amount of manual work you should be okay. The SE filter likewise works depending on formal consistency with my sample. If it fails, you may have to either tweak it or move up to a parser. I'll be glad to provide further assistance to the best of my knowledge. But you will have to make an effort to express yourself intelligibly. As a matter of fact the hardest part of proposing solutions to your problem is guessing what your problem is. I suggest you do this: before you post, show the message to a good friend and edit it until he understands it. Regards Frederic . def csound_filter (csound_file_name, name_of_formatted_instrument_blocks_file = sys.stdout): This function filters and formats instrument blocks out of a csound file. csound_formatter (csound_file_name, name_of_formatted_instrument_blocks_file) csound_formatter (csound_file_name) # Single argument: screen output import SE Instruments_Filter = SE.SE ('EAT ~;.*~==(10) ~instr(.|\n)*?endin~==(10)(10)') INDENT = 10 CODE_LENGTH = 50 def format (): for l in instruments_file: line = l.strip () if line == '': out_file.write ('\n') else: if line [0] == ';': # Comment line out_file.write ('%s\n' % line) else: code = comment = '' if line [-1] == ':': # Label out_file.write ('%s\n' % line) else: if ';' in line: code, comment = line.split (';') out_file.write ('%*s%-*s;%s\n' % (INDENT, '', CODE_LENGTH, code, comment)) else: out_file.write ('%*s%s\n' % (INDENT, '', line)) instruments_file_name = Instruments_Filter (csound_file_name) instruments_file = file (instruments_file_name, 'w+a') if name_of_formatted_instrument_blocks_file != sys.stdout: out_file = file (name_of_formatted_instrument_blocks_file, 'wa') owns_out_file = True else: out_file = name_of_formatted_instrument_blocks_file owns_out_file = False format () if owns_out_file: out_file.close () def make_instrument_dictionaries (name_of_formatted_instrument_blocks_file): This function takes a file made by the previous function and generates two dictionaries. One records instrument ids by description. The other one instrument descriptions by id. Instrument ids are made up of file name and instrument number. If these two
Re: Remap Mysql tuple to dictionary
On 9/26/06, Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: All right, sorry, looks like they want to load the entire table into RAM and key it off the first field. Kind of defeats the point of having SQL, but there you go... Keeping an in-memory cache of small, unchanging, frequently-read tables is a very common, and often very effective performance tweak in database driven systems. -- Cheers, Simon B, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
George Sakkis wrote: [Oslo, Norway short of 300-500 Java developers] Um, how many of these lots of Java developers looking for work live in, or are willing to relocate to, Oslo? Well, I really meant to say that the lots of Java developers I've seen actually are in Oslo. Certainly, every time this topic comes up in some article, people tend to complain about a mismatch between employer claims and their own experiences trying to get hired, and there wouldn't be much of a debate if those people were not within commuting distance. Another point might be that many ads prefix the offered position with senior, and my guess is that most of those looking for work don't really qualify, for any reasonable definition of senior. It's quite possible that a lot of the people out in the job market don't have the experience with Java that employers supposedly demand, although in many cases that isn't anything to do with how long they've been in the business (one definition of senior). However, I'd question the need only for senior developers in a market for a particular technology, since it would suggest that either everyone seems to think that they're doing rocket science, or the technology isn't the most appropriate or efficient way to do the work (especially given the supposed lack of developers). However, knowing the corporate/political undercurrents behind some of these recruitment advertorials, I might suggest that many of these supposedly available Java positions don't actually exist. If the handful of advertised Python positions do actually exist, on the other hand, we can at least estimate the prospects of Python practitioners with more certainty. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprise using the 'is' operator
codefire wrote: I was just trying to check if objects were the same (object), didn't know Integers were a special case. they're not, really; is works the same way for all objects. when you ask for a new immutable object, a Python implementation may always reuse an existing object, if it wants to. the CPython implementation does this for small integers, booleans, None, empty tuples, certain strings, type objects, etc. this also applies to library code; for example, string methods often return a reference to self if the method didn't actually change anything. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Jon Ribbens [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Duncan Booth wrote: I guess you've never seen anyone write tests which retrieve some generated html and compare it against the expected value. If the page contains any unescaped quotes then this change would break it. You're right - I've never seen anyone do such a thing. It sounds like a highly dubious and very fragile sort of test to me, of very limited use. So what sort of test would you use, that doesn't involve comparing actual output against expected output? -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
AOL^H^H^H, me too. And it's paid better than C++ programming. HTH, Gerald Gabriel Genellina schrieb: At Monday 25/9/2006 20:09, walterbyrd wrote: I do. If so, I doubt there are many. That's why they get well paid :) (uhm, not really... :( ) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Makin search on the other site and getting data and writing in xml
[EMAIL PROTECTED] wrote: GOOGLE IS NOT OUR SUBJECT ANY MORE. MY GOAL IS NOT MAKING SEARCH ON GOOGLE: MY GOAL IS MAKING A SEARCH ON www.onelook.com, for example Can you send me the list of words in the index? May I extract it from your site? No, sorry. If you're thinking about writing a script to systematically copy OneLook.com's word list, please don't. It's not yours to copy, for one thing. But also, it wastes tremendous bandwidth and slows things down for other users. We have software in place to detect the abuse of our service and we'll alert your ISP if you violate our trust in you. If you're looking for a decent-sized downloadable word list, try WordNet, which offers that and much more. If you're working on a project for school or academic research, let us know and we might be able to help steer you in the right direction. Consider this: if you'd offered the courtesy of a occasional lemonade for you neighbours, does that mean that you like them stomping around in your kitchen? Nearly all of sites that offer a service like this will have policies of that kind. So - get a grip, stop shouting, and start thinking if what you are trying to do is legal or social. If not, and you don't care - be my guest, but don't ask for help here! Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Georg Brandl wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Max M wrote: Lawrence is right that the escape method doesn't work the way he expects it to. Rewriting a library module simply because a developer is surprised is a *very* bad idea. I'm not surprised. Disappointed, yes. Verging on disgust at some comments in this thread, yes. But surprised is what a lot of users of the existing cgi.escape function are going to be when they discover their code isn't doing what they thought it was. Why should they be surprised? The documentation states clearly what cgi.escape() does (as does the docstring). Documentation frequently states stupid things. Doesn't mean it should be treated as sacrosanct. That's not the point. The point is that someone using cgi.escape() will hardly be surprised of what it does and doesn't do. Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: ruby %w equivalent
Antoine De Groote wrote: Thorsten Kampe wrote: * John Machin (24 Sep 2006 15:32:20 -0700) Antoine De Groote wrote: is there a python equivalent for the ruby %w operator? %w{a b c} creates an array with strings a, b, and c in ruby... | a b c.split() | ['a', 'b', 'c'] ... appears to match your single example. Something wrong with list('abc')? Or is it too simple?! Thorsten As far as I can tell this works for single characters only. You're not able to split words, as in one two three.split(). Regards, antoine And this is what Georg Brandl already posted. Sorry! -- http://mail.python.org/mailman/listinfo/python-list
Re: where are isinstance types documented?
codefire enlightened us with: I'm using the isinstance built-in function. I've found the docs for it, but there are no docs on the supported types. All types/classes are supported. For example isinstance(a, int) works fine but isinstance(s, string) doesn't - because 'string is not known'. That is because 'string' is not a class: print abc.__class__.__name__ The name is 'str', not 'string'. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Makin search on the other site and getting data and writing in xml
[EMAIL PROTECTED] wrote: GOOGLE IS NOT OUR SUBJECT ANY MORE. MY GOAL IS NOT MAKING SEARCH ON GOOGLE: MY GOAL IS MAKING A SEARCH ON www.onelook.com, for example this is usenet; you don't own the threads you start. if there's a subthread that you don't find relevant to your original question, just ignore it. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: I need some help with a regexp please
Frederic Rentsch wrote: If I may add another thought along the same line: regular expressions seem to tend towards an art form, or an intellectual game. Many discussions revolving around regular expressions convey the impression that the challenge being pursued is finding a magic formula much more than solving a problem. In addition there seems to exist some code of honor which dictates that the magic formula must consist of one single expression that does it all. hear! hear! for dense guys like myself, regular expressions work best if you use them as simple tokenizers, and they suck pretty badly if you're trying to use them as parsers. and using a few RE:s per problem (or none at all) is a perfectly good way to get things done. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL meta data
In message [EMAIL PROTECTED], BerndWill wrote: The only solution from me and my colleagues view (as poor at it sounds) is to setup a little python script pinging an amount of about 2.000 servers in daily intervals checking for the validity of those SSL certificates. There's no need to check each server more than once. It gives you its certificate, you check the expiry date, save that in a database, and you don't have to worry until the expiry date comes close, when it's time to notify somebody to organize a renewal. -- http://mail.python.org/mailman/listinfo/python-list
Re: concat next line with previous
On 26 Sep 2006 03:16:25 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: what is the python way to concat 2 lines eg line 1 with some text line 2 with some text i want to bring line 2 up , such that i get one whole string. line 1 with some text line 2 with some text line1 = line 1 with some text line2 = line 2 with some text # Simplest way: line3 = line1 + line2 # More general - joining a sequence of strings, with delimiter lines = [line1, line2] line3 = , .join(lines) -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Lawrence D'Oliveiro enlightened us with: You're proposing two separate functions: 1) quoting of non-wildcard specials 2) quoting of wildcard specials I'm suggesting functions based on the role of the string they need to escape, not the characters in that string. 1) Quoting of wildcard strings for a query using LIKE etc. 2) Quoting of values for putting into queries. You only need the first one, since every database interface that follows PEP 249. I guess I don't have a strong preference for which way we do it, but I would suggest confining our discussion to non-stupid solutions. Good suggestion. I'd say, write a function that escapes for use in LIKE queries, and leave the other quoting to the database interface. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Algorithm Question
In message [EMAIL PROTECTED], Andrew McLean wrote: I have the ability to query a database in a legacy system and extract records which match a particular pattern. Specifically, I can perform queries for records that contain a given search term as a sub-string of a particular column. What are the constraints on search terms? Are you allowed to specify the null search term, which would match everything? -- http://mail.python.org/mailman/listinfo/python-list
Re: Logfile analysing with pyparsing
You can parse it just once, you just have to setup your data structure (the structure of your XML schema) and fill it up as you parse. For example, you can represent you data structure as a dictionaries in Python: message={ MID : { ' timestamp' : TIMESTAMP, 'from':FROM, 'tolist':[TO1, TO2, ... ], 'qids': [QID1, QID2, ...], 'spam_score':S_SCORE, 'spam_filtered':Y/N, 'spam_sentdo':S_SENDTO, } } Note: I inferred this from your XML. Then as you parse each record(line?) identify what token is what and fill in the corresponding data structure. So if you pass by a line that has the message_id, queue_id and a send_to fields, check if the corresponding message_id dictionary has been created (if not do so) and fill in what you just found out. Later on you might see another record that will help you fill in other information regarding this particular message_id (such as a 'timestamp' or a 'from' field). Then translating the data into XML should be fairly easy. Note: I am not familiar with the syntax of the mail log so I presented a general idea only. My assumptions about the syntax might have been wrong. Hope this helps, Nick Vatamaniuc Andi Clemens wrote: Hi, we had some problems in the last weeks with our mailserver. Some messages were not delivered and we wanted to know why. But looking through the logfile is a time consuming process. So I wanted to write a parser to analyse the logs and parse them as XML. But I have never written a parser before and know I'm sitting in front of the logfile trying to write the grammar for pyparsing. First of all I need to know if it is possible to parse that kind of info into XML. Here is an excerpt of the logfile lines I'm interested in: Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301: message-id=[EMAIL PROTECTED] Sep 18 04:15:22 mailrelay spamd[1364]: spamd: processing message [EMAIL PROTECTED] for nobody:65534 Sep 18 04:15:25 mailrelay spamd[1364]: spamd: result: Y 15 - BAYES_99,DATE_IN_PAST_03_06,DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_DSN,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS,FORGED_MUA_OUTLOOK,SPF_SOFTFAIL scantime=3.1,size=8086,user=nobody,uid=65534,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=55277,mid=[EMAIL PROTECTED],bayes=1,autolearn=no Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E: message-id=[EMAIL PROTECTED] Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD: message-id=[EMAIL PROTECTED] Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD: to=[EMAIL PROTECTED], relay=10.49.0.7[10.49.0.7], delay=1, status=sent (250 2.6.0 [EMAIL PROTECTED] Queued mail for delivery) They are filtered by message-id, so all these lines above have something to do with the message [EMAIL PROTECTED]. The original logfile is about 25 MB big, so I can't post all of the lines of course ;-) Looking at these lines I realized that there are Queue IDs: 755387301 DA1431965E EF90720AD Filtering the log for these IDs results in the following lines: Sep 18 02:15:11 mailrelay postfix/smtpd[10841]: 755387301: client=unknown[194.25.242.123] Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301: message-id=[EMAIL PROTECTED] Sep 18 04:15:22 mailrelay postfix/qmgr[11082]: 755387301: from=[EMAIL PROTECTED], size=8152, nrcpt=7 (queue active) Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301: to=[EMAIL PROTECTED], relay=procmail, delay=14, status=sent (filter) Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301: to=[EMAIL PROTECTED], relay=procmail, delay=14, status=sent (filter) Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301: to=[EMAIL PROTECTED], relay=procmail, delay=14, status=sent (filter) Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301: to=[EMAIL PROTECTED], relay=procmail, delay=14, status=sent (filter) Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: 755387301: removed Sep 18 04:15:25 mailrelay postfix/pickup[13175]: DA1431965E: uid=65534 from=nobody Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E: message-id=[EMAIL PROTECTED] Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: DA1431965E: from=[EMAIL PROTECTED], size=11074, nrcpt=1 (queue active) Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E: to=[EMAIL PROTECTED], relay=localhost[127.0.0.1], delay=1, status=sent (250 Ok: queued as EF90720AD) Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: DA1431965E: removed Sep 18 04:15:25 mailrelay postfix/smtpd[11704]: EF90720AD: client=localhost[127.0.0.1] Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD: message-id=[EMAIL PROTECTED] Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E: to=[EMAIL PROTECTED], relay=localhost[127.0.0.1], delay=1, status=sent (250 Ok: queued as EF90720AD) Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD: from=[EMAIL
concat next line with previous
hi what is the python way to concat 2 lines eg line 1 with some text line 2 with some text i want to bring line 2 up , such that i get one whole string. line 1 with some text line 2 with some text -- http://mail.python.org/mailman/listinfo/python-list
Re: where are isinstance types documented?
Fredrik Lundh wrote: Sequences: str unicode footnote: to simplify, there's also a basestring base class that can be used to check for either str or unicode: isinstance(obj, basestring) is equivalent to isinstance(obj, (str, unicode)) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: where are isinstance types documented?
On 9/26/06, Simon Brunning [EMAIL PROTECTED] wrote: On 26 Sep 2006 02:59:07 -0700, codefire [EMAIL PROTECTED] wrote: For example isinstance(a, int) works fine but isinstance(s, string) doesn't - because 'string is not known'. In this case, you want str rather than string. A couple of points to consider: Firstly, do you really need to use isinstance() at all? It's often not necessary. Consider a duck-typing approach instead - i.e. to just try using the object as a string, and to deal with exceptions arising from the possibility that it isn't. This approach would allow string-like objects as well as real strings. Secondly, if you *really* want to use isinstance(), basestring is the super-type of both str and unicode, so it's more likely to be what you want. -- Cheers, Simon B, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pylint 0.12.1
Hi there ! I'm very pleased to announce the 0.12.1 release of PyLint. This release includes some bug fixes and have tests passing from python 2.3 to python 2.5 :). You may be surprised by the version number since we have been missing public annoucements recently, and the 0.12.0 version has not really been announced. To quote Alexandre, we got a bit sloppy in the public part of our release process, and the mails did not fly... Hopefuly we'll be better on this in a near future. Anyway there has been a lot of usability changes and a lot of bug fixes making pylint more stable (at least since the type inference has been introduced...) and nicer to configure and use, so please upgrade to this version, along with the latest logilab-common and logilab-astng version (this relelase of pylint actually depends on astng = 0.16.1). I hope you'll enjoy this release and would like to thanks everybody who contribute to pylint/astng by sending feedback or even better patch on the mailing list :) Enjoy ! What's new ? :Changes in 0.12.1 * fixed python = 2.4 format false positive with multiple lines statement * fixed some 2.5 issues * fixed generator expression scope bug (depends on astng 0.16.1) * stop requiring __revision__ :Changes in 0.12: * usability changes: - parseable, html and color options are now handled by a single output-format option - enable-checkerid and disable-all options are now handled by two (exclusive) enable-checker and disable-checker options taking a comma separated list of checker names as value - renamed debug-mode option to errors-only * started a reference user manual * new W0212 message for access to protected member from client code (close #14081) * new W0105 and W0106 messages extracted from W0104 (statement seems to have no effect) respectivly when the statement is actually string (that's sometimes used instead of comments for documentation) or an empty statement generated by a useless semicolumn * reclassified W0302 to C0302 * fix so that global messages are not anymore connected to the last analyzed module (close #10106) * fix some bugs related to local disabling of messages * fix cr/lf pb when generating the rc file on windows platforms What is pylint ? Pylint is a python tool that checks if a module satisfy a coding standard. Pylint can be seen as another pychecker since nearly all tests you can do with pychecker can also be done with Pylint. But Pylint offers some more features, like checking line-code's length, checking if variable names are well-formed according to your coding standard, or checking if declared interfaces are truly implemented, and much more (see http://www.logilab.org/projects/pylint/ for the complete check list). The big advantage with Pylint is that it is highly configurable, customizable, and you can easily write a small plugin to add a personal feature. The usage it quite simple : $ pylint mypackage.mymodule This command will output all the errors and warnings related to the tested code (here : mypackage.mymodule), will dump a little summary at the end, and will give a mark to the tested code. Pylint is free software distributed under the GNU Public Licence. Home page - http://www.logilab.org/projects/pylint Download ftp://ftp.logilab.org/pub/pylint Mailing list mailto://[EMAIL PROTECTED] -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-list
identifying new not inherited methods
Hi, I am writing a library in which I need to find the names of methods which are implemented in a class, rather than inherited from another class. To explain more, and to find if there is another way of doing it, here is what I want to do: I am defining two classes, say A and B, as: class A(object): def list_cmds(self): 'implementation needed' ? def __init__(self): ... (rest of class) class B(A): def cmd1(self, args): pass def cmd2(self, args): pass I need an implementation of list_cmds in A above so that I can get a result: b=B() b.list_cmds() ['cmd1','cmd2']#order not important I will be happy if anybody can point to me any way of doing it, using class attributes, metaclasses or otherwise. What I don't want to do is modifying class B, which contains just the cmds, if possible. Many thanks in advance. k -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a percent sign
Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], John Machin wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], John Machin wrote: 1. Reasoning: How do you get a literal ' into an SQL string constant? How do you get a literal \ into a Python string constant? How do you get a literal $ into some *x shell command lines? Do you detect a pattern? None of which applies to escaping of % characters in format strings. What I had in mind was: where surname = 'O''REILLY' install_dir = C:\\Python25 ... print The interest rate is %.2f%% p.a. % (rate * 100.0) the common pattern being that the problem character is doubled. Which doesn't apply to the $ character in *nix shell command lines. I'll take your word for it; it's been quite a while :-) *Something* in the dim dark past worked like that; I thought maybe I was thinking of m4, but that gets by without doubling. Your score so far is 1 out of 3; you have two more to go to match your original assertion None of which applies Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: A critique of cgi.escape
Jon Ribbens wrote: In article [EMAIL PROTECTED], Steve Holden wrote: I would have hoped that people don't treat that as a licence to be obnoxious, though. I am aware of Fredrik's history, which is why I was somewhat surprised and disappointed that he was being so rude and unpleasant in this thread. He is not living up to his reputation at all. Maybe he's having a bad day ;-) I generally find that Fredrik's rudeness quotient is satisfactorily biased towards discouraging ill-informed comment. It's a pity he's being rude when presented with well-informed comment then. As far as rudeness goes, I've found your approach to this discussion to be pretty obnoxious, and I'm generally know as someone with a high tolerance for idiotic behaviour. Why do you say that? I have confined myself to simple logical arguments, and been frankly very restrained when presented with rudeness and misunderstanding from other thread participants. In what way should I have modified my postings? Please allow me to apologise. I have clearly been confusing you with someone else. A review of your contributions to the thread confirms your asertion. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a percent sign
Fredrik Lundh wrote: John Machin wrote: I'll take your word for it; it's been quite a while :-) *Something* in the dim dark past worked like that makefiles? Bingo! Actually, double bingo!! From the docs for GNU Make: Because dollar signs are used to start make variable references, if you really want a dollar sign in a target or prerequisite you must write two of them, `$$' (see How to Use Variables). If you have enabled secondary expansion (see Secondary Expansion) and you want a literal dollar sign in the prerequisites lise [sic], you must actually write four dollar signs (`'). Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
Fredrik Lundh wrote: someone just posted this Site Perl Python Hotjobs 2756 655 Monster 1000 317 Dice 4828 803 From what I have seen, most of listings are not for python developers. Rather they list python as a nice to have as an extra skill. Same goes for perl. For example, sys admin jobs often list every scripting language the job writer can think of. There seem to be very few jobs where perl, or python, are the primary skills being sought. -- http://mail.python.org/mailman/listinfo/python-list
Re: where are isinstance types documented?
Fredrik Lundh [EMAIL PROTECTED] wrote: Sequences: str unicode tuple list It is also worth mentioning that you can use isinstance(a, basestring) as a way to check for either string type although, of course, isinstance(a, (str, unicode)) also works. So far as I know there is no practical use for basestring other than using it in isinstance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprise using the 'is' operator
Haha! OK thanks guys. I was just trying to check if objects were the same (object), didn't know Integers were a special case. Thanks, Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: Ordered dicts
On 2006-09-26, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have found that in certain situations ordered dicts are useful. I use an Odict class written in Python by ROwen that I have improved and updated some for personal use. So I'm thinking about a possible C version of Odict (maybe fit for the collections module). Check out http://sourceforge.net/projects/pyavl/ for a probably useful sorted mapping type, already implemented in C as an extension module. However, I haven't tried it myself. -- Neil Cerutti We're going to be exciting. Of course, it was exciting when the Titanic went down. --Bob Weiss -- http://mail.python.org/mailman/listinfo/python-list
Re: Remap Mysql tuple to dictionary
SQL databases like MySQL are _designed_ for efficiency. Efficiency with respect to what? That statement is plain wrong. They are designed for a pretty general case of data storage efficiency, in the domain of relational algebra. And for a lot of use-cases, they offer a good ratio of ease-of-use, speed and reliability and the overhead they introduce. But there are lots of cases where hand-tailored data structures - in python as well as in C - are way better suited. Think of graph representations for example, especially for reachability queries and the like. Does google use ORACLE (or whatever DB) for their index? Nope. So - without knowing the usecase, All right, sorry, looks like they want to load the entire table into RAM and key it off the first field. Kind of defeats the point of having SQL, but there you go... is a pretty strong thing to say. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
Lawrence D'Oliveiro enlightened us with: Because quoting the wildcards introduces backslash specials before each wildcard. Quoting non-wildcards then causes those backslashes to be doubled, which means they escape themselves instead of the wildcards. I don't know about other DBMSes, but in PostgreSQL you can use any escape character for the pattern, check out http://www.postgresql.org/docs/8.0/interactive/functions-matching.html Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list