(wL) Forums
Python with API's - Printable Version

+- (wL) Forums (https://war-lords.net/forum)
+-- Forum: Resources (https://war-lords.net/forum/forum-31.html)
+--- Forum: Programming (https://war-lords.net/forum/forum-33.html)
+--- Thread: Python with API's (/thread-1410.html)



Python with API's - Zaptor - May 20 2011

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