What is the trick between these?

Steven D'Aprano steve+python at pearwood.info
Mon Aug 15 20:56:45 EDT 2016


On Tue, 16 Aug 2016 04:41 am, huey.y.jiang at gmail.com wrote:

> Python complained that no attribute of load_canvas_image(). It is there,
> coexisting with load_label_image().
> 
> I cannot figure out what is wrong with it, can somebody tell me why?
> Thanks!

No, we cannot, because we are not psychic. You don't show your actual code,
and you don't show us the actual error. Do you want us to *guess* what code
you are running, and guess what error you get?

You can try it for yourself: take the code that you posted, and NOTHING
ELSE, paste it into a new file, and try to run it. Can you run that code?
No. How do you expect us to run it?

- What is `upClass`?
- There are missing imports.
- Nothing appears to create a MyClass instance().
- Or call MyClass.start.

My *guess* is that you have something like:


AttributeError: 'MyClass' object has no attribute 'load_cavas_image'

or something similar, which suggests that you have a typo in your code:


class MyClass:
    def start(self):
        self.load_cavas_image()  # Note spelling error.

    def load_canvas_image(self):
        ...


Or maybe it is the other way around:

class MyClass:
    def start(self):
        self.load_canvas_image()

    def laod_canvas_image(self):  # Note spelling error.
        ...


That's the best I can do. If this doesn't solve your problem, you will have
to as a better question:

http://sscce.org/



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list