https://azure.github.io/azure-sdk/python_introduction.html
Python Guidelines: Introduction:
Design principles
Idiomatic
Consistent
Approachable
Diagnosable
Dependable
Python Design Principles:–PEP 20 — The Zen of Python, import this
https://www.python.org/dev/peps/pep-0020/
General Guidelines:
https://azure.github.io/azure-sdk/general_introduction.html
Gitub:
https://github.com/azure/azure-sdk-for-python
Supported python versions:
Code style:
https://www.python.org/dev/peps/pep-0008/
Naming conventions:
- service_client = ServiceClient()
- service_client.list_things()
- def do_something():
- class ThisIsCorrect(object):
pass
MAX_SIZE = 4711
- database_module.py
Method signatures:
DO NOT use, static, do not use get set, use properties
- class GoodThing(object):
@property
def something(self):
""" Example of a good read-only property."""
return self._something
DO specify the parameter name when calling methods with more than two required positional parameters.
- def foo(a, b, c):
pass
- def bar(d, e):
pass
- Yes:
foo(a=1, b=2, c=3)
bar(1, 2)
bar(e=3, d=4) - No:
foo(1, 2, 3)
Public vs “private”:
yes- azure.exampleservice._some_internal_module
no – azure.exampleservice.some_internal_module
Types (or not):
DO prefer structural subtyping and protocols over explicit type checks.
https://www.python.org/dev/peps/pep-0484/
Threading:
DO maintain thread affinity for user-provided callbacks unless explicitly documented to not do so.
DO explicitly include the fact that a method (function/class) is thread safe in its documentation.
Examples: asyncio.loop.call_soon_threadsafe, queue