brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stange behavior of `__all__` ?

denis-migdal opened this issue · comments

Hi,

I'm not very familiar with Python so this may be a normal behavior.

I have a Python module BLISS containing :

def BLISS():
    pass # do stuff

When doing :

from BLISS import *;

print(dir(BLISS))
print(BLISS)

I get :

['__module__', '__defaults__', '__kwdefaults__', '__doc__', 'arg_names', 'vararg', 'kwarg', '__name__', '__qualname__', '__code__', 'test']
<function BLISS>

However, if I add __all__ = ["BLISS"] to my BLISS module, I get:

[]
<Javascript object: [object Function]>

It feels strange.

Strange indeed, I can't reproduce the bug, I get the same result (the first one) with or without __all__ in the module...

Okay, I think I got a minimal reproductive example :

<!DOCTYPE html>
<html>
  <head>
    <script src="/brython/www/src/brython.js" defer></script>
    <script src="test.js" defer></script>
    <script type="text/python">
from BLISS import *;

print(dir(BLISS))
print(BLISS)
    </script>
  </head>
</html>
// test.js
__BRYTHON__.runPythonSource(`def BLISS():
    pass # do stuff

#__all__ = ["BLISS"]
`, "BLISS");