Chalarangelo / 30-seconds-of-python

Short Python code snippets for all your development needs
https://www.30secondsofcode.org/python/p/1
Creative Commons Attribution 4.0 International
8.83k stars 1.26k forks source link

[FEATURE] Suggest using builtin functions when similar options exist #171

Closed mx-psi closed 4 years ago

mx-psi commented 4 years ago

The Python Standard Library has functions with similar behavior to some snippets. In particular:

  1. The split_lines snippet has similar functionality to the str.splitlines method (the latter being more general and omitting the last line) and
  2. the zip snippet has similar behavior to the itertools.zip_longest function (the latter returning an iterator instead of a list).

The functions don't have the exact same behavior, so it might make sense to keep them, but I believe it would be helpful for visitors to at least have a reference to the standard library version in the snippet documentation; that way they can choose the option that best fits their needs.

Chalarangelo commented 4 years ago

Thanks for informing us, I will look into these and add appropriate notes whenever possible. If you have more examples of this, you could either note them in the comments here or open a PR adding a line in each snippet's explanation, just before the code block noting that:

[`function.name`](library-link-to-function-name) provides similar functionality to this snippet.
mx-psi commented 4 years ago

Okay! I will check for other possible examples and open a PR