[vtk-developers] Question regarding Python imports.

Elvis Stansvik elvis.stansvik at orexplore.com
Wed Dec 20 03:24:36 EST 2017


2017-12-20 7:45 GMT+01:00 Andrew Maclean <andrew.amaclean at gmail.com>:
> What do people using Python mostly do/prefer?
> 1) import vtk
> 2) from vtk.xx import yy
> 3) from vtk import yy

I generally use 3, but 1 for quick one-off scripts (for the convenience).

I dislike 1 because of the resulting repetitive "vtk.vtk...." (e.g.
vtk.vtkPolyDataMapper). I prefer 3 because explicitly importing the
symbols I use somehow feels more cleanly (no real motivation for that
though).

I've never used 2.

>
> In 2) we are actually specifying the module where yy resides.
>
> In PyCharm:
> For the case of 1)  when we declare something like z = vtk.yy we get a
> cannot find reference in __init__.py() warning
> For case of 2) or 3) we get an unresolved reference for yy in the from
> statement.

It was some time since I used PyCharm for VTK stuff, but I seem to
remember these problems.

Would be great if what you guys come up with could work well in
PyCharm of course, since it's my goto IDE when writing non-trivial
things (for small stuff I use Vim).

Elvis

>
> I'm trying to speed up vtk in Windows!
>
> Regards
>    Andrew
>
> --
> ___________________________________________
> Andrew J. P. Maclean
>
> ___________________________________________
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtk-developers
>
>


More information about the vtk-developers mailing list