« first day (11 days earlier)    last day (14 days later) » 

12:38 AM
@Sham Visualizing import operator:
 
@200_success 'import operator' mean their would be a reference variable 'operator' that points to object of class 'module' and that object has all the methods and atrributes of that module as part of that Object members, correct?
ok
 
@Sham I think I drew what you described.
 
am waiting for your digram it is rotating
Do u think this info will be helpf ul to others if u paste in SO?
in that query?
 
The question is closed. You can't post to a closed question.
 
oh
every question will be closed after sometime, or becasue the question is invalid so they closed it?
 
12:43 AM
3
Q: Is a Python function stored as an object?

ShamThis query is in continuation with link to understand further on this point: In the case of functions, you have an object which has certain fields, which contain e. g. the code in terms of bytecode, the number of parameters it has, etc. My question: 1) How do i visualise a function be...

… is closed as "Unclear what you are asking"
as it should be, because I couldn't understand what you were asking until I got clarification from you.
 
hmmm
but you answered all 4 questions in this query
 
You probably should have asked them as four separate questions, each phrased with the same clarity and detail that you eventually provided.
 
hmm
closed in the sense nobody can write an answer more, but can comment, right?
 
Commenting is still allowed, yes.
 
wrt Duck typing, i have a question, can i ask?
i have been thru SO, but i want to clarify wrt shark simulation program
that i wrote in java
 
12:49 AM
Go ahead
 
in java to avoid switch case to call shark/fish/empty's update() i used polymorphism byt creating a parent class Critter and then called update() in single line
Critter creature = this.cellContents(row, col);
nextTimeStepSea.addCritter(creature.update(this));
creature.update(this)
now in python what is Duck typing? in this context?
i think this is the only scenario where duck typing is completely defined, if am not wrong
 
It means that the critters don't need to implement a common interface, nor do they need to have a common base class.
 
hmm
 
All you care about is that a fish and a shark and and empty cell all have an update() method.
If it walks like a duck and quacks like a duck, it "is" a duck.
So, as long as it is able to update(), it "is" a creature.
 
so i need to maintain a ocean of 2d array cells of no type and store each cell shark/fish/empty class, and then access each cell just like that, update() method will be called automatically. so the problem came in java i decalred type of oceanMatrix as Critter at compile time private Critter[][] oceanMatrix;
becasue* i declared
so i need to use poly to call corresponding update() method
so no need of inheritance in python? becasue i dont requrie parent class critter in python in this case?
ok will ping u later happy coding!
 
1:15 AM
You don't need interfaces in Python. You can use inheritance as a code-sharing mechanism, where appropriate.
In Python 2, all classes should inherit from the object class or a subclass thereof.
If you don't specify a base class at all, then it's considered an old-style class, which is deprecated.
 

« first day (11 days earlier)    last day (14 days later) »