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


Groups > comp.lang.python > #80264 > unrolled thread

Re: Understanding "help" command description syntax - explanation needed

Started byChris Angelico <rosuav@gmail.com>
First post2014-11-05 23:20 +1100
Last post2014-11-05 23:20 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Understanding "help" command description syntax - explanation needed Chris Angelico <rosuav@gmail.com> - 2014-11-05 23:20 +1100

#80264 — Re: Understanding "help" command description syntax - explanation needed

FromChris Angelico <rosuav@gmail.com>
Date2014-11-05 23:20 +1100
SubjectRe: Understanding "help" command description syntax - explanation needed
Message-ID<mailman.15493.1415190058.18130.python-list@python.org>
On Wed, Nov 5, 2014 at 11:13 PM, Ivan Evstegneev
<webmailgroups@gmail.com> wrote:
> That's what I'm talking about (asking actually), where do you know it from?
> I mean, if there are some resources, which explain all these syntax abbreviations? The general concept.
>
>
> Like this one(just for example):
> class bytearray([source[, encoding[, errors]]]) --- What does it mean?
> Is that  I can use it in optional way?
> Like: class bytearray(source) or class bytearray(encoding) ?
> or just write down all three of them?
> In which format do I do so?

With consecutive defaults, like that, it's written as a nested series.
You have three optional parts: the first is "source[, encoding[,
errors]]", the second (completely inside that) is ", encoding[,
errors]", and the third (also inside) is ", errors". The first one
gives you two options:

class bytearray()
class bytearray(source[, encoding[, errors]])

Then that gives you two more options:
class bytearray(source)
class bytearray(source, encoding[, errors])

Which itself gives two options:
class bytearray(source, encoding)
class bytearray(source, encoding, errors)

So what you actually have is four real, usable options:
class bytearray()
class bytearray(source)
class bytearray(source, encoding)
class bytearray(source, encoding, errors)

Does that make sense? You're allowed to provide no options, or
anywhere up to three, but they have to be the first N options.

In this particular case, it doesn't make sense to provide the later
options without also providing the earlier ones. The encoding and
errors parameters affect how source is interpreted, and errors affects
how the encoding copes with stuff it can't handle, so it wouldn't make
sense to provide either without source, or source and errors without
encoding. That's why it's written as a nested set of optional
sections, rather than as a series of stand-alone options.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web