Python marks an instance of my class undefined

Kayode Odeyemi dreyemi at gmail.com
Tue Sep 6 09:42:54 EDT 2011


I was able to get this solved by calling class like this:

>>> from core.fleet import Fleet
>>> f = Fleet()

Thanks to a thread from the list titled "TypeError: 'module' object is not
callable"

On Tue, Sep 6, 2011 at 2:02 PM, Kayode Odeyemi <dreyemi at gmail.com> wrote:

> Is there anything I need to do to create an instance of a class?
>
> I have this simple code(The class is in a package core.fleet):
>
> class Fleet(object):
>     def __init__(self):
>         """ no-arg constructor """
>     def fleet_file_upload(self, filename, type=None):
>         if type == 'user':
>             return 'photos/%Y/%m/%d'
>         return 'images'
>
>     def fleet_get_fleet(self):
>         """ Get all fleet """
>         return db.db_get_fleet()
>
>      def fleet_get_fleet_type(self):
>         """ Get fleet by type or category """
>
> For Python shell, I did this:
>
> >>> import core.fleet
> >>> f = Fleet()
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> NameError: name 'Fleet' is not defined
>
> What am I doing wrong?
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110906/6167abcd/attachment-0001.html>


More information about the Python-list mailing list