What does `\*` mean in `pyb.mount` documentation?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
hlovatt
Posts: 40
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

What does `\*` mean in `pyb.mount` documentation?

Post by hlovatt » Tue Jun 23, 2020 2:53 am

Hi All,

In the documentation for `pub.mount` the argument list contains `\*`, what does this mean?

The actual line is:

Code: Select all

mount(device, mountpoint, \*, readonly=False, mkfs=False)
I'm assuming this is a typo; and poking around with the REPL makes me think it should be `/, *`.

Anyone know the real answer?

Thanks,

Howard.

User avatar
dhylands
Posts: 3393
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: What does `\*` mean in `pyb.mount` documentation?

Post by dhylands » Tue Jun 23, 2020 8:53 pm

The convention seems to be that \* is used to document the divide between required positional arguments and optional (typically keyword) arguments.

You can see other examples here: http://docs.micropython.org/en/latest/l ... e.SPI.init

My understanding is that arguments after the \* must be provided by using keywords.

hlovatt
Posts: 40
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Re: What does `\*` mean in `pyb.mount` documentation?

Post by hlovatt » Wed Jun 24, 2020 1:21 am

Thanks for your response

The notation is `/, *` not `\*`, for dividing between positional and nominal, i.e.:

Code: Select all

def f(positional, /, either_positional_or_nominal, *, nominal)
So my reading was that `\*` was a typo, and `\, *` was intended, i.e. the transition between positional and nominal as you say.

Using `/` to mean positional is relatively new, whereas the `*` to mean nominal has been around for a while. Therefore it could be that `\*` is a typo for `*` (because when written `\` didn't exist, or it was intended that before `*` you could use either positional or nominal). However when playing with REPL it seems that the parameters must be positional before `\*`, therefore I was guessing that the best modern substitution is `/, *`.

I'm asking the question because I'm trying to write a typeshed for the PyBoard for the MicroPython plugin for PyCharm, hence I was hoping for a definitive answer rather than me trying to reverse engineer via the REPL!

Online
User avatar
pythoncoder
Posts: 4268
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What does `\*` mean in `pyb.mount` documentation?

Post by pythoncoder » Wed Jun 24, 2020 10:56 am

My understanding is that the only legal Python syntax is * meaning that subsequent args are keyword-only. I have no idea why the docs have \.

Code: Select all

def foo(x, *, y):
    print(x, y)
foo(1, y = 2)  # Works
foo(1, 2)  # Will fail
Peter Hinch

hlovatt
Posts: 40
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Re: What does `\*` mean in `pyb.mount` documentation?

Post by hlovatt » Thu Jun 25, 2020 12:07 am

Thanks for the reply.

Later versions of Python support `/`, it's https://www.python.org/dev/peps/pep-0570/. It's useful in the typeshed I'm writing since PyCharm is almost certainly running on a later version of Python. Of course the typeshed isn't downloaded to the PyBoard, and therefore not relevant that MicroPython doesn't understand it.

Don't suppose you know what the intent was? Don't feel that messing round with the REPL is the best way forward, its time consuming for a start and error prone.

Thanks again.

User avatar
Roberthh
Posts: 2024
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: What does `\*` mean in `pyb.mount` documentation?

Post by Roberthh » Thu Jun 25, 2020 6:12 am

For me the '\*' just looks liken an unnecessary attempt to escape the '*' character. So it's a kind of typo.

hlovatt
Posts: 40
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Re: What does `\*` mean in `pyb.mount` documentation?

Post by hlovatt » Thu Jun 25, 2020 7:53 am

Yeah, you could well be right. I was hoping someone would know definitively. Thanks.

User avatar
jimmo
Posts: 1710
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What does `\*` mean in `pyb.mount` documentation?

Post by jimmo » Mon Jun 29, 2020 6:33 am

Roberthh wrote:
Thu Jun 25, 2020 6:12 am
For me the '\*' just looks liken an unnecessary attempt to escape the '*' character. So it's a kind of typo.
You're right. This apparently used to be necessary (e.g. see http://docs.micropython.org/en/v1.12/li ... #pyb.mount where it was generated correctly).

Raised https://github.com/micropython/micropython/issues/6209

Post Reply