Reputation: 893
I'm having some trouble calling a function which is within a class in python.
Here is my folder hierarchy.
~/Code/program/main.py
~/Code/program/dc_functions/dcfunc.py
~/Code/program/dc_functions/init.py
Basically, I want to use a function from dcfunc.py inside of main.py. How would I do this?
Relevant contents of dcfunc.py:
import subprocess, string, os, sys
class dcfunc:
#Create raw Audio track(Part of Dreamcast Disc format) + Burn track to disk.
def __init__(self):
self.self = "self"
def burnaudiotrack(device):
**CODE***
Thanks for any suggestions!
Upvotes: 0
Views: 2032
Reputation: 45039
You need your init.py file to be named __init__.py
then use
from dc_functions.dcfunc import function_name
And you'll have acccess to the function.
Upvotes: 4