PyCharm 2019 - Auto-Generate Getters / Setters
Hi,
I am trying to auto-generate getter/setter methods for my python classes.
In IntelliJ when I am writing Java I can do this:
public class Dog {
String name;
String breed;
(alt + insert) --> getters/setters --> select fields to generate...
However, in Pycharm when I have a class like this:
class Dog:
def __init__(self, name, breed):
self.__name = name
self.__breed = breed
Using Generate (alt + insert) I get a pop up menu with overrride, implement, and copyright items. I cannot seem to find a way to generate the getter/setter methods. I have tried selecting 'implement methods' and it actually does nothing at all.
Is this functionality simply unavailable?
Thank you for your help,
Marc
Please sign in to leave a comment.
Hi Marc,
You have probably already seen my answer in your ticket https://youtrack.jetbrains.com/issue/PY-38848 , but I'll just duplicate a short version here:
PyCharm doesn't have getter/setter generator, but instead it has prop and props live templates which serve vaguely the same purpose.
A bit of shameless self promotion: https://plugins.jetbrains.com/plugin/20946-python-getters-and-setters
I stumbled upon this issue myself, and decided to spend 5+ hours automating a 5 minute task. You know how it is.