Re: Writing a package

2022-02-04 Thread Paulo da Silva

Às 02:01 de 05/02/22, Cameron Simpson escreveu:

On 05Feb2022 00:37, Paulo da Silva  wrote:

Let's say I have a dir src containing another dir named foo and a
script test.py.

So, I have
src/foo (dir)
src/test.py (script)

test.py has the folloing code:

import foo as f
c=f.C()

I am inside src and want to run python test.py.

How can I create the class C inside src/foo dir if it is possible at
all?


Define it in the file "src/foo/__init__.py".

When you go:

 import blah

Python reaches for the file "blah.py" or "blah/__init__.py" (this second
path is for "packages").



Yes, thank you.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a package

2022-02-04 Thread Cameron Simpson
On 05Feb2022 00:37, Paulo da Silva  wrote:
>Let's say I have a dir src containing another dir named foo and a 
>script test.py.
>
>So, I have
>src/foo (dir)
>src/test.py (script)
>
>test.py has the folloing code:
>
>import foo as f
>c=f.C()
>
>I am inside src and want to run python test.py.
>
>How can I create the class C inside src/foo dir if it is possible at 
>all?

Define it in the file "src/foo/__init__.py".

When you go:

import blah

Python reaches for the file "blah.py" or "blah/__init__.py" (this second 
path is for "packages").

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Writing a package

2022-02-04 Thread Paulo da Silva

Hello!

Let's say I have a dir src containing another dir named foo and a script 
test.py.


So, I have
src/foo (dir)
src/test.py (script)

test.py has the folloing code:

import foo as f
c=f.C()

I am inside src and want to run python test.py.

How can I create the class C inside src/foo dir if it is possible at all?

Thanks.
--
https://mail.python.org/mailman/listinfo/python-list