473,396 Members | 1,886 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,396 software developers and data experts.

Fw: Is there a reason not to do this?

"Hendrik van Rooyen" <ma**@microcorp.co.zawrote:

"Ron Garret" <rN*******@flownet.comwrote:
I don't want to get into a philosophical debate.
Actually, I changed my mind. Consider:
so did I - I think the chair analogy is not quite clear, so let me elucidate:

def g(): print 'G'

def h(): print 'H'

def f(): g()

class C1:
def m1(self): f()
up to here:

m1 will call f that will call g - should there ever be an m1 of this class

class C2:
def m1(self): g()
the m1 of this class will call g with no redirection, if it were called into
existence and called

c1 = C1()
c2 = C2()
two new things are made (chairs?) , called c1 and c2-
so at this point,

c1.m1() #Prints G
c2.m1() #Prints G

as expected

def f(): h()
now f is changed to call h instead of g for future calls to f (- loose talk
this - actually the name f is rebound...)

class C2:
def m1(self): h()
this is just a promise of things to come, if an instance of this new class with
the old name should be made...

c1.m1() # Prints H
c2.m1() # Prints G
yup.

On what principled basis can you justify two different outputs in this
case? Why should I be able to change the definition of f and not have
to go back and recompile all references to it, but not m1?
I think the simplest way to look at this is as follows - the inherited
"attributes" of a class instance are "fixed"
at the time of instantiation, while the function redirection works because it is
evaluated at the time that it is called, not at the time it is created (or
defined if you prefer).

To make it work the way you want, would, I expect, require that the whole
instantiation process be either checked for validity, or executed with every
call to a class instance - a sort of make and kill on the fly process, or
alternatively, at the time of the re definiton of a class, all instances of the
class of that name would have to be re initialised - and this may not be
possible, if for instance, the new __init__ method needs more variables than the
old one did - so it becomes a bit of a toffee, and it looks as if the python dev
crowd wisely decided to just leave it alone...
>
This feels to me as if you are changing the specification of what wood to use
from yellowood to teak after the chair has already been made.
so now maybe you can see why I said that. ;-)

- Hendrik
Dec 2 '06 #1
0 771

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

Similar topics

9
by: cody | last post by:
Why isn't there an StringBuilder.Append() overload with a StringBuilder as argument? Is there a reason that I missed?
10
by: sp0 | last post by:
Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think
7
by: Abhishek Saksena | last post by:
Hi all, Is there is any strong reason not to use standard C++ native datatypes. The only reason I can imagine is protability issuse on different machines.But did C++ not gurantee portaibilty of...
37
by: Greg | last post by:
Except for legacy or non-.NET applications, is there any reason to use VC++ anymore? It seems that for .NET applications, there would be no reason to choose C++ over C# since C# is faster to...
1
by: Ryan Liu | last post by:
Is there a good reason that Decimal does not have Ceiling() method, only Math class has? Thanks!
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
16
by: Ron Garret | last post by:
One of the things I find annoying about Python is that when you make a change to a method definition that change is not reflected in existing instances of a class (because you're really defining a...
10
by: mark4asp | last post by:
I ask this because only today I read advice telling me to put it within the <headelement. This is the same advice I've always been given but no one ever explained why. Last week I was told to...
2
by: BD | last post by:
Hi, all. I'm trying to implement a REFRESH IMMEDIATE MQT to help with performance of a particularly sluggish query. I cannot create it with REFRESH IMMEDIATE, because of reason code "10",...
10
by: _Who | last post by:
Given Request.Cookies and Response.Cookies in asp.net is there any reason to ever use javascript or any other method to use cookies? Thanks
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.