-2

hey I have this file in py, it is called Numbers.py:

Numbers=[1,3,5,7]
for i in Numbers:
    if i%2==0:
        print(i)
    else: 
        i%2==1
    print(i)
for l in Numbers:
        if l>1 & i%l==1:
            print(l)

how can I import it in another one?

Mazdak
  • 105,000
  • 18
  • 159
  • 188

1 Answers1

0

If your project is rather simple, you need to make a new file called __init__.py to tell python your marking the current directory where Numbers.py is a package that can be imported.

Next in your other py file you can do:

import .Numbers #if you want to import everything
from .Numbers import * # if you want to import all the variables and functions in same namespace
Mike Tung
  • 4,735
  • 1
  • 17
  • 24