Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python documentation for os.removexattr -- what does the '*' (star) argument mean?

My first question, please be gentle. I searched but could not find an answer here or elsewhere.

Note that this question does not apply to unpacking of arguments like *args.

In the python 3.3 documentation for os.removexattr the following is stated:

os.removexattr(path, attribute, *, follow_symlinks=True)

    Removes the extended filesystem attribute attribute from path.
    attribute should be bytes or str. If it is a string, it is encoded
    with the filesystem encoding.

    This function can support specifying a file descriptor and not
    following symlinks.

Note that the third argument is a star: *

I assumed that this means "specify one attribute or several attributes separated by comma", but when trying to do that, I get an exception:

import os
os.removexattr('M7-AAE-01.jpg', 'user.camera_brand', 'user.camera_model')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Function takes at most 2 positional arguments (3 given)

I also tried to supply a list of arguments, but that did not work either.

What exactly does the star argument mean in this case? Thank you.

like image 597
user3122335 Avatar asked Dec 28 '13 02:12

user3122335


1 Answers

The single asterisk * just means that it is forcing you to use named arguments. In this case if you want to pass a value for follow_symlinks, you have to pass the argument name.

The idea is you don't having to read function calls like foo(True, False, False) and not know what those values are doing.

like image 174
Greg Ennis Avatar answered Oct 19 '22 23:10

Greg Ennis