Generate function and signature in other class


tldr:  How do I get PyCharm to help add a function (in class X) by trying to use that function (in Class Y)?  

IntelliJ Idea has a great feature that allows you to use a class and generate a function (with the appropriate signature) in that other class.  I use this all the time when writing Java code.  I write the test as if the class exists and what I will pass it and get back, and then Idea will stub out the functions.  I can't figure out how to do the same Pycharm.  Is it possible? 

Imagine I have a class Car and a CarDriver class, and I want to call drive() on the car.  It looks like this:

public static void main(String[] args) {
Car c = new Car();
CarDriver d = new CarDriver();
double x =;

but drive() doesn't exist.  Idea let's me mouse over drive(d) and the hint will have 'Create method drive in Car'.  If I click on it, it produces (in Car): 

public double drive(CarDriver d) {

which is very useful.   It's frustrating I can't do that in PyCharm.  


1 comment
Comment actions Permalink

There is a similar feature in PyCharm. 
In the example below, PyCharm should highlight the foo method as unresolved

class A:

class B:
a = A()

Clicking on that method, hitting Alt+Enter and choosing Add method... should do the trick:


Please sign in to leave a comment.