Python features
To which degree python language support features of following langauage categories? Imperative, Object Oriented, Scriptig or Functional. -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python regex Doc
wrote: When used in terms of Usenet, I think it can be applied in the sense of 'a troll who is greedy for attention'. Hence the saying 'do not feed the troll'. Unless you can cause a buffer overflow :-D -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ Happy Customers: http://castleamber.com/testimonials.html -- http://mail.python.org/mailman/listinfo/python-list
Stick to what you know instead of making a complete idiot of yourself.
Xah Lee [EMAIL PROTECTED] writes: HTML Problems in Python Doc Why dont you write a Mathematica tutorial instead ? It looks like you know a little about Mathematica while your knowledge of Python is abyssmal. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python features
[EMAIL PROTECTED] wrote: To which degree python language support features of following langauage categories? Imperative, Object Oriented, Scriptig or Functional. Sounds like a homework assignment to me How about your do some research on your own, like the following: google for python and functional; first link: http://www-106.ibm.com/developerworks/linux/library/l-prog.html google for python and imperative; 10th link: http://www.everything2.com/index.pl?node=programming%20languages Quoting from that link: There are three main types of programming languages. * Imperative * Functional * Declarative Imperative programming languages are the most commonly used languages. Examples of this type of language are C, C++, Ada, Fortran, Algol, Java, Python, Perl, and so on. Programming in an imperative language is generally easier than in functional or declarative languages since it involves a more linear process of solving problems. These languages have been evolving more and more toward the object-oriented paradigm. etc. Python is Object Oriented and is described most often as scripting language. (search left as an exercise). Time required to find these links: about two minutes! Total time spent by the thousands of people that will read your message and this reply: say 1 minute * 1200 person / 60 (minutes/hour) = 20 person-hour André -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble saving unicode text to file
Svennglenn wrote: # -*- coding: cp1252 -*- titel = åäö titel = unicode(titel) Instead of this, just write # -*- coding: cp1252 -*- titel = uåäö fil = open(testfil.txt, w) fil.write(titel) fil.close() Instead of this, write import codecs fil = codecs.open(testfil.txt, w, cp1252) fil.write(titel) fil.close() Instead of cp1252, consider using ISO-8859-1. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie : checking semantics
Be reassured, I'm not working in any business related to pacemakers, avionics or railway signalling equipement ... :) I'm just a guy who is learning Python because to me it seems to be the best alternative to Perl, and trying to know what it is fit for. -- http://mail.python.org/mailman/listinfo/python-list
global lists
Hi everbybody again, I have a little problem, I don't understand the reason of this: a = [10,1,2,3] def foo(): global a for el in a: el = el*2 This doesn't make any difference, if I do def foo(): global a a[0] = 4 But def foo(): global a for n in range(len(a)): a[n] = a[n]*2 Doesn't work either... So I think that's pretty weird, why this happen? I have to create a new list and assign it back to get it working?? Thaks -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie : checking semantics
To win this point, you need to produce evidence that doesn't exist. I was not trying to win any point when I put my naive question on this forum. I'm just learning Python and trying to know what it is best made for. So far I've learnt that Python is lazy about tyche-checking, it is dynamic by nature and that there are areas which those qualities are well fit for. Still, I'm happy to learn that pychecker exists and helps you find spelling mistakes that otherwise you would have found at execution time -- http://mail.python.org/mailman/listinfo/python-list
Active Directory Modules?
Does anyone know if there are any Python Active Directory Modules out there? I looked at LDAP module but there is no version for Python 2.4 and it's support for Active Directory seems to be lacking a bit. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
pyvm -- faster python
Hi. pyvm is a program which can run python 2.4 bytecode (the .pyc files). A demo pre-release is available at: http://students.ceid.upatras.gr/~sxanth/pyvm/ Facts about pyvm: - It's FAST. According to the cooked-bench benchmark suite it finishes in 55% of the time python takes;) - It's SMALL. Currently the source code is under 15k lines with the builtin modules. - It's new. Uses no code from CPython. - It's incomplete. Not even near the stability and quality of python. It needs A LOT of work before it can be compared to CPython. Moreover, at the time it lacks many things like closures, long numbers new style classes, etc. - It's incompatible with CPython. Not all programs run. - The C API is incompatible. You can't run C modules (a thin wrapper to make pyvm appear as libpython *could* be possible but not a goal AFAIC) - The demo is an x86/linux binary only. You shouldn't trust binaries, run it in a chrooted environment not as root! Hope it works! Cheers, Stelios -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble saving unicode text to file
On Sun, 08 May 2005 11:23:49 +0200, Martin v. Löwis [EMAIL PROTECTED] wrote: Svennglenn wrote: # -*- coding: cp1252 -*- titel = åäö titel = unicode(titel) Instead of this, just write # -*- coding: cp1252 -*- titel = uåäö fil = open(testfil.txt, w) fil.write(titel) fil.close() Instead of this, write import codecs fil = codecs.open(testfil.txt, w, cp1252) fil.write(titel) fil.close() Instead of cp1252, consider using ISO-8859-1. Martin, I can't guess the reason for this last suggestion; why should a Windows system use iso-8859-1 instead of cp1252? Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Active Directory Modules?
Harlin Seritt wrote: Does anyone know if there are any Python Active Directory Modules out there? You could use ADSI with python-win32. I looked at LDAP module but there is no version for Python 2.4 Off course python-ldap works with Python 2.4. There are even Win32 binaries for Python 2.4: http://www.siosistemi.it/~mcicogni/ and it's support for Active Directory seems to be lacking a bit. Can you please elaborate about what is missing? I'm using python-ldap with Active Directory just fine. Compared to ADSI you have to program more LDAP-oriented off course. On Linux/Unix you can even use SASL/GSSAPI bind if the OpenLDAP libs wrapped by python-ldap were built with support for SASL and Kerberos. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: global lists
On 2005-05-08, andrea crotti wrote: I have a little problem, I don't understand the reason of this: a = [10,1,2,3] def foo(): global a for el in a: el = el*2 Simple data types (as integer) are _not_ implemented as references as you obviously expected. Instead el is copied by value from each a[n]. Thus you only changed temporary copies. The whole list instead _is_ a reference. If you write b = a b[0] = 57 a[0] will be effected too. This doesn't make any difference, if I do def foo(): global a a[0] = 4 That should alter a[0]. But def foo(): global a for n in range(len(a)): a[n] = a[n]*2 Doesn't work either... It does. Test it again. Bernd -- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one. [T. Jefferson] -- http://mail.python.org/mailman/listinfo/python-list
Curve fitting
Hi, I'd like to fit a curve (a rectangular hyperbola, in fact) to some data points as part of a program i'm writing. Can anyone suggest a package which would help me do this? A bit of googling suggests that SciPy might be what i want. Does that sound likely? Thanks, tom -- OBEY GIANT -- http://mail.python.org/mailman/listinfo/python-list
Controlling kwrite by dcop
Hi all, in my cross-reference tool I have the need to highlight the variables (by printing them in bold). I am using the kwrite editor, and I am not able to control it from python. I was thinking of various solutions: - consider the text file as html and use b.../b - use LaTex - define a new language for kwrite with reserved words made up of the cross-referenced variables (and so printed in bold). etc.. Googling around I found: http://phil.freehackers.org/kde/kde-techno/kde-techno-2.html Python code to make a DCOP call --- #!/usr/bin/env python from dcop import * app = DCOPApplication(kwrite) app.KWriteIface.insertText(This text was inserted from a python shell!!!, 0) app = DCOPApplication(konqueror) app.KonquerorIface.createNewWindow(http://developer.kde.org;) As you can see you can interact with kwrite from dcop. Unfortunately I don't have this module in my Python (2.3) nor I have been able to find it. Can you help me? Or have you a better solution for printing selected parts of a text file in bold, without possibly changing the editor? -- http://mail.python.org/mailman/listinfo/python-list
SGMLlib module
I am trying to use SGMLlib module to extract all links from some data I pulled from the web (via urllib). I have looked at the documentation online and can not make sense of it. As a quick example, how would I get the hyperlinks for an html file? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python regex Doc
Mike Meyer wrote: As I've suggested before, what's really needed is a short tutorial on regular expressions in general. That page could include a definition of terms that are unique to regular expressions, and the re package documentation could link the word greedy to that definition. You mean like http://www.amk.ca/python/howto/regex/ ? Which as I recall is already linked from the Python re docs. (Perhaps Xah's browser wasn't working that day...) And which, at least implicitly, defines greedy by in section 6.3 titled Greedy versus Non-Greedy. It's not perfect, but then nobody in this thread has offered anything even remotely resembling perfect documentation for regular expressions yet. wink -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Controlling kwrite by dcop
On Sunday 08 May 2005 13:41, [EMAIL PROTECTED] wrote: As you can see you can interact with kwrite from dcop. Unfortunately I don't have this module in my Python (2.3) nor I have been able to find it. It's normally installed seperately from the main kde libraries - on gentoo it's a package called dcoppython, that might help you in your search if you're on a different distro. james. pgp55bUjWf3dA.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: SGMLlib module
Harlin Seritt wrote: I am trying to use SGMLlib module to extract all links from some data I pulled from the web (via urllib). I have looked at the documentation online and can not make sense of it. As a quick example, how would I get the hyperlinks for an html file? I know you're not someone to ignore Google, but this looked like a question that could pretty easily be answered using a quick search of the comp.lang.python archives via Google Groups -- and it appears I was right. I tried http://groups.google.ca/groups?q=sgmllib+extract+links+group%3Acomp.lang.python.* and found this page, which I believe should answer your question (perhaps not directly, but it looks basically like an sgmllib tutorial): http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html I'm pretty sure you can find a dozen threads with snippets showing just what you asked if you look at the result of the results. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Coding comments/suggestions - first python script - sshd/ftpd blocking
If anyone is interested in a /etc/hosts.deny automatic update script (Unix only) based on sshd/vsftpd attacks, here's a python script: http://www.aczoom.com/tools/blockhosts/ This is a beta release, and my first attempt at Python coding. Any comments, suggestions, pointers on using more common Python idioms or example coding snippets, etc, welcome! Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: The `print' statement over Unicode
Jeremy Bowers [EMAIL PROTECTED] writes: On Sat, 07 May 2005 12:10:46 -0400, François Pinard wrote: [Martin von Löwis] François Pinard wrote: Am I looking in the wrong places, or else, should not the standard documentation more handily explain such things? It should, but, alas, it doesn't. Contributions are welcome. My contributions are not that welcome. If they were, the core team would not try forcing me into using robots and bug trackers! :-) I'm not sure that the smiley completely de-fangs this comment. Have you every tried managing a project even a tenth the size of Python *without* those tools? If you had any idea of the kind of continuous [...] I don't mean to put words into François' mouth, but IIRC he managed, for example, GNU tar for some time and, while using some kind of tracking system under the covers, didn't impose it on his users. IMVHO, that was very nice of him, but I'd be reluctant to attempt to enforce this way of working on a hard-working and competent contributor to an open source project to which I'm not a core contributor myself. John -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
Stelios Xanthakis wrote: Hi. pyvm is a program which can run python 2.4 bytecode (the .pyc files). A demo pre-release is available at: http://students.ceid.upatras.gr/~sxanth/pyvm/ Facts about pyvm: - It's FAST. According to the cooked-bench benchmark suite it finishes in 55% of the time python takes;) - It's SMALL. Currently the source code is under 15k lines with the builtin modules. - It's new. Uses no code from CPython. - It's incomplete. Not even near the stability and quality of python. It needs A LOT of work before it can be compared to CPython. Moreover, at the time it lacks many things like closures, long numbers new style classes, etc. - It's incompatible with CPython. Not all programs run. - The C API is incompatible. You can't run C modules (a thin wrapper to make pyvm appear as libpython *could* be possible but not a goal AFAIC) - The demo is an x86/linux binary only. You shouldn't trust binaries, run it in a chrooted environment not as root! Hope it works! Cheers, Stelios Hi Stelios, could You tell us a bit more about Your motivation to create an alternative C-Python interpreter? There is AFAIK no such ambitious project that has ever survived. The last one I remember died shortly after it was born: http://www.python.org/pycon/papers/pymite/ This is sad because it is still challenging to offer a tiny interpreter of a dynamic language for glue code/RAD on tiny hardware. A lot of effort was spent to provide Java for microcontrollers especially for SmartCards. I think a lot of people would show interest in Your project if it gets somehow focussed and does not seem to be redundant. Ciao, Kay -- http://mail.python.org/mailman/listinfo/python-list
Question about Pycon 2005 (Python Visual Sandbox)
Hi all, I was wondering if the session: Intuition and Python Programming - the Python Visual Sandbox did occur, of if it was canceled. To this day, there is still no sign of a corresponding paper on http://www.python.org/pycon/2005/papers/ nor did I see any report about it. Just curious, André -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: The `print' statement over Unicode
On Sun, 08 May 2005 13:46:22 +, John J. Lee wrote: I don't mean to put words into Franois' mouth, but IIRC he managed, for example, GNU tar for some time and, while using some kind of tracking system under the covers, didn't impose it on his users. IMVHO, that was very nice of him, but I'd be reluctant to attempt to enforce this way of working on a hard-working and competent contributor to an open source project to which I'm not a core contributor myself. Then I'd honor his consistency of belief, but still consider it impolite in general, as asking someone to do tons of work overall to save you a bit is almost always impolite. -- http://mail.python.org/mailman/listinfo/python-list
Re: SGMLlib module
Thanks for the help, I just didn't like the way that SGMLlib forces one to instantiate a class to do this (or httplib for that matter). I looked at those links you graciously sent (thanks!) but didn't like them. At any rate, I went ahead and wrote my own. Thank goodness that it's easy to parse with Python on your own! Thanks for the help, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie : checking semantics
On 8 May 2005 02:59:22 -0700, LDD [EMAIL PROTECTED] wrote: Be reassured, I'm not working in any business related to pacemakers, avionics or railway signalling equipement ... :) I'm just a guy who is learning Python because to me it seems to be the best alternative to Perl, and trying to know what it is fit for. I see you as being in a place where they give away all kinds of musical instruments for free, and I hear you saying you want to know what they are fit for ;-) Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Curve fitting
On 2005-05-08, Tom Anderson [EMAIL PROTECTED] wrote: I'd like to fit a curve (a rectangular hyperbola, in fact) to some data points as part of a program i'm writing. Can anyone suggest a package which would help me do this? I use the LeastSquares function in Scientific Python: http://starship.python.net/~hinsen/ScientificPython/ A bit of googling suggests that SciPy might be what i want. Does that sound likely? Sure. -- Grant Edwards grante Yow! An air of FRENCH at FRIES permeates my visi.comnostrils!! -- http://mail.python.org/mailman/listinfo/python-list
Re: SGMLlib module
Peter Hansen [EMAIL PROTECTED] writes: Harlin Seritt wrote: I am trying to use SGMLlib module to extract all links from some data I pulled from the web (via urllib). I have looked at the documentation online and can not make sense of it. As a quick example, how would I get the hyperlinks for an html file? I know you're not someone to ignore Google, but this looked like a question that could pretty easily be answered using a quick search of the comp.lang.python archives via Google Groups -- and it appears I was right. [...] Also, htmllib extends sgmllib to make this trivial, IIRC, so you (Harlin) could look at the htmllib source. John -- http://mail.python.org/mailman/listinfo/python-list
Calling a python function from C++
Let's say I have a python function do some math like the following: def doMath(self): self.val = self.val + 1 How can I call this python function from C++? Assuming I have some sort of Python wrapper around my C++ codes. -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
I've seen the benchmarks, they look quite interesting. This project is probably a LOT of work; maybe people can tell us about such efforts *before* doing so much work, so we can discuss it, and avoid wasting time. Maybe you can explain us why it is so fast, and/or maybe you can work with the other developers to improve the speed of the normal CPython, this can require equal or less work for you, and it can produce more long-lasting results/consequences for your work. Bye, Bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble saving unicode text to file
John Machin wrote: Martin, I can't guess the reason for this last suggestion; why should a Windows system use iso-8859-1 instead of cp1252? Windows users often think that windows-1252 is the same thing as iso-8859-1, and then exchange data in windows-1252, but declare them as iso-8859-1 (in particular, this is common for HTML files). iso-8859-1 is more portable than windows-1252, so it should be preferred when the data need to be exchanged across systems. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: The `print' statement over Unicode
Jeremy Bowers wrote: Then I'd honor his consistency of belief, but still consider it impolite in general, as asking someone to do tons of work overall to save you a bit is almost always impolite. This is not what he did, though - he did not break the protocol by sending in patches by email (which indeed we would reject). Instead, he said (before) that he cannot contribute because he is unwilling to/incapable of using a bug tracker. This is an acceptable position: contributors are volunteers, and he choses not to volunteer. He then has to accept (in the specific case) that the documentation is imprecise/incomplete. More precisely, he is correct that *his* contribution is not welcome, contrary to my broad statement contributions are welcome. The more narrower statement contributions that follow the guidelines are welcome still stands. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling a python function from C++
[EMAIL PROTECTED] wrote: Let's say I have a python function do some math like the following: def doMath(self): self.val = self.val + 1 How can I call this python function from C++? Assuming I have some sort of Python wrapper around my C++ codes. See the Embedding and Extending tutorial. In short, you write resultObj = PyObject_CallMethod(selfObj, doMath, ); if (resultObj == NULL) return NULL; Py_DECREF(resultObj); // resultObj should be Py_None How you get hold of self depends on your application. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Database backend?
I am in the progress of laying the groundwork for a small application I intend to make, and I'd like some expert advice, since this is the first larger project I've gotten myself into. First problem is which backend to use for data storage. The application I am trying to create is a small presentation-program with the sole purpose of displaying lyrics for songs at smaller concerts. The system is required to have a database of some kind for storing the lyrics, and this should most definitely be searchable. Naturally, I need a backend for this of some sort. I've been thinking of either XML, or full-blown MySQL. XML is very versatile, but I wonder if it is fast enough to handle lyrics for, say, 1000 songs - and then I would need to come up with some kind of indexing-algorithm. MySQL on the other hand, requires a lot of effort and adds to the complication of the installation. Honestly, I have a hard time making my mind up. Also, there might be other possibilities. Feedback will be appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
Kay Schluehr wrote: Stelios Xanthakis wrote: pyvm is a program which can run python 2.4 bytecode (the .pyc files). A demo pre-release is available at: http://students.ceid.upatras.gr/~sxanth/pyvm/ could You tell us a bit more about Your motivation to create an alternative C-Python interpreter? There is AFAIK no such ambitious project that has ever survived. .. If you check the URL more closely, you'll notice that this is a university site. It seem likely this being done at least partly as a school project, which is certainly motivation enough for such a thing, *even* if it doesn't survive (since it will pay for itself in learning). -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
could You tell us a bit more about Your motivation to create an alternative C-Python interpreter? I'd also be curious to know if the performance gains would remain once it gets fleshed out with things like closures, long numbers, new style classes and a C library compatibility shim. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Database backend?
Look for the packet called KirbyBase. Small, pythonic, text based files... -- http://mail.python.org/mailman/listinfo/python-list
Re: Database backend?
On Sun, 08 May 2005 20:09:29 +0200, Mikkel Høgh [EMAIL PROTECTED] wrote: I am in the progress of laying the groundwork for a small application I intend to make, and I'd like some expert advice, since this is the first larger project I've gotten myself into. First problem is which backend to use for data storage. The application I am trying to create is a small presentation-program with the sole purpose of displaying lyrics for songs at smaller concerts. The system is required to have a database of some kind for storing the lyrics, and this should most definitely be searchable. Naturally, I need a backend for this of some sort. I've been thinking of either XML, or full-blown MySQL. XML is very versatile, but I wonder if it is fast enough to handle lyrics for, say, 1000 songs - and then I would need to come up with some kind of indexing-algorithm. MySQL on the other hand, requires a lot of effort and adds to the complication of the installation. Honestly, I have a hard time making my mind up. Also, there might be other possibilities. Feedback will be appreciated. 1000 songs is not very many. I doubt any solution you come up with will suffer from performance problems. Your best bet will probably be to use the simplest possible data structure, perhaps pickled on disk, perhaps just written to lightly structured text files, and don't worry about using a database for now. If you find yourself needing to handle a couple orders of magnitude more songs, at that point you may wish to revisit your data storage solution. Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: pyvm -- faster python
Stelios Xanthakis [EMAIL PROTECTED] writes: - The demo is an x86/linux binary only. You shouldn't trust binaries, run it in a chrooted environment not as root! Are you going to release the source? If not, it's a lot less interesting. -- http://mail.python.org/mailman/listinfo/python-list
Re: Language documentation ( was Re: Computing Industry shams)
vermicule wrote: What is so hard to understand ? Should be perfectly clear even to a first year undergraduate. As for greedy even a minimal exposure to Djikstra's shortest path algorithm would have made the concept intuitive. And from memory, that is the sort of thing done in Computing 101 and in Data Structures and Algorithms 101 It seems to me that you want the Python doc to be written for morons. And that is not a valid complaint. He's right actually. If we understand the term greedy as it's used in graph search and optimization algorithms, Python's RE matching actually IS greedy. -- http://mail.python.org/mailman/listinfo/python-list
A question about inheritance
Hello I have a question about inheritance in Python. I'd like to do something like this: class cl1: def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): self.b = 2 But in such a way that cl2 instances have atributes 'b' AND 'a'. Obviously, this is not the way of doing it, because the __init__ definition in cl2 overrides cl1's __init__. Is there a 'pythonic' way of achieving this? Armando Serrano -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about inheritance
On 8 May 2005 12:07:58 -0700, [EMAIL PROTECTED] wrote: Hello I have a question about inheritance in Python. I'd like to do something like this: class cl1: def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): self.b = 2 But in such a way that cl2 instances have atributes 'b' AND 'a'. Obviously, this is not the way of doing it, because the __init__ definition in cl2 overrides cl1's __init__. Is there a 'pythonic' way of achieving this? class cl2(cl1): def __init__(self): cl1.__init__(self) self.b = 2 Jp -- http://mail.python.org/mailman/listinfo/python-list
Python Challenge ahead [NEW] - for riddle lovers
For the riddles' lovers among you, you are most invited to take part in the Python Challenge, the first python programming riddle on the net. You are invited to take part in it at: http://www.pythonchallenge.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Language documentation ( was Re: Computing Industry shams)
alex goldman [EMAIL PROTECTED] writes: vermicule wrote: What is so hard to understand ? Should be perfectly clear even to a first year undergraduate. As for greedy even a minimal exposure to Djikstra's shortest path algorithm would have made the concept intuitive. And from memory, that is the sort of thing done in Computing 101 and in Data Structures and Algorithms 101 It seems to me that you want the Python doc to be written for morons. And that is not a valid complaint. He's right actually. If we understand the term greedy as it's used in graph search and optimization algorithms, Python's RE matching actually IS greedy. If we, more reasonably, use the meaning of greedy that is commonly used when talking about regular expressions, there is nothing wrong with the Python docs, and Xah Lee remains the troll he has always been. -- Måns Rullgård [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe and library.zip
The zip file essentially contains the whole system in on lump. Change the system, and naturally your users will have to download the whole lump again. [...] but if it was just a dir, when they update from the svn at log in, all they do is download the extra\changed files. much much quicker then downloading a 4 meg uncompressed zip file. Not clear what you are really asking for, but maybe this will help. I have a application that is 95% normal code, packaged up via py2exe. Other 5% is a few .py files in a separate directory, modified regularly by the users (report specifications in some lists/dicts). These files are *excluded* from the py2exe build, and I manually add this directory to sys.path during the application startup. A change to one of the spec files is picked up like any normal python session, and I don't need to rebuild the entire app. Could you do the same type of thing? Brian. -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about inheritance
Thanks. Jp Calderone wrote: On 8 May 2005 12:07:58 -0700, [EMAIL PROTECTED] wrote: Hello I have a question about inheritance in Python. I'd like to do something like this: class cl1: def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): self.b = 2 But in such a way that cl2 instances have atributes 'b' AND 'a'. Obviously, this is not the way of doing it, because the __init__ definition in cl2 overrides cl1's __init__. Is there a 'pythonic' way of achieving this? class cl2(cl1): def __init__(self): cl1.__init__(self) self.b = 2 Jp -- http://mail.python.org/mailman/listinfo/python-list
Olympus R1000 Linux, Qtopia, PyQt and Python
Is here anybody who has practical experiences with programing Olympus R1000 hand-held (Linux OS) using Qtopia, PyQt and Python? If yes, can you share your experiences? I am intending to use this platform, but I would like to know if the device is mature enough and if Qtopia, PyQt and Python works smoothly on this device. Sorry if this is an off-topic posting but I do not know where somewhere else to ask. Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list
Re: Language documentation ( was Re: Computing Industry shams)
http://www.developer.com/lang/article.php/10924_3330231_3 On Sunday 08 May 2005 11:53 am, alex goldman wrote: He's right actually. If we understand the term greedy as it's used in graph search and optimization algorithms, Python's RE matching actually IS greedy. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Clueless with cPickle
On Sun, 08 May 2005 21:27:35 GMT, les [EMAIL PROTECTED] wrote: I am working on a homework assignment and trying to use cPickle to store the answers from questor.py I believe I have the syntax correct but am not sure if I am placing everything where it needs to be. Any help would be greatly appreciated. When I attempt to run what I have I end up with the following: Traceback (most recent call last): File /home/les/workspace/Module 2/questor.py, line 18, in ? f = file(questorlistfile) NameError: name 'questorlistfile' is not defined I thought that I had defined questorlistfile on the 4th line below # define some constants for future use import cPickle as p #import pickle as p questorfile = 'questor.data' # the name of the file where we will ^^^ Note this variable name # store the object questorlist = [] # Write to the file f = file(questorfile, 'w') p.dump(questorlist, f) # dump the object to a file f.close() del questorlist # remove the shoplist # Read back from the storage f = file(questorlistfile) ^^^ Compare it with this variable name. [snip] Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: Clueless with cPickle
les wrote: Traceback (most recent call last): File /home/les/workspace/Module 2/questor.py, line 18, in ? f = file(questorlistfile) NameError: name 'questorlistfile' is not defined I thought that I had defined questorlistfile on the 4th line below # define some constants for future use import cPickle as p #import pickle as p questorfile = 'questor.data' # the name of the file where we will store the object You defined questorfile, not questorlistfile. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: Clueless with cPickle
OK, looks like it is time for a break! Thanks for the replies! -- http://mail.python.org/mailman/listinfo/python-list
How to implement multiple constructors
I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something like the following: class MyClass { public: MyClass(const SomeType type); MyClass(const SomeOtherType type); ... }; In Python I cannot have two constructors that each take a single argument as Python does not distinguish the type of objects that are passed to functions. One thought I had was to use the isinstance method such as this: class MyClass: __init__(self, object): if isinstance(object, SomeType): #Initialize based on SomeType object ... elif isinstance(object, SomeOtherType): #Initialize base on SomeOtherType object ... else: #Raise some kind of exception ... Some research I've done on the Internet indicates that the use of the isinstance method can be problematic, and I'm not sure if it is the best approach to solving my problem. What is the best way for me to implement this type of functionality in Python? -- http://mail.python.org/mailman/listinfo/python-list
Strip white spaces from source
Hi all, I need to limit as much as possible the lenght of a source line, stripping white spaces (except indentation). For example: . . max_move and AC_RowStack.acceptsCards ( self, from_stack, cards ) must be reduced to: . . max_move and AC_RowStack.acceptsCards(self,from_stack,cards) My solution has been (wrogly): ''.join(source_line.split()) which gives: max_moveandAC_RowStack.acceptsCards(self,from_stack,cards) Without considering the stripping of indentation (not a big problem), the problem is instead caused by the reserved words (like 'and'). Can you help me? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about inheritance
[EMAIL PROTECTED] wrote: Hello I have a question about inheritance in Python. I'd like to do something like this: class cl1: def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): self.b = 2 But in such a way that cl2 instances have atributes 'b' AND 'a'. Obviously, this is not the way of doing it, because the __init__ definition in cl2 overrides cl1's __init__. Is there a 'pythonic' way of achieving this? If there's a chance you might have multiple inheritance at some point in this hierarchy, you might also try using super: class cl1(object): # note it's a new-style class def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): super(cl2, self).__init__() self.b = 2 Note that you probably want a new-style class even if you chose not to use super in favor of Jp Calderone's suggestion. There are very few cases for using old-style classes these days. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement multiple constructors
[EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something like the following: class MyClass { public: MyClass(const SomeType type); MyClass(const SomeOtherType type); ... }; How about using a classmethod as an alternate constructor: py class C(object): ... def __init__(self, i): ... self.i = i ... @classmethod ... def fromstr(cls, s): ... return cls(int(s)) ... py C(1).i 1 py C.fromstr('2').i 2 STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Curve fitting
On Sun, 8 May 2005, Grant Edwards wrote: On 2005-05-08, Tom Anderson [EMAIL PROTECTED] wrote: I'd like to fit a curve (a rectangular hyperbola, in fact) to some data points as part of a program i'm writing. Can anyone suggest a package which would help me do this? I use the LeastSquares function in Scientific Python: http://starship.python.net/~hinsen/ScientificPython/ I'll check that out, cheers. A bit of googling suggests that SciPy might be what i want. Does that sound likely? Sure. I ended up using scipy.optimize.minpack.leastsq, and it works brilliantly. The interface is a bit awkward - it wants a function from a guess at the parameters to a list of residuals; i'd rather give it a function from parameters + x-coordinate to y-coordinate plus a set of points, and have it work out the residuals for me - so i wrote a little wrapper to make it suit me better, and now i'm cooking with gas. The only problem is that the optimisation doesn't converge, but i think that's probably a bug in my code! tom -- Punk's not sexual, it's just aggression. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement multiple constructors
On Sunday 08 May 2005 03:05 pm, [EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something like the following: class MyClass { public: MyClass(const SomeType type); MyClass(const SomeOtherType type); ... }; In Python I cannot have two constructors that each take a single argument as Python does not distinguish the type of objects that are passed to functions. One thought I had was to use the isinstance method such as this: class MyClass: __init__(self, object): if isinstance(object, SomeType): #Initialize based on SomeType object ... elif isinstance(object, SomeOtherType): #Initialize base on SomeOtherType object ... else: #Raise some kind of exception ... Some research I've done on the Internet indicates that the use of the isinstance method can be problematic, and I'm not sure if it is the best approach to solving my problem. What is the best way for me to implement this type of functionality in Python? In case you haven't found it: http://www.canonical.org/~kragen/isinstance/ Can both of these classes (be modified to/subclassed to) support the same interface such that MyClass.__init__ will not care which is passed? I believe this would be the best solution (read: my favorite solution). If you know what type of object object is (BTW, a keyword in 2.3 and later, I believe), then one approach is to initialize with a blank MyClass instance and use fill_with_SomeType() and fill_with_SomeOtherType() methods. I think the least elegant approach is to test for interface compatibility, e.g.: try: self.avalue = isinstance.get_avalue() except NameError: self.avalue = isinstance.get_anothervalue() But this may get out of hand with many different possibilites. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement multiple constructors
On Sunday 08 May 2005 03:28 pm, James Stroud wrote: try: self.avalue = isinstance.get_avalue() except NameError: self.avalue = isinstance.get_anothervalue() I have no idea where I copied those isinstances from. Also, the except should be an AttributeError. Here is a retry: try: self.avalue = aninstance.get_avalue() except AttributeError: self.avalue = aninstance.get_anothervalue() -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Trouble saving unicode text to file
On Sun, 08 May 2005 19:49:42 +0200, Martin v. Löwis [EMAIL PROTECTED] wrote: John Machin wrote: Martin, I can't guess the reason for this last suggestion; why should a Windows system use iso-8859-1 instead of cp1252? Windows users often think that windows-1252 is the same thing as iso-8859-1, and then exchange data in windows-1252, but declare them as iso-8859-1 (in particular, this is common for HTML files). iso-8859-1 is more portable than windows-1252, so it should be preferred when the data need to be exchanged across systems. Martin, it seems I'm still a long way short of enlightenment; please bear with me: Terminology disambiguation: what I call users wouldn't know what 'cp1252' and 'iso-8859-1' were. They're not expected to know. They just type in whatever characters they can see on their keyboard or find in the charmap utility. It's what I'd call 'admins' and 'developers' who should know better, but often don't. 1. When exchanging data across systems, should not utf-8 be preferred??? 2. If the Windows *users* have been using characters that are in cp1252 but not in iso-8859-1, then attempting to convert to iso-8859-1 will cause an exception. euro_win = chr(128) euro_uc = euro_win.decode('cp1252') euro_uc u'\u20ac' unicodedata.name(euro_uc) 'EURO SIGN' euro_iso = euro_uc.encode('iso-8859-1') Traceback (most recent call last): File stdin, line 1, in ? UnicodeEncodeError: 'latin-1' codec can't encode character u'\u20ac' in position 0: ordinal not in range(256) I find it a bit hard to imagine that the euro sign wouldn't get a fair bit of usage in Swedish data processing even if it's not their own currency. 3. How portable is a character set that doesn't include the euro sign? Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Clueless with cPickle
I am working on a homework assignment and trying to use cPickle to store the answers from questor.py I believe I have the syntax correct but am not sure if I am placing everything where it needs to be. Any help would be greatly appreciated. When I attempt to run what I have I end up with the following: Traceback (most recent call last): File /home/les/workspace/Module 2/questor.py, line 18, in ? f = file(questorlistfile) NameError: name 'questorlistfile' is not defined I thought that I had defined questorlistfile on the 4th line below # define some constants for future use import cPickle as p #import pickle as p questorfile = 'questor.data' # the name of the file where we will store the object questorlist = [] # Write to the file f = file(questorfile, 'w') p.dump(questorlist, f) # dump the object to a file f.close() del questorlist # remove the shoplist # Read back from the storage f = file(questorlistfile) storedlist = p.load(f) print storedlist kQuestion = 'question' kGuess = 'guess' # define a function for asking yes/no questions def yesno(prompt): ans = raw_input(prompt) return (ans[0]=='y' or ans[0]=='Y') # define a node in the question tree (either question or guess) class Qnode: # initialization method def __init__(self,guess): self.nodetype = kGuess self.desc = guess # get the question to ask def query(self): if (self.nodetype == kQuestion): return self.desc + elif (self.nodetype == kGuess): return Is it a + self.desc + ? else: return Error: invalid node type! # return new node, given a boolean response def nextnode(self,answer): return self.nodes[answer] # turn a guess node into a question node and add new item # give a question, the new item, and the answer for that item def makeQuest( self, question, newitem, newanswer ): # create new nodes for the new answer and old answer newAnsNode = Qnode(newitem) oldAnsNode = Qnode(self.desc) # turn this node into a question node self.nodetype = kQuestion self.desc = question # assign the yes and no nodes appropriately self.nodes = {newanswer:newAnsNode, not newanswer:oldAnsNode} def traverse(fromNode): # ask the question yes = yesno( fromNode.query() ) # if this is a guess node, then did we get it right? if (fromNode.nodetype == kGuess): if (yes): print I'm a genius!!! return # if we didn't get it right, return the node return fromNode # if it's a question node, then ask another question return traverse( fromNode.nextnode(yes) ) def run(): # start with a single guess node topNode = Qnode('python') done = 0 while not done: # ask questions till we get to the end result = traverse( topNode ) # if result is a node, we need to add a question if (result): item = raw_input(OK, what were you thinking of? ) print Enter a question that distinguishes a, print item, from a, result.desc + : q = raw_input() ans = yesno(What is the answer for + item + ? ) result.makeQuest( q, item, ans ) print Got it. # repeat until done print done = not yesno(Do another? ) print # immediate-mode commands, for drag-and-drop or execfile() execution if __name__ == '__main__': run() print raw_input(press Return) else: print Module questor imported. print To run, type: questor.run() print To reload after changes to the source, type: reload(questor) # end of questor.py -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement multiple constructors
[EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. The approaches I've seen used are to use a new class method as an alternate ctor with a special name, and to use the types module for type comparison within such a ctor. -- J C LawrenceThey said, You have a blue guitar, -(*)You do not play things as they are. [EMAIL PROTECTED] The man replied, Things as they are http://www.kanga.nu/~claw/ Are changed upon the blue guitar. -- http://mail.python.org/mailman/listinfo/python-list
__brace__ (PEP?)
Hello All, If __call__ allows anobject() and __getitem__ allows anobject[arange], why not have __brace__ (or some other, better name) for anobject{something}. Such braces might be useful for cross-sectioning nested data structures: anary = [[1,2,3],[4,5,6]] anary{2} == [3,6] or for a list of dictionaries: alod = [{bob:1,ted:2,carol:3},{bob:4,ted:5,carol:6}] alod{ted} == [2,5] or, heck, a dictionary of lists: adol = {bob:[1,2,3],carol:[4,5,6],alice:[7,8,9]} adol{1} == {bob:2, carol:5, alice:8} Though I positively can not see what is wrong with this suggestion, I am sure this will raise more than a few objections. Please bash my naivete publicly on the list. Some preemptive observations 1. on syntactic ambiguity (i.e. braces already used) [] == used for both list and getitem (both for dict AND list) () == used for tuple, callable, grouping 2. on functional ambiguity (i.e. function not implicit): Q. What exactly does it mean to call an instance of class MyClass? A. Whatever the author of MyClass wanted it to mean. etc. Also, if this exists already, I apologize because I have not seen it in any Python code before and I wouldn't know what to call it for googling. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: __brace__ (PEP?)
James Stroud [EMAIL PROTECTED] wrote: why not have __brace__ (or some other, better name) for anobject{something}. Such braces might be useful for cross-sectioning nested data structures: This seems like a pretty esoteric operation to devote a bit of syntax to. It doesn't seem like something people want to do very often. -- http://mail.python.org/mailman/listinfo/python-list
Declaring self in PyObject_CallMethod
Calling a python method from C++ has the following signature: PyObject * PyObject_CallMethod(PyObject *self, char *method_name, char *arg_format, ...); I'm having trouble figuring out how to declare self. Let's say my python file is called stuff.py and is like the following, doMath() is defined in stuff.py and is not part of any class: #stuff.py def doMath(): val = val + 1 In C++, I think my codes should be like the following: PyObject *resultObj = PyObject_CallMethod( self, doMath, ); What do I put for self? Any help please? -- http://mail.python.org/mailman/listinfo/python-list
Re: __brace__ (PEP?)
On Sun, 8 May 2005 16:29:03 -0700, James Stroud [EMAIL PROTECTED] wrote: Hello All, If __call__ allows anobject() and __getitem__ allows anobject[arange], why not have __brace__ (or some other, better name) for anobject{something}. Such braces might be useful for cross-sectioning nested data structures: See Numeric Python, which uses index slices in multiple dimensions to satisfy this use case. While a new syntactic construct could be introduced to provide this feature, the minimal core, rich library school of language design suggests that doing so would not be a great idea. Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: __brace__ (PEP?)
On Sunday 08 May 2005 05:15 pm, Roy Smith wrote: This seems like a pretty esoteric operation to devote a bit of syntax to. It doesn't seem like something people want to do very often. Similar to __call__, I don't think that this syntax would be neccessarily devoted to any particular operation. I'm simply offering cross-sectioning as a potential and intuitive operation that would benefit from a shortcut. The main point is that using braces after a name is not defined right now and I think that they could be put to good use. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: __brace__ (PEP?)
In article [EMAIL PROTECTED], James Stroud [EMAIL PROTECTED] wrote: On Sunday 08 May 2005 05:15 pm, Roy Smith wrote: This seems like a pretty esoteric operation to devote a bit of syntax to. It doesn't seem like something people want to do very often. Similar to __call__, I don't think that this syntax would be neccessarily devoted to any particular operation. I'm simply offering cross-sectioning as a potential and intuitive operation that would benefit from a shortcut. The main point is that using braces after a name is not defined right now and I think that they could be put to good use. James One of the nice things about Python is that the syntax is relatively simple, and words are generally favored over punctuation. There's lots of punctuation which is not currently used, but that doesn't mean it's a good idea to go off inventing meanings for it. I supposed we could have: foo-bar == foo.__arrrow__(bar) foo$bar == foo.__dollar__(bar) foo#bar == foo.__hash__(bar) foo::bar == foo.__scope__(bar) and so on down the list of non-alphanumeric characters, but the result wouldn't be anything most of us would recognize as Python. -- http://mail.python.org/mailman/listinfo/python-list
undefined symbol?
Hi, I upgraded my laptop from RH9 to Fedora 3 yesterday. It seems to have a problem with an undefined symbol in Python. Specifically, if I try to run system-config-packages, I get the following error: Unable to import gtk module. This may be due to running without $DISPLAY set. Exception was: /usr/lib/python2.3/site-packages/gtk-2.0/gtk/_gtk.so: undefined symbol: gtk_font_button_set_show_style I get similar errors running other system-config-* applications. I have python 2.3.4-13.1, pygtk2-2.4.0-1 and gtk2-2.4.14-3.fc3. Still the error message above refers to a library in the Python sub-directory named gtk-2.0: could that be the problem? What am I missing here? (Note that DISPLAY is correctly set to :0.0) hint/help/solution would be greatly appreciated. Thanks Nemtos -- http://mail.python.org/mailman/listinfo/python-list
how to calc the difference between two datetimes?
After an hour of research, I'm more confused than ever. I don't know if I should use the time module, or the eGenix datetime module. Here's what I want to do: I want to calculate the time difference (in seconds would be okay, or minutes), between two date-time strings. so: something like this: time0 = 2005-05-06 23:03:44 time1 = 2005-05-07 03:03:44 timedelta = someFunction(time0,time1) print 'time difference is %s seconds' % timedelta. Which function should I use? confusedly yours, -- Stewart Midwinter [EMAIL PROTECTED] [EMAIL PROTECTED] Skype: midtoad -- http://mail.python.org/mailman/listinfo/python-list
RE: how to calc the difference between two datetimes?
Stewart Midwinter wrote: After an hour of research, I'm more confused than ever. I don't know if I should use the time module, or the eGenix datetime module. Here's what I want to do: I want to calculate the time difference (in seconds would be okay, or minutes), between two date-time strings. so: something like this: time0 = 2005-05-06 23:03:44 time1 = 2005-05-07 03:03:44 timedelta = someFunction(time0,time1) print 'time difference is %s seconds' % timedelta. Which function should I use? Use datetime.datetime objects and subtract one from the other: http://docs.python.org/lib/datetime-datetime.html import datetime time0 = datetime.datetime(2005, 5, 6, 23, 3, 44) time1 = datetime.datetime(2005, 5, 7, 3, 3, 44) td = time1 - time0 print 'time difference is %s seconds' % td The td object will be a datetime.timedelta object. Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: how to calc the difference between two datetimes?
On Sun, 8 May 2005 19:06:31 -0600, Stewart Midwinter [EMAIL PROTECTED] wrote: After an hour of research, I'm more confused than ever. I don't know if I should use the time module, or the eGenix datetime module. Here's what I want to do: I want to calculate the time difference (in seconds would be okay, or minutes), between two date-time strings. so: something like this: time0 = 2005-05-06 23:03:44 time1 = 2005-05-07 03:03:44 timedelta = someFunction(time0,time1) print 'time difference is %s seconds' % timedelta. Which function should I use? The builtin datetime module: import datetime x = datetime.datetime(2005, 5, 6, 23, 3, 44) y = datetime.datetime(2005, 5, 8, 3, 3, 44) x - y datetime.timedelta(-2, 72000) y - x datetime.timedelta(1, 14400) Parsing the time string is left as an exercise for the reader (hint: see the time module's strptime function). Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python regex Doc
Peter And which, at least implicitly, defines greedy by in section Peter 6.3 titled Greedy versus Non-Greedy. It's not perfect, but Peter then nobody in this thread has offered anything even remotely Peter resembling perfect documentation for regular expressions Peter yet. wink In the re syntax page: http://www.python.org/dev/doc/devel/lib/re-syntax.html the *?, +? and ?? operators *, + and ? are described as greedy: *?, +?, ?? The *, +, and ? qualifiers are all greedy; they match as much text as possible. Sometimes this behaviour isn't desired; if the RE .* is matched against 'H1title/H1', it will match the entire string, and not just 'H1'. Adding ? after the qualifier makes it perform the match in non-greedy or minimal fashion; as few characters as possible will be matched. Using .*? in the previous expression will match only 'H1'. {m,n}? is also described as a non-greedy version of {m,n} and A|B is described as never being greedy (if A matches, B is never tried). Perhaps there's no explicit definition of the word greedy in the context of regular expressions, but I think that after reading that page most people will at least have an intuitive notion of the meaning. If it's still unclear, a little experimentation should suffice: import re re.match((a+), a).group(1) 'a' re.match((a+?), a).group(1) 'a' In short, I think the re docs are fine as-is w.r.t. the greedy concept. I also added a definition to the Python Glossary for good measure: http://www.python.org/moin/PythonGlossary Feel free to amend/enhance/correct as you see fit. (Feel free to flesh out any definitions for that matter, especially those with ??? as the definition.) Skip -- http://mail.python.org/mailman/listinfo/python-list
computer unable to load _pysvn.pyc
this is truely maddening Traceback (most recent call last): File PubWare.py, line 11, in ? File Main.pyc, line 46, in ? File pysvn\__init__.pyc, line 12, in ? File pysvn\_pysvn.pyc, line 9, in ? File pysvn\_pysvn.pyc, line 7, in __load ImportError: DLL load failed: A device attached to the system is not functioning. any ideas? it works perfectly on another computer -- http://mail.python.org/mailman/listinfo/python-list
Re: computer unable to load _pysvn.pyc
Timothy Smith wrote: this is truely maddening Traceback (most recent call last): File PubWare.py, line 11, in ? File Main.pyc, line 46, in ? File pysvn\__init__.pyc, line 12, in ? File pysvn\_pysvn.pyc, line 9, in ? File pysvn\_pysvn.pyc, line 7, in __load ImportError: DLL load failed: A device attached to the system is not functioning. any ideas? it works perfectly on another computer ok more information - windows 98 computers have this issue, xp computers are fine. how do i work around this? obviously one of the pysvn dll's won't load on win98. note this is py2exe package made on a windows xp system -- http://mail.python.org/mailman/listinfo/python-list
Using a Scripting Language as Your Scripting Language
FWIW: http://www.informit.com/guides/content.asp?g=windowsserverseqNum=183rl=1 .. Remove NOSPAM. before replying Pursuant to U.S. code, title 47, Chapter 5, Subchapter II, Section 227 Any and all unsolicited commercial E-mail sent to this address is subject to a fee of US $500.00. E-Mailing denotes acceptance of these terms. Consult http://www.law.cornell.edu/uscode/47/227.html for details. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to calc the difference between two datetimes?
thanks Robert, those 4 lines of code sure beat the 58 of my home-rolled time-date function! cheers S -- http://mail.python.org/mailman/listinfo/python-list
Outlook-MAPI
Hi there, Can any one please help in getting me Python-Outlook programming issue clarified. I just wanted to do the following using Python: 1)Open a New Oulook Mail Window 2) Fill the field: to-email address and Write some body to it.(I DON't want to send it automatically) That's all. But, I am getting an error when I try to initiate the MAPI-Session using object = win32com.client.Dispatch(Outlook.Application) ns = object.GetNamespace(MAPI) mapi = win32com.client.dynamic.Dispatch(MAPI.session) Error I see is : File C:\Program Files\GNU\WinCvs 2.0\Macros\TemplateCvsMacro.py, line 140, in SendMAPIMail mapi = win32com.client.Dispatch(MAPI.session) File C:\Python24\Lib\site-packages\win32com\client\__init__.py, line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName (dispatch,userName,clsctx) File C:\Python24\Lib\site-packages\win32com\client\dynamic.py, line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File C:\Python24\Lib\site-packages\win32com\client\dynamic.py, line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) Can any one please help me in this regard. Thanks, Sekhar -- http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh
Fredrik Lundh wrote: D H [EMAIL PROTECTED] wrote: Why do you think you need a regular expression? If another approach that involved no regular expressions worked much better, would you reject it for some reason? A regular expression will work fine for his problem. Just match the digits separated by underscores using a regular expression, then afterward check if the values are valid. you forgot to mention Boo here, Doug. nice IronPython announcement, btw. the Boo developers must be so proud of you. /F You never learn, do you Fredrik. I guess that explains why Boo will never be mentioned on the python daily site your pythonware business controls. Here are some of Fredrik's funnier crazy rants right here: http://www.oreillynet.com/pub/wlg/6291 Any that you perceive as competition and threatening to your consulting business really draws out your true nature. -- http://mail.python.org/mailman/listinfo/python-list
urllib open error
Hi all, trying to download a file using urllib. Working fine on most machines.. failing in one.. Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information. import urllib; url=''; f=urllib.urlopen(url); f.read()'HTMLHEAD\nTITLEERROR: The requested URL could not be retrieved/TITLE\n/HEADBODY\nH1ERROR/H1\nH2The requested URL could not be retrieved/H2\nHR\nP\nWhile trying to retrieve the URL:\nA HREF=""http://192.168.100.233/app/Assets/AssetDownload/A\nP\nThe following error was encountered:\nUL\nLI\nSTRONG\nConnection Failed\n/STRONG\n/UL\n\nP\nThe system returned:\nPREI (110) Connection timed out/I/PRE\n\nP\nThe remote host or network may be down. Please try the request again.\nPYour cache administrator is A HREF=""root/A. \n\nbr clear="all"\nhr noshade size=1\nGenerated Mon, 09 May 2005 04:00:56 GMT by ipcop (Squid/2.4.STABLE6)\n/BODY/HTML\n' if I copy the url to a browser it works fine. suggest any debug techiniques so I can figure out whats going wrong. Note: I have tried the same stuff and it's working fine on (windows 2000, XP and on mac) not this particular windows 2000 machine Thanks in advance Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Fredrik Lundh
D H wrote: Fredrik Lundh wrote: you forgot to mention Boo here, Doug. nice IronPython announcement, btw. the Boo developers must be so proud of you. /F You never learn, do you Fredrik. I guess that explains why Boo will never be mentioned on the python daily site your pythonware business controls. It's called Daily Python-URL not Daily Python-Like-Languages-URL. *That* explains it. It's not like Pythonware is hiding its relationship. Here are some of Fredrik's funnier crazy rants right here: http://www.oreillynet.com/pub/wlg/6291 Funny you should mention that article since I showed that Fredrik's benchmarks were correctly done (if not diligently-reported) while Uche's were wrong on both marks. http://www.oreillynet.com/cs/user/view/cs_msg/51158 Any that you perceive as competition and threatening to your consulting business really draws out your true nature. Oy, my head hurts. Take it off-list, both of you. The rest of us don't care about your bickering. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
clear the files using python
Hi, I'm not a programmer. I start working as text miner and as a first task I have given 1000 dirty files that needs to be cleaned before classification tasks. I have been told python is the best tool for this job. Each file's structure as below: Comments: This is article 1965 obtained from the website Title: Banana Report #65, September 2003 Author: dylab Date: 1st September 2003 Section: pulse In the past month: A mass hit North America, cutting electricity to 50 million people across the North east I'm expected execute the python script so the file suppose to look like this: pulse, In, the, past, month, A, mass, hit, North, America, cutting, electricity, to, 50, million, people, across, the, North east, dylab Could you please point me to right direction here. Or provide some example code. In the mean time I'll be searching myself. I know you guys hate novice people like me but I would appreciated if you could provide little help here. Thanks regards, Sez -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement multiple constructors
James Stroud wrote: If you know what type of object object is (BTW, a keyword in 2.3 and later, I believe) Not a keyword, but a builtin as of 2.2. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: computer unable to load _pysvn.pyc
Timothy Smith [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] | Timothy Smith wrote: | | this is truely maddening | | Traceback (most recent call last): | File PubWare.py, line 11, in ? | File Main.pyc, line 46, in ? | File pysvn\__init__.pyc, line 12, in ? | File pysvn\_pysvn.pyc, line 9, in ? | File pysvn\_pysvn.pyc, line 7, in __load | ImportError: DLL load failed: A device attached to the system is not | functioning. | | any ideas? it works perfectly on another computer | | | ok more information - windows 98 computers have this issue, xp computers | are fine. | how do i work around this? obviously one of the pysvn dll's won't load | on win98. First, you will need to establish which .dll this is. Than check if the .dll has any dependencies that are not present on the host system (using depends.exe for example) -- i.e. function calls that are not supported. -- Vincent Wehren | note this is py2exe package made on a windows xp system | -- http://mail.python.org/mailman/listinfo/python-list
urllib open error
Hi It's seem to me that it works fine if I use hostname instead of ip address. Note: Can anyone tell me how i reply to a question in thread, rather than starting a new one" regards Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: computer unable to load _pysvn.pyc
vincent wehren wrote: Timothy Smith [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] | Timothy Smith wrote: | | this is truely maddening | | Traceback (most recent call last): | File PubWare.py, line 11, in ? | File Main.pyc, line 46, in ? | File pysvn\__init__.pyc, line 12, in ? | File pysvn\_pysvn.pyc, line 9, in ? | File pysvn\_pysvn.pyc, line 7, in __load | ImportError: DLL load failed: A device attached to the system is not | functioning. | | any ideas? it works perfectly on another computer | | | ok more information - windows 98 computers have this issue, xp computers | are fine. | how do i work around this? obviously one of the pysvn dll's won't load | on win98. First, you will need to establish which .dll this is. Than check if the .dll has any dependencies that are not present on the host system (using depends.exe for example) -- i.e. function calls that are not supported. -- Vincent Wehren | note this is py2exe package made on a windows xp system | i think i'll wait for a response from barry scott the maintainer of pysvn. buggering around trying to find some dll that it's calling most likely won't get me anywhere anyway. bloody windows - DLL HELL -- http://mail.python.org/mailman/listinfo/python-list
Re: __brace__ (PEP?)
Roy Smith wrote: foo-bar == foo.__arrrow__(bar) foo$bar == foo.__dollar__(bar) foo#bar == foo.__hash__(bar) foo::bar == foo.__scope__(bar) I'm strongly in favor for the arrow ( but with two r only ). The question is simply: for what? and so on down the list of non-alphanumeric characters, but the result wouldn't be anything most of us would recognize as Python. After many sleepless nights reading all the comments and flames about @decorators I finally came up using them. Ciao, Kay -- http://mail.python.org/mailman/listinfo/python-list
[ python-Bugs-1197806 ] % gives wrong results
Bugs item #1197806, was opened at 2005-05-08 19:35 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197806group_id=5470 Category: Python Interpreter Core Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Jonathan (nathanoj) Assigned to: Nobody/Anonymous (nobody) Summary: % gives wrong results Initial Comment: when playing with % i got 5 % -3 = -1 This occured on the windows python 2.3 build, and a python 2.4.1 build on a linux pc (with gcc 3.3.5) -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197806group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1197806 ] % gives wrong results
Bugs item #1197806, was opened at 2005-05-08 20:35 Message generated for change (Comment added) made by mwh You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197806group_id=5470 Category: Python Interpreter Core Group: Python 2.4 Status: Closed Resolution: Invalid Priority: 5 Submitted By: Jonathan (nathanoj) Assigned to: Nobody/Anonymous (nobody) Summary: % gives wrong results Initial Comment: when playing with % i got 5 % -3 = -1 This occured on the windows python 2.3 build, and a python 2.4.1 build on a linux pc (with gcc 3.3.5) -- Comment By: Michael Hudson (mwh) Date: 2005-05-08 21:08 Message: Logged In: YES user_id=6656 Why do you think this is a bug? On http://docs.python.org/ref/binary.html we find: The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand. Closing. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197806group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1197883 ] Installation path sent to configure
Bugs item #1197883, was opened at 2005-05-09 00:56 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197883group_id=5470 Category: Installation Group: None Status: Open Resolution: None Priority: 5 Submitted By: Björn Lindqvist (sonderblade) Assigned to: Nobody/Anonymous (nobody) Summary: Installation path sent to configure Initial Comment: This is a minor problem but it makes some regression tests that rely upon Python's installation path to fail. $ ./configure --prefix=/opt/ All Python stuff will be installed with an extra '/'. /opt//bin/python /opt//lib/python2.5 etc. Not good. Configure or some other installation script should recognise the redundant '/' and strip it. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1197883group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com