Skip to content

PixelSymbols/questionable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

questionable

A simple python package to get non-empty value out of 2 options

If both are empty, None will be returned. If both have a value, first value will be returned

Installation

pip install questionable

Examples

how to use:

from questionable import qq

def your_func(your_args=...):
	# your code
	...
	return qq(<your value>,<default value>) # `<your value>` will be returned
  • Values can be:
    • int
    • float
    • str
    • None
    • bool
    • list
    • tuple
    • set

Description

Why?

instead of doing:

class NotYoutubeLink(Exception):
	def __str__(self):
		text = super().__str__()
		if text: return text
		return "This link is not from youtube! :bonk:"

you will be able todo:

from questionable import qq

class NotYoutubeLink(Exception):
	def __str__(self):
		return qq(super().__str__(),"This link is not from youtube! :bonk:")

other cases

see test.py to better understand what would happen in other cases. But in short: both aren't empty -> first will be returned both are empty -> None will be returned first isn't empty -> first will be returned second isn't empty -> second will be returned

Author

PixelSymbols

Dependencies

is_empty

License

This project is licensed under the MIT License - see the LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages