Python Forum
How i can use categories with folder?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How i can use categories with folder?
#1
Hello,

I want to know how can I import a subfolder?

I have tried with:
from test.test2 import file

but this isn't works.

Best regards
Reply
#2
You don't import folders, you import packages and modules.

Are your trying to do this?
Output:
test |_test2 |_file
If so, the "test", "test2" and "file" folders need to contain a file named "__init__.py". This file can be empty. It's presence tells Python that this directory is part of a package.

if test2 is a Python file, and file is an object in the test2.py file, you only need an __init__.py file in the test folder.
Output:
test |_ __init__.py, test2.py
Reply
#3
First read what the Python tutorial has to say about modules and packages
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 567 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,510 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,486 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  Python Cut/Copy paste file from folder to another folder rdDrp 4 5,081 Aug-19-2020, 12:40 PM
Last Post: rdDrp
  A mail scraper for sorting emails into categories anata2047 1 5,487 Sep-03-2019, 11:03 PM
Last Post: micseydel
  Delete directories in folder is not working after folder is updated asheru93 2 2,670 Feb-13-2019, 12:37 PM
Last Post: asheru93
  copy content of folder to existing folder shlomi27 0 2,646 Aug-11-2018, 01:44 PM
Last Post: shlomi27

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020