From 9610b4345ac040efaa371e79dfef9db10c7732b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 5 Dec 2019 01:37:35 +0100 Subject: [PATCH] Open --- README.md | 4 ++-- index.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0d83af7..eb0d4f2 100644 --- a/README.md +++ b/README.md @@ -1526,7 +1526,7 @@ Open * **`'IsADirectoryError'` and `'PermissionError'` can be risen by any.** * **`'OSError'` is the parent class of all listed exceptions.** -### File +### File Object ```python .seek(0) # Moves to the start of the file. .seek(offset) # Moves 'offset' chars/bytes from the start. @@ -2151,7 +2151,7 @@ class MyMetaClass(type): return type.__new__(cls, name, parents, attrs) ``` * **New() is a class method that gets called before init(). If it returns an instance of its class, then that instance gets passed to init() as a 'self' argument.** -* **It receives the same arguments as init(), except for the first one that specifies the desired class of returned instance (MyMetaClass in our case).** +* **It receives the same arguments as init(), except for the first one that specifies the desired class of the returned instance (MyMetaClass in our case).** * **New() can also be called directly, usually from a new() method of a child class (**`def __new__(cls): return super().__new__(cls)`**), in which case init() is not called.** ### Metaclass Attribute diff --git a/index.html b/index.html index 37a16fd..d6580fa 100644 --- a/index.html +++ b/index.html @@ -1409,16 +1409,16 @@ value = args.<name>
  • 'a+' - Read and write from the end.
  • 't' - Text mode (default).
  • 'b' - Binary mode.
  • -

    Exceptions

      +

    Exceptions

    • 'FileNotFoundError' can be risen when reading with 'r' or 'r+'.
    • 'FileExistsError' can be risen when writing with 'x'.
    • 'IsADirectoryError' and 'PermissionError' can be risen by any.
    • 'OSError' is the parent class of all listed exceptions.
    • -

    File

    <file>.seek(0)                      # Moves to the start of the file.
    +

    File Object

    <file>.seek(0)                      # Moves to the start of the file.
     <file>.seek(offset)                 # Moves 'offset' chars/bytes from the start.
     <file>.seek(0, 2)                   # Moves to the end of the file.
     <bin_file>.seek(±offset, <anchor>)  # Anchor: 0 start, 1 current pos., 2 end.
    -
    +
    @@ -1874,7 +1874,7 @@ param_names = list(<sig>.parameters.keys())
    • New() is a class method that gets called before init(). If it returns an instance of its class, then that instance gets passed to init() as a 'self' argument.
    • -
    • It receives the same arguments as init(), except for the first one that specifies the desired class of returned instance (MyMetaClass in our case).
    • +
    • It receives the same arguments as init(), except for the first one that specifies the desired class of the returned instance (MyMetaClass in our case).
    • New() can also be called directly, usually from a new() method of a child class (def __new__(cls): return super().__new__(cls)), in which case init() is not called.

    Metaclass Attribute

    Right before a class is created it checks if it has a 'metaclass' attribute defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().

    class MyClass(metaclass=MyMetaClass):