Skip to main content

Oven

An util package that includes algorithms, functions and IO similar to that of other languages' standard library.

Installation

Installation with pip is recommended.

pip install oven

Table of Contents

Standard I/O

The stdio package includes convient functions to redefine basic I/O.

from oven.stdio import *

Creating Session

The stdio session is required in order to call any I/O functions. A session is created as such:

set_io(IO_STREAM, 'path/to/file', METHOD)

The IO_STREAM can be any of:

  • stdio.FILE: Redirect the IO stream to a file
  • stdio.CONSOLE: Redirect the IO stream to the console

The METHOD can be any of:

  • r : Read from a file
  • w : Write to a file, create/override if nessesary
  • a : Append to a file, create if nessesary

Method w overrides the file and dump all output from the session, while a append all output from the session to the end of the file.

If the IO_STREAM is set to CONSOLE, then the path argument will be ignored.

Note that the stdio session is created on the global scope, therefore one session will always suffice for one method of IO action.

An example is given below. This code reads a line of input from a file and print it to the screen.

from oven.stdio import *

set_io(FILE, 'text.in', 'r')
set_io(CONSOLE, None, 'w')

text = cin()
cout(text)

Calling cin/cout

Despite the name, the cin/cout also applies to file IO.

cin() # Read one line.
cout('Hello World') # Write. Note that \n is not added at the end.

Pointer

The Pointer package includes a pointer object.

from oven.pointer import Pointer

Instantiating Pointers

A Pointer is created as such:

ptr_1 = Pointer()
ptr_2 = Pointer(INIT_VALUE)

Calling Pointers

Getting value from pointer:

value = ptr()

Assigning value to pointer:

ptr(value)

Structs

The structs package features some data structures.

from oven.structs import *

Stack

from oven.structs import Stack

The Stack class is a subclass of python's list, its methods are:

  • push : Push a value to the stack
  • pop : Remove and return the ending element of the stack

Queue

from oven.structs import Queue

The Queue class is a subclass of python's list, its methods are:

  • push : Push a value to the queue
  • pop : Remove and return the starting element of the queue

Tree

from oven.structs import Tree

The Tree class is a recursive node of a tree. The value of the node can be assigned either in the constructor or by calling the value attribute (variable).

# Both nodes are tree nodes with the value 42

node_1 = Tree(42)

node_2 = Tree()
node_2.value = 42

A child can be added to a node by calling the addChild method and passing the child as the parameter. The children of a node can be accessed by calling the children attribute (variable).

Other methods include:

  • dfs : Returns a list of the tree's nodes in depth first search order.
  • bfs : Returns a list of the tree's nodes in breadth first search order.

BinaryTree

from oven.structs import BinaryTree

The BinaryTree class is a subclass of the Tree class. The left and right children can be accessed by:

node.left() # Returns the left node
node.right() # Returns the right node

node.left(newNode) # Sets the left node
node.right(newNode) # Sets the right node

Due to this, the addChild method is removed.

All other methods are identical to that of the Tree class except the dfs method, which is tweaked so that the calling of it becomes:

node.dfs(MODE)

The MODE can be any of:

  • PREORDER
  • INORDER
  • POSTORDER

All of the above modes are imported as such:

from oven.structs import PREORDER, INORDER, POSTORDER

Release files for oven 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oven 0.1.0
File Size Uploaded
oven-0.1.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oven 0.1.0
File Interpreter ABI Platform
oven-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / oven-0.1.0.tar.gz

Download URL oven-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
df6876b446809e1fb319c1e213d210a464c9de5a84eddaf2b7a4167f581ee251
BLAKE2b-256 checksum
How to use checksums
27595bfef19cb6699e51a2af1f9d161ea14805744720ed5ddf987a3bfa5c2c79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / oven-0.1.0-py3-none-any.whl

Download URL oven-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
115b8958a9d1ca501e1e6ec48798ef4f9d3103afe07f15bd3a92fcf16317c8ac
BLAKE2b-256 checksum
How to use checksums
0866aa65b3128ca0ececec4a4601d292d69e9e87d531456c11c08b89c37abc16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page