(wL) Forums

Full Version: Python with API's
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When you write a large program you will use API's, well that is to say if you don't may god have mercy on your soulĀ  ;D

This is a part of the API I am working on for database/file management
Btw, this is untested atm, i will update and make a note if there is problems.

Note that mem is a class (that i use for global variable calls)
Note that mem.data is the only list that is modified by the "other commands" (not seen)
Code:
class store:#handler for managing multiple files
    def pushas(value):
        if isinsance(value,str) is True:
        if value < len(mem.store):
            mem.store[value]=mem.data
        else:
            mem.store.append(mem.data)
        return
    def pullas(value):
        if value < len(mem.store):
            mem.data=mem.store[value]
        else:
            return None
    return
    def push():
        mem.store[mem.current]=mem.data
        return
    def pull(value):
        if isinstance(value,str) is True:
            value=getvalue(value)
        mem.current=value
        mem.data=mem.store[mem.current]
        return
    def swap(value):
        push()
        pull(value)
        return
    def name(value,name):
        mem.storevalue[value]=name
        return
    def getvalue(name):#[returns list location]
        mylist=mem.storevalue
        loc=mylist.index(name)
        return loc