Useful Python decorators for Data Scientists

Marton Trencseni - Sun 22 May 2022 • Tagged with python, decorators

I show toy implementations of Python decorator patterns that may be useful for Data Scientists.

Python decorators

Continue reading

Building a toy Python @dataclass decorator

Marton Trencseni - Thu 12 May 2022 • Tagged with python, dataclass, decorator

I write a toy implementation of Python's @dataclass decorator to improve my Python fu and learn more about decorators and metaprogramming.

Python enum

Continue reading

Python decorator patterns

Marton Trencseni - Sun 08 May 2022 • Tagged with python, decorators

I show toy implementations of Python decorator patterns such as @measure, @repeat, @trace, @count, @singleton, and @app.route (made famous by Flask).

Python enum

Continue reading

Building a toy Python Enum class - Part II

Marton Trencseni - Thu 05 May 2022 • Tagged with python, enum

I extend my previous toy implementation of Python's Enum class to add more features.

Python enum

Continue reading

Building a toy Python Enum class - Part I

Marton Trencseni - Tue 03 May 2022 • Tagged with python, enum

I write a toy implementation of Python's Enum class to learn about Python metaclasses.

Python enum

Continue reading

Python types for Data Scientists - Part III

Marton Trencseni - Fri 22 April 2022 • Tagged with python, types

I show slightly more advanced aspects of type checking in Python for Data Scientists.

Mypy

Continue reading

Python types for Data Scientists - Part II

Marton Trencseni - Sun 17 April 2022 • Tagged with python, types

I show slightly more advanced uses of type checking in Python.

Python snake

Continue reading

Python types for Data Scientists - Part I

Marton Trencseni - Fri 08 April 2022 • Tagged with python, types

I show how to use basic type hints and get type checking working in ipython notebooks.

Python types for Data Scientists

Continue reading

rxe: literate and composable regular expressions

Marton Trencseni - Sat 02 March 2019 • Tagged with python

rxe is a thin wrapper around Python's re module. The various rxe functions are wrappers around corresponding re patterns. For example, rxe.digit().one_or_more('a').whitespace() corresponds to \da+\s. Because rxe uses parentheses but wants to avoid unnamed groups, the internal (equivalent) representation is actually \d(?:a)+\s. This pattern can always be retrieved with get_pattern().

rxe example code

Continue reading