Re: Creating a class template file generator inside Python language

Thanks for the previous mail. I would like to highlight the value my thought offers to the developers. They often have to write classes while writing a module. In the class, they are supposed to write classes and objects. In a class, typically the attributes are private, and we have getters and setters to access and modify them. My thought is to automate the process of creating such class files with command line. For this, I have made my initial attempt to create a module that does so. Here is a short video in which I am demonstrating it. I am also attaching the details of my terminal to get a bit of more details. I am looking forward to hearing from you if I should work on integrating it within the Python Language features, or I should go some other way round, or this is not a very useful tool for many people. *avanishcodes@avanishcodes*:*~*$ echo "No Student.py file here" No Student.py file here*avanishcodes@avanishcodes*:*~*$ ls*Academics* *Documents* *node_modules* *Pictures* *snap* *Videos**bin* *Downloads* package.json *Projects* Student.py*Desktop* *Music* package-lock.json *Public* *Templates**avanishcodes@avanishcodes*:*~*$ rm Student.py *avanishcodes@avanishcodes*:*~*$ ls*Academics* *Documents* *node_modules* *Pictures* *snap**bin* *Downloads* package.json *Projects* *Templates**Desktop* *Music* package-lock.json *Public* *Videos**avanishcodes@avanishcodes*:*~*$ pip install classgen Requirement already satisfied: classgen in ./.local/lib/python3.8/site-packages (0.0.7)*avanishcodes@avanishcodes*:*~*$ python3 -m classgen Student member1,member2,member3,member4,member5,member6 Class Student generated successfully.*avanishcodes@avanishcodes*:*~*$ cat Student.py #(class) Student class Student: """ This class is used to represent a Student. Attributes: member1: The member1 of the Student. member2: The member2 of the Student. member3: The member3 of the Student. member4: The member4 of the Student. member5: The member5 of the Student. member6: The member6 of the Student. Methods: get_member1(self): Gets the member1 of the Student. get_member2(self): Gets the member2 of the Student. get_member3(self): Gets the member3 of the Student. get_member4(self): Gets the member4 of the Student. get_member5(self): Gets the member5 of the Student. get_member6(self): Gets the member6 of the Student. set_member1(self, member1): Sets the member1 of the Student. set_member2(self, member2): Sets the member2 of the Student. set_member3(self, member3): Sets the member3 of the Student. set_member4(self, member4): Sets the member4 of the Student. set_member5(self, member5): Sets the member5 of the Student. set_member6(self, member6): Sets the member6 of the Student. """ _member1: None _member2: None _member3: None _member4: None _member5: None _member6: None def __init__(self, member1, member2, member3, member4, member5, member6): """ Initializes a Student object. Params: member1: The member1 of the Student. member2: The member2 of the Student. member3: The member3 of the Student. member4: The member4 of the Student. member5: The member5 of the Student. member6: The member6 of the Student. """ self._member1 = member1 self._member2 = member2 self._member3 = member3 self._member4 = member4 self._member5 = member5 self._member6 = member6 def get_member1(self): """ Gets the member1 of the Student. Returns: get_member1: The member1 of the Student. """ return self._member1 def get_member2(self): """ Gets the member2 of the Student. Returns: get_member2: The member2 of the Student. """ return self._member2 def get_member3(self): """ Gets the member3 of the Student. Returns: get_member3: The member3 of the Student. """ return self._member3 def get_member4(self): """ Gets the member4 of the Student. Returns: get_member4: The member4 of the Student. """ return self._member4 def get_member5(self): """ Gets the member5 of the Student. Returns: get_member5: The member5 of the Student. """ return self._member5 def get_member6(self): """ Gets the member6 of the Student. Returns: get_member6: The member6 of the Student. """ return self._member6 def set_member1(self, member1): """ Sets the member1 of the Student. Params: member1: The member1 of the Student. """ self._member1 = member1 def set_member2(self, member2): """ Sets the member2 of the Student. Params: member2: The member2 of the Student. """ self._member2 = member2 def set_member3(self, member3): """ Sets the member3 of the Student. Params: member3: The member3 of the Student. """ self._member3 = member3 def set_member4(self, member4): """ Sets the member4 of the Student. Params: member4: The member4 of the Student. """ self._member4 = member4 def set_member5(self, member5): """ Sets the member5 of the Student. Params: member5: The member5 of the Student. """ self._member5 = member5 def set_member6(self, member6): """ Sets the member6 of the Student. Params: member6: The member6 of the Student. """ self._member6 = member6 *avanishcodes@avanishcodes*:*~*$ AvanishCodes - VMware Workstation 16 Player (No... <https://drive.google.com/file/d/1I4rbwjr-l5eNqbNzpnY8QOGrXP-c3t_B/view?usp=d...> Thanks and Regards Avanish On Mon, Feb 14, 2022 at 4:59 AM Avanish Gupta <avanishcodes@gmail.com> wrote:

On Tue, Feb 15, 2022 at 03:43:54PM +0530, Avanish Gupta wrote:
If developers are writing classes with lots of getters and setters, they probably think they are writing Java instead of Python. https://dirtsimple.org/2004/12/python-is-not-java.html I think you have done the right thing to put your code on PyPI. We'll wait to see whether people find it useful. -- Steve

On Thu, 17 Feb 2022 at 00:18, Avanish Gupta <avanishcodes@gmail.com> wrote:
Thanks for the previous mail. I would like to highlight the value my thought offers to the developers. They often have to write classes while writing a module. In the class, they are supposed to write classes and objects. In a class, typically the attributes are private, and we have getters and setters to access and modify them. My thought is to automate the process of creating such class files with command line.
Even better than automating the generation of code is NOT generating the code. Just write what you need, instead of writing classes with classes and objects in them, and getters and setters. None of that is necessary (in ANY language), and it exists only because people perpetuate the idea that it's somehow necessary. I think you'll find that Python can be even easier to use than you imagined; start by not writing code, and then you'll find that you can not-debug the code you didn't write, and not-test that non-code, and so on. Fewer lines of code has an exponential cascading benefit in development effort! ChrisA

Are you aware of https://docs.python.org/3.10/library/dataclasses.html? That essentially provides a way to generate the boilerplate without having to put it all in your code. El mié, 16 feb 2022 a las 5:20, Avanish Gupta (<avanishcodes@gmail.com>) escribió:

On Tue, Feb 15, 2022 at 03:43:54PM +0530, Avanish Gupta wrote:
If developers are writing classes with lots of getters and setters, they probably think they are writing Java instead of Python. https://dirtsimple.org/2004/12/python-is-not-java.html I think you have done the right thing to put your code on PyPI. We'll wait to see whether people find it useful. -- Steve

On Thu, 17 Feb 2022 at 00:18, Avanish Gupta <avanishcodes@gmail.com> wrote:
Thanks for the previous mail. I would like to highlight the value my thought offers to the developers. They often have to write classes while writing a module. In the class, they are supposed to write classes and objects. In a class, typically the attributes are private, and we have getters and setters to access and modify them. My thought is to automate the process of creating such class files with command line.
Even better than automating the generation of code is NOT generating the code. Just write what you need, instead of writing classes with classes and objects in them, and getters and setters. None of that is necessary (in ANY language), and it exists only because people perpetuate the idea that it's somehow necessary. I think you'll find that Python can be even easier to use than you imagined; start by not writing code, and then you'll find that you can not-debug the code you didn't write, and not-test that non-code, and so on. Fewer lines of code has an exponential cascading benefit in development effort! ChrisA

Are you aware of https://docs.python.org/3.10/library/dataclasses.html? That essentially provides a way to generate the boilerplate without having to put it all in your code. El mié, 16 feb 2022 a las 5:20, Avanish Gupta (<avanishcodes@gmail.com>) escribió:
participants (4)
-
Avanish Gupta
-
Chris Angelico
-
Jelle Zijlstra
-
Steven D'Aprano