Table of Contents


Using nested generators

Starting with Python 3.3, you can use delegated generators

def foo(x):
    yield from range(x, 0, -1)
    yield from range(x)

list(foo(5))

Viewing the source for classes/modules

Works great with syntax highlighting.

import inspect

inspect.getsource(azureml.automl.runtime.featurization.data_transformer)

Checking if an object has a certain property/method

if hasattr(myobject, 'myprop'):
    dostuff()

if hasattr(myobject, 'myfunction') and callable(myobject.myfunction):
    domorestuff()

– via StackOverflow