Re: [Python-Dev] zlib module doesn't build - inflateCopy() not found

2006-05-20 Thread Georg Brandl
Martin v. Löwis wrote:
> Guido van Rossum wrote:
>> It seems I have libz 1.1.4. Is this no longer supported?
> 
> Apparently so. This function started to be used with
> 
> 
> r46012 | georg.brandl | 2006-05-16 09:38:27 +0200 (Di, 16 Mai 2006) | 3
> lines
> Geänderte Pfade:
>M /python/trunk/Doc/lib/libzlib.tex
>M /python/trunk/Lib/test/test_zlib.py
>M /python/trunk/Misc/NEWS
>M /python/trunk/Modules/zlibmodule.c
> 
> Patch #1435422: zlib's compress and decompress objects now have a
> copy() method.
> 
> 
> 
> zlib itself contains inflateCopy since
> 
> Changes in 1.2.0 (9 March 2003)
> - Added inflateCopy() function to record state for random access on
>   externally generated deflate streams (e.g. in gzip files)
 >
> The options for Python now are these:
> 1. require users to install zlib 1.2.x if they want the zlib module
>drawback: more work for the system administrator
 >
> 2. conditionalize copy/uncopy on the system zlib being 1.2.x
>drawback: Python applications relying on these functions would
>break if the system zlib is too old
 >
> 3. make setup.py fall back to the bundled zlib if the system zlib
>is too old
>drawback: you get all the problems of static linking, e.g.
>the size increase, and the problems with two zlib versions
>living in the same address space for some embedded Python
>applications
 >
> I'm not volunteering to implement any of the options.

Of course, option 4 is to revert the patch if none of these options
are acceptable.

Georg

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New string method - splitquoted

2006-05-20 Thread Heiko Wundram
Am Donnerstag 18 Mai 2006 06:06 schrieb Dave Cinege:
> This is useful, but possibly better put into practice as a separate
> method??

I personally don't think it's particularily useful, at least not in the 
special case that your patch tries to address.

1) Generally, you won't only have one character that does quoting, but 
several. Think of the Python syntax, where you have ", ', """ and ''', which 
all behave slightly differently. The logic for " and ' is simple enough to 
implement (basically that's what your patch does, and I'm sure it's easy 
enough to extend it to accept a range of characters as splitters), but if you 
have more complicated quoting operators (such as """), are you sure it's 
sensible to implement the logic in split()?

2) What should the result of "this is a \"test string".split(None,-1,'"') be? 
An exception (ParseError)? Silently ignoring the missing delimiter, and 
returning ['this','is','a','test string']? Ignoring the delimiter altogether, 
returning ['this','is','a','"test','string']? I don't think there's one case 
to satisfy all here...

3) What about escapes of the delimiter? Your current patch doesn't address 
them at all (AFAICT) at the moment, but what should the escaping character 
be? Should "escape processing" take place, i.E. what should the result 
of "this is a \\\"delimiter \\test".split(None,-1,'"') be?

Don't get me wrong, I personally find this functionality very, very 
interesting (I'm +0.5 on adding it in some way or another), especially as a 
part of the standard library (not necessarily as an extension to .split()).

But there's quite a lot of semantic stuff to get right before you can 
implement it properly; see the complexity of the csv module, where you have 
to define pretty much all of this in the dialect you use to parse the csv 
file...

Why not write up a PEP?

--- Heiko.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New string method - splitquoted - New EmailAddress

2006-05-20 Thread Dave Cinege
Sorry to all about tmda on my dcinege-mlists email addy. It was not supposed 
to be, however the dash in dcinege-mlists was flipping out the latest 
incarnation of my mail server config. Please use this address to reply to me
in this thread.

Dave

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New string method - splitquoted

2006-05-20 Thread Dave Cinege
On Thursday 18 May 2006 11:11, Guido van Rossum wrote:
> This is not an apropriate function to add as a string methods. There
> are too many conventions for quoting and too many details to get
> right. One method can't possibly handle them all without an enormous
> number of weird options. It's better to figure out how to do this with
> regexps or use some of the other approaches that have been suggested.
> (Did anyone mention the csv module yet? It deals with this too.)

Maybe my idea is better called splitexcept instead of splitquoted, as my goal 
is to (simply) provide a way to limit the split by delimiters, and not dive 
into an all encompassing quoting algorithm.

It me this is in the spirit of the maxsplit option already present.

Dave

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New string method - splitquoted

2006-05-20 Thread Dave Cinege
On Thursday 18 May 2006 16:13, you wrote:
> Dave Cinege wrote:
> > For example:
> >
> > s = '  Chan: 11  SNR: 22  ESSID: "Spaced Out Wifi"  Enc: On'
>
> My complaint with this example is that you are just using the wrong tool
> to do this job. If I was going to do this, I would've immediately jumped
> on the regex-press train.
>
> wifi_info = re.match('^\s+'
>   'Chan:\s+(?P[0-9]+)\s+'
>   'SNR:\s+(?P[0-9]+)\s+'
>   'ESSID:\s+"(?P[^"]*)"\s+'
>   'Enc:\s+(?P[a-zA-Z]+)'
>   , s)

For the 5 years of been pythoning, I've used re probably twice. 
I find regex to be a tool of last resort, and quite a bit of effort to get 
right, as regex (for me) is quite prone it giving unintended results without 
a good deal of thought. I don't want to have to think. That's why I use 
python.  : )

.split() and slicing has always been python's holy grail for me, and I find it 
a lot easier to .replace() 'stray' chars with spaces or a delimiter and then 
split() that.  It's easier to read and (should be) a lot quicker to process 
then regex. (Which I care about, as I'm also often on embedded CPU's of a few 
hundred MHz)

So .split works just super duper.but I keep running in to situations where 
I'd like a substr to be excluded from the split'ing.

The clearest one is excluding a 'quoted' string that has whitespace.
Here's another, be it, a very poor example: 

s = '\t\tFrequency:2.462 GHz (Channel 11)'  # This is real output from 
iwlist:
s.replace(':',')').replace(' (','))').split(None,-1,')')
['Frequency', '2.462 GHz', 'Channel 11']

I wanted to preserve the '2.462 GHz' substr. Let's assume, that could come out 
as '900 MHz' or '11.3409 GHz'. The above code gets what I want in 1 shot, 
either way. Show me an easier way, that doesn't need multiple splits, and 
string re-assembly, and I'll use it.

Dave

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] zlib module doesn't build - inflateCopy() not found

2006-05-20 Thread Guido van Rossum
On 5/20/06, Georg Brandl <[EMAIL PROTECTED]> wrote:
> Martin v. Löwis wrote:
> > Guido van Rossum wrote:
> >> It seems I have libz 1.1.4. Is this no longer supported?
> >
> > Apparently so. This function started to be used with
> >
> > 
> > r46012 | georg.brandl | 2006-05-16 09:38:27 +0200 (Di, 16 Mai 2006) | 3
> > lines
> > Geänderte Pfade:
> >M /python/trunk/Doc/lib/libzlib.tex
> >M /python/trunk/Lib/test/test_zlib.py
> >M /python/trunk/Misc/NEWS
> >M /python/trunk/Modules/zlibmodule.c
> >
> > Patch #1435422: zlib's compress and decompress objects now have a
> > copy() method.
> >
> > 
> >
> > zlib itself contains inflateCopy since
> >
> > Changes in 1.2.0 (9 March 2003)
> > - Added inflateCopy() function to record state for random access on
> >   externally generated deflate streams (e.g. in gzip files)
>  >
> > The options for Python now are these:
> > 1. require users to install zlib 1.2.x if they want the zlib module
> >drawback: more work for the system administrator

That's unacceptable; I'd have to fight a whole layer of burocracy to
change the system image (and I wouldn't even want to do this since one
premise here is that engineering workstations are interchangeable).

> > 2. conditionalize copy/uncopy on the system zlib being 1.2.x
> >drawback: Python applications relying on these functions would
> >break if the system zlib is too old

That would be fine for me. Since the feature is apparently brand new
(in Python) I doubt that I'd miss it.

> > 3. make setup.py fall back to the bundled zlib if the system zlib
> >is too old
> >drawback: you get all the problems of static linking, e.g.
> >the size increase, and the problems with two zlib versions
> >living in the same address space for some embedded Python
> >applications

That would work too (probably better). As long as it prints some kind
of warning durning build IMO this would be the best option. The
drawbacks don't matter for me.

> > I'm not volunteering to implement any of the options.
>
> Of course, option 4 is to revert the patch if none of these options
> are acceptable.

Not so quick. :-)

What was the purpose of the patch in the first place?

If you could volunteer #3 that would be great IMO.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New string method - splitquoted

2006-05-20 Thread Guido van Rossum
"I'm sorry Dave, I'm afraid I can't do that."

We hear you, Dave, but this is not a suitable function to add to the
standard library. Many respondents are trying to tell you that in many
different ways. If you keep arguing for it, we'll just ignore you.

--Guido

PS. Give up TDMA. Try Spambayes instead. It works much better and is
less annoying for your correspondents.

On 5/18/06, Dave Cinege
<[EMAIL PROTECTED]> wrote:
> On Thursday 18 May 2006 16:13, you wrote:
> > Dave Cinege wrote:
> > > For example:
> > >
> > > s = '  Chan: 11  SNR: 22  ESSID: "Spaced Out Wifi"  Enc: On'
> >
> > My complaint with this example is that you are just using the wrong tool
> > to do this job. If I was going to do this, I would've immediately jumped
> > on the regex-press train.
> >
> > wifi_info = re.match('^\s+'
> >   'Chan:\s+(?P[0-9]+)\s+'
> >   'SNR:\s+(?P[0-9]+)\s+'
> >   'ESSID:\s+"(?P[^"]*)"\s+'
> >   'Enc:\s+(?P[a-zA-Z]+)'
> >   , s)
>
> For the 5 years of been pythoning, I've used re probably twice.
> I find regex to be a tool of last resort, and quite a bit of effort to get
> right, as regex (for me) is quite prone it giving unintended results without
> a good deal of thought. I don't want to have to think. That's why I use
> python.  : )
>
> .split() and slicing has always been python's holy grail for me, and I find it
> a lot easier to .replace() 'stray' chars with spaces or a delimiter and then
> split() that.  It's easier to read and (should be) a lot quicker to process
> then regex. (Which I care about, as I'm also often on embedded CPU's of a few
> hundred MHz)
>
> So .split works just super duper.but I keep running in to situations where
> I'd like a substr to be excluded from the split'ing.
>
> The clearest one is excluding a 'quoted' string that has whitespace.
> Here's another, be it, a very poor example:
>
> s = '\t\tFrequency:2.462 GHz (Channel 11)'  # This is real output from 
> iwlist:
> s.replace(':',')').replace(' (','))').split(None,-1,')')
> ['Frequency', '2.462 GHz', 'Channel 11']
>
> I wanted to preserve the '2.462 GHz' substr. Let's assume, that could come out
> as '900 MHz' or '11.3409 GHz'. The above code gets what I want in 1 shot,
> either way. Show me an easier way, that doesn't need multiple splits, and
> string re-assembly, and I'll use it.
>
> Dave
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com