Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python with API's
#1
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
I used to be an admin. Two mergers and a year later and just look at me now. Amazing!
[Image: zaptorx3sig.png]

Users browsing this thread: 1 Guest(s)