I am new to python.
I have few questions
a. Is there something like function overloading in python?
b. Can I overload __init__ method
Thanks in advance
regards
prasad chandrasekaran
--- Cancer cures smoking
-----Original Message-----
From: py************* *************** *************** **@python.org
[mailto:py****** *************** *************** *********@pytho n.org] On
Behalf Of py************* ****@python.org
Sent: Friday, September 30, 2005 6:36 PM
To: py*********@pyt hon.org
Subject: Python-list Digest, Vol 24, Issue 455
Send Python-list mailing list submissions to py*********@pyt hon.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to py************* ****@python.org
You can reach the person managing the list at py************* **@python.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."
This message contains information that may be privileged or confidentialand is the property of the Capgemini Group. It is intended only for theperson to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive thismessage in error, please notify the sender immediately and delete all copies of this message. 3 2883
I may be reading this question different than Fredrik.
This example is with old-style classes.
class baseclass:
def __init__(self, arg):
#
# Do some initialization
#
def method1(self, arg):
#
# baseclass method goes here
#
class myclass(basecla ss):
def __init__(self, arg):
#
# This method gets called when I instantiate this class.
# If I want to call the baseclass.__ini t__ method I must
# do it myself.
#
baseclass.__ini t__(arg)
def method1(self, arg):
#
# This method would replace method1 in the baseclass
# in this instance of the class.
#
myObj=myclass(a rg)
I could be way off base, but maybe it will help.
-Larry Bates
Iyer, Prasad C wrote: I am new to python.
I have few questions a. Is there something like function overloading in python? b. Can I overload __init__ method
Thanks in advance regards prasad chandrasekaran
--- Cancer cures smoking -----Original Message----- From: py************* *************** *************** **@python.org [mailto:py****** *************** *************** *********@pytho n.org] On Behalf Of py************* ****@python.org Sent: Friday, September 30, 2005 6:36 PM To: py*********@pyt hon.org Subject: Python-list Digest, Vol 24, Issue 455
Send Python-list mailing list submissions to py*********@pyt hon.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to py************* ****@python.org
You can reach the person managing the list at py************* **@python.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..."
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
Larry Bates wrote: class myclass(basecla ss): def __init__(self, arg): # # This method gets called when I instantiate this class. # If I want to call the baseclass.__ini t__ method I must # do it myself. # baseclass.__ini t__(arg)
This is an example of polymorphism generally, not overloading.
--
Michael Hoffman
Larry Bates wrote: I may be reading this question different than Fredrik.
it looks like you're using a non-standard definition of the word "overloadin g".
here are the usual definitions (quoting from a random google page):
"Overloadin g a method refers to having two methods which share the
same name but have different signatures."
"Overriding a method refers to having a new implementation of a method
with the same signature in a subclass."
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Terje Slettebø |
last post by:
To round off my trilogy of "why"'s about PHP... :) If this subject have been
discussed before, I'd appreciate a pointer to it. I again haven't found it
in a search of the PHP groups.
The PHP manual mentions "overloading"
(http://no.php.net/manual/en/language.oop5.overloading.php), but it isn't
really overloading at all... Not in the sense it's used in other languages
supporting overloading (such as C++ and Java). As one of the...
|
by: Fuzzyman |
last post by:
I've been programming in python for a few months now - and returning
to programming after a gap of about ten years I've really enjoyed
learning python.
I've just made my first forays into inheritance and operator
overloading (both concepts that I initially found hard to grasp).
I've written a simple config file parser - and I thought I'd
experiment with making the interface easier by subclassing dict and
overloading the __setitem__,...
|
by: Sergey Krushinsky |
last post by:
Hello all,
Is there a common way to emulate constructor overloading in Python class?
For instanse, I have 3 classes:
1/ Polar - to hold polar coordinates;
2/ Cartesian - to hold cartesian coordinates;
3/ Coordinates3D, which holds synchronized instances of the both in
__p__ and __c__ fields respectively.
|
by: Doran_Dermot |
last post by:
Hi All,
I've seen lots of code in which the attributes of a class are accessed and
modified using two separate methods. For example:
class Problems:
def __init__( self, refNum ):
self._refNum = refNum
self._title = ""
self._problem = ""
|
by: Martin Häcker |
last post by:
Hi there,
I just tried to run this code and failed miserably - though I dunno why.
Could any of you please enlighten me why this doesn't work?
Thanks a bunch.
--- snip ---
import unittest
from datetime import datetime
| |
by: John M. Gabriele |
last post by:
I know that Python doesn't do method overloading like
C++ and Java do, but how am I supposed to do something
like this:
--------------------- incorrect ------------------------
#!/usr/bin/python
class Point3d:
pass
|
by: placid |
last post by:
Hi all,
Is it possible to be able to do the following in Python?
class Test:
def __init__(self):
pass
def puts(self, str):
print str
|
by: sturlamolden |
last post by:
Python allows the binding behaviour to be defined for descriptors,
using the __set__ and __get__ methods. I think it would be a major
advantage if this could be generalized to any object, by allowing the
assignment operator (=) to be overloaded.
One particular use for this would be to implement "lazy evaluation".
For example it would allow us to get rid of all the temporary arrays
produced by NumPy.
For example, consider the...
|
by: Benny the Guard |
last post by:
Working on a class that I would use multiple constructors in C++ since I have different ways of creating the data. Tried this in python by defining multiple __init__ methods but to no avail, it seems to only find the second one. So I have:
class myclass:
__init__ (self, mystring1, mystring2)
self.name = mystring1
self.value = mystring2
__init__ (self, xmldoc):
<some code to parse the XML into my...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |