Re: FAQ for XML with Python

2006-05-19 Thread softwindow
Thanks! is very usefull for me -- http://mail.python.org/mailman/listinfo/python-list

Re: performance problem of streaming data over TCP

2006-05-19 Thread Fredrik Lundh
Changhao wrote: > I am implementing a protocol on top of 'asyncore.dispatcher' to > send streaming multimedia data over TCP socket. However, I found that > the throughput of my current implementation is surprisingly low. I'm not sure what you think you're doing in your code, but I'm quite

Re: number of different lines in a file

2006-05-19 Thread Paddy
Paul McGuire wrote: > "Kaz Kylheku" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Paddy wrote: > > ...if you are lucky enough to have a "zero copy" > > pipe implementation whcih allows data to go from the writer's buffer > > directly to the reader's one without intermediate ker

Re: number of different lines in a file

2006-05-19 Thread Paddy
Hi Kaz, The 'Unix way' is to have lots of small utilities that do one thing well, then connect them via pipes. It could be that the optimised sort algorithm is hampered if it has to remove duplicates too, or that the maintainers want to draw a line on added functionality. Personally, 95%* of the t

file() and open() separate in Python 2.5 (was: Re: DO NOT USE file())

2006-05-19 Thread Ben Finney
"Tim Peters" <[EMAIL PROTECTED]> writes: > [John Salerno, on the difference between `open` and `file`] > > Interesting. What is the difference between them now? > > In 2.5 `file` is unchanged but `open` becomes a function: > > >>> file > > >>> open > In that case I'll happily use 'file()', si

Re: Using metaclasses to inherit class variables

2006-05-19 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > I want to inherit fresh copies of some class variables. So I set up a > metaclass and meddle with the class variables there. > > Now it would be convenient to run thru a dictionary rather than > explicitly set each variable. However getattr() and setattr() are out > beca

PEP 3102 for review and comment

2006-05-19 Thread Talin
(Note: PEPs in the 3xxx number range are intended for Python 3000, however this particular PEP may be backported if there is support for it.) PEP: 3102 Title: Keyword-Only Arguments Version: $Revision: 46053 $ Last-Modified: $Date: 2006-05-19 22:23:44 -0700 (Fri, 19 May 2006) $ Author: Talin Stat

Re: python vs perl lines of code

2006-05-19 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > John Bokma wrote: > >> Edward Elliott <[EMAIL PROTECTED]> wrote: >> > like "from X import *" which are generally frowned on in python > while 'use MOD qw(id)' is encouraged in perl. Not by me, and I doubt it is in general. >>> >>> W

Re: performance problem of streaming data over TCP

2006-05-19 Thread Changhao
I figured out the reason. It was because of asyncore.dispatcher's inefficient implementation of messange sending. Instead of using its 'push' method. I directly call the underlying 'socket.send' and got the problem solved. Sorry about the spam. Thanks Changhao wrote: > Hi, friends, > > I

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Tim Peters
[Tim Peters] >> In 2.5 `file` is unchanged but `open` becomes a function: >> >> >>> file >> >> >>> open >> [Paul Rubin] > So which one are we supposed to use? Use for what? If you're trying to check an object's type, use the type; if you're trying to open a file, use the function. >>> type(op

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Paul Rubin
"Tim Peters" <[EMAIL PROTECTED]> writes: > In 2.5 `file` is unchanged but `open` becomes a function: > > >>> file > > >>> open > So which one are we supposed to use? -- http://mail.python.org/mailman/listinfo/python-list

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread John Salerno
Tim Peters wrote: > [John Salerno, on the difference between `open` and `file`] >> Interesting. What is the difference between them now? > > In 2.5 `file` is unchanged but `open` becomes a function: > file > open > So they are still used in the same way though? -- http://mail.python

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Tim Peters
[John Salerno, on the difference between `open` and `file`] > Interesting. What is the difference between them now? In 2.5 `file` is unchanged but `open` becomes a function: >>> file >>> open -- http://mail.python.org/mailman/listinfo/python-list

Re: altering an object as you iterate over it?

2006-05-19 Thread Paul McGuire
"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > bruno at modulix a écrit : > (snip) > > (responding to myself) > (but under another identity - now that's a bit schizophrenic, isn't it ?-) > Do you ever flame yourself? -- Paul -- http://mail.python.org/mailma

Re: deleting texts between patterns

2006-05-19 Thread John Savage
Tim Chase <[EMAIL PROTECTED]> writes: >> I wish to delete lines that are in between 'abc' and >> 'xyz' and print the rest of the lines. Which is the best >> way to do it? > >sed -n -e'1,/abc/p' -e'/xyz/,$p' file.txt > >which is pretty straight-forward. While it looks neat, it will not work

Re: python vs perl lines of code

2006-05-19 Thread Edward Elliott
John Bokma wrote: > Edward Elliott <[EMAIL PROTECTED]> wrote: > like "from X import *" which are generally frowned on in python while 'use MOD qw(id)' is encouraged in perl. >>> >>> Not by me, and I doubt it is in general. >> >> Well it's all over the Perl Cookbook. > > Yeah, sure, a

Weekly Python Patch/Bug Summary

2006-05-19 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 378 open ( +0) / 3238 closed (+22) / 3616 total (+22) Bugs: 907 open (+13) / 5831 closed (+20) / 6738 total (+33) RFE : 218 open ( +2) / 217 closed ( +2) / 435 total ( +4) New / Reopened Patches __ Patch fix

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread John Salerno
Aahz wrote: > Python 2.5a2 (trunk:46052, May 19 2006, 19:54:46) > [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. open is file > False > > Per the other comments in this thread, Guido agreed that mak

DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Aahz
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: >Paul McGuire wrote: >> >> 1. open("xxx") still works - not sure if it's even deprecated or not - but >> the new style is to use the file class > >Python 2.3.4 (#4, Oct 25 2004, 21:40:10) >[GCC 3.3.2 (Mandrake Linux 10.0 3.3.

Re: Question about Python on Mac

2006-05-19 Thread elventear
On 2006-05-19 16:19:51 -0500, "elventear" <[EMAIL PROTECTED]> said: > The weird thing is that just for kicks I tried building with Python > that comes with MacOSX (py2.3) and it works. It builds and it loads > fine. Anybody have an idea why this would happen? Any ideas how to > solve this? In the

performance problem of streaming data over TCP

2006-05-19 Thread Changhao
Hi, friends, I am implementing a protocol on top of 'asyncore.dispatcher' to send streaming multimedia data over TCP socket. However, I found that the throughput of my current implementation is surprisingly low. Below is a snippet of my code with a note that: the packet sent over the

Re: python vs perl lines of code

2006-05-19 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > John Bokma wrote: > >> Edward Elliott <[EMAIL PROTECTED]> wrote: >> >>> The question is how to count explicit names like module.class.func; >>> should that be 1 identifier or 3? Counting as 3 would reward things >>> like "from X import *" which are ge

Re: Tabs versus Spaces in Source Code

2006-05-19 Thread Roedy Green
On Mon, 15 May 2006 02:44:54 GMT, Eli Gottlieb <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who said : >Actually, spaces are better for indenting code. Agreed. All it takes is one programmer to use a different tab expansion convention to screw up a project. Spaces are unambig

Creating a new file object; open() vs file() (was: Re: altering an object as you iterate over it?)

2006-05-19 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Paul McGuire wrote: > > > I think it is just part of the objectification trend - "f = > > open('xyzzy.dat')" is sort of a functional/verb concept, so it has > > to return something, and its something non-objecty like a file > > handle - urk! Instead, us

Re: noob import question

2006-05-19 Thread Ben Finney
[Please don't top-post. Please don't indiscriminately quote the entire message you respond to. http://en.wikipedia.org/wiki/Top_posting>] Brian Blazer <[EMAIL PROTECTED]> writes: > Thank you for your responses. I had a feeling is had something to > do with a namespace issue but I wasn't sure. A

Re: Python sqlite and regex.

2006-05-19 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Paul McGuire wrote: > > "Paul McGuire" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >> where '*' matches one or more characters, and '?' matches any > >> single > > > > oops, I meant '*' matches zero or more characters. > > '?'

Re: problem with import autotest ...

2006-05-19 Thread Ben Finney
"bravegag" <[EMAIL PROTECTED]> writes: > I have a script that works just fine on linux but when I try to > debug from Windows using Eclipse and PyDEV plugin then it does not > work. The Python version is the same 2.3.x , and command line is > roughly the same. 2.3.x is not a version. Which versio

Re: How to append to a dictionary

2006-05-19 Thread Ben Finney
"Harlin Seritt" <[EMAIL PROTECTED]> writes: > groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'} > > I want to add another key: 'ITALIAN' : 'orange' > > How do I append this to 'groups'? Dictionary items have no implicit sequence, so you don't "append" to one. Assigning any value to a key in th

HTML bodies in a text medium (was: Re: Python and Test Driven Development)

2006-05-19 Thread Ben Finney
"Diego Torres Milano" <[EMAIL PROTECTED]> writes: > [a message body in HTML] > Comments are gladly welcome. First comment: please don't compose your message body in anything but plain text, unless you *know* *every* recipient wants it otherwise. In a public discussion forum, where you *can't* kn

Re: Exception style

2006-05-19 Thread Ben Finney
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Cameron Laird wrote: > > how do I know that the NameError means VARIABLE didn't resolve, > > rather than that it did, but that evaluation of > > commands.VARIABLE() itself didn't throw a NameError? My usual > > answer: umm, unless I go to efforts to p

Re: calling python functions using variables

2006-05-19 Thread Ben Finney
bruno at modulix <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > You'll also need to anticipate the situation where the value bound > > to VARIABLE is not the name of an attribute in 'commands'. > > > > Either deal with the resulting NameError exception (EAFP[0]) > > try: > getattr(command

Re: altering an object as you iterate over it?

2006-05-19 Thread Max Erickson
Bruno Desthuilliers wrote > > It has been, at a time, recommended to use file() instead of > open(). Don't worry, open() is ok - and I guess almost anyone > uses it. http://mail.python.org/pipermail/python-dev/2005-December/059073.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimal and Exponentiation

2006-05-19 Thread Dan Bishop
Tim Peters wrote: ... > Wait <0.3 wink>. Python's Decimal module intends to be a faithful > implementation of IBM's proposed standard for decimal arithmetic: > > http://www2.hursley.ibm.com/decimal/ > > Last December, ln, log10, exp, and exponentiation to non-integral > powers were added to th

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
On Fri, 19 May 2006 18:52:38 GMT, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > "Dan Sommers" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Doesn't SQL already have lightweight wildcards? >> >> SELECT somefield FROM sometable WHERE someotherfield LIKE '%foo%' > Yes it does - '%

Re: altering an object as you iterate over it?

2006-05-19 Thread Bruno Desthuilliers
bruno at modulix a écrit : (snip) (responding to myself) (but under another identity - now that's a bit schizophrenic, isn't it ?-) > For the general case, the best way to go would probably be an iterator: > > def iterfilter(fileObj): > for line in fileObj: > if line.strip(): > yield

Re: altering an object as you iterate over it?

2006-05-19 Thread Bruno Desthuilliers
John Salerno a écrit : > Paul McGuire wrote: > >> Your coding style is a little dated - are you using an old version of >> Python? This style is the old-fashioned way: > > > I'm sure it has more to do with the fact that I'm new to Python, but > what is old-fashioned about open()? It has been

Re: python vs perl lines of code

2006-05-19 Thread Edward Elliott
John Bokma wrote: > Edward Elliott <[EMAIL PROTECTED]> wrote: > >> The question is how to count explicit names like module.class.func; >> should that be 1 identifier or 3? Counting as 3 would reward things >> like "from X import *" which are generally frowned on in python while >> 'use MOD qw(id

Re: altering an object as you iterate over it?

2006-05-19 Thread Bruno Desthuilliers
John Salerno a écrit : > John Salerno wrote: > >> What is the best way of altering something (in my case, a file) while >> you are iterating over it? I've tried this before by accident and got >> an error, naturally. >> >> I'm trying to read the lines of a file and remove all the blank ones. >>

Re: FAQ for XML with Python

2006-05-19 Thread Sybren Stuvel
Dave Kuhlman enlightened us with: > For those who are beginners to using Python to process XML, I've > recently updated my Python XML FAQ (PyXMLFaq). It has a number of > code samples that may help you get started. You might want to include a list of things you assume the reader already knows, in

Re: memory error with zipfile module

2006-05-19 Thread Bruno Desthuilliers
Roger Miller a écrit : > The basic problem is that the zipfile interface only reads and writes > whole files, so it may perform poorly or fail on huge files. At one > time I implemented a patch to allow reading files in chunks. However I > believe that the current interface has too many problems

Re: python vs perl lines of code

2006-05-19 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > The question is how to count explicit names like module.class.func; > should that be 1 identifier or 3? Counting as 3 would reward things > like "from X import *" which are generally frowned on in python while > 'use MOD qw(id)' is encouraged in perl.

FAQ for XML with Python

2006-05-19 Thread Dave Kuhlman
For those who are beginners to using Python to process XML, I've recently updated my Python XML FAQ (PyXMLFaq). It has a number of code samples that may help you get started. You can find it here: http://www.rexx.com/~dkuhlman/pyxmlfaq.html Comments and suggestions will be appreciated. Dav

Re: python vs perl lines of code

2006-05-19 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > But first things first... and this one I think is solvable - their has > got to be an equitable way to count how much code was written - maybe > it isn't lines maybe it is > ANd that's it - not can we make a qualitative > statement beyond that. But simply can we q

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Serge Orlov wrote: > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > > > Ron Garret wrote: > > > > > > > I'm using an OS X terminal to ssh to a Linux mach

Re: Daily python url archives

2006-05-19 Thread gene tani
gene tani wrote: > Bobert wrote: > > Hi, > > > > Do you know by chance if someone has archives from the "daily python url" > > feed (http://www.pythonware.com/daily/rss2.xml) ? An archive of the last 3 > > or 6 months would be most useful to me. > > it gets picked up on Swik.net, with a bunch of o

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > > > > > In theor

hidden file detection

2006-05-19 Thread Lenny G.
What's the best way to do cross-platform hidden file detection? I want to do something like weed-out the files that should be 'hidden' from os.listdir() (which would be files that start with '.' under Unix, files that have the hidden attribute set on windows, and whatever it is that makes Mac file

Re: Complex evaluation bug

2006-05-19 Thread Heiko Wundram
Am Freitag 19 Mai 2006 18:03 schrieb Paul McGuire: > An eval-less approach - the problem is the enclosing parens. > I've just submitted two patches to the Python bugtracker at: http://sourceforge.net/tracker/index.php?func=detail&aid=1491866&group_id=5470&atid=305470 which either change the rep

Re: Feature request: sorting a list slice

2006-05-19 Thread Heiko Wundram
Am Freitag 19 Mai 2006 23:24 schrieb George Sakkis: > This is great, thanks Heiko ! Any idea on the chances of being > considered for inclusion in 2.5 ? Don't ask me, I'm not one of the core developers... ;-) But, anyway, the people on python-dev are doing their best to review patches. Just: I ra

Re: the tostring and XML methods in ElementTree

2006-05-19 Thread Serge Orlov
George Sakkis wrote: > > > I'm currently using > > > (a variation of) the workaround below instead of ET.tostring and it > > > works fine for me: > > > > > > def tostring(element, encoding=None): > > > text = element.text > > > if text: > > > if not isinstance(text, basestring): > >

Re: Which is More Efficient?

2006-05-19 Thread John Machin
Dustan wrote: > Fredrik Lundh wrote: >> are you for real? > And what exactly is that supposed to mean? The obscurity in that communication is probably caused by the instance of the effbot with which you have been corresponding having been invoked with mildmannered=True -- apparently this is not t

Re: Daily python url archives

2006-05-19 Thread gene tani
Bobert wrote: > Hi, > > Do you know by chance if someone has archives from the "daily python url" > feed (http://www.pythonware.com/daily/rss2.xml) ? An archive of the last 3 > or 6 months would be most useful to me. it gets picked up on Swik.net, with a bunch of other stuff: http://swik.net/Pyt

Re: Python sqlite and regex.

2006-05-19 Thread Matt Good
Oops, sorry about the confusion regarding the built-in REGEXP. That's kind of disappointing. It would appear that the user-defined regexp function in the original post should work assuming the SQL and regex syntax errors are corrected. However, there *is* a GLOB built-in to SQLite 3 that has a d

Re: Which is More Efficient?

2006-05-19 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > The task manager says "CPU Usage: 100%" when the program is running, > > and only when the program is running. > > > > Efficiency is a measure of 2 things: CPU usage and time. If you measure > > just time, you're not necessarily getting the efficiency. >

Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-19 Thread Christopher Weimann
On 05/19/2006-07:18AM, Duncan Booth wrote: > > My experience of programming with either spaces or tabs has taught me > that tabs are evil not for themselves, but simply because no matter how > hard you try they always end up being mixed with spaces. > Swap the word 'tabs' for the word 'spaces'

Re: Encode exception for chinese text

2006-05-19 Thread John Machin
MvL wrote: > Also, *by definition*, though :-) Ah yes, indeed; and thanks for reminding me. Aside: Similar definition, but not similar design: IMHO utf-8 sits on top of ASCII like a rose on a stalk, whereas gb18030 sits on top of gb2312 like a rhinoceros on a unicycle :-) Cheers, John -- http://

Re: python vs perl lines of code

2006-05-19 Thread [EMAIL PROTECTED]
> Yes, like the shorter version might be overlooking many real world > situations and is naive code. As for generalization, if you bet that the > shorter one is later written, that's to me a generalization. I agree that > there is a change that after reexamining the code, and algorithm can be > wr

Re: Feature request: sorting a list slice

2006-05-19 Thread George Sakkis
Heiko Wundram wrote: > Am Donnerstag 18 Mai 2006 19:27 schrieb George Sakkis: > > It would be useful if list.sort() accepted two more optional > > parameters, start and stop, so that you can sort a slice in place. > > I've just submitted: > > http://sourceforge.net/tracker/index.php?func=detail&ai

Re: newb: comapring two strings

2006-05-19 Thread bearophileHUGS
Paul Rubin>Still terrible. Use a better algorithm!< I agree, it's O(n^2), but if you need to run this program just 1 time, and the program is in C, and you don't want to use much time to think and code a better algorithm (or you aren't able to do it) then maybe that naive solution can be enough,

Question about Python on Mac

2006-05-19 Thread elventear
Hello, I am working with Python 2.4.3 built from source courtesy of Fink. So far so good, until now. I want to use a module called GMPY (http://gmpy.sf.net/). I am able to build correctly the module, but once I try to import it I get the following error: ImportError: Failure linking new module: g

Re: Decimal and Exponentiation

2006-05-19 Thread Tim Peters
[elventear] > I am the in the need to do some numerical calculations that involve > real numbers that are larger than what the native float can handle. > > I've tried to use Decimal, but I've found one main obstacle that I > don't know how to sort. I need to do exponentiation with real > exponents,

Re: [silly] Does the python mascot have a name ?

2006-05-19 Thread Carl J. Van Arsdall
Ralf Muschall wrote: > John D Salt wrote: > > >> I'll believe you if you can give me a list of ten things that don't have >> names. >> > > [ sub{$_}, sub{$_+1}, sub{$_+2}, sub{$_+3}, sub{$_+4}, > sub{$_+5}, sub{$_+6}, sub{$_+7}, sub{$_+8}, sub{$_+9}] > > That was easy. > Wakka wakka.

Re: Request for comments on python distributed technologies

2006-05-19 Thread Carl J. Van Arsdall
Paul McGuire wrote: >> > > What you describe sounds very much like pyro, which should probably be added > to your list. > Pyro looks nothing short of amazing. I will definitely spend some time studying this technology as well. Does anyone here use pyro or any of the other technologies e

Re: newb: comapring two strings

2006-05-19 Thread John Machin
Paul Rubin wrote: > [EMAIL PROTECTED] writes: >>> I have suggested C because if the words are all of the same length then >>> you have 3^2 = 90 000 000 000 pairs to test. >> Sorry, you have (n*(n-1))/2 pairs to test (~ 45 000 000 000). > Still terrible. Use a better algorithm! To put all t

Using metaclasses to inherit class variables

2006-05-19 Thread [EMAIL PROTECTED]
I want to inherit fresh copies of some class variables. So I set up a metaclass and meddle with the class variables there. Now it would be convenient to run thru a dictionary rather than explicitly set each variable. However getattr() and setattr() are out because they chase the variable thru the

Re: [silly] Does the python mascot have a name ?

2006-05-19 Thread Ralf Muschall
John D Salt wrote: > I'll believe you if you can give me a list of ten things that don't have > names. [ sub{$_}, sub{$_+1}, sub{$_+2}, sub{$_+3}, sub{$_+4}, sub{$_+5}, sub{$_+6}, sub{$_+7}, sub{$_+8}, sub{$_+9}] That was easy. Ralf -- http://mail.python.org/mailman/listinfo/python-list

Re: python vs perl lines of code

2006-05-19 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > John Bokma wrote: >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> >> > But if a 1 person, using 1 language, with the same set of tools >> > withing a 3 month period implements the same algo without bugs - >> > I'll bet you the shorter one was t

sock2

2006-05-19 Thread gangesmaster
sock2 is an attempt to improve python's socket module, by a more pythonic version (options are properties, protocols are classes, etc.etc) you can get it here (including a small demo) http://iostack.wikispaces.com/download i would like to receive comments/bug reports, to improve it. just reply to

Re: bitstream

2006-05-19 Thread bearophileHUGS
Maybe this is what you are looking for: http://cheeseshop.python.org/pypi/BitBuffer/0.1 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: altering an object as you iterate over it?

2006-05-19 Thread Richard Townsend
On Fri, 19 May 2006 13:36:35 -0700, James Stroud wrote: > Paul McGuire wrote: >> Your coding style is a little dated - are you using an old version of >> Python? This style is the old-fashioned way: > [clip] >> 1. open("xxx") still works - not sure if it's even deprecated or not - but >> the new

Re: how to suppress the "source code echo" output by warnings.warn("x")?

2006-05-19 Thread funkyj
Peter Otten wrote: > funkyj wrote: > > > I've been googling around trying to find the answer to this question > > but all I've managed to turn up is a 2 year old post of someone else > > asking the same question (no answer though). > How about monkey-patching? > > import warnings > > def formatwa

Re: memory error with zipfile module

2006-05-19 Thread Roger Miller
The basic problem is that the zipfile interface only reads and writes whole files, so it may perform poorly or fail on huge files. At one time I implemented a patch to allow reading files in chunks. However I believe that the current interface has too many problems to solve by incremental patching,

Re: python vs perl lines of code

2006-05-19 Thread [EMAIL PROTECTED]
John Bokma wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > But if a 1 person, using 1 language, with the same set of tools withing > > a 3 month period implements the same algo without bugs - I'll bet you > > the shorter one was theone written second. > > You might lose that bet very

Re: altering an object as you iterate over it?

2006-05-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Paul McGuire wrote: > 1. open("xxx") still works - not sure if it's even deprecated or not - but > the new style is to use the file class It's not deprecated and may be still used for opening files. I guess the main reason for introducing `file` as a synonym was the possi

Re: altering an object as you iterate over it?

2006-05-19 Thread John Salerno
Paul McGuire wrote: > I think it is just part of the objectification trend - "f = > open('xyzzy.dat')" is sort of a functional/verb concept, so it has to return > something, and its something non-objecty like a file handle - urk! Instead, > using "f = file('xyzzy.dat')" is more of an object const

Re: Process forking on Windows - or what is MQSeries

2006-05-19 Thread Benji York
Andrew Robert wrote: > In this situation, it is possible for a process(my python program) to > monopolize and block other processes from being triggered. > > Ideally, this needs to be avoided through the use of a fork. Another option would be to write the incoming messages to your own queue (an

Re: altering an object as you iterate over it?

2006-05-19 Thread John Salerno
Paul McGuire wrote: >>> answer is - you are STILL UPDATING THE LIST YOUR ARE ITERATING OVER!!! >> Doh! I see that now! :) >> > > Sorry about the ALL CAPS... I think I got a little rant-ish in that last > post, didn't mean to shout. :) > > Thanks for being a good sport, Heh heh, actually it was

Re: altering an object as you iterate over it?

2006-05-19 Thread Paul McGuire
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul McGuire wrote: > > > Your coding style is a little dated - are you using an old version of > > Python? This style is the old-fashioned way: > > I'm sure it has more to do with the fact that I'm new to Python, but > w

Re: altering an object as you iterate over it?

2006-05-19 Thread James Stroud
Paul McGuire wrote: > Your coding style is a little dated - are you using an old version of > Python? This style is the old-fashioned way: [clip] > 1. open("xxx") still works - not sure if it's even deprecated or not - but > the new style is to use the file class Python 2.3.4 (#4, Oct 25 2004, 2

Re: altering an object as you iterate over it?

2006-05-19 Thread John Salerno
Paul McGuire wrote: > Your coding style is a little dated - are you using an old version of > Python? This style is the old-fashioned way: I'm sure it has more to do with the fact that I'm new to Python, but what is old-fashioned about open()? Does file() do anything different? I know they are

Re: altering an object as you iterate over it?

2006-05-19 Thread Paul McGuire
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > John Salerno wrote: > > What is the best way of altering something (in my case, a file) while > > you are iterating over it? I've tried this before by accident and got an > > error, naturally. > > > > I'm trying to read th

Re: altering an object as you iterate over it?

2006-05-19 Thread John Salerno
bruno at modulix wrote: > Now if what you want to do is just to rewrite the file without the blank > files, you need to use a second file: > > fin = open(path, 'r') > fout = open(temp, 'w') > for line in fin: > if line.strip(): > fout.write(line) > fin.close() > fout.close() > > then delet

Re: Programming language productivity

2006-05-19 Thread Jack Diederich
On Fri, May 19, 2006 at 02:21:39AM -0700, malv wrote: > Once you get involved in larger projects, the dynamic nature of the > programming tool becomes much more important. I mean by this, the > ability to stop running code, modify or add to it and continue without > having to re-establish the state

Re: Why does the _winreg module start with an underscore

2006-05-19 Thread 3c273
"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 3c273 wrote: > > > Does it signify something? Just curious. > > Dear quasar, > > Typically an identifier starting with an underscore signifies something > that is not intended to be exposed as part of a public API. I

Re: Segmenting a pickle stream without unpickling

2006-05-19 Thread Tim Peters
[Boris Borcic] > Assuming that the items of my_stream share no content (they are > dumps of db cursor fetches), is there a simple way to do the > equivalent of > > def pickles(my_stream) : > from cPickle import load,dumps > while 1 : > yield dumps(load(my_stream)) > > without the

Re: Why does the _winreg module start with an underscore

2006-05-19 Thread Fredrik Lundh
3c273 wrote: > Does it signify something? Just curious. from the module documentation: This module exposes a very low-level interface to the Windows registry; it is expected that in the future a new winreg module will be created offering a higher-level interface to th

Re: [silly] Does the python mascot have a name ?

2006-05-19 Thread Mel Wilson
John D Salt wrote: > Mel Wilson <[EMAIL PROTECTED]> wrote in news:_s2bg.8867$aa4.296233 > @news20.bellglobal.com: > > [Snips] >> Just reinforces the central truth. The mascot doesn't >> *have* a name. Most things don't. > > Most things don't have names? > > I'll believe you if you can give m

Re: altering an object as you iterate over it?

2006-05-19 Thread bruno at modulix
John Salerno wrote: > What is the best way of altering something (in my case, a file) while > you are iterating over it? I've tried this before by accident and got an > error, naturally. > > I'm trying to read the lines of a file and remove all the blank ones. > One solution I tried is to open the

Re: altering an object as you iterate over it?

2006-05-19 Thread John Salerno
John Salerno wrote: > What is the best way of altering something (in my case, a file) while > you are iterating over it? I've tried this before by accident and got an > error, naturally. > > I'm trying to read the lines of a file and remove all the blank ones. > One solution I tried is to open

Re: Modifying a variable in a non-global outer scope?

2006-05-19 Thread bruno at modulix
Edward C. Jones wrote: > #! /usr/bin/env python > """ > When I run the following program I get the error message: > > UnboundLocalError: local variable 'x' referenced before assignment > > Can "inner" change the value of a variable defined in "outer"? Not this way > Where > is this explained i

Re: number of different lines in a file

2006-05-19 Thread Paul McGuire
"Grant Edwards" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Why would the second running of uniq remove any additional lines that > > weren't removed in the first pass? > > Because uniq only removes _adjacent_ identical lines. > Thanks, guess my *nix ignorance is showing (this

Re: number of different lines in a file

2006-05-19 Thread Paul McGuire
"Kaz Kylheku" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paddy wrote: > ...if you are lucky enough to have a "zero copy" > pipe implementation whcih allows data to go from the writer's buffer > directly to the reader's one without intermediate kernel buffering. > I love it when

Re: Feature request: sorting a list slice

2006-05-19 Thread Heiko Wundram
Am Donnerstag 18 Mai 2006 19:27 schrieb George Sakkis: > It would be useful if list.sort() accepted two more optional > parameters, start and stop, so that you can sort a slice in place. I've just submitted: http://sourceforge.net/tracker/index.php?func=detail&aid=1491804&group_id=5470&atid=30547

Re: number of different lines in a file

2006-05-19 Thread Kaz Kylheku
Paddy wrote: > If the log has a lot of repeated lines in its original state then > running uniq twice, once up front to reduce what needs to be sorted, > might be quicker? Having the uniq and sort steps integrated in a single piece of software allows for the most optimization opportunities. The s

Re: Why does the _winreg module start with an underscore

2006-05-19 Thread Erik Max Francis
3c273 wrote: > Does it signify something? Just curious. Dear quasar, Typically an identifier starting with an underscore signifies something that is not intended to be exposed as part of a public API. In other words, it's an implementation detail in whatever you're using and as such you prob

[ANNOUNCE] Thirty-first release of PythonCAD now available

2006-05-19 Thread Art Haas
Hi. I'm pleased to announce the thirty-first development release of PythonCAD, a CAD package for open-source software users. As the name implies, PythonCAD is written entirely in Python. The goal of this project is to create a fully scriptable drafting program that will match and eventually exceed

Modifying a variable in a non-global outer scope?

2006-05-19 Thread Edward C. Jones
#! /usr/bin/env python """ When I run the following program I get the error message: UnboundLocalError: local variable 'x' referenced before assignment Can "inner" change the value of a variable defined in "outer"? Where is this explained in the docs? """ def outer(): def inner(): x

altering an object as you iterate over it?

2006-05-19 Thread John Salerno
What is the best way of altering something (in my case, a file) while you are iterating over it? I've tried this before by accident and got an error, naturally. I'm trying to read the lines of a file and remove all the blank ones. One solution I tried is to open the file and use readlines(), th

Re: Request for comments on python distributed technologies

2006-05-19 Thread Paul McGuire
"Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey everyone, another question for the list. In particular i'm looking > for comments on some of the distributed technologies supported in > python. Specifically, I'm looking at XML-RPC, RPyC, CORBA, and Twisted.

Re: number of different lines in a file

2006-05-19 Thread Grant Edwards
On 2006-05-19, Paul McGuire <[EMAIL PROTECTED]> wrote: >> If the log has a lot of repeated lines in its original state then >> running uniq twice, once up front to reduce what needs to be sorted, >> might be quicker? >> >> uniq log_file | sort| uniq | wc -l >> >> - Pad. > > Why would the second r

  1   2   3   >