473,397 Members | 2,033 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,397 software developers and data experts.

Re: property getter with more than 1 argument?

I don't understand what you're trying to do here.
On Thu, Jul 17, 2008 at 10:57 AM, mk <mr****@gmail.comwrote:
>
It seems like getter is defined in such way that it passes only 'self':
class FunDict(dict):
def __init__(self):
self.fundict = dict()

def fget(self, fun):
return fundict[fun.func_name]

def fset(self, newfun):
self.fundict[newfun.func_name] = newfun

newfun = property (fget, fset)

>>>a=FunDict()

a.newfun=f1

a.newfun('f1')

Traceback (most recent call last):
File "<pyshell#67>", line 1, in <module>
a.newfun('f1')
TypeError: fget() takes exactly 2 arguments (1 given)

Is it possible to pass more than one argument to fget function?

I know: I can define a function with property name ('newfun' in the example)
and call it with more arguments. But then I do not get the benefits of
setter and property in general!

--
http://mail.python.org/mailman/listinfo/python-list
Jul 17 '08 #1
0 843

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

Similar topics

3
by: kepes.krisztian | last post by:
Hi ! I want to create a property that can use parameter(s). In Delphi I can create same thing (exm: Canvas.Pixel -> Canvas.GetPixel(self,X,Y):integer; Canvas.SetPixel(self,X,Y,Color::integer); ...
13
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does...
16
by: Flare | last post by:
Hi...Why canīt I access a property thorug property? Eg. class Foo { public SizeF MySize { get { return ms; } set { ms = value; } }}
8
by: Herve Bocuse | last post by:
Hi, I'm just wondering what are the guidelines for using a Property or a pair of get/set methods related to a member variable ? What do yu guys do ? Thank you Herve
4
by: Jimbo | last post by:
I am sort of new to C#. Currently have a private property called "_name" in a class. I have written a public getter and setter routine for it called "Name". Currently, the getter for the...
13
by: Peter Kirk | last post by:
Hi there, can someone tell me what exactly a "property" is in a C# class? As far as I can see it is "two methods" - ie a getter and a setter for an instance variable. What is the difference...
5
by: Brent Ritchie | last post by:
Hello, This is my first attempt at template programming so please bear with me. This is what I have so far: Property.h -------------------------- #ifndef PROPERTY_H_ #define PROPERTY_H_
7
by: Jaimi McEntire | last post by:
Given a property define like this: public decimal ControlAmount { get { return mControlAmount; } set { mControlAmount = value; } } I expected (under release mode) that when used as a...
1
by: mk | last post by:
It seems like getter is defined in such way that it passes only 'self': class FunDict(dict): def __init__(self): self.fundict = dict() def fget(self, fun): return fundict
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.