(Aug-24-2018, 07:27 AM)Winfried Wrote: 1. What does this do? Why import the same module twice?
Because that's the way they have made the package link
gpxpy.
Could it just have been
import gpxpy
yes.
Then they have to modify
__init__.py
You see that now only
from . import parser as mod_parser
is added there.
This mean that only
parse
get used bye using
import gpxpy
.
Using
pdir2 for easier show what going on.
>>> import gpxpy
>>> import pdir
>>> pdir(gpxpy)
module attribute:
__cached__, __file__, __loader__, __name__, __package__, __path__, __spec__
property:
__builtins__
special attribute:
__doc__
function:
parse: Parse xml (string) or file object. This is just an wrapper for
>>> gpxpy.parse
<function parse at 0x04458660>
Doing import
gpxpy.gpx
,will add the rest geo, gpx, gpxfield, utils.
>>> pdir(gpxpy)
module attribute:
__cached__, __file__, __loader__, __name__, __package__, __path__, __spec__
property:
__builtins__, geo, gpx, gpxfield, utils
special attribute:
__doc__
function:
parse: Parse xml (string) or file object. This is just an wrapper for
# Now rest of import work.
>>> gpxpy.geo
<module 'gpxpy.geo' from '......geo.py'>
It's kind of okay to have 2 import,because they have in in documentation.
It could be cleaner to have one import,they can have there reason(good or bad) to have
parser()
function in own import.