Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107764

Re: Python Madlibs.py code and error message

From Stephen Hansen <me@ixokai.io>
Newsgroups comp.lang.python
Subject Re: Python Madlibs.py code and error message
Date 2016-04-27 23:50 -0700
Message-ID <mailman.177.1461826249.32212.python-list@python.org> (permalink)
References (1 earlier) <dodj48Fb8o8U1@mid.individual.net> <6c0d96c5-c7f5-4659-a2e9-20f8d202d701@googlegroups.com> <1461820617.3238425.591942249.1484DAC3@webmail.messagingengine.com> <85fuu6jo1o.fsf@benfinney.id.au> <1461826246.3257796.591992793.54C5CC58@webmail.messagingengine.com>

Show all headers | View raw


On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote:
> Stephen Hansen <me+python@ixokai.io> writes:
> 
> > The error message means there's a mismatch between the number of
> > formatting instructions (ie, %s) and arguments passed to formatting. I
> > leave it to you to count and find what's missing or extra, because I'm
> > seriously not going to do that :)
> 
> Better: when you have many semantically-different values, use named (not
> positional) parameters in the format string.
> 
>     Some simple format string examples:
> 
>     "First, thou shalt count to {0}" # References first positional
>     argument
>     "Bring me a {}"                  # Implicitly references the first
>     positional argument
>     "From {} to {}"                  # Same as "From {0} to {1}"
>     "My quest is {name}"             # References keyword argument 'name'
>     […]
> 
>     <URL:https://docs.python.org/3/library/string.html#formatstrings>

Except the poster is not using Python 3, so all of this is for naught. 

-- 
Stephen Hansen
  m e @ i x o k a i  . i o

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python Madlibs.py code and error message Cai Gengyang <gengyangcai@gmail.com> - 2016-04-27 21:37 -0700
  Re: Python Madlibs.py code and error message Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-28 16:50 +1200
    Re: Python Madlibs.py code and error message Cai Gengyang <gengyangcai@gmail.com> - 2016-04-27 22:01 -0700
      Re: Python Madlibs.py code and error message Stephen Hansen <me+python@ixokai.io> - 2016-04-27 22:16 -0700
      Re: Python Madlibs.py code and error message Ben Finney <ben+python@benfinney.id.au> - 2016-04-28 15:32 +1000
      Re: Python Madlibs.py code and error message Stephen Hansen <me@ixokai.io> - 2016-04-27 23:50 -0700
      Re: Python Madlibs.py code and error message Ben Finney <ben+python@benfinney.id.au> - 2016-04-28 16:55 +1000
      Re: Python Madlibs.py code and error message Stephen Hansen <me@ixokai.io> - 2016-04-28 00:08 -0700
        Re: Python Madlibs.py code and error message Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-04-28 17:25 +1000
          Re: Python Madlibs.py code and error message Cai Gengyang <gengyangcai@gmail.com> - 2016-05-03 04:12 -0700
      Re: Python Madlibs.py code and error message Ben Finney <ben+python@benfinney.id.au> - 2016-04-28 17:17 +1000
  Re: Python Madlibs.py code and error message Stephen Hansen <me+python@ixokai.io> - 2016-04-27 21:55 -0700

csiph-web