It is currently Sun Feb 12, 2012 8:53 am

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: what is last line in class definitions?
PostPosted: Thu Feb 04, 2010 8:47 am 
Offline

Joined: Sat Jan 16, 2010 2:59 am
Posts: 27
Location: Australia
Please excuse my ignorance.

I have just quickly learned python, and according to all I have read, a class definition just ends with a blank line.

But in Open Object classes the last line has the name of the class and parenthenses, like (from account_asset.py):

Code:
class account_move_line(osv.osv):
    _inherit = 'account.move.line'
    _columns = {
        'asset_id': fields.many2one('account.asset.asset', 'Asset'),
    }
account_move_line()


why is this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 04, 2010 9:27 am 
Offline

Joined: Mon Dec 03, 2007 8:22 am
Posts: 1472
Location: Belgium
using account_move_line()
we are creating object of that class so it will call __init__ of osv.osv and initialize _columns,_defaults,_name,_table etc...
It is necessary.

_________________
OpenERP=Easier, Adaptable, Affordable, Modular


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 04, 2010 1:26 pm 
Offline

Joined: Sat Jan 16, 2010 2:59 am
Posts: 27
Location: Australia
thanks, I didn't realise you could instantiate an object in python without assigning it to a variable, ie I thought you had to:
x=account_move_line()

So that last line in the class definition isn't actually part of the class definition, technically? It is (again, excuse my newbie ignorance) in the __account_asset__ module namespace and being executed immediately upon import of the module????


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP