importing from the current source directory fails

Đang mở
#671 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, python
Lĩnh vực
compilers

Hướng nghiên cứu

Reproduce the failure with lib1/code1.py importing Class2 from lib1/code2.py using a relative import, then compare it with the top-level lib1.code2 form. Start by tracing Transcrypt's import-resolution path; done means compiling the example succeeds without rewriting imports when run from the top directory.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

STATE: under consideration

Let's say you have two files in lib1/ directory

lib1/
code1.py
code2.py

You can import something in code2.py from code1.py using '.' dotation notifying the current directory.

in code1.py:

from .code2 import Class2

But transcypt fails the import when it is executed in the top directory.

Error while compiling (offending file last):
Import error, can't find any of:

So I have to modify all source files in subdirectory to import starting from the top directory.
in code1.py:

from lib1.code2 import Class2

It makes source ugly when project size grows, and it requires a lot of work to modify source code whenever copying/moving/modifying directory. I hope that this bug is fixed soon.

Buy the way, please let me know if there is an easy way to go around this problem.

Ngôn ngữ chính
Python
Star
2.9k
Fork
218
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TranscryptOrg/Transcrypt

Tất cả issue của TranscryptOrg/Transcrypt

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.