Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

args object, some implementation questions

Gabriel
2006-06-14
2013-11-04
  • Gabriel
    Gabriel
    2006-06-14

    Slowly but surely I am perusing the code for a greater understanding of PyDSTool.

    One question I have is how args is implemented in common.py.

    Why are class instances mapped to key values? Is this simply a visual addition, make it look more like structs as opposed to a python dictionary?

    Do be more clear, is there any reason to write

    PCargs.name = 'Rozen'

    vs

    PCargs['name'] = 'Rozen'

    The latter seems more pythonic . . . though I have no real vested interest in either.

    Gabriel

     
    • Gabriel
      Gabriel
      2006-06-14

      Sorry I ment to write 'To be more clear'
      not 'Do be more clear' ! the latter is aggressive, which was certainly not intended . . .

      Not sure how to edit my posts.

      Gabriel

       
    • Rob Clewley
      Rob Clewley
      2006-06-14

      We originally used dictionaries exclusively, but some users complained that putting large numbers of parameter settings using names in quotes was irritating.

      That was fair enough, so the args class simply provides an alternative, struct-like syntax for the same thing. So it's entirely up to you which syntax you prefer to use. There's no efficiency loss as far as we're concerned.

      The idea is that whenever an args class is used, a dictionary would also work. The args class implements pretty much every method needed to act like a dictionary...

      Rob