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


Groups > comp.lang.python > #80264

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

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'source,': 0.04; 'syntax': 0.04; 'encoding': 0.05; 'nested': 0.07; 'subject:help': 0.08; 'so?': 0.09; 'subject:command': 0.09; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; '(also': 0.16; '(completely': 0.16; 'defaults,': 0.16; 'encoding)': 0.16; 'encoding.': 0.16; 'errors)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interpreted,': 0.16; 'ivan': 0.16; 'mean,': 0.16; 'optional': 0.16; 'subject:description': 0.16; 'usable': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'options.': 0.19; 'later': 0.20; 'written': 0.21; 'cc:addr:python.org': 0.22; 'affects': 0.24; 'earlier': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'options': 0.25; 'second': 0.26; 'header:In-Reply- To:1': 0.27; "doesn't": 0.30; 'errors': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'gives': 0.31; 'ones.': 0.31; 'them?': 0.31; 'way?': 0.31; 'class': 0.32; 'stuff': 0.32; 'third': 0.33; 'sense': 0.34; "can't": 0.35; 'anywhere': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'options:': 0.36; 'two': 0.37; 'nov': 0.38; 'subject:needed': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'explain': 0.39; 'does': 0.39; 'itself': 0.39; 'subject:" ': 0.39; 'either': 0.39; 'how': 0.40; 'affect': 0.61; 'providing': 0.61; "you're": 0.61; 'first': 0.61; 'provide': 0.64; 'more': 0.64; 'talking': 0.65; 'series': 0.66; 'concept.': 0.84; 'that)': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=hF4xU6Ldb/FGfjqVPyfDQW9RYri7klbTjPWZqh+bCV4=; b=IKxFmq4Hov0WhPoEgLEHc2nOUzwyqHgu97VxiXCzujZrJnNy1akF53/N1c5zTO16xx kz2QIqxUBbBrqbar664p3WY4RQEPZkjYb8eNMDvcG5uPl3pxOhvoqYZJ0lL7PKoFG1mQ aMWKTt1gOxKVf0ncgr6DPE8jztWfrJxY2zc3kIV1hTQVfYEPq9XrD0VLNM0PItJKAzRj 5HFOPhJ3HPu14B9uGdXkoLXXLoi26Wa8HAUu3fTeCc/PyUFVrrAGfGXBOxcmK6D9tGAe G6NJEs/6PYvvnxtlSC+FaSheuS3/t7w395RfriF3Rs2b1MOjgn3umD2S4ZoH3vOk52C2 q1Eg==
MIME-Version 1.0
X-Received by 10.50.79.135 with SMTP id j7mr4971135igx.14.1415190055872; Wed, 05 Nov 2014 04:20:55 -0800 (PST)
In-Reply-To <000501cff8f1$ed99cc40$c8cd64c0$@gmail.com>
References <000001cff8e7$af51ef30$0df5cd90$@gmail.com> <88543346.5460.1415188500802.JavaMail.root@sequans.com> <000501cff8f1$ed99cc40$c8cd64c0$@gmail.com>
Date Wed, 5 Nov 2014 23:20:55 +1100
Subject Re: Understanding "help" command description syntax - explanation needed
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15493.1415190058.18130.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415190058 news.xs4all.nl 2830 [2001:888:2000:d::a6]:48863
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80264

Show key headers only | View raw


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

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


Thread

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

csiph-web