understanding operator overloading

2012-06-01 Thread Josh Benner
Is there a good way to trace what's going on under the hood wrt operator overloading? I am trying to understand what is happening in the code and output listed below. Why doesn't __getitem__ in mylist return the same result as the builtin list object? Does it have something to do with the start

Re: understanding operator overloading

2012-06-01 Thread Chris Rebert
On Fri, Jun 1, 2012 at 9:39 AM, Josh Benner sjben...@gmail.com wrote: Is there a good way to trace what's going on under the hood wrt operator overloading? I am trying to understand what is happening in the code and output listed below. Why doesn't __getitem__ in mylist return the same

[issue2102] New style vs. old style classes __ror__() operator overloading

2010-06-16 Thread Terry J. Reedy
Changes by Terry J. Reedy tjre...@udel.edu: -- resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2102 ___

[issue2102] New style vs. old style classes __ror__() operator overloading

2008-12-04 Thread Fred L. Drake, Jr.
Changes by Fred L. Drake, Jr. [EMAIL PROTECTED]: -- assignee: fdrake - ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2102 ___ ___ Python-bugs-list

[issue2102] New style vs. old style classes __ror__() operator overloading

2008-03-19 Thread Sean Reifschneider
Changes by Sean Reifschneider [EMAIL PROTECTED]: -- assignee: - fdrake components: +Documentation -Interpreter Core nosy: +fdrake priority: - normal __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2102 __

[issue2102] New style classes __ror__() operator overloading problem

2008-02-13 Thread Wummel
: Interpreter Core files: t.py messages: 62361 nosy: calvin severity: normal status: open title: New style classes __ror__() operator overloading problem type: behavior versions: Python 2.4, Python 2.5 Added file: http://bugs.python.org/file9425/t.py __ Tracker [EMAIL

[issue2102] New style classes __ror__() operator overloading problem

2008-02-13 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Doc says: http://docs.python.org/dev/reference/datamodel.html#object.__ror__ These functions are only called if the left operand does not support the corresponding operation and the operands are of different types. For operands of the same type, it is

[issue2102] New style vs. old style classes __ror__() operator overloading

2008-02-13 Thread Wummel
compatibility. The documentation should mention the different behaviour though. -- title: New style classes __ror__() operator overloading problem - New style vs. old style classes __ror__() operator overloading __ Tracker [EMAIL PROTECTED] http

Re: Operator overloading

2008-01-26 Thread MRAB
On Jan 25, 8:52 pm, Hexamorph [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hexamorph wrote: You mean you want the ability to change for example the + operator for ints to something like calculating the cosine instead of doing addition? Sure. Cosines are a monadic operation and

Re: Operator overloading

2008-01-26 Thread Terry Reedy
| Sure. Cosines are a monadic operation and the monadic '+' is a NOP, so | why shouldn't I define +45 to return cosine of 45, (presuming I needed | lots of cosines). I'd even let you define your own operators. Lots of | programmers really liked '++' and '--', for examples. One cannot

Re: Operator overloading

2008-01-25 Thread Hexamorph
[EMAIL PROTECTED] wrote: Diez B. Roggisch wrote: No, there is no way. You would change general interpreter behavior if you could set arbitrary operators for predefined types. Start grumping... Thank you, Diez. If I ever design a language, please remind me that complete, easy,

Re: Operator overloading

2008-01-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Diez B. Roggisch wrote: No, there is no way. You would change general interpreter behavior if you could set arbitrary operators for predefined types. Start grumping... Thank you, Diez. If I ever design a language, please remind me that complete, easy,

Re: Operator overloading

2008-01-25 Thread Hexamorph
[EMAIL PROTECTED] wrote: Hexamorph wrote: You mean you want the ability to change for example the + operator for ints to something like calculating the cosine instead of doing addition? Sure. Cosines are a monadic operation and the monadic '+' is a NOP, so why shouldn't I define +45 to

Re: Operator overloading

2008-01-25 Thread MartinRinehart
Diez B. Roggisch wrote: No, there is no way. You would change general interpreter behavior if you could set arbitrary operators for predefined types. Start grumping... Thank you, Diez. If I ever design a language, please remind me that complete, easy, well-documented access to the working

Re: Operator overloading

2008-01-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: If it were my choice, the plus sign would do this: def itemadd( i1, i2 ): if ( type(i1) == str ) or ( type(i2) == str ): return str(i1) + str(i2) else: return i1 + i2 I'd like to redefine it so it works my way but operator overloading

Operator overloading

2008-01-25 Thread MartinRinehart
If it were my choice, the plus sign would do this: def itemadd( i1, i2 ): if ( type(i1) == str ) or ( type(i2) == str ): return str(i1) + str(i2) else: return i1 + i2 I'd like to redefine it so it works my way but operator overloading seems strictly confined to classes I

Re: Operator overloading

2008-01-25 Thread MartinRinehart
Hexamorph wrote: You mean you want the ability to change for example the + operator for ints to something like calculating the cosine instead of doing addition? Sure. Cosines are a monadic operation and the monadic '+' is a NOP, so why shouldn't I define +45 to return cosine of 45,

operator overloading on built-ins

2007-11-08 Thread r . grimm
Hallo, could you explaint me the difference between the two following statements. Python 2.5 (r25:51908, Oct 7 2006, 23:45:05) [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. (1).__cmp__(10) -1 1.__cmp__(10) File stdin,

Re: operator overloading on built-ins

2007-11-08 Thread Steven Bethard
[EMAIL PROTECTED] wrote: (1).__cmp__(10) -1 Integer object (1) followed by method call .__cmp__(10) 1.__cmp__(10) File stdin, line 1 1.__cmp__(10) ^ SyntaxError: invalid syntax Floating point number 1. followed by __cmp__(10). STeVe --

Re: operator overloading on built-ins

2007-11-08 Thread Marc 'BlackJack' Rintsch
On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote: (1).__cmp__(10) -1 As the dot is an operator like ``+`` or ``/`` you can also add spaces to avoid the ambiguity: In [493]: 1 . __cmp__(10) Out[493]: -1 In [494]: 1 .__cmp__(10) Out[494]: -1 Ciao, Marc 'BlackJack' Rintsch --

Re: operator overloading

2007-04-05 Thread Steve Holden
[EMAIL PROTECTED] wrote: On Apr 4, 4:55 pm, Terry Reedy [EMAIL PROTECTED] wrote: Ziga Seilnacht [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | This looks like a bug in Python. It works for all the other | operators: [SNIP] | i ** 3 | 74088 | | You should submit a bug

operator overloading

2007-04-04 Thread looping
Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: class myint(int): def __pow__(self, value): return self.__add__(value) a = myint(3) a ** 3 6 OK, it works. Now I try different way to achieve the same

Re: operator overloading

2007-04-04 Thread Ziga Seilnacht
looping wrote: Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: class myint(int): def __pow__(self, value): return self.__add__(value) a = myint(3) a ** 3 6 OK, it works. Now I try

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 3:36 am, looping [EMAIL PROTECTED] wrote: Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: class myint(int): def __pow__(self, value): return self.__add__(value) a = myint(3) a ** 3

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 12:41 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 4, 3:36 am, looping [EMAIL PROTECTED] wrote: Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: class myint(int): def __pow__(self, value

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 12:41 pm, 7stud [EMAIL PROTECTED] wrote: According to Python in a Nutshell(p.102), a name that is a slot can only be bound(i.e. assigned to) inside the class body. Upon closer reading, it actually says that the name __slots__ has to be bound inside the class body for the slot

Re: operator overloading

2007-04-04 Thread Terry Reedy
Ziga Seilnacht [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | This looks like a bug in Python. It works for all the other | operators: | | class MyInt(int): | ... __sub__ = int.__add__ | ... __mul__ = int.__add__ | ... __div__ = int.__add__ | ... __truediv__ =

Re: operator overloading

2007-04-04 Thread [EMAIL PROTECTED]
On Apr 4, 4:55 pm, Terry Reedy [EMAIL PROTECTED] wrote: Ziga Seilnacht [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | This looks like a bug in Python. It works for all the other | operators: [SNIP] | i ** 3 | 74088 | | You should submit a bug report to the bug tracker: |

Re: operator overloading

2007-04-04 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | FWIW: | Python 2.5 (r25:51908, Jan 21 2007, 03:10:25) | [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on HOSTNAME_REDACTED | Type help, copyright, credits or license for more information. | class MyInt(int): | ... __pow__ = int.__add__ |

Re: operator overloading

2007-04-04 Thread Lenard Lindstrom
looping wrote: Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: class myint(int): def __pow__(self, value): return self.__add__(value) a = myint(3) a ** 3 6 OK, it works. Now I try different

Re: operator overloading + - / * = etc...

2006-10-13 Thread Piet van Oostrum
Fredrik Lundh [EMAIL PROTECTED] (FL) wrote: FL Piet van Oostrum wrote: The official Python documentation (language reference manual) talks a lot about variables. So it seems silly to say that Python doesn't have variables. FL the language reference mostly uses the term variables when

Re: operator overloading + - / * = etc...

2006-10-13 Thread Bruno Desthuilliers
Terry Reedy wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The current namespace object, of course. Implementing a namespace as a Python object (ie, dict)

Re: operator overloading + - / * = etc...

2006-10-12 Thread Bruno Desthuilliers
Georg Brandl wrote: Bruno Desthuilliers wrote: Steven D'Aprano wrote: On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you

Re: operator overloading + - / * = etc...

2006-10-12 Thread Bruno Desthuilliers
Terry Reedy wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The current namespace object, of course. Implementing a namespace as a Python object (ie, dict) is completely optional and implementation dependent. For CPython, the local namespace of a

Re: operator overloading + - / * = etc...

2006-10-12 Thread Terry Reedy
Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The current namespace object, of course. Implementing a namespace as a Python object (ie, dict) is completely

Re: operator overloading + - / * = etc...

2006-10-12 Thread OKB (not okblacke)
Terry Reedy wrote: Implementing a namespace as a Python object (ie, dict) is completely optional and implementation dependent. For CPython, the local namespace of a function is generally *not* done that way. Sure, but this is all just theoretical talk anyway, right? I would like to

Re: operator overloading + - / * = etc...

2006-10-10 Thread Theerasak Photha
On 9 Oct 2006 11:27:40 GMT, Antoon Pardon [EMAIL PROTECTED] wrote: I honestly don't see why variable would be an inappropiate word to use. AFAIU, python assignment seems to behave much like lisp and smalltalk and I never heard that those communities found the word variable inappropiate to

Re: operator overloading + - / * = etc...

2006-10-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-08 11:44:18 +0100: That's because assignment isn't an operator - that's why (for example) print x = 33 would be a syntax error. This is a deliberate design decision about which, history shows, there is little use complaining. Just to clarify: not

Re: operator overloading + - / * = etc...

2006-10-10 Thread Fredrik Lundh
Roman Neuhauser wrote: People who complain often fail to see how x = foo() while x: process(x) x = foo() is safer than while x = foo(): process(x) that's spelled: for x in foo(): process(x) in Python, or, if foo() just refuses be turned

Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes: or for the perhaps-overly-clever hackers, for x in iter(lambda: foo() or None, None): process(x) for x in takewhile(foo() for _ in repeat(None)): process (x) -- http://mail.python.org/mailman/listinfo/python-list

Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes: or for the perhaps-overly-clever hackers, for x in iter(lambda: foo() or None, None): process(x) for x in takewhile(bool, (foo() for _ in repeat(None))): process(x) Meh, both are ugly. --

Re: operator overloading + - / * = etc...

2006-10-10 Thread Antoon Pardon
On 2006-10-10, Paul Rubin http wrote: Fredrik Lundh [EMAIL PROTECTED] writes: or for the perhaps-overly-clever hackers, for x in iter(lambda: foo() or None, None): process(x) for x in takewhile(foo() for _ in repeat(None)): process (x) for x in takewhile(foo() for _ in

Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Antoon Pardon [EMAIL PROTECTED] writes: for x in takewhile(foo() for _ in repeat(None)): ... print x ... Traceback (most recent call last): File stdin, line 1, in ? TypeError: takewhile expected 2 arguments, got 1 Yeah, I cancelled and posted a followup for x in takewhile(bool,

Re: operator overloading + - / * = etc...

2006-10-10 Thread Antoon Pardon
On 2006-10-10, Paul Rubin http wrote: Fredrik Lundh [EMAIL PROTECTED] writes: or for the perhaps-overly-clever hackers, for x in iter(lambda: foo() or None, None): process(x) for x in takewhile(bool, (foo() for _ in repeat(None))): process(x) Meh, both are ugly.

Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Antoon Pardon [EMAIL PROTECTED] writes: Suppose one has the following intention in mind: while x = setup(): if y = pre_process() in ErrorCondition: break post_process(y) else: NormalTermination() Maybe we need a new itertools function: def forever(func, *args,

Re: operator overloading + - / * = etc...

2006-10-10 Thread Piet van Oostrum
Steven D'Aprano [EMAIL PROTECTED] (SD) wrote: SD Despite sloppy talk to the contrary (which I think most of us do from time SD to time), Python doesn't have variables. It has names and objects. Names SD are just labels -- there is no difference in behavior between the *names* SD

Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Piet van Oostrum [EMAIL PROTECTED] writes: The official Python documentation (language reference manual) talks a lot about variables. So it seems silly to say that Python doesn't have variables. The symbols on the left side of = signs are called variables even in Haskell, where they don't vary

Re: operator overloading + - / * = etc...

2006-10-10 Thread Fredrik Lundh
Piet van Oostrum wrote: The official Python documentation (language reference manual) talks a lot about variables. So it seems silly to say that Python doesn't have variables. the language reference mostly uses the term variables when discussing local variables and instance variables, and is

Re: operator overloading + - / * = etc...

2006-10-10 Thread Fredrik Lundh
Paul Rubin wrote: The symbols on the left side of = signs are called variables even in Haskell, where they don't vary (you can't change the value of a variable once you have set it). at the language specification level, the things to the left side of = signs are called targets in Python. if

Re: operator overloading + - / * = etc...

2006-10-10 Thread Leif K-Brooks
Paul Rubin wrote: The symbols on the left side of = signs are called variables even in Haskell, where they don't vary (you can't change the value of a variable once you have set it). FWIW, that's the original, mathematical meaning of the word 'variable'. They _do_ vary, but only when you call

Re: operator overloading + - / * = etc...

2006-10-09 Thread Antoon Pardon
On 2006-10-08, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that?

Re: operator overloading + - / * = etc...

2006-10-09 Thread Bruno Desthuilliers
Steven D'Aprano wrote: On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that? For the same reason one would

Re: operator overloading + - / * = etc...

2006-10-09 Thread Georg Brandl
Bruno Desthuilliers wrote: Steven D'Aprano wrote: On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that? For

Re: operator overloading + - / * = etc...

2006-10-09 Thread Terry Reedy
Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The current namespace object, of course. Implementing a namespace as a Python object (ie, dict) is completely optional and implementation dependent. For CPython, the local namespace of a function is generally

Re: operator overloading + - / * = etc...

2006-10-08 Thread Steve Holden
Tim Chase wrote: Can these operators be overloaded? Yes. With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. There might be some oddball way to do it via property() but AFAIK, this only

Re: operator overloading + - / * = etc...

2006-10-08 Thread SpreadTooThin
Daniel Nogradi wrote: Can these operators be overloaded? If so. How? http://www.python.org/doc/ref/numeric-types.html HTH, Daniel Thanks everyone. -- http://mail.python.org/mailman/listinfo/python-list

operator overloading + - / * = etc...

2006-10-07 Thread SpreadTooThin
Can these operators be overloaded? If so. How? -- http://mail.python.org/mailman/listinfo/python-list

Re: operator overloading + - / * = etc...

2006-10-07 Thread Sybren Stuvel
SpreadTooThin enlightened us with: Can these operators be overloaded? Yes. If so. How? Implement __add__, __sub__ etc. in the class that you want to be able to add, subtract, etc. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ --

Re: operator overloading + - / * = etc...

2006-10-07 Thread Daniel Nogradi
Can these operators be overloaded? If so. How? http://www.python.org/doc/ref/numeric-types.html HTH, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: operator overloading + - / * = etc...

2006-10-07 Thread Tim Chase
Can these operators be overloaded? Yes. With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. There might be some oddball way to do it via property() but AFAIK, this only applies to

Re: operator overloading + - / * = etc...

2006-10-07 Thread Georg Brandl
Tim Chase wrote: Can these operators be overloaded? Yes. With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. There might be some oddball way to do it via property() but AFAIK, this only

Re: operator overloading + - / * = etc...

2006-10-07 Thread Sybren Stuvel
Tim Chase enlightened us with: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that? Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ --

Re: operator overloading + - / * = etc...

2006-10-07 Thread Tim Chase
With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that? For the same reason one would use property() to create getter/setter functions for a particular variable--to

Re: operator overloading + - / * = etc...

2006-10-07 Thread Steven D'Aprano
On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: With the caveat of the = mentioned in the subject-line (being different from ==)...I haven't found any way to override assignment in the general case. Why would you want to do that? For the same reason one would use property() to

Re: Problem with operator overloading and inheritance in Python

2006-09-18 Thread Calvin Spealman
define new-style classes? - Edward Original Message Follows From: Calvin Spealman [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Edward Waugh [EMAIL PROTECTED] Subject: Re: Problem with operator overloading and inheritance in Python Date: Mon, 18 Sep 2006 17:06:53 -0400 On 9/18

Problem with operator overloading and inheritance in Python

2006-09-17 Thread Edward A. Waugh
Consider the following code: import sys class FirstClass: def __init__(self, value): self.data = ""> def __add__(self, value): return FirstClass(self.data + value) def display(self): print self.data class SecondClass(FirstClass): def __add__(self, value): # Generalized version of

Re: Problem with operator overloading and inheritance in Python

2006-09-17 Thread Calvin Spealman
On 9/17/06, Edward A. Waugh [EMAIL PROTECTED] wrote: Consider the following code: import sys class FirstClass: def __init__(self, value): self.data = value def __add__(self, value): return FirstClass(self.data + value) def display(self): print

Operator Overloading Basics

2006-08-28 Thread Mohit Bhatt
Hello, I just started out with python( couple of weeks). I have a query regarding Operator Overloading class c1: def __init__(self,value): self.data = ""> def __add__ (self,operand2): self.data += operand2 obj1 = c1(1) obj1 + 10 # this works just fine 10 +

Re: Operator Overloading Basics

2006-08-28 Thread Fredrik Lundh
Mohit Bhatt wrote: Hello, I just started out with python( couple of weeks). I have a query regarding Operator Overloading class c1: def __init__(self,value): self.data = value def __add__ (self,operand2

Re: Operator Overloading Basics

2006-08-28 Thread Tim Chase
obj1 = c1(1) obj1 + 10 # this works just fine 10 + obj1 # throws exception Q. What do I have to do to make the following line work? 10 + obj1 http://docs.python.org/ref/numeric-types.html You want to read the section on __radd__ (and it's other

RE: Operator Overloading Basics

2006-08-28 Thread Mohit Bhatt
Thanks a lot Fredrik and Tim for your help. Cheers, Mohit -- http://mail.python.org/mailman/listinfo/python-list

Operator Overloading

2005-08-01 Thread Gurpreet Sachdeva
Hi, Is there any provision in python which allows me to make my own operators? My problem is that I need to combine two dictonaries with their keys and I don't want to use any of the existing operators like '+','-','*'. So is there a way I can make '**' or '~' as my operators to add two

Re: Operator Overloading

2005-08-01 Thread Robert Kern
Gurpreet Sachdeva wrote: Hi, Is there any provision in python which allows me to make my own operators? My problem is that I need to combine two dictonaries with their keys and I don't want to use any of the existing operators like '+','-','*'. So is there a way I can make '**' or '~'

Re: Operator Overloading

2005-08-01 Thread Calvin Spealman
On 1 Aug 2005 05:12:47 -, Gurpreet Sachdeva [EMAIL PROTECTED] wrote: Hi, Is there any provision in python which allows me to make my own operators? My problem is that I need to combine two dictonaries with their keys and I don't want to use any of the existing operators like

Re: Newbie question about class operator overloading

2005-02-16 Thread Rory Campbell-Lange
Hi Steve I've been playing around with your two suggestions. The Record class is an elegant solution. It doesn't however help in the case where the class has the following general data structure (something I should have stated originally): class.config1 = param class.config2 = param

Newbie question about class operator overloading

2005-02-15 Thread Rory Campbell-Lange
Hi. I'm just starting to use python. I am anxious about how best to set and access items one level down in a data structure if I am using __setitem__ and __getitem__. At the moment I can do for a data structure Data: object.Data = { 'one' : [1, 2, {}, 4], 'two' : [5, 6,

Re: Newbie question about class operator overloading

2005-02-15 Thread Rory Campbell-Lange
Anyone out there? Criticism about the objective of my question, not just the execution, gratefully received! Basically, if I have a class This: def __init__(self, x, y): self.x=x self.y=y self.data = {} and then make all my setitem and getitem

Re: Newbie question about class operator overloading

2005-02-15 Thread Steven Bethard
Rory Campbell-Lange wrote: Hi. I'm just starting to use python. I am anxious about how best to set and access items one level down in a data structure if I am using __setitem__ and __getitem__. At the moment I can do for a data structure Data: object.Data = { 'one' : [1, 2, {}, 4],

Re: Operator Overloading

2004-11-29 Thread Bengt Richter
On 25 Nov 2004 06:35:23 -0800, [EMAIL PROTECTED] (Sebastien Boisgerault) wrote: Peter Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Sebastien Boisgerault schrieb: I wonder if the following quotation from the Python Reference Manual (release 2.3.3) about operator