user3184809
user3184809

Reputation: 173

Class in python

I have created a class called Functions which contains many functions I define this function:

def distance(self,seq1,seq2,seq3)

In another file I want to call the function of this class.

I have defined three DNA sequences:

a=Functions()
a.distance(seq1,seq2,seq3)

When I try to call Functions(), I get the following error:

name 'Functions' is not defined

Upvotes: 0

Views: 72

Answers (1)

rodrigo
rodrigo

Reputation: 98328

Usually, if the file is named distance.py for example, you just:

import distance
a = distance.Functions()

Or if you feel lazy:

from distance import Functions
a = Functions()

Or if you feel very lazy:

from distance import *
a = Functions()

Upvotes: 6

Related Questions