Skip to content
Advertisement

Tag: import

How do I make a list of imported classes in Python?

Is there a way to avoid having to call foo(x)for each imported object? Some context: a, b, c are webpage classes and foo is a route() function that creates a route for each webpage. Update: There will be a growing list of imported classes in the main module as the application grows. I mentioned a, b, and c simply as

How can I convert a .py to .exe using pmw? [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question I’m building a GUI program in Python 3.8 and I want to convert

I cannot understand the module of the python

Thankyou for helping me in advance. What I am curious is this. I made the File A, and in there exist module named B, and there is function C. Then to use the C, I should type from A import B B.C() Something like this. but when I use the module numpy, there is file named numpy, and there are

How can I import subpackage?

I have a file structure like this: Dir2.__init__.py have has the same code, but with .Something2 Something.py has simple add method, Something2.py has simple sub method. What I need: But I get an error AttributeError: module ‘Dir1’ has no attribute ‘Dir2’. If I use from .Dir2 import * in Dir1.__init__.py code in test.py works, but also works print(Dir1.sub(10, 14)), what

Do I need to import submodules directly?

Let’s say I have a module foo and a submodule foo.bar. If I want to use a method in foo.bar, do I need to import foo.bar directly or is importing foo sufficient? For example, the following throws an error: and the following works: But I’m not sure if this is generally what’s needed, or if there’s something wrong with my

Python 3.6 Module cannot be found: Folium

I am trying to import folium into a Jupyter notebook I’m working on and I cannot seem to solve the import issues with the Folium library. Has anyone else solved this problem? Output from the above yields: Answer From the source: Choose the sandbox folder of your choice (~/sandbox for example) Clone folium from github: Run the installation script

Module imports and __init__.py

I am trying to understand what the best practices are with regards to Python’s (v2.7) import mechanics. I have a project that has started to grow a bit and lets say my code is organized as follows: The package name is foo and underneath it I have module Foo.py which contains code for the class Foo. Hence I am using

Python imports relative path

I’ve got a project where I would like to use some python classes located in other directories. Example structure: The absolute path varies, because this project is run on different machines. When my python file with MySampleClass located in /mydir is executed, how do I import OtherClassRoot located in /dir or OtherClassA located in /subdirA? I tried things like: or

Advertisement