Skip to main content

PYON Reader - Python Object Nation

Project description

pyon

PYON Reader - Python Object Nation

Table of Contents

Installation

pip install pyonr

How to use

Creating PYON file

let's create our PYON file, i'm going to call it friends.pyon

{
    "me": {
        "name": "Nawaf",
        "age": 15
    }
}

Reading File

import pyonr

file = pyonr.read('friends.pyon') # Replace "friends.pyon" with your file name

fileData = file.readfile # {'me': {'name': 'Nawaf', 'age': 15}}
type(filedata) # <class 'dict'>

Writing File

import pyonr

file = pyonr.read('friends.pyon')
fileData = file.readfile

fileData['khayal'] = {
    "name": "Khayal",
    "age": 14
}
# This will update "fileData" only, we need to save it

file.write(fileData)

File will get updated too

{
    'me': {
        'name': 'Nawaf',
        'age': 15
        },

    'khayal': {
        'name': 'Khayal',
        'age': 14
    }
}

Built-in Functions

PYON Built-in Functions

fetch:

fetch is used to fetch any file/url content to the file

{
    'data_from_file_pyon': fetch(r'D:\very_secret_data.pyon')
}

fetch can fetch data from pyon or json files

{
    'data_from_file_json': fetch(r'D:\very_secret_data.json')
}

exact same result as above

fetching data from url

fetch('https://example.com/api')

note: fetch won't change file content, it will only be changed inside a program

Python Built-in Functions

every Python built-in function is supported in PYON

Examples

{
    "sum_example": sum([i for i in range(10)])
}
{
    "sum_with_map_example": sum(
        map(lambda e:e ** 2, [i for i in range(10)])
    )
}

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

pyonr-1.1.1.tar.gz (6.0 kB view hashes)

Uploaded Source

Supported by

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