Re: Regexp problem, which pattern to use in split
Hans Almåsbakk wrote: Is there a relatively hassle-free way to get the csv module working with 2.1? The server is running Debian stable/woody, and it also seemed 2.2 can coexist with 2.1, when I checked the distro packages, if that is any help. 2.3 and 2.4 can also coexist with 2.1 (use make altinstall to leave python alone, so if you're using a pure-Python application, upgrading might be a good idea. alternatively, the following module (with a slightly different API) should work under 2.1: http://www.object-craft.com.au/projects/csv/ /F -- http://mail.python.org/mailman/listinfo/python-list
Re: while 1 vs while True
Fredrik Lundh wrote: Steve Holden wrote: It was unfortunate that so many people chose to use that for compatibility, when if they'd used the same code that the win32all extensions did they could have retained backward compatibility even across a change to constants: try: True except AttributeError: True, False = (1==1), (1!=1) that doesn't work, though: $ python2.1 test.py Traceback (most recent call last): File test.py, line 2, in ? True NameError: name 'True' is not defined Well, OK. But, lest people should think the worse of win32all because of my laziness in not finding the exact quote, I should point out that the code I meant to quote actually says: # Pre 2.2.1 compat. try: True, False except NameError: True = 1==1; False = 1==0 I believe this should work for all versions up to 2.4, and would also work with a 2.5 that made True and False constants. But if anyone can prove me wrong it would be you ... :-) regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: Emailing in Python
Philippe Reynolds wrote: I'm learning python...one of my tasks is to send out emails... I can send emails to one person at a time but not as groups Do you think you can help. Cheers Philippe Reynolds Here is the section of code: # me == the sender's email address me = '[EMAIL PROTECTED]' # you == the recipient's email address email_list= '[EMAIL PROTECTED], [EMAIL PROTECTED]' that's a string, not a list. how about: email_list= [[EMAIL PROTECTED], [EMAIL PROTECTED]] msg['Subject'] = 'EVENT REPORT' msg['From'] = me msg['To'] = email_list # Send the message via our own SMTP server, but don't include the # envelope header. s = smtplib.SMTP() s.connect() s.sendmail(me, [email_list], msg.as_string()) and s.sendmail(me, email_list, msg.as_string()) s.close() ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Help need with converting Hex string to IEEE format float
Max M wrote: Oh, programmers loves this kind stuff. You should get tons of answers. data = '80 00 00 00' import Image v = Image.fromstring(F, (1, 1), data, hex, F;32BF).getpixel((0, 0)) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: gather information from various files efficiently
On Tue, 14 Dec 2004 10:40:56 -0500, Peter Hansen [EMAIL PROTECTED] wrote: Keith Dart wrote: Sigh, this reminds me of a discussion I had at my work once... It seems to write optimal Python code one must understand various probabilites of your data, and code according to the likely scenario. And this is different from optimizing in *any* other language in what way? In other languages, by the time you get the bloody thing working it's time to ship, and you don't have to bother worrying about making it optimal. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Chris wrote: What IDE's do y'all recommend for Python? I'm using PythonWin atm, but I'd like something with more functionality. Chris Oh god we're all going to die. But er, ActiveState Komodo is quite nice IIRC (can't use it anymore as all my coding is commercial and I don't need it enough to spend that much cash on it) but EditPlus is nice once you get it setup but not very IDEy. Eclipse with one of the various Python modules is horrible don't bother. There is of course always Emacs, but again it's hardly Visual Studio (im only talking about the UI, emacs fans please dont flame me) Personally my vote goes for Komodo, it's at least worth a try with a personal liscense. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
If you're willing to pay for one, Komodo is very good. Especially for projects. Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
What IDE's do y'all recommend for Python? I'm using PythonWin atm, but I'd like something with more functionality. Oh god we're all going to die. -chuckle- Hopefully I don't start off a full fledged war.-grin- But er, ActiveState Komodo is quite nice IIRC (can't use it anymore as all my coding is commercial and I don't need it enough to spend that much cash on it) but EditPlus is nice once you get it setup but not very IDEy. Eclipse with one of the various Python modules is horrible don't bother. There is of course always Emacs, but again it's hardly Visual Studio (im only talking about the UI, emacs fans please dont flame me) Personally my vote goes for Komodo, it's at least worth a try with a personal liscense. Why didn't you like Eclipse? Was it that the Python modules were bad, or just Eclipse in general? I use it for my Java developement and haven't had any problems with it. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0
Okay, color me stupid, but what is everyone referencing when they mention Python 3.0? I didn't see any mention of it on the Python site. http://www.python.org/peps/pep-3000.html (which happens to be the first hit if you search for python 3.0 in the search box on python.org...) Okay, I feel dumb now. :) Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Html or Pdf to Rtf (Linux) with Python
In article [EMAIL PROTECTED], Axel Straschil [EMAIL PROTECTED] wrote: Hello! Sorry Cameron, I was replying, now my folloup ;-): Are you trying to convert one document in particular, or automate the process of conveting arbitrary HTML documents? I have an small CMS System where the customer has the posibility to view certain Html-Pages as Pdf, the CMS ist Python based. I also thought about passing the Url to an external converter Script, but found nothing ;-( What computing host is available to you--Win*? Linux? MacOS? Solaris!? Linux Is Word installed? No. OpenOffice? Yes. Why have you specified Python? Becouse I like Python ;-) The System behind generating the HTML-Code is written in Python. . . . That's a fine reason to use Python. It helps me to know, though. I do a lot of this sort of thing--automation of conversion between different Web display-formats. I don't have a one-line answer for the particular one you describe, but it's certainly feasible. I'm willing to bet there's an HTML-to-RTF converter available for Linux, but I've never needed (more accurately: I have written my own for special purposes--for my situations, it hasn't been diffi- cult) one, so I can't say for sure. My first step would be to look for such an application. Failing that, I'd script OpenOffice (with Python!) to read the HTML, and SaveAs RTF. I list a few PDF-to-RTF converters in URL: http://phaseit.net/claird/comp.text.pdf/PDF_converters.html#RTF . Again, I think there are more, but haven't yet made the time to hunt them all down. -- http://mail.python.org/mailman/listinfo/python-list
Python IDE
What IDE's do y'all recommend for Python? I'm using PythonWin atm, but I'd like something with more functionality. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: RegEx: find all occurances of a single character in a string
Franz Steinhaeusler wrote: given a string: st=abcdatraataza ^ ^ ^ ^ (these should be found) I want to get the positions of all single 'a' characters. (Without another 'a' neighbour) So I tried: r=re.compile('[^a]a([^a]') but this applies only for the a's, which has neighbours. So I need also '^a' and 'a$'. Am I doing something wrong? Is there a easier solution? How can I quickly get all these positions? Thank you in advance. import re s='abcdatraataza' r=re.compile('(?!a)a(?!a)') a_list=[ match.start() for match in re2.finditer(s) ] -- Pádraig Brady - http://www.pixelbeat.org -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Why didn't you like Eclipse? Was it that the Python modules were bad, or just Eclipse in general? I use it for my Java developement and haven't had any problems with it. Just the python stuff really, I've used it for some java stuff and know plenty of people that do every day and they all love it for Java, but having tried using it for anything else it's next to useless. In fact it's worse than a plain editor in some ways when your not using it for Java. -- http://mail.python.org/mailman/listinfo/python-list
Re: do you master list comprehensions?
Steven Bethard wrote: python -m timeit -s data = [range(10) for _ in range(1000)] sum(data, []) 10 loops, best of 3: 54.2 msec per loop python -m timeit -s data = [range(10) for _ in range(1000)] [w for d in data for w in d] 100 loops, best of 3: 1.75 msec per loop The sum function used in this way (or a loop with a +=) is O(N**2) while the LC is O(N). also: timeit -s data = [range(10) for _ in range(1000)] L = sum(data, []) 10 loops, best of 3: 4.02e+004 usec per loop timeit -s data = [range(10) for _ in range(1000)] L = [w for d in data for w in d] 1000 loops, best of 3: 1.12e+003 usec per loop timeit -s data = [range(10) for _ in range(1000)] L = []; map(L.extend, data) 1000 loops, best of 3: 283 usec per loop timeit -s data = [range(10) for _ in range(1000)]; from Tkinter import _flatten L = _flatten(data) 1000 loops, best of 3: 308 usec per loop (the last one supports arbitrary nestings, the others don't) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: do you master list comprehensions?
Timothy Babytch wrote: Will Stuyvesant wrote: data = [['foo','bar','baz'],['my','your'],['holy','grail']] sum(data, []) ['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail'] The second parameter passed to sum is just to overrride default initial value zero. It's worth keeping in mind that this solution has the same efficiency problems that a loop that =+ strings does: python -m timeit -s data = [range(10) for _ in range(100)] sum(data, []) 1000 loops, best of 3: 530 usec per loop python -m timeit -s data = [range(10) for _ in range(100)] [w for d in data for w in d] 1 loops, best of 3: 151 usec per loop python -m timeit -s data = [range(10) for _ in range(1000)] sum(data, []) 10 loops, best of 3: 54.2 msec per loop python -m timeit -s data = [range(10) for _ in range(1000)] [w for d in data for w in d] 100 loops, best of 3: 1.75 msec per loop The sum function used in this way (or a loop with a +=) is O(N**2) while the LC is O(N). Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
A paper finding that OOP can lead to more buggy software is at http://www.leshatton.org/IEEE_Soft_98a.html Les Hatton Does OO sync with the way we think?, IEEE Software, 15(3), p.46-54 This paper argues from real data that OO based systems written in C++ appear to increase the cost of fixing defects significantly when compared with systems written in either C or Pascal. It goes on to suggest that at least some aspects of OO, for example inheritance, do not fit well with the way we make mistakes. His comments under invited feedback are amusing and confirm my impression that OOP is partly (but perhaps not entirely) hype: I should not that this paper because it criticised OO had an unusually turbulent review period. 2 reviewers said they would cut their throats if it was published and 3 said the opposite. The paper was only published if the OO community could publish a rebuttal. I found this very amusing as my paper contains significant data. The rebuttal had none. This sort of thing is normal in software engineering which mostly operates in a measurement-free zone. What papers have scientific evidence for OOP? Paul Graham's skeptical comments on OOP are at http://www.paulgraham.com/noop.html . If OOP is so beneficial for large projects, why are the Linux kernel, the interpreters for Perl and Python, and most compilers I know written in C rather than C++? -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess vs. proctools
Donn Cave wrote: Keith Dart [EMAIL PROTECTED] wrote: | if exitstatus: | print good result (errorlevel of zero) | else: | print exitstatus # prints message with exit value This is indeed how the shell works, though the actual failure value is rarely of any interest. It's also in a more general sense how C works - whether errors turn out to be true or false, in either case you test for that status (or you don't.) Python doesn't work that way, there is normally no such thing as an error return. An idiomatic Python interface would be try: proc = proctools.spawn(command) proc.wait() print 'good result' except proctools.error, ev: print sys.stderr, '%s: %s' % (proc.name, ev.text) Your first statement is exactly right. One does not always care about the return value of an external process. And some programs still return an undefined value, even when successful. Therefore, I don't want to always have to wrap a call to an external program in a try..except block. Thus, it returns an ExitStatus object that you can easily test true-false with as in a shell, or get the actual value if you need it. Otherwise, just ignore it. [... list of features ...] | You always invoke the spawn* functions with a string. This is parsed by | a shell-like parser (the shparser module that comes with it), but no | /bin/sh is invoked. The parser can handle single and double quotes, and | backslash escapes. It was sounding good up to here. A lot depends on the quality of the parser, but it's so easy to support a list of arguments that gets passed unmodified to execve(), and such an obvious win in the common case where the command parameters are already separate values, that an interface where you always have to encode them in a string to be submitted to your parser seems to be ignoring the progress that os.spawnv and popen2.Popen3 made on this. Of course you don't need to repeat their blunders either and accept either string or list of strings in the same parameter, which makes for kind of a shabby API, but maybe a keyword parameter or a separate function would make sense. Actually, an earlier version of proctools did take a list. However, after much usage I realized that in most cases what I got was a string to begin with. Either from user input or read from a file. I also found it easier to construct command-lines using the string-mod operator, substituting various attributes into option-value pairs in arbitrary ways. I was having to split/parse a string so often I decided to just make the Process object parse it itself. The shparser module has been perfectly adequate for this, and you can pass to the Process object pretty much the same string as you would to a real shell (thus making it easier to use for *nix people). I could add a list-input check, but likely I would never use it. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart [EMAIL PROTECTED] public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: python gui
zhao wrote: python 2.4 is released, but the gui package wxpython now is only for 2.3, how long can it can released for 2.4? This has been asked numerous times on the wxPython list in recent weeks. :) Robin Dunn is reportedly working now on updating his build environment and scripts to use VS.NET, and hopes to have wxPython built for 2.4 Real Soon Now(tm). Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Paul McGuire wrote: Jive [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip But by '86, the Joy of OOP was widely known. Widely known? Errr? In 1986, object-oriented programming was barely marketing-speak. Computing hardware in the mid-80's just wasn't up to the task of dealing with OO memory and messaging overhead. Apple Macs were still coding in C and Forth. Borland didn't ship Turbo-Pascal with Object-Oriented programming until 1989, and Turbo-C++ shipped in 1991. Smalltalk had been around for 10 years by 1986, but it was still a curiosity, hardly widely known. It wasn't until the publication of David Taylor's Object Technology: A Manager's Guide in 1990 that OOP began to be legitimized to many management decision makers, that it was more than just fairy dust (as Bill Gates had characterized it in an attempt to discredit Borland's forays into the field). Well, that's not true either, and the fact that Bill Gates was denigrating it implies that he at least knew about it, even if he chose not to adopt it (then: of course nowadays Microsoft call almost all their technologies object oriented; sometimes this description is as accurate as when Gates speaks about our open Windows environment). I would pick the publication of Design Patterns in 1995 by the Gang of Four (Gamma, Helm, Johnson, and Vlissides), to be the herald of when the Joy of OOP would be widely known. DP formalized a taxonomy for many of the heuristics that had evolved only intuitively up until then. Its emergence reflects a general maturation of concept and practice, sufficient to say that the Joy of OOP could be said to be widely known. We could all make our own choices, but anyone who's been programming *seriously* since the 60s will likely remember Simula as the birth of many oft he ideas later picked up by Alan Kay and promoted by the Xerox PARC SmallTalk group. I visited that group in 1981 (after Kay left, unfortunately, and then being headed by Adele Goldberg, who is now coincidentally promoting the delights of Python at conferences like OSCON), and object-oriented programming was certainly something that was being taken pretty seriously in the academic world as a potential solution to some serious PLIT engineering problems. The fact that it took the technology a relatively long time to appear in the wild, so to speak, is simply the natural maturation of any new technology. Given that UNIX was developed in the early 1970s I'd say it took UNIX 20 years to start becoming mainstream. But a lot of people knew about it before it *became* mainstream, especially those who had to place their technology bets early. The same is true of object-oriented concepts. I guess this is just to say that I'd dispute your contention that SmallTalk was a curiosity - unless you define anything of interest mostly to the academic world as a curiosity, in which case there's no way to overcome your objection. It was the first major implementation of an entire system based exclusively on OO programming concepts and, while far from ideal, was a seminal precursor to today's object-oriented systems. regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 Good points all. And yes, I recall the BYTE article on Smalltalk. I guess I was just reacting mostly to the OP's statement that by '86 the Joy of OOP was widely known. He didn't say OOP all began when... or OOP was widely known, which I think still would have been a stretch - he implied that by '86 OOP was widely recognized as Goodness, to which I disagree. This was the year of the first OOPSLA conference, but as PyCon people know, just having a conference doesn't guarantee that a technology is widely and joyfully accepted. Just as my commercial-centric view may understate academic interest in some topics, an academic-centric view may overestimate the impact of topics that are ripe for research, or technically cool, but little understood or adopted outside of a university setting. I would characterize the 80's as the transitional decade from structured programming (which really started to hit its stride when Djikstra published Use of GOTO Considered Harmful) to OOP, and that OOP wasn't really joyful until the early-to-mid 90's. (And I apologize for characterizing Smalltalk as a curiosity. I admit my bias is for software that is widely commercially deployed, and even the most ardent Smalltalkers will have difficulty citing more than a handful of applications, compared to C,C++,VB,COBOL,Delphi, etc. I personally have seen Smalltalk-based factory control and automation systems, but they are rapidly self-marginalizing, and new customers are extremely reluctant to enfold Smalltalk into an already patchwork
Re: Python 3.0
Chris [EMAIL PROTECTED] wrote: Okay, color me stupid, but what is everyone referencing when they mention Python 3.0? I didn't see any mention of it on the Python site. http://www.python.org/peps/pep-3000.html (which happens to be the first hit if you search for python 3.0 in the search box on python.org...) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing and 'keywords'
On Tue, 14 Dec 2004 18:39:19 GMT, Paul McGuire [EMAIL PROTECTED] wrote: If I try however to parse the String if test; testagain; fi;, it does not work, because the fi is interpreted as an expr, not as the end of the if statement, and of course, adding another fi doesn't solve this either. The simplest way I can think of for this grammar off the top of my head is to use a parse action to reject keywords. Thank you for your quick and good solution, that did the trick indeed. But I'm wondering, isn't it possible to have some sort of lexing phase which already identifies keywords as such? Or to provide a table with keywords, which pyparsing is able to automatically recognize? So you would be able to do IF = Keyword(if), just as a Literal now is created, but now the parser knows this word shouldn't be interpreted any other way than as a keyword. Or would that be a bad idea? Berteun -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing and 'keywords'
Berteun Damman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I'm having some problems with pyparsing, I could not find how to tell it to view certain words as keywords, i.e. not as a possible variable name (in an elegant way), for example, I have this little grammar: terminator = Literal(;) expr = Word(alphas) body = Forward(); ifstat = if + body + fi stat = expr | ifstat body OneOrMore(stat + terminator) program = body I.e. some program which contains statements separated by semicolons. A statement is either an if [] fi statement or simply a word. If I try however to parse the String if test; testagain; fi;, it does not work, because the fi is interpreted as an expr, not as the end of the if statement, and of course, adding another fi doesn't solve this either. How to fix this? Thank you, Berteun Berteun - The simplest way I can think of for this grammar off the top of my head is to use a parse action to reject keywords. keywords = [ if, fi, else, return ] def rejectKeywords(string,loc,tokens): if tokens[0] in keywords: raise ParseException(string,loc,found keyword %s % tokens[0]) expr.setParseAction( rejectKeywords ) I took a different tack in the idl parser that is included in the pyparsing examples directory, but it is more extensive. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Paul McGuire wrote: Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [some stuff] Good points all. And yes, I recall the BYTE article on Smalltalk. I guess I was just reacting mostly to the OP's statement that by '86 the Joy of OOP was widely known. He didn't say OOP all began when... or OOP was widely known, which I think still would have been a stretch - he implied that by '86 OOP was widely recognized as Goodness, to which I disagree. This was the year of the first OOPSLA conference, but as PyCon people know, just having a conference doesn't guarantee that a technology is widely and joyfully accepted. Just as my commercial-centric view may understate academic interest in some topics, an academic-centric view may overestimate the impact of topics that are ripe for research, or technically cool, but little understood or adopted outside of a university setting. I would characterize the 80's as the transitional decade from structured programming (which really started to hit its stride when Djikstra published Use of GOTO Considered Harmful) to OOP, and that OOP wasn't really joyful until the early-to-mid 90's. (And I apologize for characterizing Smalltalk as a curiosity. I admit my bias is for software that is widely commercially deployed, and even the most ardent Smalltalkers will have difficulty citing more than a handful of applications, compared to C,C++,VB,COBOL,Delphi, etc. I personally have seen Smalltalk-based factory control and automation systems, but they are rapidly self-marginalizing, and new customers are extremely reluctant to enfold Smalltalk into an already patchwork mix of technologies, as is typically found in factory settings.) Nothing to disagree with here. regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Paul McGuire wrote: Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [some stuff] Good points all. And yes, I recall the BYTE article on Smalltalk. I guess I was just reacting mostly to the OP's statement that by '86 the Joy of OOP was widely known. He didn't say OOP all began when... or OOP was widely known, which I think still would have been a stretch - he implied that by '86 OOP was widely recognized as Goodness, to which I disagree. This was the year of the first OOPSLA conference, but as PyCon people know, just having a conference doesn't guarantee that a technology is widely and joyfully accepted. Just as my commercial-centric view may understate academic interest in some topics, an academic-centric view may overestimate the impact of topics that are ripe for research, or technically cool, but little understood or adopted outside of a university setting. I would characterize the 80's as the transitional decade from structured programming (which really started to hit its stride when Djikstra published Use of GOTO Considered Harmful) to OOP, and that OOP wasn't really joyful until the early-to-mid 90's. (And I apologize for characterizing Smalltalk as a curiosity. I admit my bias is for software that is widely commercially deployed, and even the most ardent Smalltalkers will have difficulty citing more than a handful of applications, compared to C,C++,VB,COBOL,Delphi, etc. I personally have seen Smalltalk-based factory control and automation systems, but they are rapidly self-marginalizing, and new customers are extremely reluctant to enfold Smalltalk into an already patchwork mix of technologies, as is typically found in factory settings.) Nothing to disagree with here. regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt on MAC OS X
dMichael McGarry [EMAIL PROTECTED] wrote: You must use pythonw for graphics application =) So launch the script with pythonw instead of python ;-) Thanks using pythonw did the trick. I appreciate everyone's help. ;-) Happy programming with your mac and python -- Whamoo www.rknet.it Powerd by: MacOsX, Gnu/Linux Debian Sarge, Amiga Os 3.9, Milk. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0
Chris wrote: Okay, color me stupid, but what is everyone referencing when they mention Python 3.0? I didn't see any mention of it on the Python site. http://www.python.org/peps/pep-3000.html (which happens to be the first hit if you search for python 3.0 in the search box on python.org...) Okay, I feel dumb now. :) Chris You are not dumb. Many search phrases are obvious if and only if you have already seen them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0
Edward C. Jones wrote: You are not dumb. Many search phrases are obvious if and only if you have already seen them. or typed them, in this case (did you read the subject before posting? ;-) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Automate Python-2.4 Installs on Windows
+1 Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 338: Executing modules inside packages with '-m'
[Nick Coghlan [EMAIL PROTECTED]] Python 2.4's -m command line switch only works for modules directly on sys.path. On my Windows machine this command line switch really makes my life so much easier. I appreciate -m very much. Going further as proposed in PEP 338 sounds good to me. One thing I stumbled across with the current implementation: Why doesn't python -m abc work with ./abc/ ./abc/__init__.py assuming ./abc/ is directly on the path? In analogy to normal module import? mb - Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a coder to do some work
Sounds like a generic html based information kiosk. Anyone can do this pretty easily using embedded IE or Mozilla ActiveX control wrapped up in Venster. Just run an internal http server in another thread.. I've done this for desktop apps. Though, full-screen windows I haven't tried, but should be straightforward. -- Novell DeveloperNet Sysop #5 -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin Not Updating
It works fine here. -- It's me Chris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm working on a program in PythonWin. The problem I'm running into is that after I make a code change, PythonWin doesn't always see it. Has anyone else had this problem? Chris -- http://mail.python.org/mailman/listinfo/python-list
RE: need some help quickly
Allan Irvine wrote: Hope you can help - any thoughts welcome Here is the best place you can get help for your problem: http://www.catb.org/~esr/faqs/smart-questions.html Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list
Archiving directory without external tools?
Does Python have any internal facility for creating recursive archives of a directory? I'd like to avoid reliance on extenal tools (winzip,tar,etc). Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
projecktzero wrote: A co-worker considers himself old school in that he hasn't seen the light of OOP ... He thinks that OOP has more overhead and is slower than programs written the procedural way. He may be right, but consider the alternatives. Think of an integer. An integer is an object! You can assign a new integer-value to the object. You can read the integer-value of the object. (The integer can be part of complex expressions.) Usually you are unaware (or don't care) _how_ the object is implemented. Wether the bits are red, green, turns upside-down or are inverted - you doesn't really care, as long as it can hold the values that you want it to hold and be used in the relevant contexts (addition, multiplication, ...). Some lanugages gives you the choise of many integer-implementations, some languages gives you only a few choises and some languages gives you only one choise. Surely we can agree that the presence of an integer-object is extremely useful! If you had to do all the integer-stuff in machine code _every_ time, you would soon be very, very tired of working with integers. There is no doubt that objects are (or can be) extremely useful, time-saving and very efficient. Chances are that your own machine-code integer-inplementation is not nearly as good as the one made by a team of top-tuned programmers (no offense) programming the integer-implementation object. Wether the language should give you the choise of one, some, many or extremely many integer-implementations, depends entirely on your needs (what a pervert - he needs an integer!). Lowering the number of choises of implementations, rises the chances of having to chose a not very good implementation. Letting the language automaticly chose the right one, frees your mind to other processes, but at the risk of some kind of run-time overhead. --- Tomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Fuzzyman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If you're willing to pay for one, Komodo is very good. Especially for projects. I would recomend Wing IDE over Komodo. My experience is that Wing IDE has far better code completion. And the Source Assistant feature of the professional version is very useful. As for projects, it doesn't support CVS or anything similar. Still, I don't miss this feature, because there are other excelent and free CVS clients. I use TortoiseCVS, http://www.tortoisecvs.org/, which integrates CVS-support in Explorer. -Tomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Archiving directory without external tools?
[EMAIL PROTECTED] wrote: Does Python have any internal facility for creating recursive archives of a directory? I'd like to avoid reliance on extenal tools (winzip,tar,etc). import os, sys, zipfile directory = sys.argv[1] zip = zipfile. ZipFile(directory + .zip, w) for path, dirs, files in os.walk(directory): for file in files: file = os.path.join(path, file) print file, ... zip.write(file) print done tweak as necessary. (did you even look in the library reference, btw?) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I convert characters into integers?
On 2004-12-14, Markus Zeindl [EMAIL PROTECTED] wrote: I want to write a simple encrypter, but I've got a problem: How can I convert characters into integers? $ python Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2 Type help, copyright, credits or license for more information. ord('A') 65 -- Grant Edwards grante Yow! .. does your DRESSING at ROOM have enough ASPARAGUS? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I convert characters into integers?
Markus Zeindl [EMAIL PROTECTED] writes: Now I get every character with a loop: code buffer = for i in range(len(message)): ch = message[i-1:i] You mean ch = message[i] what you have does the wrong thing when i = 0. Here is the problem. I got a string with one character and I want his ascii representain, for a - 97 but I want to calculate like iCh = iCh+3 or something else. iCh = ord(ch) The next step is how I convert it back to an char and append it to the buffer, but that' no problem. ch = chr(iCh) -- http://mail.python.org/mailman/listinfo/python-list
Re: New versions breaking extensions, etc.
Jive wrote: But it makes no difference, no? The problem is that both Python.exe and the extensions are *compiled* to link with a *particular* crt. No, that is not (really) the case. They are compiled to link with msvcrt.lib, which could, at link time, then become msvcrt.dll, msvcrt40.dll, or msvcr71.dll. (How dyanamic is that?) The actual code of the DLL is not provided until run-time - only at run-time, the precise implementation of the CRT routines is available - and it indeed may vary from system to system, as different versions of msvcrt40.dll might be installed (or of python24.dll, for that matter). We could probably kluge around the problem if it were not for the fact that one crt might perversely define some struct, (FILE, for example), with difference layouts in different crt DLL's. Right? Wrong. struct FILE binds us the the MS CRT (so the Borland or glibc CRTs are incompatible), but struct FILE has stayed the same for more than 10 years now, so you can, in principle, mix object files compiled with different compilers. One would need to check the header files to determine they are really compatible, but that appears to be the intent, and Microsoft does not dare to change it (except perhaps for the _ctype thing, which I don't fully understand). What really hurts is that the CRT has a number of global variables: the global FILE objects (FILE 0 to FILE 63, I believe), the global heap, and the global atexit handlers. If you have multiple CRTs, you get multiple copies of these globals, and the different routines in the different CRTs each operate on their own copy of the global variable. So it would seem that as far as the crt goes, we are at the mercy of the micro soft ones. They could introduce an incompatible crt at any time. They could, but they won't. I believe they have long given up changing or improving the CRT, since that would make things worse in most cases. The only things they still do is to add new features; the existing ABI apparently is never touched (again, perhaps except for a _ctype change I don't understand). By the way, I've googled around and found others outside the Python community who have run into the same problem. In some cases, they have opted just to stay with VC 6.0. One said, At least the 6.0 compiler is 2.5 times as fast. Groan. This is what Python did for 2.3. Already at that time, user pressure was quite high to move to a more recent compiler; with 2.4, it was clear that we do need some of the new features (in particular, ongoing commercial availability, and IPv6 support in winsock.h). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
[EMAIL PROTECTED] wrote: A paper finding that OOP can lead to more buggy software is at http://www.leshatton.org/IEEE_Soft_98a.html [snip description of paper that compares C++ versus Pascal or C] What papers have scientific evidence for OOP? That's of course a good question. I'm sure also that comp.object has argued about this a thousand times. I'll just note that one paper is just a single data point with specific circumstances. The OO languages under investigation might have caused increased or lower failure rates for other reasons than their (lack of) object-orientedness, for instance. It is of course possible to come up with a lot of other explanations for a single data point besides a conclusion that OOP can lead to more buggy software. It for instance certainly not surprising to me that C++ can lead to more buggy software than some other languages. :) [snip] If OOP is so beneficial for large projects, why are the Linux kernel, the interpreters for Perl and Python, and most compilers I know written in C rather than C++? Because C++ is not an ideal object oriented language? Because a Linux kernel has very stringent predictability requirements for what kind of machine code is generated that C meets and is much harder to do with C++? There are other reasons to choose C, such as portability, obiquity and performance. Some of the same reasons probably apply to Perl and Python, though at a lesser degrees. I do not know a lot about Perl's implementation. I do know that Guido van Rossum has in fact considered rewriting Python in C++ in the past. And right now, there are various projects that are using object oriented languages to reimplement Python, including Python itself. Finally, it is certainly possible to program in object oriented style in C. It is more cumbersome than in a language that supports it natively, but it is certainly possible. Such OO in C patterns occur throughout the Linux kernel, which needs a pluggability architecture for its various types of drivers. It can also be seen in many aspects of Python's implementation. Another example of a C-based system that uses object oriented technologies is the GTK+ widget set. Anyway, this question is using a few data points to make an overly generic argument, and the data points themselves do not really support the argument so very well either. Regards, Martijn -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Roy Smith [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I think the real reason Python is a better teaching language for teaching OO concepts is because it just gives you the real core of OO: inheritence, encapsulation, and association of functions with the data they act on. C++ has so much stuff layed on top of that (type bondage, access control, function polymorphism, templates) that it's hard to see the forest for the trees. You get C++ jocks who are convinced that that stuff is part and parcel of OO, and if it doesn't have (for example), private data, it can't be OO. +1, QOTW!! :) (esp. type bondage!) -- http://mail.python.org/mailman/listinfo/python-list
Re: Automate Python-2.4 Installs on Windows
Martin v. Löwis wrote: which might be great if you know how things work, but is bloody confusing if you don't. most importantly, how do you set properties? How do you know they are called properties?-) I would have thought that Additional parameters can be passed at the end of this command line is precise enough not when you call them properties in the rest of the document: The property TARGETDIR ..., A number of properties, etc. (and KEY=VALUE isn't exactly standard command-line syntax, even under Windows). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: New versions breaking extensions, etc.
Robin Becker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Cameron Laird wrote: There was no rational reason for me to upgrade to VC 7.x, but now I'm forced to by my preferred language. -- Robin Becker That's the way I feel about it too. Actually, I'm getting pushed toward Microsoft from other directions, also for no good reason -- and for a whole lot of computers, not just for the one on my desk. Open letter to Bill Gates: Dear Bill, Okay. You win again. It was silly of me to think Python would help me escape your clutches. Look at how good I am being now. I am typing this into an Outlook Express window, using a Microsoft operating system that you will no doubt find a way to make me replace very soon. You beat me fair and square. Well, square, anyway. Congratulations. I give up. Jive -- http://mail.python.org/mailman/listinfo/python-list
effbot ElementTree question
Hi, Is anyone here familiar with ElementTree by effbot? With htmlbodyhello/body/html how is hello stored in the element tree? Which node is it under? Similarly, with: foo a href = blah blah /a bar, how is bar stored? Which node is it in? Cheers, Ming -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance (pystone) of python 2.4 lower then python 2.3 ???
Lucas Hofman wrote: A 7% speed DECREASE??? According to the documentation it should be a 5% increase? I also see an 8-10% speed decrease in 2.4 (I built) from 2.3.3 (shipped w/Fedora2) in the program I'm writing (best of 3 trials each). Memory use seems to be about the same. 2.4: real2m44.131s 2.3.3: real2m29.865s /Dan -- dedded att verizon dott net -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Instead of copy and paste, I use functions for code reuse. I didn't see the light of OOP, yet. I use Python but never did anything with OOP. I just can't see what can be done with OOP taht can't be done with standart procedural programing. There are cases where functions just don't do the job. I at one time needed to use the little-used (and probably little-know) account featre of an ftp server to automate a regular file transfer. Both Perl and Python come with ftp modules. Perl's was (is?) procedural, Python's is OO. Neither supported the account feature. Now, if I used perl to do this, I'd have to either modify the module in place, meaning I'd have to remember to put the mods back every time we updated perl if I couldn't get them to buy the patch, or I could make a local copy of the module, meaning it wouldn't get any bug fixes that might come with new versions of perl. With the Python version, I created a subclass of the FTP connection module, rewrote just the login method, and installed that locally. Now I don't have to worry about installing new versions of Python, as my code is outside the distribution. But I still get the benefit of any bug fixes that show up outside the login method. I also submitted the new login method, and it's now part of the standard module. This kind of code reuse just isn't possible with procedural code. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
logging in omniORB for python
Hello newsgroup, I work with omniORB for python and I what to log the calls, does anyone in this group know how I can do this? I use the command to initialize the ORB ORB = CORBA.ORB_init(sys.argv + [-ORBtraceLevel, 40], CORBA.ORB_ID) but I dont get a log file or a message in pythonwin output display about anything. Does anyone know, were the log data is? And how I can store it in a file? By the way I ask also the omniORB mailing list, but here are the python experts. -- Mit freundlichen Grüßen / best regards Birgit Rahm -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
You can do this without regular expressions if you like uptime='12:12:05 up 21 days, 16:31, 10 users, load average: 0.01, 0.02, 0.04' load = uptime[uptime.find('load average:'):] load 'load average: 0.01, 0.02, 0.04' load = load.split(':') load ['load average', ' 0.01, 0.02, 0.04'] load[1].split(',') [' 0.01', ' 0.02', ' 0.04'] One liner: uptime[uptime.find('load average:'):].split(':')[1].split(',')[0] ' 0.01' On Tue, 14 Dec 2004 23:16:43 -0700, Michael McGarry [EMAIL PROTECTED] wrote: Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. load average: 0.04, 0.02, 0.01 how can I extract this number with RE or otherwise? Michael -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
Michael McGarry wrote: Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. load average: 0.04, 0.02, 0.01 how can I extract this number with RE or otherwise? This particular example might be parsed more quickly and easily just by chopping it up: s = load average: 0.04, 0.02, 0.01 [left, right] = s.split(:) [av1, av2, av3] = map(float, map(str.strip, right.split(,))) -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart [EMAIL PROTECTED] vcard: http://www.kdart.com/~kdart/kdart.vcf public key: ID: F3D288E4 URL: http://www.kdart.com/~kdart/public.key -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
Binu K S wrote: You can do this without regular expressions if you like uptime='12:12:05 up 21 days, 16:31, 10 users, load average: 0.01, 0.02, 0.04' load = uptime[uptime.find('load average:'):] load 'load average: 0.01, 0.02, 0.04' load = load.split(':') load ['load average', ' 0.01, 0.02, 0.04'] load[1].split(',') [' 0.01', ' 0.02', ' 0.04'] One liner: uptime[uptime.find('load average:'):].split(':')[1].split(',')[0] ' 0.01' Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Regular Expression
Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. load average: 0.04, 0.02, 0.01 how can I extract this number with RE or otherwise? Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: effbot ElementTree question
[EMAIL PROTECTED] wrote: Is anyone here familiar with ElementTree by effbot? With htmlbodyhello/body/html how is hello stored in the element tree? Which node is it under? Similarly, with: foo a href = blah blah /a bar, how is bar stored? Which node is it in? reposting the reply I just posted to the discussion board where you asked the same question: in the body case, the hello text ends up in the 'text' attribute of the body node (in HTML/CSS terminology, this is known as an anonymous block). in the other case, the trailing text is stored in the 'tail' attribute of the preceeding element (a in this case); see: http://effbot.org/zone/element-infoset.htm#mixed-content for details on how ElementTree deals with mixed content. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration within re.sub()?
Bryant Huang wrote: Hi, Is it possible to perform iteration within the re.sub() function call? Sure. As the docs note: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. For example: #!/usr/bin/env python import re class Counter: def __init__(self): self.count = -1 def increment(self, matchObject): self.count += 1 return str(self.count) text = abbababbaabbaaa expected = a01a2a34aa56aaa # Replace all b's with an integer that increments from 0. c = Counter() pat = re.compile((b)) actual = pat.sub(c.increment, text) assert expected == actual -- http://mail.python.org/mailman/listinfo/python-list
[OT] Re: [Boa Constr] new open source project developing with Boa Constructor
Stephen Waterbury wrote: sosman wrote: Just letting people know, I have launched a homebrew software package that is being developed with boa. http://sourceforge.net/projects/brewsta/ So, give us a hint ... does it make beer or what? :) Oops! Sorry gang. Sent my wise-ass reply to the wrong list! (The OP was on the boa-users list ... heh :) -- http://mail.python.org/mailman/listinfo/python-list
Re: do you master list comprehensions?
On Tue, 14 Dec 2004 00:41:36 +0100, Max M wrote: Fredrik Lundh wrote: Max M wrote: I tried funnies like [[w for w in L] for L in data], That is absolutely correct. It's not a funnie at all. well, syntactically correct or not, it doesn't do what he want... Doh! *I* might not be used to list comprehensions then... You are right. That example could have been expressed more clearly as: result = data result = data[:] :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for blocking on read of a real file (not socket or pipe)
Steven wrote: I'm seeking a read method that will block until new data is available. Is there such a python function that does that? It may be relevant which platform(s) are of interest. Linux? Mac? Windows? All? The more cross-platform this needs to be, the less likely it exists... -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
projecktzero wrote: A co-worker considers himself old school in that he hasn't seen the light of OOP.(It might be because he's in love with Perl...but that's another story.) He thinks that OOP has more overhead and is slower than programs written the procedural way. I poked around google, but I don't know the magic words to put in to prove or disprove his assertion. Can anyone point me toward some resources? Sounds like your co-worker has a major case of premature optimization. I don't know about speed issues with OO, but for large projects, using OOP makes data encapsulation so much easier. Writing correct code with minimum effort should be the first goal, speed issues (at that level) should be brought into the game later on. You should ask your co-worker if he also puts all his data in global variables :) *wink* -- Timo Virkkala -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Jive [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip But by '86, the Joy of OOP was widely known. Widely known? Errr? In 1986, object-oriented programming was barely marketing-speak. Computing hardware in the mid-80's just wasn't up to the task of dealing with OO memory and messaging overhead. Apple Macs were still coding in C and Forth. Borland didn't ship Turbo-Pascal with Object-Oriented programming until 1989, and Turbo-C++ shipped in 1991. Smalltalk had been around for 10 years by 1986, but it was still a curiosity, hardly widely known. It wasn't until the publication of David Taylor's Object Technology: A Manager's Guide in 1990 that OOP began to be legitimized to many management decision makers, that it was more than just fairy dust (as Bill Gates had characterized it in an attempt to discredit Borland's forays into the field). I would pick the publication of Design Patterns in 1995 by the Gang of Four (Gamma, Helm, Johnson, and Vlissides), to be the herald of when the Joy of OOP would be widely known. DP formalized a taxonomy for many of the heuristics that had evolved only intuitively up until then. Its emergence reflects a general maturation of concept and practice, sufficient to say that the Joy of OOP could be said to be widely known. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration within re.sub()?
Bryant Huang wrote: Ah beautiful, thank you both, Robert and Mark, for your instant and helpful responses. I understand, so the basic idea is to keep a variable that is globally accessible and call an external function to increment that variable... accessible for the callback function, that is. see Mark's example for the right way to do it (using a object to hold the state, and an object method as the callback -- the latter is known as a bound method, and holds a reference to both the data (self) and the code). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance (pystone) of python 2.4 lower then python 2.3 ???
Istvan Albert ialbert at mailblocks.com writes: Lucas Hofman wrote: Anyone who understands what is going on? It is difficult to measure a speedup that might be well within your measurement error. Run the same pystone benchmark repeatedly and see what variation you get. Istvan. Very little variation actually. The system measured is only lightly loaded (and it is a 2 processor box). I ran the benchmark 4 times and got 3 results that are within 1% of each other. Lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: how do I peek into the next line?
[EMAIL PROTECTED] wrote: suppose I am reading lines from a file or stdin. I want to just peek in to the next line, and if it starts with a special character I want to break out of a for loop, other wise I want to do readline(). [snip example] Neither your description above nor your example actually requires looking ahead. Are you sure you need to? You would only need it if *after* breaking out of the loop, you wanted to continue reading from the file *and* wanted the line which triggered the loop termination still to be available for reading. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 338: Executing modules inside packages with '-m'
In article [EMAIL PROTECTED], Fredrik Lundh [EMAIL PROTECTED] wrote: Nick Coghlan wrote: $ python -c import foo.bar arg This doesn't work. Any code protected by if __name__ == '__main__': won't run in this context (since 'foo.bar' is being imported as a module, not run as a script). I appreciate that you're taking the time to teach me about Python, but I can assure you that it's not really needed. Neither is the sarcasm. as for the rest of your arguments, I have to assume that you were joking. (or that you have no experience whatsoever of distribution of Python programs in Unix and Windows environments). Whatever. You suggestion does not work in many cases. How about a program that starts threads? Can't do that as a side effect of import. Just -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
projecktzero [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I know this might not be the correct group to post this, but I thought I'd start here. A co-worker considers himself old school in that he hasn't seen the light of OOP. Just how old *is* his school? I saw the light in the 70's. For those of you too young to remember, those were menacing and sinister days, when pant legs were too wide at the bottom, and the grotesque evil of top down programming was on the land. But by '86, the Joy of OOP was widely known. Flowers bloomed and birds chirped. Pant legs narrowed. I believe that was the year I attended the first C++ conference in Santa Fe. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Steven Bethard [EMAIL PROTECTED] writes: Lenard Lindstrom wrote: Steven Bethard [EMAIL PROTECTED] writes: Brian Beck wrote: http://exogen.cwru.edu/python2.png Oooh, I like this one. Very cool! Its visually stunning. But under Windows gears show up in the DLL and batch file icons. Is that a problem? The fact that they show up in DLLs and batch files means they're not exclusive to a certain type of file... And neither of these have pythons winding around them, I believe. ;) The only reason I bring it up is there are Python Windows icons for .py, .pyw, and .pyc files, but not .pyd extension modules. I make do by setting .pyd files to use the same icon as other DLLs. But if an icon with a snake and gear is made into the new Windows icon for Python it would make me think of the .pyd file icon that should have been. Lenard Lindstrom [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: [dictionary] how to get key by item
In article [EMAIL PROTECTED], Skip Montanaro [EMAIL PROTECTED] wrote: Egor i know how to get item by key ... Egor but i wonder how to get key by item Assuming your dictionary defines a one-to-one mapping, just invert it: forward = {10 : 50, 2 : 12, 4 : 43} reverse = dict([(v,k) for (k,v) in forward.iteritems()]) print forward {10: 50, 4: 43, 2: 12} print reverse {50: 10, 43: 4, 12: 2} That doubles your storage, so you'll have to trade that off against the speed gain of not having to loop over the entire dictionary. Well, you *do* loop over the entire dictionary, but you only do it once, when you create the reverse dict. If you are only going to do a single lookup, it's no gain, but if you amortize the cost over many lookups, it's almost certainly a big win. This raises an interesting question. Let's assume that you add all the entries to the dictionary before you do any lookups, and you then need to lookup things up in both directions. Which is faster, to simultaneously build both the forward and reverse dicts, or to just build the forward one and when you're done doing that, build the reverse one in a single shot with the above list comprehension? BTW, does Python really build the intermediate list and throw it away after using it to initialize the dictionary, or is it smart enough to know that it doesn't really need to build the whole list in memory? -- http://mail.python.org/mailman/listinfo/python-list
how can I import a module without using pythonpath?
Hi, I'm using python 2.2, I want to import a module by referring to its relative location. The reason for this is that there is another module with the same name that's already in pythonpath( not my decision, but I got to work around it, bummer). So is there any easy way to do it? something like import module from this location Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting ./configure --prefix
Hi Dan, LD_LIBRARY_PATH=/some/private/dir/lib; export LD_LIBRARY_PATH LD_LIBRARY_PATH does the trick, and sys.path seems okay by default. Thanks! If you are the admin of the machine and python is not the only package installed in a non-standard directory, then editing the /etc/ld.so.conf file might be the better option. Have look at 'man ldconfig' and 'man ld.so'. Yours, Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
In article [EMAIL PROTECTED], projecktzero [EMAIL PROTECTED] wrote: I know this might not be the correct group to post this, but I thought I'd start here. A co-worker considers himself old school in that he hasn't seen the light of OOP.(It might be because he's in love with Perl...but that's another story.) He thinks that OOP has more overhead and is slower than programs written the procedural way. In the world of computers, the statement X is slower than Y is true for almost every value of X and Y under some circumstances. IMHO, loves perl doesn't mesh with either old school or cares about overhead, but that's just me. Alan -- Defendit numerus -- http://mail.python.org/mailman/listinfo/python-list
Re: how can I import a module without using pythonpath?
Nice, thanks so much! Doug Holton wrote: Phd wrote: Hi, I'm using python 2.2, I want to import a module by referring to its relative location. The reason for this is that there is another module with the same name that's already in pythonpath( not my decision, but I got to work around it, bummer). So is there any easy way to do it? import sys, os sys.path.insert(0,os.path.abspath(relative path)) import module sys.path.remove(os.path.abspath(relative path)) -- http://mail.python.org/mailman/listinfo/python-list
Re: [dictionary] how to get key by item
Delaney, Timothy C (Timothy) [EMAIL PROTECTED] wrote: Python will do what you tell it. Certainly it does. The problem is that sometimes what I told it to do and what I think I told it to do are two different things :-) Using Python 2.4, the above can be rewritten as a generator expression: Ah. Very cool. I really should take a look at 2.4. -- http://mail.python.org/mailman/listinfo/python-list
Re: Namespaces and the timeit module
Roy Smith [EMAIL PROTECTED] writes: I'm playing with the timeit module, and can't figure out how to time a function call. I tried: def foo (): x = 4 return x t = timeit.Timer (foo()) print t.timeit() and quickly figured out that the environment the timed code runs under is not what I expected: Traceback (most recent call last): File ./d.py, line 10, in ? print t.timeit() File /usr/local/lib/python2.3/timeit.py, line 158, in timeit return self.inner(it, self.timer) File timeit-src, line 6, in inner NameError: global name 'foo' is not defined In fact, trying to time print dir() gets you: ['_i', '_it', '_t0', '_timer'] It seems kind of surprising that I can't time functions. Am I just not seeing something obvious? Like the documentation for Timer? :-) class Timer([stmt='pass' [, setup='pass' [, timer=timer function]]]) You can't use statements defined elsewhere, you have to define them in the setup arguments (as a string). Like this: define_foo = ''' def foo(): x = 4 return x ''' t = timeit.Timer(foo() setup=define_foo) print t.timeit() One common idiom I've seen is to put your definition of foo() in a module (say x.py), then, from the command line: $ python -m timeit -s 'from x import foo' 'foo()' (the -m is for python 2.4 to run the timeit module; use the full path to timeit.py instead for earlier pythons) Alternatively, the examples for the timeit module has another way to time functions defined in a module. -- ||\/| /--\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca -- http://mail.python.org/mailman/listinfo/python-list
RE: [dictionary] how to get key by item
Tim Python will do what you tell it. In the above case, it will build a Tim list. Whoops, yeah. I called .iteritems() then forgot to use a generator expression... Skip -- http://mail.python.org/mailman/listinfo/python-list
re: A problem with list
Hi There are many different ways to solve the problem that you are having. The easiest if you are planning on only dealing with strings or a predictable data structure would be to do something like this: Code: ~~ #Pre: Pass in a string and the character you want it tokenized by #Post: Returns a list of all the tokens def tokenizer(str, chr=' '): #heres a useful tool just like StringTokenizer feature in Java if chr != '': chr = chr[0] else: chr = ' ' x = tokens = [] z = 0 for x in str: if x != chr: tokens[z] = tokens[z] + x else: z = z + 1 tokens.append() return tokens list = ['abc', 'def', 'xyz'] str = '' for x in list: str+=list+'.' #note this is a delimiter could be anything, if you wanted to you could re-implement the above function to work with delimiters of any length not just length 1 #save the str #load str a loadedStr loadedList = tokenizer(loadedStr, '.') #loadedList = ['abc', 'def', 'xyz'] ~~ that is one way too solve your problem another is to use some sort of real database structure, for simplicity, you could use XML example xml structure: ~~ list-element date_typefloat/data_type value3.14/value element_number0/element_number /list-element list-element date_typeint/data_type value3/value element_number1/element_number /list-element list-element date_typestring/data_type valueHi i am a string/value element_number2/element_number /list-element ~~ The first way to solve your problem is quick dirty and efficient. The XML version is highly scalable but requires a lot more code to implement. As mentioned before there are a number of other solutions to the same problem --- Cheers Tim Henderson original message: The following code ## import string MyList=['abc','def'] for i in MyList: print i ### works as I expect that is I get abc def but when I have Mylist in a file and I read it from the file it does not work as I expect. # import string ff=open('C:\\Robotp\\MyFile.txt','r') # read MyList from a file MyList=ff.read() for i in MyList: print i ### I will get [ ' a b c ' , ' d e f ' ] where my MyFile.txt looks like this: ['abc','def'] Where is a problem? Thanks for help Lad -- http://mail.python.org/mailman/listinfo/python-list
Re: from string to raw string
Yeah, you're right. I got it all twisted in my mind. It's late and I must be getting tired. Thanks. Dan Brian Beck [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan Perl wrote: Is there a way to convert a regular string to a raw string so that one could get from '\bblah' to r'\bblah' other than parsing the string and modifying the escapes? There's no such thing as a raw string, only raw string literals. In other words, it's a syntax to tell the Python interpreter which characters in your string are 'special' and has no effect on strings not input as literals directly within your code. Strings from files or any input besides the interactive Python shell will already be what you're looking for. -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Redirecting ./configure --prefix
I suspect this isn't specifically a Python question, but I encountered it with Python so I thought I'd ask here. I'm running Linux (Fedora 2), and just downloaded the Python 2.4 kit. I did the following from my user account: ./configure --prefix=/some/private/dir --enable-shared make make test # all was okay make install Now, when I try to run this I get the following error: python: error while loading shared libraries: libpython2.4.so.1.0: cannot open shared object file: No such file or directory This library is in /some/private/dir/lib, but that directory is not being searched. So, I have these questions: - Can I get Python to search /some/private/dir/lib for library files? - Will sys.path be okay? How can I make it okay? - Is there anything else I need to worry about? Any help would be appreciated. Thanks, Dan -- dedded att verizon dott net -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for blocking on read of a real file (not socket or pipe)
[EMAIL PROTECTED] wrote: I doubt that the recipe you recomended will work at all in the case of different processes. To do this right file has to be open in shared mode (by both programs). Python does not support shared access. In the case of one program, but different threads probably this will work. do you always assume that everyone uses the same operating system as you do? (even if the user agent they used to post the message doesn't run on your operating system... ;-) /F -- http://mail.python.org/mailman/listinfo/python-list
RE: xsdb does XML, SQL is dead as disco :) (oops)
Some people pointed out that bighunks of my HUGE ZIP file contained junk that could be regenerated. Thanks! It's now much smaller. Sorry for the screw up. -- Aaron Watters I wrote: xsdb does XML, SQL is dead as disco :) The xsdbXML framework provides a flexible and well defined infrastructure to allow tabular data to be published, retrieved, and combined over the Internet. It's a little bit like the daughter of the Gadfly SQL engine in the buff, on steroids. This is a major departure from the previous releases of xsdb. Please read about it and download it from http://xsdb.sourceforge.net Note that the download is over 90% documentation and example data files -- the software itself is small. The xsdb framework makes all of the following assertions true. Database queries over web distributed data: Databases may be broken up into multiple files or servers on multiple machines and queried as a single resource. Simple Publication: Publishing a queriable collection of data (a context) can be as simple as placing an XML document on a web server. Sophisticated Publication: Large and complex databases may also be published using server software which provides indexing and other optimizations. Heterogeneity: Published data collections may be built using parts of remotely defined data collections. External Data: A data context may make reference to another arbitrary web object. Open formats and definitions: Databases may be constructed and queried using standard formats and standard web protocols using any programming language in any computational environment. Simple formats The content of a database or query may be expressed in a manner which is easy to parse and interpret (both for human readers and for computer programs). Data, queries and query responses are represented using the same language of expressions. Clear definition The meaning of database entries and queries are defined using simple mathematical definitions. There ain't no sanity clause -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for blocking on read of a real file (not socket or pipe)
I doubt that the recipe you recomended will work at all in the case of different processes. To do this right file has to be open in shared mode (by both programs). Python does not support shared access. In the case of one program, but different threads probably this will work. -- http://mail.python.org/mailman/listinfo/python-list
Re: Namespaces and the timeit module
[EMAIL PROTECTED] (David M. Cooke) wrote: It seems kind of surprising that I can't time functions. Am I just not seeing something obvious? Like the documentation for Timer? :-) class Timer([stmt='pass' [, setup='pass' [, timer=timer function]]]) You can't use statements defined elsewhere, you have to define them in the setup arguments (as a string). Doh! Of course. Now that you point it out, it makes perfect sense, but I didn't get that from reading the description. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: New versions breaking extensions, etc.
Martin v. Löwis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] It's not hard-coded in the linker, but hard-coded in the import library. So if you link with msvcrt.lib (which might not be the precise name of the import library - I cannot look up the precise name right now), msvcrt.lib will in turn refer to msvcr71.dll. But it makes no difference, no? The problem is that both Python.exe and the extensions are *compiled* to link with a *particular* crt. (How dyanamic is that?) We could probably kluge around the problem if it were not for the fact that one crt might perversely define some struct, (FILE, for example), with difference layouts in different crt DLL's. Right? The header files contain the poison. So it would seem that as far as the crt goes, we are at the mercy of the micro soft ones. They could introduce an incompatible crt at any time. By the way, I've googled around and found others outside the Python community who have run into the same problem. In some cases, they have opted just to stay with VC 6.0. One said, At least the 6.0 compiler is 2.5 times as fast. Groan. -- http://mail.python.org/mailman/listinfo/python-list
Re: New versions breaking extensions, etc.
Cameron Laird wrote: . . Part of the trick is that it demands deep understanding to detect the antisynergies that arise from the interac- tions of the DLL, registry, and filesystem schemes. I know it was only this year that I realized the whole installation-requires-reboot absurdity is a consequence of DLL (mis-)design. That's judgmental of me. What I'm saying is *I* wouldn't do an OS that way. It's certain, though, that I'll never extract as much consumer surplus as Microsoft has, so my evaluations should count for little. what seems strange is that although the OS hasn't changed we need a whole new framework just because the compiler underwent a version change. That would not happen in a *nix style OS because the framework is the OS. In the M$ world the $ value of causing reams of people to get the new compiler outways any sense of what would be a decent approach to OS design etc. It's sad that people who are otherwise sensible about opensource seem to be a bit silly about the poisoned apples. There was no rational reason for me to upgrade to VC 7.x, but now I'm forced to by my preferred language. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance (pystone) of python 2.4 lower then python 2.3 ???
Hi Lucas, On a dual Xeon 3.0 Ghz: [...] Which shows a decrease in performance. Could this have anything to do with the fact that is is a dual processor box? Maybe. But my 3Gh P4/HT is also detected as a dual processor machine (Kernel 2.6), so it might be a general problem with the Xeon? BTW: The discussion got me interested so I compiled Python 2.4 myself with different compiler switches and different compilers, just to find that generating machine dependant code doesn't speed up the pystone benchmark in any way (with gcc 3.3.4) and using intel's icc V8 only results in a small speedup (from approx. 4 with gcc to approx. 41500 with icc). So python performance doesn't seem to be that dependant on machine code representation. Maybe you're running into a different problem like cache size. In addition: running python2.3 with psyco 1.2 proxying all 8 Procs of pystone resulted in approx 155000 pystones, while python2.4 with psyco 1.3 resulted in approx 20 pystones ... Mark -- http://mail.python.org/mailman/listinfo/python-list
RE: Python mascot proposal
Here are my suggestions: 1. A larch (nice play on early Java) 2. Shoebox in middle o' road! (totally meaningless) 3. A Python sitting in a comfy chair (indicating ease-of-use) 4. A larch All very Pythonic and non-controversial (unless you're a member of the Prevention of Cruelty to Shoeboxes Society). P.S. Anybody know what a larch looks like? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Robert Sent: 14 December 2004 10:37 To: [EMAIL PROTECTED] Subject: Re: Python mascot proposal What about a dead camel? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: uptime for Win XP?
Writting this script was harder than I initially thought due to a lack of documentation for win32all. And I still don't know what that bizzare_int value stands for (an error/status code?). [Fredrik Lundh] if I'm not mistaken, the corresponding Win32 function is called PdhGetFormattedCounterValue, which has two [in] parameters (counter handle, format code) and two [out] parameters (counter type, counter value) so counter type is a good guess. /F [David Bolen] The pywin32 documentation tends not to duplicate information already available via MSDN (whether in a local installation or at msdn.microsoft.com) on the underlying Win32 API, so when in doubt, that's where to look. Then, the pywin32 documentation will sometimes qualify how the Python interface maps that function. But in particular, a general rule (as has already been posted) is that any out parameters are aggregated along with the overall result code into a result tuple. -- David Thanks for reply! MSDN did contain the answer, but I didn't noticed it. -- Andrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Dimitri Tcaciuc wrote: Yup, I was aware of the fact of Monty Python roots of the language name. However, you will probably agree that a snake is more associative. Plus, if to use some characteristic MP feature like a giant foot, I'm not positive that it won't trigger any copyright issues. I prefer an alternate meaning: 2. A diviner by spirits. ``[Manasses] observed omens, and appointed pythons.'' --4 Kings xxi. 6 (Douay version). Since Python is a divine language, and conjures up quick solutions to ghastly problems. And, in the spirit of oracles, reflects the wisdom of the languages design. 8-) Now, how about an icon that conveys something like that? hm... smoke curled around wizard perhaps? -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart [EMAIL PROTECTED] public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: gather information from various files efficiently
Keith Dart wrote: Aye... the dict.keys() line creates a temporary list, and then the 'in' does a linear search of the list. Better would be: try: dict[a].append(b) except KeyError: dict[a] = [b] since you expect the key to be there most of the time, this method is most efficient. You optomistically get the dictionary entry, and on the exceptional case where it doesn't yet exist you add it. I wonder if dct.setdefault(a,[]).append(b) wouldn't be even faster. It saves setting up the try/except frame handling in python (I assume the C implementation of dicts achieves similar results with much less overhead). Cheers, f ps. I changed dict-dct because it's a generally Bad Idea (TM) to name local variables as builtin types. This, for the benefit of the OP (I know you were just following his code conventions). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
Another tuple/list question. Fredrik Lundh wrote: http://www.python.org/doc/faq/general.html#why-are-there-separate-tuple-and-list-data-types Apart from historical, compatibility reasons, why is foo %s bar %s % [2, 4] illegal? I could imagine that anything accepting numerical values for __getitem__ (foo[0], foo[1], ...) or that is iterable (foo.next(), foo.next()) could be sensibly used as a formatting rhs. Of course, it is not compatible because foo %s % [2, 4] is correct and foo %s % (2, 4) is not, but are there other reasons that it has been chosen like this? Or is it possible that this behaviour will change in Python 3000? let's-do-Duck-Typing!-ly - y'rs - Gerrit -- Weather in Lulea / Kallax, Sweden 14/12 12:50: 2.0C mist mostly cloudy wind 8.9 m/s S (34 m above NAP) -- In the councils of government, we must guard against the acquisition of unwarranted influence, whether sought or unsought, by the military-industrial complex. The potential for the disastrous rise of misplaced power exists and will persist. -Dwight David Eisenhower, January 17, 1961 -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
Hello projecktzero, A co-worker considers himself old school in that he hasn't seen the light of OOP.(It might be because he's in love with Perl...but that's another story.) He thinks that OOP has more overhead and is slower than programs written the procedural way. I poked around google, but I don't know the magic words to put in to prove or disprove his assertion. Can anyone point me toward some resources? Try http://www.dreamsongs.com/Essays.html (search for Objects Have Failed) for an interesting discussion. Bye. -- Miki Tebeka [EMAIL PROTECTED] http://tebeka.bizhat.com The only difference between children and adults is the price of the toys -- http://mail.python.org/mailman/listinfo/python-list
Re: from string to raw string
Dan Perl wrote: Yeah, you're right. I got it all twisted in my mind. It's late and I must be getting tired. Perl Twisted in the same thread, that should fool the search engines :D -- http://mail.python.org/mailman/listinfo/python-list
Re: while 1 vs while True
Nick Coghlan [EMAIL PROTECTED] writes: Until this code: . import pdb . pdb.True = 0 . pdb.x = Darn writeable module dictionaries . from pdb import True . True 0 . from pdb import x . x 'Darn writeable module dictionaries' If Python really does behave that way, that bug should be fixed immediately. -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
[EMAIL PROTECTED] wrote: I just can't see what can be done with OOP taht can't be done with standart procedural programing. Well, there's absolutely nothing you can do with OOP that can't be done with standard procedural programming (SPP). But that's hardly the point. After all, anything you can do with OOP or SPP can be done with assembly language as well. OOP is way of approaching the design and construction of the software. As a starting point, consider the advantages of procedural programming over using raw assembly language. Now consider that there might be similar advantages in using OOP instead of procedural programming. And, lastly, to bring this on topic for this forum, consider that there might be advantages in using *Python*, specifically, for doing this OOP programming, compared to many other languages. Not that you can do things in Python you can't do in other languages (such as, say, assembly). Just that you can do them much more easily, and the resulting code will be much more readable to you and others. (To be fair, for certain tasks using OOP provides basically no advantages, and in fact might represent a more awkward model for the code than a simple procedural program would. If that's the sort of program you are faced with writing, by all means stick with SPP and leave OOP to those who write complex applications that really benefit from it.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
RE: Python mascot proposal
[EMAIL PROTECTED] wrote: Here are my suggestions: ... 4. A larch ... Anybody know what a larch looks like? Right! Well, some rather good pictures of the Larch on this website (my, stunning, the larch looks, eh?!) http://www.neuroinformatik.ruhr-uni-bochum.de/PEOPLE/bolder/montypython/larch1.html -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL and format conversions -- Noobie.
Ron Phillips wrote: I have a monster jpg (128 mb) that comprises a handful of colors (20 or so, max). It should never have been compressed with jpeg compression, as I understand it. It should have been a png or gif, since they are made to handle blocks of a few colors. if you compress an image that originally had 20 or so colors, max, as JPEG, and then decompress it, you get a lot more colors in the resulting image. an example: import Image let's load an arbitrary color image: im = Image.open(lenna.ppm) im.mode 'RGB' len(im.getcolors()) Traceback (most recent call last): File stdin, line 1, in ? TypeError: len() of unsized object by default, getcolors() returns None if the image contains more than 256 colors. let's try raising that limit: len(im.getcolors(100)) 119023 okay, we have some 12 unique colors in this RGB image. let's cut the number of colors down to 20: im = im.quantize(20) im.mode 'P' len(im.getcolors()) 20 and roundtrip via JPEG: im.convert(RGB).save(out.jpg) im = Image.open(out.jpg) len(im.getcolors(100)) 32593 oops. I used PIL to convert it to png and to gif, and it got even bigger (6 - 8 x) -- am I using PIL wrong, or is PIL the wrong tool? If so, how should I use PIL so it best compresses the outfile? Or, what tool should I use? this might work: im = Image.open(myimage.jpg) im = im.convert( P, dither=Image.NONE, palette=Image.ADAPTIVE, colors=20 ) im.save(myimage.png) (trying various colors settings might be a good idea; if you leave it out, you'll get no more than 256 colors). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Html or Pdf to Rtf (Linux) with Python
In article [EMAIL PROTECTED], Alexander Straschil [EMAIL PROTECTED] wrote: Hello! I have to convert an HTML document to rtf with python, was just googling for an hour and did find nothing ;-( Has anybody an Idea how to convert (under Linux) an HTML or Pdf Document to Rtf? Thanks, AXEL Are you trying to convert one document in particular, or automate the process of conveting arbitrary HTML documents? What computing host is available to you--Win*? Linux? MacOS? Solaris!? Is Word installed? OpenOffice? Why have you specified Python? -- http://mail.python.org/mailman/listinfo/python-list
Re: from string to raw string
On 14 Dec 2004 05:11:07 -0800, rumours say that [EMAIL PROTECTED] might have written: Dan Perl wrote: Yeah, you're right. I got it all twisted in my mind. It's late and I must be getting tired. Perl Twisted in the same thread, that should fool the search engines :D Now, if only Sam Ruby appeared to post his opinion... -- TZOTZIOY, I speak England very best. Be strict when sending and tolerant when receiving. (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Html or Pdf to Rtf (Linux) with Python
Hello! Sorry Cameron, I was replying, now my folloup ;-): Are you trying to convert one document in particular, or automate the process of conveting arbitrary HTML documents? I have an small CMS System where the customer has the posibility to view certain Html-Pages as Pdf, the CMS ist Python based. I also thought about passing the Url to an external converter Script, but found nothing ;-( What computing host is available to you--Win*? Linux? MacOS? Solaris!? Linux Is Word installed? No. OpenOffice? Yes. Why have you specified Python? Becouse I like Python ;-) The System behind generating the HTML-Code is written in Python. Thanks, AXEL. -- http://mail.python.org/mailman/listinfo/python-list
Python 3.0
Okay, color me stupid, but what is everyone referencing when they mention Python 3.0? I didn't see any mention of it on the Python site. Chris -- http://mail.python.org/mailman/listinfo/python-list
RE: Python IDE
If you want to spend the $35 I can recommend WingIDE. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Sent: 14 December 2004 16:37 To: [EMAIL PROTECTED] Subject: Python IDE What IDE's do y'all recommend for Python? I'm using PythonWin atm, but I'd like something with more functionality. Chris -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
pyparsing and 'keywords'
Hello, I'm having some problems with pyparsing, I could not find how to tell it to view certain words as keywords, i.e. not as a possible variable name (in an elegant way), for example, I have this little grammar: terminator = Literal(;) expr = Word(alphas) body = Forward(); ifstat = if + body + fi stat = expr | ifstat body OneOrMore(stat + terminator) program = body I.e. some program which contains statements separated by semicolons. A statement is either an if [] fi statement or simply a word. If I try however to parse the String if test; testagain; fi;, it does not work, because the fi is interpreted as an expr, not as the end of the if statement, and of course, adding another fi doesn't solve this either. How to fix this? Thank you, Berteun -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python Test Environment
Well sort of... More a request for comments really - to see if anyone is interested in this. http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv I've created a script that will build a 'test environment'. Windoze(tm) only as it uses py2exe. It scans your Python\Lib folder and builds a script that *fakes* an import of every file. This *more* or less amounts to everything in the standard lib. There is then another script that turns this into a python executable. The result is an executable that will run any python script. It gives sensible values to sys.path, sys.argv and __file__. This is useful for two purposes : 1) Easily have test environments for multiple versions of python - to test your scripts. 2) Run any python script on a machine without python installed. Usage : testenv python file arg1 arg2... Which should be the equivalent of : python python file arg1 arg2... Sample output : (Built with Python 2.4 - then 2.3 - prints sys.version first) D:\New Folder\testenvtestenv test.py arg1 arg2 arg3 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] sys.path = ['D:\\New Folder\\testenv\\library.zip', 'D:\\New Folder\\testenv', ' D:\\New Folder\\testenv'] sys.argv = ['D:\\New Folder\\testenv\\test.py', 'arg1', 'arg2', 'arg3'] import Tkinter # succeeded import dummylibrary # succeeded D:\New Folder\testenv ## D:\Python Projects\modules in progress\py2exe-testenv\disttestenv test.py arg1 arg2 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] sys.path = ['D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist\\lib \\shared.zip', 'D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist', 'D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist'] sys.argv = ['D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist\\tes t.py', 'arg1', 'arg2'] import Tkinter # succeeded import dummylibrary # succeeded D:\Python Projects\modules in progress\py2exe-testenv\dist ~~~ I'm sure this can be improved in lots of ways - only about an hours hacking or so - but already useful to me. Comments and suggestions for improvements welcomed. Regards, Fuzzy -- http://mail.python.org/mailman/listinfo/python-list