Skip to content

Instantly share code, notes, and snippets.

@tomascapek
Last active November 8, 2017 13:57
Show Gist options
  • Save tomascapek/28426a078444337e0ecd24346f245e4a to your computer and use it in GitHub Desktop.
Save tomascapek/28426a078444337e0ecd24346f245e4a to your computer and use it in GitHub Desktop.

Python notes

Logging

Using loggers through the project

Instead of passing instances of loggers (like logging.Logger), it is sometimes better, to just create them (logging.get_logger('logger name')) in places, where you want to use them.

Passing is preferend only in cases, where many objects is created in short ammount of time, because getting logger is a bit slow process.

MR addressed notes

Use super().__init__(path) in Python 3
Reason: TBA

Testing

Looping in pytest

import pytest
@pytest.mark.parametrize("test_input,expected", [
    ("3+5", 8),
    ("2+4", 6),
    ("6*9", 42),
])
def test_eval(test_input, expected):
    assert eval(test_input) == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment