On Fri, Jun 1, 2012 at 9:39 AM, Josh Benner 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 my
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
On 2/6/2012 12:48 AM, Mohsen Pahlevanzadeh wrote:
Dear all,
You know python has many functions for operators overloading such as
__add__, __radd__, __invert__, __eq__ and so on.
How i see the complete list of them with help function?
>>> import operator
>>> help(operator
On Sun, Feb 5, 2012 at 9:48 PM, Mohsen Pahlevanzadeh
wrote:
> Dear all,
>
> You know python has many functions for operators overloading such as
> __add__, __radd__, __invert__, __eq__ and so on.
> How i see the complete list of them with help function?
I don't know if there&
Dear all,
You know python has many functions for operators overloading such as
__add__, __radd__, __invert__, __eq__ and so on.
How i see the complete list of them with help function?
Yours,
Mohsen
signature.asc
Description: This is a digitally signed message part
--
http://mail.python.org
On Fri, Sep 30, 2011 at 09:50:42PM -0700, Fletcher Johnson wrote:
> Is it possible to overload operators for a function?
>
> For instance I would like to do something roughly like...
>
> def func_maker():
> def func(): pass
>
> def __eq__(other):
> if other == "check": return True
>
On Fri, Sep 30, 2011 at 9:50 PM, Fletcher Johnson wrote:
> Is it possible to overload operators for a function?
>
> For instance I would like to do something roughly like...
>
> def func_maker():
> def func(): pass
>
> def __eq__(other):
> if other == "check": return True
> return False
>
Is it possible to overload operators for a function?
For instance I would like to do something roughly like...
def func_maker():
def func(): pass
def __eq__(other):
if other == "check": return True
return False
func.__eq__ = __eq__
return func
newfunc = func_maker()
newfunc ==
On 6/24/2011 2:01 PM, anand jeyahar wrote:
Not sure, this is the right place, redirect me if it's not.
I was curious about the
functionoverloading(http://svn.python.org/view/sandbox/trunk/overload/)
and was trying to do a svn checkout of the branch and failed. Is it
restricted access for even ch
Not sure, this is the right place, redirect me if it's not.
I was curious about the functionoverloading(
http://svn.python.org/view/sandbox/trunk/overload/) and was trying to do a
svn checkout of the branch and failed. Is it restricted access for even
checkout? How do i get read-only access?
On Oct 25, 12:57 pm, Brendan wrote:
> I am posting here in the hopes the author of java2python will see it.
> Does j2py handle overloading of the __init__ constructor? For me it
> is calling __init__ and not calling the decorator overloaded __init__0.
Never mind. Moronic type mistake.
I am posting here in the hopes the author of java2python will see it.
Does j2py handle overloading of the __init__ constructor? For me it
is calling __init__ and not calling the decorator overloaded __init__0.
--
http://mail.python.org/mailman/listinfo/python-list
Am 27.02.2010 10:00, schrieb alex23:
Michael Rudolf wrote:
In Java, Method Overloading is my best friend
Guido wrote a nice article[1] on "multimethods" using decorators,
which Ian Bicking followed up on[2] with a non-global approach.
1: http://www.artima.com/weblogs/viewpost.
Michael Rudolf wrote:
> In Java, Method Overloading is my best friend
Guido wrote a nice article[1] on "multimethods" using decorators,
which Ian Bicking followed up on[2] with a non-global approach.
1: http://www.artima.com/weblogs/viewpost.jsp?thread=101605
2: http://blog.ianbic
Michael Rudolf a écrit :
(snip)
(pseudocode - this is *not* python ;)
class Machines (Object):
@classmethod
def shutdown(cls, Machine, emergency=False):
try:
if Machine is instanceof(Fileservers):
if not emergency:
Machine.unmount_raid_first
Machine.powerswitch.Off()
@classmethod
def emergency(cls):
for machine in cls.instances:
cls.shutdown(machine, 1)
Other design patterns might me good too, but I like the idea of having
emergency protocols in *one* place here. But without m
t has its advantages: 1
docstring,
1 way do do it, 1 interface.
Yes, I see. Actually I do now realize that even in Java I use method
overloading mostly to implement optional arguments anyway, like:
void constructor(){this.foo='foo'; this.initotherstuff();}
void construct
ng,
1 way do do it, 1 interface.
Yes, I see. Actually I do now realize that even in Java I use method
overloading mostly to implement optional arguments anyway, like:
void constructor(){this.foo='foo'; this.initotherstuff();}
void constructor(int x) {this.x=x; this.constructor();}
and
1 way do do it, 1 interface.
Yes, I see. Actually I do now realize that even in Java I use method
overloading mostly to implement optional arguments anyway, like:
void constructor(){this.foo='foo'; this.initotherstuff();}
void constructor(int x) {this.x=x; this.constructor();}
and so
interface.
Yes, I see. Actually I do now realize that even in Java I use method
overloading mostly to implement optional arguments anyway, like:
void constructor(){this.foo='foo'; this.initotherstuff();}
void constructor(int x) {this.x=x; this.constructor();}
and so on.
So most of
Michael Rudolf wrote:
Just a quick question about what would be the most pythonic approach
in this.
In Java, Method Overloading is my best friend, but this won't work in
Python:
>>> def a():
pass
>>> def a(x):
pass
>>> a()
Traceback (most recent c
On 02/24/10 05:25, Michael Rudolf wrote:
> Just a quick question about what would be the most pythonic approach in
> this.
>
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
> So - What would be the most pythonic way to emulate this?
>
Michael Rudolf writes:
> Just a quick question about what would be the most pythonic approach
> in this.
>
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
>
>>>> def a():
> pass
>>>> def a(x):
>
On 2/23/2010 1:25 PM, Michael Rudolf wrote:
Just a quick question about what would be the most pythonic approach in
this.
In Java, Method Overloading is my best friend, but this won't work in
Python:
>>> def a():
pass
>>> def a(x):
pass
>>> a()
Traceba
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
>
> >>> def a():
> pass
> >>> def a(x):
> pass
> >>> a()
> Traceback (most recent call last):
>File "", line 1, in
>
Just a quick question about what would be the most pythonic approach in
this.
In Java, Method Overloading is my best friend, but this won't work in
Python:
>>> def a():
pass
>>> def a(x):
pass
>>> a()
Traceback (most recent call last):
File &
Chris Rebert wrote:
On Tue, Jan 20, 2009 at 10:18 AM, MRAB wrote:
K-Dawg wrote:
Can you overload methods in Python?
Can I have multiple __inits__ with different parameters passed in?
Simple answer: no.
More complicated answer: Yes, with some caveats.
You usually don't need to overload me
>
> class Foo(object):
> def __init__(self, a, b=10, c=None):
>
> Whereas in Java or C++ this would require several overloads, it can be
> succinctly expressed as a single method in Python.
>
Not that it's important to the discussion, but, while Java does not
have the capability to give defau
(top-posting just for consistency)
In that case, you might also be interested in:
http://dirtsimple.org/2004/12/python-is-not-java.html
Cheers,
Chris
On Tue, Jan 20, 2009 at 12:19 PM, K-Dawg wrote:
> Thank you for the explanation. With my background in Java, I have to get
> myself to think a l
Thank you for the explanation. With my background in Java, I have to get
myself to think a little differently.
Kevin
On Tue, Jan 20, 2009 at 1:41 PM, Chris Rebert wrote:
> On Tue, Jan 20, 2009 at 10:18 AM, MRAB wrote:
> > K-Dawg wrote:
> >>
> >> Can you overload methods in Python?
> >>
> >> C
On Tue, Jan 20, 2009 at 10:18 AM, MRAB wrote:
> K-Dawg wrote:
>>
>> Can you overload methods in Python?
>>
>> Can I have multiple __inits__ with different parameters passed in?
>>
> Simple answer: no.
More complicated answer: Yes, with some caveats.
You usually don't need to overload methods in
K-Dawg wrote:
Can you overload methods in Python?
Can I have multiple __inits__ with different parameters passed in?
Simple answer: no.
--
http://mail.python.org/mailman/listinfo/python-list
Can you overload methods in Python?
Can I have multiple __inits__ with different parameters passed in?
Thanks.
Kevin
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 8, 2008, at 2:48 AM, Gabriel Genellina wrote:
En Wed, 03 Dec 2008 02:29:32 -0200, Philip Semanchuk
<[EMAIL PROTECTED]> escribió:
On Dec 2, 2008, at 11:21 PM, [EMAIL PROTECTED] wrote:
Is there a cross-platform way to launch multiple Python processes
and monitor CPU usage
os.getload
En Wed, 03 Dec 2008 02:29:32 -0200, Philip Semanchuk
<[EMAIL PROTECTED]> escribió:
On Dec 2, 2008, at 11:21 PM, [EMAIL PROTECTED] wrote:
Is there a cross-platform way to launch multiple Python processes
and monitor CPU usage
os.getloadavg() might be useful. It certainly works on *nix, don't
imitations.
HTH
Philip
and disk i/o so that the maximum number of
independent processes can be running at all times without
overloading their environment? By process I mean independent
application sessions vs. multiple threads of a single
application. I'm looking for suggestions on what
Is there a cross-platform way to launch multiple Python processes
and monitor CPU usage and disk i/o so that the maximum number of
independent processes can be running at all times without
overloading their environment? By process I mean independent
application sessions vs. multiple threads of a
y thought was that this might be able to be completed via
> overloading, but I am not sure if (or how) it could be done.
>
> overloadings:
> + ==> OR
> * ==> AND
> / ==> NOT
>
> Example original code:
> A=/B+C*D
> translates to:
> A=not B
cation
> step. My thought was that this might be able to be completed via
> overloading, but I am not sure if (or how) it could be done.
>
> overloadings:
>+ ==> OR
>* ==> AND
>/ ==> NOT
>
> Example original code:
> A=/B+C*D
> tran
y thought was that this might be able to be completed via
> overloading, but I am not sure if (or how) it could be done.
>
> overloadings:
> + ==> OR
> * ==> AND
> / ==> NOT
>
> Example original code:
> A=/B+C*D
> translates to:
> A=not B
I am trying to simulate the execution of some PLC ladder logic in
python.
I manually modified the rungs and executed this within python as a
proof of concept, but I'd like to be able to skip the modification
step. My thought was that this might be able to be completed via
overloading, but
On Thu, Oct 16, 2008 at 10:54 PM, Lie Ryan <[EMAIL PROTECTED]> wrote:
> On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Something that is more pythonic is something that doesn't use
> multimethods. It's just an elaborated way to do type checking. In python,
> you usually avoid type checking a
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I defined.
>
>
> What is the best way to do this? Shall I use a lot of "if...e
Thanks for the suggestion. I think I'm gonna try the multimethods way,
that I didn't know about it.
--
http://mail.python.org/mailman/listinfo/python-list
On 15 Okt., 14:34, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator dep
On Oct 15, 7:34 am, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator dep
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I defined.
>
> Sometimes I need a different behavior of the operator depending on
On Oct 15, 7:34 am, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator dep
Hi,
in a project I'm overloading a lot of comparison and arithmetic
operators to make them working with more complex classes that I
defined.
Sometimes I need a different behavior of the operator depending on the
argument. For example, if I compare a object with an int, I get a
result, but
On Aug 24, 6:15 pm, Hussein B <[EMAIL PROTECTED]> wrote:
> Please correct me if I'm wrong but Python doesn't support method
> overload, right?
Guido once wrote an article on rolling your own:
http://www.artima.com/weblogs/viewpost.jsp?thread=101605
--
http://mail.python.org/mailman/listinfo/pyth
Hussein B wrote:
Please correct me if I'm wrong but Python doesn't support method
overload, right?
--
def method(self):
#code
def method(self, data):
#code
--
The last declaration of method() erase the previous one (like
JavaScript).
in Python, methods are callable attributes, and an attribu
On Aug 24, 6:15 pm, Hussein B <[EMAIL PROTECTED]> wrote:
> Hey,
> Please correct me if I'm wrong but Python doesn't support method
> overload, right?
> --
> def method(self):
> #code
> def method(self, data):
> #code
> --
> The last declaration of method() erase the previous one (like
> JavaScrip
Hey,
Please correct me if I'm wrong but Python doesn't support method
overload, right?
--
def method(self):
#code
def method(self, data):
#code
--
The last declaration of method() erase the previous one (like
JavaScript).
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
> I have a feeling that the form produced by Qt Designer, once converted to
> code, contains references to QCalendarWidget where you really want to use a
> customized calendar widget. If so, you should "promote" the calendar widget
> in Qt Designer to use your widget instead, and make sure you impo
> }
>
> I can't find how I can do similar thing in Python without inheriting
> QCalendarWidget and overloading this method in inherited class (it's
> long and I must create additional class). The only thing I done its
> full replacement of handler:
>
> calendar.pai
En Thu, 22 May 2008 20:38:39 -0300, Andreas Matthias <[EMAIL PROTECTED]>
escribió:
> [EMAIL PROTECTED] wrote:
>
>> actually i ddin't think about the fact that you're overloading dict, which
>> can already take multiple values in getitem
>
> Oh, I didn
> Apparently, args already is a tuple, so this should be:
>
> def __getitem__(self, args):
>
> Is this documented somewhere? I couldn't find it anywhere.
>
Don't know, I just assumed it would take multiple arguments because I knew I
had seen the form d[1,2] before, which incidentally is equival
[EMAIL PROTECTED] wrote:
> actually i ddin't think about the fact that you're overloading dict, which
> can already take multiple values in getitem
Oh, I didn't know that. I totally misinterpreted the error message.
> so how about
>
> class crazy: pass
&g
actually i ddin't think about the fact that you're overloading dict, which
can already take multiple values in getitem
so how about
class crazy: pass
and then in your dict class:
def __getitem__(*args):
if args[-1] is crazy:
return self.get(args[:-1])*5
else:
return sel
"inhahe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> crazy = True
> print foo['a',crazy]
>
just to clarify, you could use it like:
crazy = "I'm crazy" #this only has to be done once
print foo['a'] #not crazy
print foo['a',crazy] #crazy
(this may be totally unPythonic
it seems like you can't do it exactly the way you're trying but you could do
this
def __getitem__(*args):
if len(args) > 1 and args[1]: return self.get(args[0]) * 5
return self.get(args[0])
then you would use it like
print foo['a']
print foo['a',True]
or even
print foo['a',"crazy"]
if you
The following code doesn't run but I hope you get what I
am trying to do.
class my_dict (dict):
def __getitem__ (self, key, crazy = False):
if crazy == True:
return 5 * self.get(key)
else:
return self.get(key)
foo = my_dict()
foo['a'] = 123
print fo
On Apr 1, 2:22 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> >> Surely an A isn't equal to every other object which just happens to
> >> have the same attributes 'a' and 'b'?
>
> > And why not ?-)
>
> >> I would have thoughts the tests want to be
> >
Duncan Booth a écrit :
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>>> Surely an A isn't equal to every other object which just happens to
>>> have the same attributes 'a' and 'b'?
>> And why not ?-)
>>
>>> I would have thoughts the tests want to be
>>> something like:
>>>
>>> class A:
>>>
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>> Surely an A isn't equal to every other object which just happens to
>> have the same attributes 'a' and 'b'?
>
> And why not ?-)
>
>> I would have thoughts the tests want to be
>> something like:
>>
>> class A:
>> def __eq__(self,other):
>>
On Mar 31, 5:03 pm, gigs <[EMAIL PROTECTED]> wrote:
> Raj Bandyopadhyay wrote:
> > Hi
>
> > Here's a simple class example I've defined
>
> > #
> > class myInt(int):
> >def __add__(self,other):
> > return 0
>
> > print 5 + myInt(4) #prints 9
> > print myInt(4)
Raj Bandyopadhyay wrote:
> Hi
>
> Here's a simple class example I've defined
>
> #
> class myInt(int):
>def __add__(self,other):
> return 0
>
> print 5 + myInt(4) #prints 9
> print myInt(4) + 5 #prints 0
> #
>
> The Python bi
Hi
Here's a simple class example I've defined
#
class myInt(int):
def __add__(self,other):
return 0
print 5 + myInt(4) #prints 9
print myInt(4) + 5 #prints 0
#
The Python binary operation function (binary_op1() in
Objects/a
On Mar 31, 3:42 pm, Amit Gupta <[EMAIL PROTECTED]> wrote:
> On Mar 31, 11:00 am, xkenneth <[EMAIL PROTECTED]> wrote:
>
> > Yeah, this is what I'm talking about:
>
> > > def __eq__(self, other) :
> > > try :
> > > return <>
> > > except AttributeError:
> > > return False
>
> > That see
On Mar 31, 11:00 am, xkenneth <[EMAIL PROTECTED]> wrote:
> Yeah, this is what I'm talking about:
>
> > def __eq__(self, other) :
> > try :
> > return <>
> > except AttributeError:
> > return False
>
> That seems a bit nasty to me.
One thing about python (IMO); you can't just say this
On 31 mar, 20:09, Duncan Booth <[EMAIL PROTECTED]> wrote:
> xkenneth <[EMAIL PROTECTED]> wrote:
> > Now obviously, if I test an instance of either class equal to each
> > other, an attribute error will be thrown, how do I handle this? I
> > could rewrite every __eq__ function and catch attribute er
On Mar 31, 1:23 pm, xkenneth <[EMAIL PROTECTED]> wrote:
> So i generally write quite a few classes, and in most I need to
> overload the == operator.
>
> If i have two classes, like below:
>
> Class A:
> attribute a
> attribute b
>
> Class B:
> attribute a
> attribute c
>
> So if I've overloaded th
xkenneth <[EMAIL PROTECTED]> wrote:
> Now obviously, if I test an instance of either class equal to each
> other, an attribute error will be thrown, how do I handle this? I
> could rewrite every __eq__ function and catch attribute errors, but
> that's tedious, and seemingly unpythonic. Also, I don
Yeah, this is what I'm talking about:
> def __eq__(self, other) :
> try :
> return <>
> except AttributeError:
> return False
That seems a bit nasty to me.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 31 Mar 2008 10:23:24 -0700 (PDT), xkenneth <[EMAIL PROTECTED]> wrote:
>So i generally write quite a few classes, and in most I need to
>overload the == operator.
>
>If i have two classes, like below:
>
>Class A:
>attribute a
>attribute b
>
>Class B:
>attribute a
>attribute c
>
>So if I've o
On Mar 31, 10:23 am, xkenneth <[EMAIL PROTECTED]> wrote:
>
> class A:
> def __eq__(self,other):
> return self.a == other.a and self.b == other.b
>
> class B:
> def __eq__(self,other):
> return self.a == other.a and self.c == other.c
>
> Thanks!
>
> Regards,
> Kenneth Mille
So i generally write quite a few classes, and in most I need to
overload the == operator.
If i have two classes, like below:
Class A:
attribute a
attribute b
Class B:
attribute a
attribute c
So if I've overloaded their respective __eq__ functions, and I want to
test whether or not the individua
On Feb 25, 11:04 am, [EMAIL PROTECTED] wrote:
> > B1.fun(A(x), A(y), A(z)) == B.fun(A(x), A(y), A(z))
> > but
> > B1.fun(A1(x), A(y), A(z) != B.fun(A1(x), A(y), A(z))
>
> > Is there a data-structure solution or third party module that would
> > mimic this behavior?
>
> class B:
> xfun= Overloade
> B1.fun(A(x), A(y), A(z)) == B.fun(A(x), A(y), A(z))
> but
> B1.fun(A1(x), A(y), A(z) != B.fun(A1(x), A(y), A(z))
>
> Is there a data-structure solution or third party module that would
> mimic this behavior?
'''
An Overloaded instance, B.xfun, is created in the base class of the
classes the memb
On Feb 25, 1:33 am, Allen Peloquin <[EMAIL PROTECTED]> wrote:
> I have a personal project that has an elegant solution that requires
> both true multiple inheritance of classes (which pretty much limits my
> language choices to C++ and Python) and type-based function
> overloadi
On Feb 25, 2:33 am, Allen Peloquin <[EMAIL PROTECTED]> wrote:
> I have a personal project that has an elegant solution that requires
> both true multiple inheritance of classes (which pretty much limits my
> language choices to C++ and Python) and type-based function
> overloadi
Stefan Behnel schrieb:
> Allen Peloquin wrote:
>> On Feb 24, 11:44 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>>> Allen Peloquin wrote:
class B
{
fun(A x, A y, A z)...
fun(A1 x, A y, A z)...
}
class B1
{
fun(A1 x, A y, A z)...
}
Such t
Allen Peloquin a écrit :
> I have a personal project that has an elegant solution that requires
> both true multiple inheritance of classes (which pretty much limits my
> language choices to C++ and Python) and type-based function
> overloading.
>
> Now, while this makes it so
Allen Peloquin wrote:
> On Feb 24, 11:44 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>> Allen Peloquin wrote:
>>> class B
>>> {
>>> fun(A x, A y, A z)...
>>> fun(A1 x, A y, A z)...
>>> }
>>> class B1
>>> {
>>> fun(A1 x, A y, A z)...
>>> }
>>> Such that any previous behavior is inherite
Allen Peloquin <[EMAIL PROTECTED]> writes:
> I have a personal project that has an elegant solution that requires
> both true multiple inheritance of classes (which pretty much limits my
> language choices to C++ and Python) and type-based function
> overloading.
>
Com
(x,y,z)
> # ...
>
> def _fun(x,y,z):
> # ...
>
> class B1(B):
> def _fun(x,y,z):
> # ...
>
> Stefan
The problem is that I want to reuse the code of the parent classes
through inheritance, otherwise this would work fine.
I am aware that because
Stefan Behnel wrote:
> Allen Peloquin wrote:
>> class B
>> {
>> fun(A x, A y, A z)...
>> fun(A1 x, A y, A z)...
>> }
>>
>> class B1
>> {
>> fun(A1 x, A y, A z)...
>> }
>>
>> Such that any previous behavior is inherited, but behaves
>> polymorphically because of the single function name.
Allen Peloquin wrote:
> class B
> {
> fun(A x, A y, A z)...
> fun(A1 x, A y, A z)...
> }
>
> class B1
> {
> fun(A1 x, A y, A z)...
> }
>
> Such that any previous behavior is inherited, but behaves
> polymorphically because of the single function name.
Try something like this:
class
I have a personal project that has an elegant solution that requires
both true multiple inheritance of classes (which pretty much limits my
language choices to C++ and Python) and type-based function
overloading.
Now, while this makes it sound like I have to resign myself to C++,
which I am not a
| > > 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 c
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
[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 defin
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, (presum
[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, e
[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,
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 worki
so it works my way but operator overloading
> seems strictly confined to classes I create. Is there a way? Or do I
> just have to grump, "Even a kludge like Perl ..."?
>
No, there is no way. You would change general interpreter behavior if
you could set arbitrary operators for
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 clas
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
--
htt
[EMAIL PROTECTED] wrote:
(1).__cmp__(10)
> -1
Integer object "(1)" followed by method call ".__cmp__(10)"
1.__cmp__(10)
> File "", line 1
> 1.__cmp__(10)
> ^
> SyntaxError: invalid syntax
Floating point number "1." followed by "__cmp__(10)".
STeVe
--
http://mail.pyt
1 - 100 of 314 matches
Mail list logo