Skip to main content

python stack manager

Project description

PyStack

PyStack is a Python library for use stack. Stacks are a type of list-like variable but, with additional constraints (view more).

Installation

Use the package manager pip to install PyStack.

pip install pystack-manager

Use

Basic example

from pystack import Stack

stack = Stack() #create new stack
stack.push(5) #add element in stack
print(stack.pop()) #return and delete last element in stack
print(stack.last()) #return and don't delete last element in stack

Particular stack

Limited stack

The package allows to create a stack of fixed size.

from pystack import Stack

limited_stack = Stack(limite=5) #create new stack with fixed size

If we try to add more than the fixed size of the stack, an error is generated

Typed stack

The package allows to create a stack of stack with one element type.

from pystack import Stack

typed_stack = Stack(typed=int) #create stack accepting only integer
typed_stack_2 = Stack(typed=(int, float)) #create stack accepting only integer or float

If we try to add an element with a type not corresponding to the type of the stack, an error is generated.

In general

You can create stack with or without any of the previous options.

Stack modification

Add element

Several methods exist to add element to a stack.

Add one element:

stack.push(value) # add items to a stack

value can a stack, an object, an integer, a float or other.

Add items from one stack to another:

stack.transfer(another_stack) # add items from another_stack to a stack

another_stack can a stack, a list or a tuple.

Another solution:

stack = first_stack + second_stack #create new stack with elements of first_stack and second_stack

stack have same option (fixed size, typed) as first_stack

Get element

Two methods exist to get the last element of the stack.

value = stack.pop() #return and delete the last element of the stack
value = stack.last() #return and doesn't delete the last element of the stack

If stack is empty, an error is generated.

Comparison

Different technique can be applied to study a stack.

Equality:

if first_stack == second_stack:
    #True statement
else:
    #False statement

If first_stack elements are identical to those of the second, equality is respected (options are not necessarily the same).

Contains:

if value in stack: # True if value in the stack
    #True statement
else:
    #False statement

Support

if you encounter any bugs, you can report them by email, by attaching the error message and the program.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Source Code

The code source can be found here

License

GNU GPLv3

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

pystack-manager-0.9.3.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pystack_manager-0.9.3-py2.py3-none-any.whl (16.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pystack-manager-0.9.3.tar.gz.

File metadata

  • Download URL: pystack-manager-0.9.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3

File hashes

Hashes for pystack-manager-0.9.3.tar.gz
Algorithm Hash digest
SHA256 72846bf6ab28e6cce777b2589a0036d29fca69840fe3b670b0666ddec36053d6
MD5 65a6081820b91bd8204e254871a9ff3f
BLAKE2b-256 453e60f3ad7b9cc6d46314f084db7c119bbe9cb922dbfcb1247ceaa698f94770

See more details on using hashes here.

File details

Details for the file pystack_manager-0.9.3-py2.py3-none-any.whl.

File metadata

  • Download URL: pystack_manager-0.9.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3

File hashes

Hashes for pystack_manager-0.9.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 82fe5be432dbe08bb29c703121e04e546259db996ab93a73c8106ded2d338381
MD5 e00f6f44d6ed6bec219fa13c79593e5b
BLAKE2b-256 b288f0b1b3b6e1100e5f59eeea5c434f6a9eb7a4e1b16b198c971540c9254503

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page