New to Python and setting up

dieter dieter at handshake.de
Mon Oct 19 02:04:02 EDT 2015


Glenn Schultz <glennmschultz at gmail.com> writes:
> ...
> Following the example of Ivan7777 I have setup A folder structure.  My understand is that if each folder has an __init__.py  From what it is considered a module.  Have I set this up correctly?

An "__init__.py" in a folder used to indicate that this folder
is a package/subpackage (modern Python 3.x version may no longer need
such an "__init__.py" for this purpose). A "package/subpackage" is
a modularisation unit, where a set of modules and subpackages work closer
together to implement the unit's task.


> In the time_value module I have a function present_value_factor.   I am having trouble documenting the function.  How is this done?  

In the Python world, source code documentation often uses
so called "doc string"s (beside documenting comments).

For example, when your (non comment) code at the beginning of a module
is a string/unicode string, then this is the module's "doc string",
conventionally used to describe the module's purpose.
Similar for a class and function definition.

Python does not prescribe how the "doc string"s should look like.
However, often, a documentation tool is used to extract overviews from
the source code documentation and those tools may support
special annotations to recognize special kinds of objects (e.g. types,
return values). If you plan to use such a tool, look for its documentation
to find out about details.


> Finally, I have read something to the effect that when creating a deployment locally use a virtual environment but I am not sure what that means in this case.  What is the workflow here?  I am having a hard time finding good primers on the subject.

Often, there is no need to use a virtual environment.
It is mainly used to isolate a project from other Python projects
in order to minimize interference.

Advantages of a "virtual environment":

  *  you can set it up locally and extend it
     (by installing additional packages) without administrator rights.
     This is especially important when you lack those rights in
     your development environment

  *  things you are doing in your virtual environment (for a given
     project) is not likely to interfere with other projects
     (if they use there own virtual environment).
     Similarly, you have some protection against the interference from
     other projects




More information about the Python-list mailing list