This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Descriptors & Decorators | |
Example 2: A decorator that changes the signature of the function. | |
""" | |
from functools import wraps | |
class DomainObject: | |
"""Dummy object that requires the common parameters for processing""" | |
def __init__(self, *args): | |
self.args = args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An example of a descriptor with a ``__delete__()`` method. | |
The code is for illustration purposes only, and it does not correspond to any | |
actual implementation. | |
""" | |
class ProtectedAttribute: | |
"""A class attribute that can be protected against deletion""" | |
def __set_name__(self, owner, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Mutable objects as class attributes.""" | |
import logging | |
logger = logging.getLogger(__name__) | |
class Query: | |
PARAMETERS = {"limit": 100, "offset": 0} | |
def run_query(self, query, limit=None, offset=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A small script to find all months that have a Monday 25th for a particular | |
year. | |
Input: year in format YYYY | |
Output: print list of dates that are a Monday 25 in that year | |
""" | |
import re | |
import sys | |
from typing import Iterator | |
from datetime import date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Top(object): | |
pass | |
class A(Top): pass | |
class B(Top): pass | |
class A1(A): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# | |
Vagrant.configure(2) do |config| | |
# This is an image of Ubuntu 14.04 LTS with libvirt support | |
config.vm.box = "baremettle/ubuntu-14.04" | |
config.vm.provision :shell, path: "provision.sh" | |
# config.vm.synced_folder "../data", "/vagrant_data" |
As a user, to use the new implementation of gRCP in the asynchronous version, I will compile by passing a specific flag:
$ python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. proto/echo.proto --aiogrpc
This compiles the stubs, generated with the asynchronous code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Code for the talk "Discovering Descriptors" | |
> PyCon CZ 2017 - 8 to 10 June - Prage, Czech Republic | |
June 9th, 2017 11:00 CET | |
> EuroPython 2017 - 9 to 16 July - Rimini, Italy | |
July 11th, 2017 15:45 CET | |
https://ep2017.europython.eu/conference/talks/discovering-descriptors | |
Python 3.6 |
NewerOlder