A library to check your values in your projects
Project description
pyis
pyis is a library to check values in your python projects.
- Installation
- Documentation
- Examples
- Developers
- Next Update
Installation
- Way number 1 : Using pip
pip3 install pyis
- Way number 2 : Clone and install
git clone https://github.com/BlackIQ/pyis && cd pyis
pip3 install -e .
Documentation
pyis has lots of functions that we will name them and say an aexample for each of them.
First import it.
from pyis import *
version
for check version
print(version)
is_set()
is a function that check variable is set or not.
i = "Hello"
ii = None
is_set(i) # Returns True
is_set(ii) # Returns False
is_empty()
is a function that check variable is empty or not.
e = "Hey"
ee = None
is_empty(e) # Returns False
is_empty(ee) # Returns True
is_number()
is a function that check variable is int or not.
v1 = 18
v2 = "string"
is_number(v1) # Returns True
is_number(v2) # Returns False
is_string()
is a function that check variable is str or not.
v1 = "Annahita"
v2 = 3.14
is_string(v1) # Returns True
is_string(v2) # Returns False
is_float()
is a function that check variable is float or not.
v1 = 3.14
v2 = ['hi', 'hey', 'hello']
is_float(v1) # Returns True
is_float(v2) # Returns False
is_list()
is a function that check variable is list or not.
v1 = ['github', 'gitlab']
v2 = 2021
is_list(v1) # Returns True
is_list(v2) # Returns False
is_bool()
is a function that check variable is bool or not.
v1 = True
v2 = "false"
is_bool(v1) # Returns True
is_bool(v2) # Returns False
is_positive()
is a function that check variable is positive or not.
v1 = 20
v2 = 5 - 7
is_positive(v1) # Returns True
is_positive(v2) # Returns False
is_negative()
is a function that check variable is negative or not.
v1 = 10 - 30
v2 = 1
is_negative(v1) # Returns True
is_negative(v2) # Returns False
is_zero()
is a function that check variable is zero or not.
v1 = 0
v2 = 1
is_zero(v1) # Returns True
is_zero(v2) # Returns False
is_function()
is a function that check variable is function or not.
def hello(name):
print(f"Hello {name}")
is_function(hello) # Returns True
Examples
Here are some examples that you can get the point better.
Numbers, check number is float or int. Then check is positive or negative or zero
Here we use is_number
to check if input is int
and is_float
to see input is float
.
then we use functions for check value. As you know, we have:
is_positive
for check if number is more than 0.is_negative
for check if number is less than 0.is_zero
for check if number is exactly 0.
number = input("Give me number")
# Check number is int or not
if is_number(number):
# Number is more than 0 function
if is_positive(number):
print("Number is positive")
# Number is less than 0 function
elif is_negative(number):
print("Number is negative")
# Number is equal to 0 function
elif is_zero(number):
print("Number is zero")
# Check number is float or not
elif is_float(number):
# Number is more than 0 function
if is_positive(number):
print("Number is positive")
# Number is less than 0 function
elif is_negative(number):
print("Number is negative")
# Number is equal to 0 function
elif is_zero(number):
print("Number is zero")
Set or empty and talking about tuple
, list
and dictionary
Think there is a list
or dictionary
that you want to check values.
For check if var is:
list
we useis_list
.tuple
we useis_tuple
.dict
we useis_dict
.
So we use is_set
to check if var is set or not. For check is var is empty we use is_empty
.
tpl = (1, 2, 5)
l = ['Hi', 10]
dct = {'name': None}
# Function returns ( True ). Parm is dictionary
if is_dict(dct):
# Here is a tuple.
if is_tuple(tpl):
print("This is a tuple")
# Lets check list
if is_list(l):
# See is it set or not. Returns ( True )
if is_set(l[1]):
print("This item is set")
# Here we get ( True ). Parm is not set. It is empty
if is_empty(dct['name']):
print("This var is empty")
Strings and Booleans
Time of say some examples for strings and booleans.
When there is something and you want to check is it string
you can use is_string
. We do same for bool
, is_bool
for see var is boolean
or not.
So we know this two functions now:
is_string
for check strings.is_bool
to see var isboolean
lst = ['False', 'amir', True]
# Here it will returns ( True ). Why? Item is string
if is_string(lst[0]):
print("Item 1 is string")
# Now we get ( False ). As you can see, item is string
if is_bool(lst[1]):
print("This item is boolean")
# Nice ( True ). Item is boolean
if is_bool(lst[2]):
print("I can see a boolean")
Functions checking
See, think there is callable
var. How do you check? You can use is_function
to check it.
So, how user can check functions?
is_function
for check function
def you(name, friend):
print(f"Hello {name} and {friend}!")
# Get True or False. You is a function, so it returns ( True )
if is_function(you):
print("Look, a function!")
Developers
Amirhossein Mohammadi.
Pull Requests are welcome to every one.
Next Update
- Add most repeted item in a list
- Add class checker
- Add link string checker
- Add IP checker
- Add version value
pyis 2021 ©
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyis-1.9.3.tar.gz
.
File metadata
- Download URL: pyis-1.9.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 309b8f34b13587987140b6cdbd69e0906ad4ed349b2543e278487c2cf6d27f95 |
|
MD5 | 278c9be8982cb9d578e9d68543698e82 |
|
BLAKE2b-256 | 29cb70b435413c847977dbfce65ad2594612f24fe66d862850ac956b2ac4edf2 |