473,382 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

failing to instantiate an inner class because of its order

class Model:
Controller()

class View:
Model()

class Controller:pass
Python interpreter complains that 'Name Error: Controller()' not defined.

Dec 27 '06 #1
4 1173
Pyenos <py****@pyenos.orgwrites:
class Model:
Controller() #problem

class View:
Model()

class Controller:pass
Python interpreter complains that 'Name Error: Controller()' not defined.
Following Edward Kozlowski's advice I can suggest to myself a solution:

class Model:pass

class View:
Model() #this part is fine

class Controller:
def __init__(self):
self.Model=Model()

Controller.Model.Controller() #solution
Dec 27 '06 #2
Pyenos <py****@pyenos.orgwrites:
Pyenos <py****@pyenos.orgwrites:
class Model:
Controller() #problem

class View:
Model()

class Controller:pass
Python interpreter complains that 'Name Error: Controller()' not defined.

Following Edward Kozlowski's advice I can suggest to myself a solution:

class Model:pass

class View:
Model() #this part is fine

class Controller:
def __init__(self):
self.Model=Model()

Controller.Model.Controller() #solution
class Model:
def fuck(self):print "fuck!"

class View:
Model() #this part is fine

class Controller:
def __init__(self):
self.Model=Model()

Controller().Model.fuck() #actually slight problem in previous solution
Has to call in this way. I have confirmed this works.

Dec 27 '06 #3
At Wednesday 27/12/2006 20:37, Pyenos wrote:
>class Model:
def fuck(self):print "fuck!"

class View:
Model() #this part is fine

class Controller:
def __init__(self):
self.Model=Model()

Controller().Model.fuck() #actually slight problem in previous solution
Has to call in this way. I have confirmed this works.
The Model() inside View is *not* fine - you construct a Model
instance just to discard it! Besides some side effects that
constructing a Model() might have, this is useless.
If you are trying to implement a real MVC, usually the model exists
by itself even before you need the view, so usually the view
constructor gets the model as an argument.
I prefer to use lowercase attribute names: self.model = Model(), this
way there is no confusion between model (an instance) and Model (a class).
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Dec 28 '06 #4
class Model:
def fuck(self):print "fuck!"

class View:
Model() #this part is fine

class Controller:
def __init__(self):
self.Model=Model()

Controller().Model.fuck() #actually slight problem in previous solution
Has to call in this way. I have confirmed this works.
What is even the point of the class View there since you don't use it?

/buffi (buffis.com)

Dec 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Average_Joe | last post by:
Hello PHP people, Was wondering if PHP5 had some sort of "nested class" functionality. I'm trying to figure out how to return an object (with a private constructor) that has access to...
7
by: Wolfgang Jeltsch | last post by:
Hello, I want to write a list class with an iterator class as an inner class. The iterator class must have access to certain private members of the list class in order to do its job. Here is a...
7
by: robert | last post by:
running 8.1.7 server, 8.1.6 client. i *thought* inner join should not return nulls, but not only that, but i get way more rows than i'm expecting. assume: order table: order_number
9
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added...
6
by: Philip Potter | last post by:
I have a graph data structure. It goes something like this: class GraphNode { private: friend class Graph; // successor GraphNodes stored as indices of the Graph's array int value; int next1,...
6
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
2
by: Pyenos | last post by:
class model:pass class view: model() class controller: model() I can instantiate clsss model from inside class view but I can't instantiate class model from inside controller, due to the...
5
by: Pyenos | last post by:
class One: Two() #can't instantiate class Two: Three() #can't instantiate class Three:pass
3
by: modernshoggoth | last post by:
G'day all, I'm trying to update a single table (containing plans for flights) with information from the same and other tables (containing info for organisations and locations). tblFlightPlans...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.