0

This might seem very trivial, but I cannot figure this out. In OOP language like c#, I can pass instance of self type to a function. For example,

class Edge 
{
void F(Edge e){
// Do something here.
}
}

Here function F takes an argument of type Edge, to which it belongs.

However, I am unable to do this in python.

class Edge:

    def f(self, that: Edge):
        pass

I get an error,

NameError: name 'Edge' is not defined

Can anyone point out how to get this working?

Thank you.

2
  • What for? That information is accessible within the class. Commented Mar 23, 2021 at 5:31
  • I want to pass an object of the same type and use this object variables to compare with the value of current instance. Something like compareTo in c# Commented Mar 23, 2021 at 5:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.