LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2010, 11:26 AM   #1
madsovenielsen
Member
 
Registered: Aug 2009
Posts: 183

Rep: Reputation: 15
Python OOP - Class and code in seperate files, not working


Hello

I have made this in Python 2.7´

test.py
Code:
class sqlQueryTool():
    def query(self,sql):
        print "Query executed succesfully."
test2.py
Code:
import sql_query_tool

test = sqlQueryTool()
test.query("SELECT * FROM awm_accounts")
raw_input("")
I get this error:
Code:
Traceback (most recent call last):
  File "C:\Users\admin\Desktop\test2.py", line 3, in <module>
    test = sqlQueryTool()
NameError: name 'sqlQueryTool' is not defined
Any help is greatly appriciated.

/mads
 
Old 08-25-2010, 11:56 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
how about this:
Code:
...
test = sql_query_tool.sqlQueryTool()
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python n00b: promoting a derived class to base class? CoderMan Programming 2 03-11-2010 01:46 PM
Python: finding substring code not working :( PiNPOiNT Programming 1 08-31-2009 08:34 PM
PHP OOP... where does the code go? eco Programming 2 01-12-2009 08:38 AM
php projects: define each class in a seperate file? ldp Programming 4 09-16-2004 05:00 PM
OOP / Python inheritance question usernamenumber Programming 1 12-02-2003 10:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration