From e65b8715e2e4895efc0c152bff28977d7fb4c76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 27 Jan 2022 11:30:00 +0100 Subject: [PATCH] Datetime, Class, Coroutines --- README.md | 16 ++++++++-------- index.html | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c56cfbe..869fd1c 100644 --- a/README.md +++ b/README.md @@ -643,11 +643,11 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary ### Format ```python ->>> dt = datetime.strptime('2015-05-14 23:39:00.00 +0200', '%Y-%m-%d %H:%M:%S.%f %z') +>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +02:00', '%Y-%m-%d %H:%M:%S.%f %z') >>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z") "Thursday, 14th of May '15, 11:39PM UTC+02:00" ``` -* **`'%Z'` only accepts `'UTC/GMT'` and local timezone's code. `'%z'` also accepts `'±HH:MM'`.** +* **`'%Z'` only accepts `'UTC/GMT'` and local timezone's code. `'%z'` also accepts `'±HHMM'`.** * **For abbreviated weekday and month use `'%a'` and `'%b'`.** ### Arithmetics @@ -964,18 +964,18 @@ class : #### Str() use cases: ```python print() -print(f'{}') -raise Exception() -csv.writer().writerow([]) +f'{}' logging.warning() +csv.writer().writerow([]) +raise Exception() ``` #### Repr() use cases: ```python print([]) -print(f'{!r}') ->>> +f'{!r}' Z = dataclasses.make_dataclass('Z', ['a']); print(Z()) +>>> ``` ### Constructor Overloading @@ -2327,7 +2327,7 @@ async def random_controller(id_, moves): async def human_controller(screen, moves): while True: ch = screen.getch() - key_mappings = {259: D.n, 261: D.e, 258: D.s, 260: D.w} + key_mappings = {258: D.s, 259: D.n, 260: D.w, 261: D.e} if ch in key_mappings: moves.put_nowait(('*', key_mappings[ch])) await asyncio.sleep(0.005) diff --git a/index.html b/index.html index 7ee2c5b..7beb5b0 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -570,13 +570,13 @@ to_exclusive = <range>.stop <float> = <DTa>.timestamp() # Seconds since the Epoch, from DTa. -

Format

>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +0200', '%Y-%m-%d %H:%M:%S.%f %z')
+

Format

>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +02:00', '%Y-%m-%d %H:%M:%S.%f %z')
 >>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z")
 "Thursday, 14th of May '15, 11:39PM UTC+02:00"
 
    -
  • '%Z' only accepts 'UTC/GMT' and local timezone's code. '%z' also accepts '±HH:MM'.
  • +
  • '%Z' only accepts 'UTC/GMT' and local timezone's code. '%z' also accepts '±HHMM'.
  • For abbreviated weekday and month use '%a' and '%b'.

Arithmetics

<D/DT>   = <D/DT>  ± <TD>                   # Returned datetime can fall into missing hour.
@@ -821,16 +821,16 @@ creature = Creature(point, direction)
 
  • If only repr() is defined, it will also be used for str().
  • Str() use cases:

    print(<el>)
    -print(f'{<el>}')
    -raise Exception(<el>)
    -csv.writer(<file>).writerow([<el>])
    +f'{<el>}'
     logging.warning(<el>)
    +csv.writer(<file>).writerow([<el>])
    +raise Exception(<el>)
     

    Repr() use cases:

    print([<el>])
    -print(f'{<el>!r}')
    ->>> <el>
    +f'{<el>!r}'
     Z = dataclasses.make_dataclass('Z', ['a']); print(Z(<el>))
    +>>> <el>
     

    Constructor Overloading

    class <name>:
    @@ -1903,7 +1903,7 @@ W, H = 15, 7
     async def human_controller(screen, moves):
         while True:
             ch = screen.getch()
    -        key_mappings = {259: D.n, 261: D.e, 258: D.s, 260: D.w}
    +        key_mappings = {258: D.s, 259: D.n, 260: D.w, 261: D.e}
             if ch in key_mappings:
                 moves.put_nowait(('*', key_mappings[ch]))
             await asyncio.sleep(0.005)
    @@ -2881,7 +2881,7 @@ $ pyinstaller script.py --add-data '<path>:.'