79121603

Date: 2024-10-24 11:10:16
Score: 3
Natty:
Report link

You can't just use file like an object in python, you must import the class to use it in your file1 :

from .file2 import mytest

After that you can use it in your file1

def f0():
    mytest.f1("5")

But it will throw an error because in your class constructor, you call f2() before f1() so n isn't instantiated.

  Traceback (most recent call last):
  File "C:\Dev\tmp\file1.py", line 1, in <module>
    from file2 import mytest
  File "C:\Dev\tmp\file2.py", line 1, in <module>
    class mytest:
  File "C:\Dev\tmp\file2.py", line 10, in mytest
    f2()
  File "C:\Dev\tmp\file2.py", line 8, in f2
    print("test f2 : " + n)
                         ^
NameError: name 'n' is not defined

Btw you shouldn't call functions in your class constructor.

I doesn't understand why you need global variable, can you explain it please ?

Reasons:
  • Whitelisted phrase (-1.5): you can use
  • RegEx Blacklisted phrase (2.5): can you explain
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Malfeitor