Jan-01-2017, 07:07 PM
I have been trying to figure out classes and I can't wrap my brain around it.
I believe I know the syntax for creating classes but when it comes to getting them to run I get lost quickly.
I get unbound method, not enough arguments, and instance errors.
here is my latest example.
As a standalone function
I guess I don't know how to call a function from within a class using
I believe I know the syntax for creating classes but when it comes to getting them to run I get lost quickly.
I get unbound method, not enough arguments, and instance errors.
here is my latest example.
import sqlite3
class create_database(object):
def createdb(self):
conn = sqlite3.connect('bid.db')
cursor = conn.cursor()
sql = '''create table bid (
colum1 text,
colum2 int,
colum3 int)'''
cursor.execute(sql)
cursor.close()
class main(object):
def __init__(self):
bid = create_database()
bid
main()This doesn't produce any errors but it doesn't create the bid.db file either.As a standalone function
creatdb() works fine.I guess I don't know how to call a function from within a class using
__init__().
