[x3d-public] need help with import

John Carlson yottzumm at gmail.com
Tue Apr 23 15:14:20 PDT 2019


I think what we want to do is create packages out of components, so that a
component, say navigation, contains several classes.   Don, do you concur?

On Tue, Apr 23, 2019 at 4:17 PM Peitso, Loren (CIV) <lepeitso at nps.edu>
wrote:

> I don't think so.  It looks to me like you are trying to identify
> something internal to a module that way.  Import works on the module itself
> and builds the interpreter’s symbol table for the whole module to allow
> resolving everything correctly.
>
> from xxx import yyy   Kind of does what you ask for one method at a time.
> And you can probably use the as functionality too,  you do still pollute
> namespace that way, but not quite as willy-nilly.
>
> Really though, just because it might feel a little more java-ish for the
> from imports and how they avoid needing to prepend module names, thats
> exactly a backwards goal if you want the end result to be robust in Python.
>
> v/r Loren
>
> Sent from my iPhone
>
> On Apr 23, 2019, at 13:16, John Carlson <yottzumm at gmail.com> wrote:
>
> Could I do:
>
>
>
> import org.web3d.x3d.jsail.Core.X3DObject.X3DObject as X3D
>
>
>
> ???
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Peitso, Loren (CIV) <lepeitso at nps.edu>
> *Sent: *Tuesday, April 23, 2019 11:23 AM
> *To: *John Carlson <yottzumm at gmail.com>; Brutzman, Donald (Don) (CIV)
> <brutzman at nps.edu>
> *Cc: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *Re: need help with import
>
>
>
> You want
>
>
>
> import classpath
>
> import org.web3d.x3d.jsail.Core.X3DObject as X3D
>
>
>
> X3D0 = X3D.X3D() /
>
>
>
>
>
>
>
> The module error was due to not having the module name prepended to the
> constructor call, which is the required tradeoff for avoiding the namespace
> messes of from inporting.   It is the from style importing that creates
> potential silent namespace overwrite problems.
>
>
>
> I hope this helps. Apologies on the terseness, I'm down with a bug.
>
>
>
> v/r  Loren
>
>
>
>
>
>
>
> <F85A8FD195EF4BCE94B2236B20B5A947.png>
>
> *From:* John Carlson <yottzumm at gmail.com>
> *Sent:* Tuesday, April 23, 2019 12:08:09 AM
> *To:* Brutzman, Donald (Don) (CIV); Peitso, Loren (CIV)
> *Cc:* X3D Graphics public mailing list
> *Subject:* RE: need help with import
>
>
>
> I think that Loren suggested import * clouded the namespace too much (did
> we get the same email?).
>
>
>
> We could do
>
>
>
> import X3Dautoclass
>
>
>
> John
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>
> *Sent: *Tuesday, April 23, 2019 12:53 AM
> *To: *John Carlson <yottzumm at gmail.com>; Peitso, Loren (CIV)
> <lepeitso at nps.edu>
> *Cc: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *Re: need help with import
>
>
>
> Yes this is a Loren question.
>
>
>
> From prior email conversation and guidance from Loren, I think a good .py
> file starts with
>
>
>
> from X3Dautoclass import *
>
> X3D0 = X3D() \
>
>     .setProfile("Immersive") \
>
>     .setVersion("3.3") \
>
>     # [etc.]
>
>
>
>
>
>
>
> On 4/22/2019 10:15 PM, John Carlson wrote:
>
> > import classpath
>
> >
>
> > import org.web3d.x3d.jsail.Core.X3DObject as X3D
>
> >
>
> > The above doesn’t work. Message:
>
> >
>
> > $ python abox.future.py
>
> >
>
> > Traceback (most recent call last):
>
> >
>
> >    File "abox.future.py", line 20, in <module>
>
> >
>
> >      X3D0 = X3D() \
>
> >
>
> > TypeError: 'module' object is not callable
>
> >
>
> > $ cat org/web3d/x3d/jsail/Core/X3DObject.py
>
> >
>
> > from jnius import autoclass
>
> >
>
> > X3DObject = autoclass('org.web3d.x3d.jsail.Core.X3DObject')
>
> >
>
> > Suggestions?
>
> >
>
> > Thanks,
>
> >
>
> > John
>
> >
>
>
>
>
>
> all the best, Don
>
> --
>
> Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
>
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
>
> X3D graphics, virtual worlds, navy robotics
> http://faculty.nps.edu/brutzman
>
>
>
>
>
> <F85A8FD195EF4BCE94B2236B20B5A947.png>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190423/10057184/attachment.html>


More information about the x3d-public mailing list