Steve Holden wrote:
Michael Spencer wrote:
Andrew Dalke wrote:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
Gah! I guess that torpedoes the regexp approach, then.
Thanks for looking at this
Micha
On Wed, 20 Apr 2005 17:09:16 -0700, Michael Spencer <[EMAIL PROTECTED]> wrote:
>Andrew Dalke wrote:
>
>> I see you assume that only \w+ can fit inside of a %()
>> in a format string. The actual Python code allows anything
>> up to the balanced closed parens.
>>
>Gah! I guess that torpedoes the r
Michael Spencer wrote:
Andrew Dalke wrote:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
Gah! I guess that torpedoes the regexp approach, then.
Thanks for looking at this
Michael
While Andrew may
Peter Otten wrote:
Greg Ewing wrote:
This seems to happen even with a custom subclass of tuple,
so it must be doing an exact type check.
No, it doesn't do an exact type check, but always calls the tuple method:
I guess you mean len(). On further investigation,
this seems to be right, except that it
Andrew Dalke wrote:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
Gah! I guess that torpedoes the regexp approach, then.
Thanks for looking at this
Michael
--
http://mail.python.org/mailman/listin
Michael Spencer wrote:
> I have wrapped up my current understanding in the following class:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
>>> class Show:
... def __getitem__(self, text):
...
Bengt Richter wrote:
On Wed, 20 Apr 2005 11:01:28 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
...
"%s %(x)s %(y)s" % D()
My experiments suggest that you can have a maximum of one unnamed argument in a
mapping template - this unnamed value evaluates to the map itself
...
So under what circumstanc
On Wed, 20 Apr 2005 11:01:28 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> Parse might be a big word for
>>
>> >> def tupreq(fmt): return sum(map(lambda s:list(s).count('%'),
>> >> fmt.split('%%')))
>> ..
>> >> tupreq('%s this %(x)s not %% but %s')
>>
>> (if it wor
Bengt Richter wrote:
> Parse might be a big word for
>
> >> def tupreq(fmt): return sum(map(lambda s:list(s).count('%'),
> >> fmt.split('%%')))
> ..
> >> tupreq('%s this %(x)s not %% but %s')
>
> (if it works in general ;-)
Which it doesn't:
>>> def tupreq(fmt): return sum(map(lambda s:lis
On Wed, 20 Apr 2005 09:14:40 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
>Greg Ewing wrote:
>
>> Steve Holden wrote:
>>
>>> I've been wondering whether it's possible to perform a similar analysis
>>> on non-mapping-type format strings, so as to know how long a tuple to
>>> provide,
>>
>> I jus
Greg Ewing wrote:
> Steve Holden wrote:
>
>> I've been wondering whether it's possible to perform a similar analysis
>> on non-mapping-type format strings, so as to know how long a tuple to
>> provide,
>
> I just tried an experiment, and it doesn't seem to be possible.
>
> The problem seems to
Steve Holden wrote:
I've been wondering whether it's possible to perform a similar analysis
on non-mapping-type format strings, so as to know how long a tuple to
provide,
I just tried an experiment, and it doesn't seem to be possible.
The problem seems to be that it expects the arguments to be
in
Steve Holden wrote:
> I was messing about with formatting and realized that the right kind of
> object could quite easily tell me exactly what accesses are made to the
> mapping in a string % mapping operation. This is a fairly well-known
> technique, modified to tell me what keys would need to be
On Mon, 18 Apr 2005 16:24:39 -0400, Steve Holden <[EMAIL PROTECTED]> wrote:
>I was messing about with formatting and realized that the right kind of
>object could quite easily tell me exactly what accesses are made to the
>mapping in a string % mapping operation. This is a fairly well-known
>te
Steve Holden wrote:
I've been wondering whether it's possible to perform a similar analysis
on non-mapping-type format strings, so as to know how long a tuple to
provide, or whether I'd be forced to lexical analysis of the form string.
regards
Steve
I do not know if it is possible to do that.
B
I was messing about with formatting and realized that the right kind of
object could quite easily tell me exactly what accesses are made to the
mapping in a string % mapping operation. This is a fairly well-known
technique, modified to tell me what keys would need to be present in any
mapping u
16 matches
Mail list logo