|
@ -8,13 +8,13 @@ Comprehensive Python Cheatsheet |
|
|
|
|
|
|
|
|
Contents |
|
|
Contents |
|
|
-------- |
|
|
-------- |
|
|
** ** **1. Collections:** ** ** **[`List`](#list)**__,__ **[`Dict`](#dictionary)**__,__ **[`Set`](#set)**__,__ **[`Range`](#range)**__,__ **[`Enumerate`](#enumerate)**__,__ **[`Namedtuple`](#named-tuple)**__,__ **[`Iterator`](#iterator)**__,__ **[`Generator`](#generator)**__.__ |
|
|
|
|
|
** ** **2. Types:** ** ** **[`Type`](#type)**__,__ **[`String`](#string)**__,__ **[`Regex`](#regex)**__,__ **[`Format`](#format)**__,__ **[`Numbers`](#numbers)**__,__ **[`Combinatorics`](#combinatorics)**__,__ **[`Datetime`](#datetime)**__.__ |
|
|
|
|
|
** ** **3. Syntax:** ** ** **[`Arguments`](#arguments)**__,__ **[`Splat`](#splat-operator)**__,__ **[`Inline`](#inline)**__,__ **[`Closure`](#closure)**__,__ **[`Decorator`](#decorator)**__,__ **[`Class`](#class)**__,__ **[`Enum`](#enum)**__,__ **[`Exceptions`](#exceptions)**__.__ |
|
|
|
|
|
** ** **4. System:** ** ** **[`Print`](#print)**__,__ **[`Input`](#input)**__,__ **[`Command_Line_Arguments`](#command-line-arguments)**__,__ **[`Open`](#open)**__,__ **[`Path`](#path)**__,__ **[`Command_Execution`](#command-execution)**__.__ |
|
|
|
|
|
** ** **5. Data:** ** ** **[`CSV`](#csv)**__,__ **[`JSON`](#json)**__,__ **[`Pickle`](#pickle)**__,__ **[`SQLite`](#sqlite)**__,__ **[`Bytes`](#bytes)**__,__ **[`Struct`](#struct)**__,__ **[`Array`](#array)**__,__ **[`MemoryView`](#memory-view)**__,__ **[`Deque`](#deque)**__.__ |
|
|
|
|
|
** ** **6. Advanced:** ** ** **[`Threading`](#threading)**__,__ **[`Introspection`](#introspection)**__,__ **[`Metaprograming`](#metaprograming)**__,__ **[`Operator`](#operator)**__,__ **[`Eval`](#eval)**__,__ **[`Coroutine`](#coroutine)**__.__ |
|
|
|
|
|
** ** **7. Libraries:** ** ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profile)**__,__ |
|
|
|
|
|
|
|
|
** ** **1. Collections:** ** ** **[`List`](#list)**__,__ **[`Dict`](#dictionary)**__,__ **[`Set`](#set)**__,__ **[`Range`](#range)**__,__ **[`Enumerate`](#enumerate)**__,__ **[`Namedtuple`](#named-tuple)**__,__ **[`Iterator`](#iterator)**__,__ **[`Generator`](#generator)**__.__ |
|
|
|
|
|
** ** **2. Types:** ** ** **[`Type`](#type)**__,__ **[`String`](#string)**__,__ **[`Regex`](#regex)**__,__ **[`Format`](#format)**__,__ **[`Numbers`](#numbers)**__,__ **[`Combinatorics`](#combinatorics)**__,__ **[`Datetime`](#datetime)**__.__ |
|
|
|
|
|
** ** **3. Syntax:** ** ** **[`Arguments`](#arguments)**__,__ **[`Splat`](#splat-operator)**__,__ **[`Inline`](#inline)**__,__ **[`Closure`](#closure)**__,__ **[`Decorator`](#decorator)**__,__ **[`Class`](#class)**__,__ **[`Enum`](#enum)**__,__ **[`Exceptions`](#exceptions)**__.__ |
|
|
|
|
|
** ** **4. System:** ** ** **[`Print`](#print)**__,__ **[`Input`](#input)**__,__ **[`Command_Line_Arguments`](#command-line-arguments)**__,__ **[`Open`](#open)**__,__ **[`Path`](#path)**__,__ **[`Command_Execution`](#command-execution)**__.__ |
|
|
|
|
|
** ** **5. Data:** ** ** **[`CSV`](#csv)**__,__ **[`JSON`](#json)**__,__ **[`Pickle`](#pickle)**__,__ **[`SQLite`](#sqlite)**__,__ **[`Bytes`](#bytes)**__,__ **[`Struct`](#struct)**__,__ **[`Array`](#array)**__,__ **[`MemoryView`](#memory-view)**__,__ **[`Deque`](#deque)**__.__ |
|
|
|
|
|
** ** **6. Advanced:** ** ** **[`Threading`](#threading)**__,__ **[`Introspection`](#introspection)**__,__ **[`Metaprograming`](#metaprograming)**__,__ **[`Operator`](#operator)**__,__ **[`Eval`](#eval)**__,__ **[`Coroutine`](#coroutine)**__.__ |
|
|
|
|
|
** ** **7. Libraries:** ** ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profile)**__,__ |
|
|
** ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__.__ |
|
|
** ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__.__ |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -467,7 +467,7 @@ from dateutil.tz import UTC, tzlocal, gettz |
|
|
<D> = date(year, month, day) |
|
|
<D> = date(year, month, day) |
|
|
<T> = time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, fold=0) |
|
|
<T> = time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, fold=0) |
|
|
<DT> = datetime(year, month, day, hour=0, minute=0, second=0, ...) |
|
|
<DT> = datetime(year, month, day, hour=0, minute=0, second=0, ...) |
|
|
<TD> = timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, |
|
|
|
|
|
|
|
|
<TD> = timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, |
|
|
minutes=0, hours=0, weeks=0) |
|
|
minutes=0, hours=0, weeks=0) |
|
|
``` |
|
|
``` |
|
|
* **Use `'<D/DT>.weekday()'` to get the day of the week (Mon == 0).** |
|
|
* **Use `'<D/DT>.weekday()'` to get the day of the week (Mon == 0).** |
|
@ -1834,7 +1834,7 @@ duration = pc() - start_time |
|
|
### Timing a Snippet |
|
|
### Timing a Snippet |
|
|
```python |
|
|
```python |
|
|
>>> from timeit import timeit |
|
|
>>> from timeit import timeit |
|
|
>>> timeit('"-".join(str(a) for a in range(100))', |
|
|
|
|
|
|
|
|
>>> timeit('"-".join(str(a) for a in range(100))', |
|
|
... number=10000, globals=globals(), setup='pass') |
|
|
... number=10000, globals=globals(), setup='pass') |
|
|
0.34986 |
|
|
0.34986 |
|
|
``` |
|
|
``` |
|
@ -2082,7 +2082,7 @@ Basic Script Template |
|
|
#!/usr/bin/env python3 |
|
|
#!/usr/bin/env python3 |
|
|
# |
|
|
# |
|
|
# Usage: .py |
|
|
# Usage: .py |
|
|
# |
|
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
|
from collections import namedtuple |
|
|
from collections import namedtuple |
|
|
from enum import Enum |
|
|
from enum import Enum |
|
|