1. Python: map

The map() function applies a given function to all items in an input list (or any other iterable) and returns a map object (an iterator). This is particularly useful for transforming data in a list comprehensively. An iterable is any python object: capable of returning its members one at a time, permitting it to be iterated over in a for-loop. implements __iter__ method, which returns an iterator, or __getitem__ method suitable for indexed lookup. The examples are list, tuple, string, dict, set. An iterator is an object that: ...

June 5, 2025 · map[name:Minjun Jeon]

2. Python: filter

The filter() function constructs an iterator from elements of an iterable for which a function returns true. It is used to filter out items from a list (or any other iterable) based on a condition. The syntax is similar to map: filter(func1, iterable) Examples: num_list = [i for i in range(1, 13)] # [1, ..., 12] print(list(filter(lambda x: x%2==0, num_list))) # output: [2, 4, 6, 8, 10, 12 ] You can filter with multiple conditions: num_list = [i for i in range(1,10)] #[1,2,...,9] even_and_greater_than_five = list(filter(lambda x: x> 5 and x%2==0, num_list)) print(even_and_greater_than_five) # output: [6, 8] You can perform filter operation on dictionaries: ...

June 5, 2025 · map[name:Minjun Jeon]

3. Custom Package and __init__.py

We can install packages from the Python Package Index (PyPI) through pip(PyPI Install Packages). Furthermore, we can import these through import. But … how can we create our custom package? Let’s walk through how to structure a custom Python package, add subpackages, the roles of __init__.py and how to publish the custom package to PyPI. Additionally, we look at setting up dependencies and version management using Poetry. 1. Basic Package Structure Let’s say we want to build a simple package named mypackage. Here is a minimal project structure: ...

June 5, 2025 · map[name:Minjun Jeon]