On May 4, 2010, at 2:29 PM, mhulse wrote: > +++++++++++++ > > Question 01: > > Going back to the AS example, I really dig using a dollar sign for > method arguments and the underscore for class properties. > > Does Python/Django allow for anything similar? :)
Not as such. Names (of anything) must start with either a letter or an underscore (http://docs.python.org/reference/lexical_analysis.html#identifiers). Names that start with an underscore have special meaning (http://docs.python.org/reference/lexical_analysis.html#reserved-classes-of-identifiers), and should generally not be used for normal names of functions, class methods or class attributes. > > +++++++++++++ > > Question 02: > > Is there a good Python listserv out there? I could not find an > obviously popular Google group. Something like the PHP user group > would be cool. :) comp.lang.python (http://groups.google.com/group/comp.lang.python/) > > +++++++++++++ > > Question 03: > > I am building a view, and I would like to move functions within the > view into other files (for the sake of modularity)... In general, > where do you like to store your generic (to everything) / specific (to > a particular view) "helper" methods/functions? > > My co-worker suggested that I put "helper" methods in a "utilities.py" > file: > > views.py > utilities.py > > That might work well, but a part of me would prefer to do something > like this: > > views.py > utilities/ > +--- paginate.py > +--- other.py > +--- this.py > > In other words, one method per class file, vs. cramming everything > into one utilities file. > > What do ya'll suggest? > > Also, let's say "paginate.py" could be used for any project... Where > would you suggest I store "global" utility classes/methods? Utility functions that are used by multiple other files should go in a separate utilities.py. Helper functions that are specific to either a single view or are used just within views.py should be included in views.py, subject to "taste" limitations as to how long views.py should be. Separating out one helper function per file will make other Python programmers hate you. :) Keeping a bunch of unrelated functions, classes and methods together all in one file will also make other Python programmers hate you. You should use one file to hold all related classes and functions. If the file starts getting too large, you haven't thought enough about how related the classes and functions are. Notice how I'm not defining either "related" or "too large". If you break each individual function into its own file, you are going to need lots and lots of import statements in order to get anything done. That's an awful lot of unnecessary typing. > +++++++++++++ > > Sorry if silly questions. :( Not silly, just new. You would do well to read some good Python code, to get a feel for how things are done. For instance, take a look through Django's source code, not so much to understand what it does, but just to get a feel for how it is laid out, the flow of organization, and how related subjects are organized and things are named. HTH, ---Peter Herndon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

