🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #16004

Kawalek kodu do poprawienia

#16004
From: Husio
Date: Fri, 30 Jun 2006 12:21
44 lines
2424 bytes
Mam problem z nastepujacym kodem...

  1 from pysqlite2 import dbapi2 as sqlite
  2 import os, sys
  3
  4 mypath = os.path.dirname(os.path.abspath(__file__))
  5 databasedir = os.path.join(mypath, 'a.db')
  6
  7
  8 class DataBase(object):
  9     databasedir = os.path.join( os.path.abspath(sys.argv[0]),
'brain.db')
 10
 11     def __init__(self):
 12         self.con = sqlite.connect(databasedir)
 13         self.cur = con.cursor()
 14
 15     def show_commands(self):
 16         self.cur.execute('SELECT command FROM knowledge')
 17         a = ''
 18         for output in self.cur.fetchall():
 19             a += output + ' | '
 20         return  a
 21
 22     def write_to(self, command, text):
 23         self.cur.execute('INSERT INTO knowledge (command, text)
VALUES (?, ?)', (command, text))
 24         self.con.commit()
 25
 26
 27 print ' *************************************\n'
 28 print mypath, '      ', databasedir
 29 print ' *************************************\n'
 30 print DataBase.show_commands()
 31 print ' *************************************\n'


Traceback (most recent call last):
  File "a.py", line 30, in ?
    print DataBase.show_commands()
TypeError: unbound method show_commands() must be called with DataBase
instance as first argument (got nothing instead)

Nie mam pojecia co z tym zrobic.
Technical Details
Message-ID: <1151670089.236583.64760@b68g2000cwa.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!postnews.google.com!b68g2000cwa.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!postnews.google.com!b68g2000cwa.googlegroups.com!not-for-mail
From: "Husio" <PHusiatynski@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Kawalek kodu do poprawienia
Date: 30 Jun 2006 05:21:29 -0700
Organization: http://groups.google.com
Lines: 45
Message-ID: <1151670089.236583.64760@b68g2000cwa.googlegroups.com>
NNTP-Posting-Host: 83.31.240.163
Mime-Version: 1.0
X-Trace: posting.google.com 1151670093 28004 127.0.0.1 (30 Jun 2006 12:21:33 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 30 Jun 2006 12:21:33 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060614 Firefox/1.5.0.4,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: b68g2000cwa.googlegroups.com; posting-host=83.31.240.163;   posting-account=ekpN7g0AAAACjjgW7WL5rwyHzND0aiIT
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit