python documentation for os.removexattr -- what does the '*' (star) argument mean? [duplicate]

  • Last Update :
  • Techknowledgy :

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.

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)

Suggestion : 2

The platform module provides detailed checks for the system’s identity.,File Names, Command Line Arguments, and Environment Variables,Command line arguments, environment variables and filenames are decoded to text using the UTF-8 encoding.,Send signal sig to the process pid. Constants for the specific signals available on the host platform are defined in the signal module.

for fd in range(fd_low, fd_high):
   try:
   os.close(fd)
except OSError:
   pass
if os.access("myfile", os.R_OK):
   with open("myfile") as fp:
   return fp.read()
return "some default data"
try:
fp = open("myfile")
except PermissionError:
   return "some default data"
else:
   with fp:
   return fp.read()
with os.scandir(path) as it:
   for entry in it:
   if not entry.name.startswith('.') and entry.is_file():
   print(entry.name)
>>>
import os
   >>>
   statinfo = os.stat('somefile.txt') >>>
   statinfo
os.stat_result(st_mode = 33188, st_ino = 7876932, st_dev = 234881026,
      st_nlink = 1, st_uid = 501, st_gid = 501, st_size = 264, st_atime = 1297230295,
      st_mtime = 1297230027, st_ctime = 1297230027) >>>
   statinfo.st_size
264
os.stat in os.supports_dir_fd

Suggestion : 3

Last Updated : 26 Nov, 2020,Technical Scripter 2020

Arithmetic operators priorities order in Decreasing Mode:

() >> ** >> * >> /  >>  / / >> % >> + >> -

Output:

32
50

Suggestion : 4

Oct 11th, 2018 7:30 am | Comments , Posted by Trey Hunner Oct 11th, 2018 7:30 am favorite, python

1
2
3
4
>>> 2 * 5
10
   >>>
   2 ** 5
32
>>> numbers = [2, 1, 3, 4, 7] >>>
   more_numbers = [ * numbers, 11, 18] >>>
   print( * more_numbers, sep = ', ')
2, 1, 3, 4, 7, 11, 18
1
2
3
4
5
>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato'] >>>
   print(fruits[0], fruits[1], fruits[2], fruits[3])
lemon pear watermelon tomato
   >>>
   print( * fruits)
lemon pear watermelon tomato
def transpose_list(list_of_lists):
   return [
      list(row)
      for row in zip( * list_of_lists)
   ]

Suggestion : 5

In Python, file names, command line arguments, and environment variables are represented using the string type. On some systems, decoding these strings to and from bytes is necessary before passing them to the operating system. Python uses the file system encoding to perform this conversion (see sys.getfilesystemencoding()).,All functions in this module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.,Changed in version 3.1: On some systems, conversion using the file system encoding may fail. In this case, Python uses the surrogateescape encoding error handler, which means that undecodable bytes are replaced by a Unicode character U+DCxx on decoding, and these are again translated to the original byte on encoding.,Set the environment variable named key to the string value. Such changes to the environment affect subprocesses started with os.system(), popen() or fork() and execv().

for fd in range(fd_low, fd_high):
   try:
   os.close(fd)
except OSError:
   pass
if os.access("myfile", os.R_OK):
   with open("myfile") as fp:
   return fp.read()
return "some default data"
try:
fp = open("myfile")
except PermissionError:
   return "some default data"
else:
   with fp:
   return fp.read()
with os.scandir(path) as it:
   for entry in it:
   if not entry.name.startswith('.') and entry.is_file():
   print(entry.name)
>>>
import os
   >>>
   statinfo = os.stat('somefile.txt') >>>
   statinfo
os.stat_result(st_mode = 33188, st_ino = 7876932, st_dev = 234881026,
      st_nlink = 1, st_uid = 501, st_gid = 501, st_size = 264, st_atime = 1297230295,
      st_mtime = 1297230027, st_ctime = 1297230027) >>>
   statinfo.st_size
264
os.stat in os.supports_dir_fd