开发者

Import custom package in python google app engine

开发者 https://www.devze.com 2023-02-08 08:42 出处:网络
OK guys I can\'t find a solution anywhere for my problem, and I hope the solution is a simple one. Previously I had a flat file system for my gae project with no folders. I\'ve been refactoring some c

OK guys I can't find a solution anywhere for my problem, and I hope the solution is a simple one. Previously I had a flat file system for my gae project with no folders. I've been refactoring some code and I tried to put some in a folder. I'm a bit new and I've never done something like this before, but nothing on the internet suggests that I shouldn't easily be able to move my files into a folder. I added the __init__.py file to the folder and I import the folder name from my main program. However when I attempt to access a particular function in one of the files, it chokes and says AttributeError: 'module' obj开发者_开发技巧ect has no attribute 'site1_ripper'

here is my file structure:

main.py
SiteCrawlers\
    __init__.py
    site1_ripper.py

here are important parts of the files:

main.py

import SiteCrawlers
class Updater(webapp.RequestHandler):
    def get(self):
        SiteCrawlers.site1_ripper.siteCrawler()

site1_ripper.py

def siteCrawler()
    #stuff here


I think the problem is that you need to explicitly import site1_ripper unless it's specified in __init__.py. Make your main import be:

import SiteCrawlers.site1_ripper


In your main file try:

from SiteCrawlers.site1_ripper import siteCrawler

class Updater(webapp.RequestHandler):
    def get(self):
        siteCrawler()
0

精彩评论

暂无评论...
验证码 换一张
取 消