Glob returning an empty list when passed a variable
MRAB
google at mrabarnett.plus.com
Sat Feb 10 11:20:46 EST 2007
On Feb 10, 8:32 am, Steve Holden <s... at holdenweb.com> wrote:
> Steven D'Aprano wrote:
> > On Fri, 09 Feb 2007 14:15:51 +0000, Steve Holden wrote:
>
> >> area_name_string = '*% s*' % (Area_name)
>
> >> Interesting, I never realised until now that you can have spaces between
> >> the percent sign and th format effector.
>
> > Space is one of the flags. From the docs:
>
> > The conversion flag characters are:
>
> > Flag Meaning
> > # The value conversion will use the ``alternate form'' (where defined
> > below).
> > 0 The conversion will be zero padded for numeric values.
> > - The converted value is left adjusted (overrides the "0" conversion if
> > both are given).
> > (a space) A blank should be left before a positive number (or empty
> > string) produced by a signed conversion.
> > + A sign character ("+" or "-") will precede the conversion (overrides a
> > "space" flag).
>
> >http://docs.python.org/lib/typesseq-strings.html
>
> >>> "% s" % 'banana'
> 'banana'
> >>> "% s" % 1
> '1'
> >>> "% s" % -1
> '-1'
> >>>
>
[snip]
I've just tried it and it works for the "d" format but not the "s"
format:
>>> "%d" % 1
'1'
>>> "%+d" % 1
'+1'
>>> "% d" % 1
' 1'
More information about the Python-list
mailing list