-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tst: keep expanding coverage, add tiny doctests
- Loading branch information
Showing
4 changed files
with
108 additions
and
60 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Basic miscelaneous utilities.""" | ||
|
||
|
||
def front(inlist): | ||
""" | ||
Pop from a list or tuple, otherwise return untouched. | ||
Examples | ||
-------- | ||
>>> front([1, 0]) | ||
1 | ||
>>> front("/path/somewhere") | ||
'/path/somewhere' | ||
""" | ||
if isinstance(inlist, (list, tuple)): | ||
return inlist[0] | ||
return inlist | ||
|
||
|
||
def last(inlist): | ||
""" | ||
Return the last element from a list or tuple, otherwise return untouched. | ||
Examples | ||
-------- | ||
>>> last([1, 0]) | ||
0 | ||
>>> last("/path/somewhere") | ||
'/path/somewhere' | ||
""" | ||
if isinstance(inlist, (list, tuple)): | ||
return inlist[-1] | ||
return inlist |
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
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
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