[Tutor] Tutor FAQ
Kent Johnson
kent37 at tds.net
Thu Apr 27 03:42:35 CEST 2006
Mike Hansen wrote:
> Here's the next batch of questions and answers for the tutor FAQ. If
> you have any clarifications or corrections, please let me know. I'll
> try to post this on the web site in a couple of days.
Thanks Mike!
> ---------------------------------------------------------------------
> What's the best editor/IDE for Python?
>
> It's really a matter of preference. There are many features of an
> editor or IDE such as syntax highlighting, code completion, code
> folding, buffers, tabs, ... Each editor or IDE has some or all of
> these features, and you'll have to decide which features are important
> to you.
> See http://wiki.python.org/moin/PythonEditors for a list of editors.
> Also http://wiki.python.org/moin/IntegratedDevelopmentEnvironments has
> a list of IDEs.
This question is asked every few weeks on comp.lang.python so searching
the archives will yield many opinions.
>
> ---------------------------------------------------------------------
> How do I make public and private attributes and methods in my classes?
>
> Python followws the philosophy of "we're all adults here" with respect
> to hiding attributes and methods. i.e. trust the other programmers who
> will use your classes. You can't really hide variables and methods in
> Python. You can give clues to other programmers.
By convention, a name that starts with a single underscore is an
implementation detail that may change and should not be used by client code.
Python does do name
> mangling. By putting two underscores before the attribute or method
> name and not putting two underscores after the name, Python will mangle
> the name by putting the class name in front of it.
<IMO this needs work but not by me tonight...>
>
> For an short example see
> http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_Python
>
> ---------------------------------------------------------------------
> Why doesn't my regular expression work?
>
> Typically, it's an isssue between re.match and re.search. Match matches
> the beginning only and search checks the entire string. See the regular
> expression HOWTO for more details.
>
> http://www.amk.ca/python/howto/regex/
Python comes with a handy program for testing regular expressions,
Tools\Scripts\redemo.py.
>
> ---------------------------------------------------------------------
> How do I perform matrix operations using Python?
>
> The Python FAQ has an entry on how to create multidimensional lists:
> http://python.org/doc/faq/programming.html#how-do-i-create-a-
> multidimensional-list
>
> You may want to look into the 'numarray' third party module:
> http://www.stsci.edu/resources/software_hardware/numarray
<Numarray is being replaced with numpy - we should refer people there>
You may want to look into the 'numpy' module which contains many
resources for scientific computing including powerful matrix operations:
http://numeric.scipy.org/
Kent
More information about the Tutor
mailing list