Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 15th, 2002, 09:05 AM
nickname nickname is offline
inexperienced and useless
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Stevenage, uk
Posts: 10 nickname User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy classes causing problems

I'm pretty new to progranmming and I'm trying my first use of classes in Python. The thing is that they don't seem to work.
Here's how I defined it:

class search (self, value):
def sub_search (self, value):
self.value = value
#rest of function here
searchit=search

then when I called it:

if structureorsmiles == SMILES:
searchit.sub_search(SMI)
else:
searchit.sub_search(struc_smi)

SMI and struc_smi are both defined,
I don't get any errors generated, it just doesn't do anything, almost like the call of the class doesn't work. If anyone can see an obvious fault, please help

Thanks

Reply With Quote
  #2  
Old February 16th, 2002, 03:38 AM
Taradino Taradino is offline
Python Prophet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Amersfoort, The Netherlands
Posts: 45 Taradino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
What are you trying to do? In the code you post nothing is printed to the screen, so it's right nothing gets printed.

Anyway, there's something wrong with your class definition:

class search(self, value):

Anything you put between these parentheses are the classes you want to inherit from. I don't think that's what you want here, You probably want something like this:
Code:
class Search:
    def __init__(self, Value):
        self.Value = Value
    
    def SubSearch(self):
        # Function goes here.

SearchIt = Search(Value) # The value you want to search.
if structureorsmiles == SMILES:
    SearchIt.SubSearch(self, SMI)
else:
    SearchIt.SubSearch(self, struc_smi)


You know, you should really try reading a good beginners book on CS and Python. I'd recommend this one:

How to think like a computer scientist: Learning with Python

Also, try putting your code within [ code][ /code] blocks(omit the spaces).
__________________
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. - Jamie Zawinski, in comp.lang.emacs

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > classes causing problems

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap