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
""" | |
The command-line interface for the downloader | |
""" | |
import argparse | |
from .downloader import download | |
def main(): | |
parser = argparse.ArgumentParser( | |
description="An over-simplified downloader to demonstrate python packaging." |
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
import setuptools | |
with open("README.md", "r", encoding="utf-8") as fhand: | |
long_description = fhand.read() | |
setuptools.setup( | |
name="over-simplified-downloader", | |
version="0.0.1", | |
author="Liu Zheng", | |
author_email="zheng@example.com", |
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
[build-system] | |
requires = ["setuptools>=42"] | |
build-backend = "setuptools.build_meta" |
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
from typing import Iterable, TypeVar, Optional | |
T = TypeVar('T') | |
def linear_search(l: Iterable[T], | |
target: T, | |
upper_limit: Optional[int]=None) -> bool: | |
for idx, item in enumerate(l): |
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
def linear_search(l, target, upper_limit=None): | |
"""Search ``l`` (up to the ``upper_limit`` element | |
if specified) for ``target``. Return a boolean indicating | |
whether ``target`` is found in ``l`` or not. | |
""" | |
for idx, item in enumerate(l): | |
if item == target: | |
return True | |
if upper_limit is not None and idx >= upper_limit: | |
break |
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
from typing import Iterable | |
def linear_search(l: Iterable, target, upper_limit=None) -> bool: | |
for idx, item in enumerate(l): | |
if item == target: | |
return True | |
if upper_limit is not None and idx >= upper_limit: | |
break | |
return False |
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
from typing import Iterable, TypeVar | |
T = TypeVar('T') | |
def linear_search(l: Iterable[T], | |
target: T, | |
upper_limit=None) -> bool: | |
for idx, item in enumerate(l): | |
if item == target: | |
return True |