Jay Taylor's notes
back to listing indexWelcome to Python cheatsheet! — pysheeet
[web search]
Original source (www.pythonsheets.com)
Tags:
python
www.pythonsheets.com
Clipped on: 2016-11-12
Welcome to Python cheatsheet!
- Python basic cheatsheet
- Python Naming Styles
- Check object attributes
- Define a function __doc__
- Check instance type
- Check, Get, Set attribute
- Check inheritance
- Check all global variables
- Check “callable”
- Get function/class name
__new__
&__init__
- Representations of your class behave
- Get list item “SMART”
- Get dictionary item “SMART”
- Set a list/dict “SMART”
- NamedTuple
- Delegating Iteration (__iter__)
- Using Generator as Iterator
- Emulating a list
- Emulating a dictionary
- Decorator
- Decorator with arguments
- for: exp else: exp
- try: exp else: exp
- Lambda function
- Option arguments - (*args, **kwargs)
type()
declare (create) aclass
- Callable object
- Context Manager - “with” statement
- Using @contextmanager
- Using “with” statement open file
- Property - Managed attributes
- Computed attribures - Using property
- Descriptor - manage attributes
- @staticmethod, @classmethod
- Abstract method - Metaclass
- Common Use “Magic”
- Python unicode cheatsheet
- Python generator cheatsheet
- Glossary of Generator
- Produce value via generator
- Implement Iterable object via generator
- Send message to generator
- “yield from” expression
- yield (from) EXPR return RES
- Generate sequences
- What “RES = yield from EXP” actually do?
- Check generator type
- Check Generator State
- Simple compiler
- Context manager and generator
- What @contextmanager actually doing?
- profile code block
- ‘yield from’ and ‘__iter__’
- “yield from == await” expression
- Closure in Python - using generator
- Implement a simple scheduler
- Simple round-robin with blocking
- simple round-robin with blocking and non-blocking
- Python Regular Expression cheatsheet
- Python socket cheatsheet
- Get Hostname
- IP dotted-quad string & byte format convert
- Mac address & byte format convert
- Simple TCP Echo Server
- Simple TCP Echo Server Via SocketServer
- Simple SSL TCP Echo Server
- Simple UDP Echo Server
- Simple UDP Echo Server Via SocketServer
- Simple UDP client - Sender
- Broadcast UDP Packets
- Simple UNIX Domain Socket
- Simple duplex processes communication
- Simple Asynchronous TCP Server - Thread
- Simple Asynchronous TCP Server - select
- High-Level API - selectors
- “socketpair” - Similar to PIPE
- Sniffer IP packets
- Sniffer ARP packet
- Python cryptography cheatsheet
- Python Concurrency Cheatsheet
- Create a thread via “threading”
- Performance Problem - GIL
- Consumer and Producer
- Thread Pool Template
- Using multiprocessing ThreadPool
- Mutex lock
- Deadlock
- Implement “Monitor”
- Control primitive resources
- Ensure tasks has done
- Thread-safe priority queue
- Multiprocessing
- Custom multiprocessing map
- Simple round-robin scheduler
- Scheduler with blocking function
- PoolExecutor
- What “with ThreadPoolExecutor” doing?
- Future Object
- Future error handling
- Python SQLAlchemy Cheatsheet
- Set a database URL
- Sqlalchemy Support DBAPI - PEP249
- Transaction and Connect Object
- Metadata - Generating Database Schema
- Inspect - Get Database Information
- Reflection - Loading Table from Existing Database
- Get Table from MetaData
- Create all Tables Store in “MetaData”
- Create Specific Table
- Create table with same columns
- Drop a Table
- Some Table Object Operation
- SQL Expression Language
- insert() - Create an “INSERT” Statement
- select() - Create a “SELECT” Statement
- join() - Joined Two Tables via “JOIN” Statement
- Delete Rows from Table
- Check Table Existing
- Create multiple tables at once
- Create tables with dynamic columns (Table)
- Object Relational add data
- Object Relational update data
- Object Relational delete row
- Object Relational relationship
- Object Relational self association
- Object Relational basic query
- mapper: Map
Table
toclass
- Get table dynamically
- Object Relational join two tables
- join on relationship and group_by count
- Create tables with dynamic columns (ORM)
- Close database connection
- Python asyncio cheatsheet
- What is @asyncio.coroutine?
- What is a Task?
- What event loop doing? (Without polling)
- What
asyncio.wait
doing? - Future like object
- Future like object
__await__
other task - Patch loop runner
_run_once
- Put blocking task into Executor
- Socket with asyncio
- Event Loop with polling
- Transport and Protocol
- Transport and Protocol with SSL
- What
loop.create_server
do? - Inline callback
- Asynchronous Iterator
- What is asynchronous iterator
- Asynchronous context manager
- What is asynchronous context manager
- What loop.sock_* do?
- Simple asyncio connection pool
- Simple asyncio UDP echo server
- Simple asyncio web server
- Simple HTTPS asyncio web server
- Simple asyncio WSGI web server
- Python test cheatsheet
- A simple Python unittest
- Python unittest setup & teardown hierarchy
- Different module of setUp & tearDown hierarchy
- Run tests via unittest.TextTestRunner
- Test raise exception
- Pass arguments into a TestCase
- Group multiple testcases into a suite
- Group multiple tests from different TestCase
- Skip some tests in the TestCase
- Monolithic Test
- Cross-module variables to Test files
- skip setup & teardown when the test is skipped
- Re-using old test code
- Testing your document is right
- Re-using doctest to unittest
- Mocking Test
- Python C API cheatsheet
- Python Design Pattern in C
About pysheeet
This project tries to provide a lot of piece of Python code that makes life easier.
Useful Links
Quick search
©2016, crazyguitar.
|
Page source