Python Forum
importing functions from a separate python file in a separate directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
importing functions from a separate python file in a separate directory
#2
This works for me
myfunc.py in myfuncs folder
def print_it(arg):
    return arg
test.py
from myfuncs import myfunc
print(myfunc.print_it('Hello World!'))
Output:
Hello World!
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: importing functions from a separate python file in a separate directory - by menator01 - May-16-2022, 01:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i combine these two functions so i only open the file once? cubangt 4 935 Aug-14-2023, 05:04 PM
Last Post: snippsat
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,676 Jun-27-2023, 01:17 PM
Last Post: diver999
  Split Bytearray into separate Files by Hex delimter lastyle 5 2,863 Mar-09-2023, 07:49 AM
Last Post: bowlofred
  Can I get some clarification on importing functions from external files. wh33t 3 955 Feb-25-2023, 08:07 PM
Last Post: deanhystad
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 1,066 Jan-23-2023, 04:56 AM
Last Post: deanhystad
  How to separate the values in an element to add them monty024 4 1,084 Jan-23-2023, 04:28 AM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,176 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  no such file or directory in SFTP saisankalpj 2 1,634 Nov-25-2022, 11:07 AM
Last Post: DeaD_EyE
  New2Python: Help with Importing/Mapping Image Src to Image Code in File CluelessITguy 0 755 Nov-17-2022, 04:46 PM
Last Post: CluelessITguy
  python standard way of importing library mg24 1 954 Nov-15-2022, 01:41 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020