#๐Ÿ”’ How to import multiple files/modules into one alias/namespace?

8 messages ยท Page 1 of 1 (latest)

karmic vergeBOT
#

@thorny glen

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

humble shard
#

depends how many foo's and bar's you have

#

i sketched up this and it works pretty well

#
# test2.py
def subtract2(n1, n2):
    return n1 - n2

# test3.py
def add2(n1, n2):
    return n1 + n2

# test.py
from test2 import subtract2
from test3 import add2

class Delta:
    def __init__(self):
        self.subtract2 = subtract2
        self.add2 = add2

delta = Delta()
print(delta.add2(1, 2))```
#

if it's just 2 functions this works pretty well

#

or enough that you wont sigh at a list of stuff to add

karmic vergeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.