Automatic Generation of Python Class Files

Sunburned Surveyor sunburned.surveyor at gmail.com
Mon Oct 22 14:05:52 EDT 2007


On Oct 22, 10:26 am, "Chris Mellon" <arka... at gmail.com> wrote:
> On 10/22/07, Sunburned Surveyor <sunburned.surve... at gmail.com> wrote:
>
>
>
>
>
> > I was thinking of a way I could make writing Python Class Files a
> > little less painful. I was considering a Ptyhon script that read a
> > file with a list of property names and method names and then generated
> > a skeleton class file.
>
> > I was even thinking of automatically generating the shell for doc
> > strings and epydoc tags.
>
> > Is there existing scripts that do something like this? If not, I will
> > try to come up with something. If I'm sucessful I'll release the code
> > under the GPL and will report back to the list.
>
> > However, I thought I would check here first so that I don't reinvent
> > the wheel.
>
> > Thanks,
>
> > Scott Huey
>
> I can't think of a single reason why you would ever want to do this,
> since your "list of method and property names" would be just as
> verbose as just typing the actual python code.
>
> Auto generated documentation stubs are considered harmful because they
> take the place of real documentation.- Hide quoted text -
>
> - Show quoted text -

Chris,

You wrote: " can't think of a single reason why you would ever want to
do this,
since your "list of method and property names" would be just as
verbose as just typing the actual python code."

I don't think I understand how this would be the same amount of
typing. Consider the following example that would generate a Monster
class file from an input text file (I only did one property and method
in generated class file.):

Contents of input text file:

[Name]
Fire Breathing Dragon

[Properties]
Strength
Scariness
Endurance

[Methods]
eatMaiden argMaiden
fightKnight argKnight

Generated Python Class File:

def class FireBreathingDragon:

   def getStrength(self):
      """
      Docstring goes here.

      @return
      @rtype
      """
      return self.strength

   def setStrength(self, argStrength):
      """
      Docstring goes here.

      @param argStrength
      @ptype
      """
      return self.strength

   def eatMaiden(self, argMaiden):
      """
      Docstring goes here.

      @param argMaiden
      @ptype
      """







More information about the Python-list mailing list