Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
143 user(s) are online (126 user(s) are browsing Forums)

Members: 1
Guests: 142

rjd324, more...

Support us!

Headlines

 
  Register To Post  

« 1 (2)
Re: Python
Just can't stay away
Just can't stay away


See User information
@all

A. PYTHONPATH
----------------------
A1. How you can do it

i succeeded in a last try to set the PYTHONPATH environmental variable.

when not set you get:
>> sys.path
['', 'PYTHON:Lib/', 'PYTHON:Lib/plat-amiga/', 'PYTHON:Lib/lib-dynload/',

7.Amiga OS 4:S> setenv PYTHONPATH "PYTHON:Lib/scripts/"
7.Amiga OS 4:S> python
'import site' failed; use -v for traceback
Python 2.5.5 (r255:1.2, Mar 27 2010, 21:00:30)
[GCC 4.2.4 (adtools build 20090118)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'PYTHON:Lib/scripts/'] # this is unexpected according to doc this should be appended to default search string. I thinkl it may be reproted as a BUG (1)

7.Amiga OS 4:S> setenv PYTHONPATH "PYTHON:Lib/scripts/,PYTHON:Lib/,PYTHON:Lib/plat-amiga/,PYTHON:Lib/lib-dynload/"
7.Amiga OS 4:S> python
Python 2.5.5 (r255:1.2, Mar 27 2010, 21:00:30)
[GCC 4.2.4 (adtools build 20090118)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> import sys
>>> sys.path
['', 'PYTHON:Lib/scripts/', 'PYTHON:Lib/', 'PYTHON:Lib/plat-amiga/', 'PYTHON:Lib/lib-dynload/']

(1)
A2 BUG ; condensed form tutorial 1.2 & 2.1.6

1. The module search path
Actually, modules are searched in the list of directories given by the variable sys.path
which is initialized
- from the directory containing the input script (or the current directory),
- the environmental variable PYTHONPATH
- installation- dependent default.

The search is done IN THIS ORDER

2. The default module search path

This default search path is installation dependent, but generally begins with prefix/lib/pythonversion
(see PYTHONHOME above).
So it is given with sys.path in when PYTHONPATH is not set
AOS4:
>>> sys.path
['', 'PYTHON:Lib/', 'PYTHON:Lib/plat-amiga/', 'PYTHON:Lib/lib-dynload/', 'PYTHON:Lib/site-packages/']

The first item '' stands for the current (script) directory, and as such is not part of the search default path

3. Environmental variables PYTHONPATH (Tutorial 1.2 )

Augment the default search path for module files.

The format is the same as the shell's PATH:
one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows).
>>> os.pathsep #OS4
','
Remark: The PATH environmental variable on OS4 system is a Cygnix variable and follows the UNIX convention

Non-existent directories are silently ignored.

In addition to normal directories, individual PYTHONPATH entries may refer
to zipfiles containing pure Python modules (in either source or compiled form).
Extension modules ??- cannot be imported from zipfiles.

3.Manipulation of the search path

The search path is given from within a Python program as the variable sys.path which is a Python list
This list can be manipulated eg with sys.path.append("myscriptpath")

This allows Python programs that know what they're doing to modify or replace the module search path.
Note that because the directory containing the script being run is on the search path,
it is important that the script not have the same name as a standard module,
or Python will attempt to load the script as a module when that module is imported.
This will generally be an error.
See section Standard Modules for more information.


B. LEARNING PYTHON
---------------------------
In addition to previously mentioned interesting sites, these seem very interesting
- http://pyschools.appspot.com "interactive learning"
- http://effbot.org/librarybook/ "modules in the standard library " At least you can easilyt see what belongs together.

C. P_DocString_.gc
-----------------------
- Added possibility to launch python on scripts in Python:lib/script drawer appearing in left directory listview and to edit them.
- Target cycler has now the following possibilities
Lib directory view on Python:Lib
Scpt directory view on Python:Scripts :
Mod listview on help("modules") generated list
Key listview on help("keywords") generated list
Tpc listview on help("topics") generated list
B_In listview on buitlin functions

Go to top

  Register To Post
« 1 (2)

 




Currently Active Users Viewing This Thread: 4 ( 0 members and 4 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project