ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
Re: [Jython-users] ovverride and operator?
by Nicola de Candussio other posts by this author
Oct 29 2003 3:10PM messages near this date
[Jython-users] ovverride and operator? | Re: [Jython-users] ovverride and operator?
Hi all,

thanks for your answers and examples.
I tried to override the __and__ operator on a java class and it does not 
work ... actually it works BUT only when I call the & operator and not 
the "and" .
Maybe there's a difference when dealing with Java classes ???

thanks in advance

Nicola


Kent Johnson wrote:

>  You might want to look into JNumeric, I think it provides array 
>  classes that support primitive operations 
>  http://jnumerical.sourceforge.net/
> 
>  In Jython you can and two arrays like this:
> 
> >>>  import jarray, operator
> >>>  a=jarray.array([0, 0, 1, 1], 'z')
> >>>  a
> >>
>  array([0, 0, 1, 1], boolean)
> 
> >>>  b=jarray.array([0, 1, 0, 1], 'z')
> >>>  b
> >>
>  array([0, 1, 0, 1], boolean)
> 
> >>>  map(operator.__and__, a, b)
> >>
>  [0, 0, 0, 1]
> 
>  HTH
>  Kent
> 
>  At 2:42 PM +0100 10/29/03, Diez B. Roggisch wrote:
> 
> > Am Freitag, 10. Oktober 2003 01:54 schrieb Nicola de Candussio:
> >
> >>  Hi all,
> >>
> >>  is it possible to ovveride the and operator by implementing any 
> >> specific
> >>  jyhton method ?
> >>  I would like to "and" boolean arrays  and have returned the array 
> >> of the
> >>  compared boolean elements but I could not find any documentation 
> >> about it
> >
> >
> > Radio eriwan says: It depends....
> >
> > You can overload operators in classes like this:
> >
> > class Foo:
> >   def __and__(self, rightOp):
> >     ...
> >     return result
> >
> > However, this doesn't help when you work with built in types. Maybe 
> > you can
> > create your own array-class, by overloading some other operators as 
> > well, but
> > I'm currently not sure.
> >
> > If you'd provide some more details on what you want to do, I'd come 
> > up with a
> > similar elegant solution, using some higher order functions.
> >
> > Regards,
> >
> > Diez
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SF.net Giveback Program.
> > Does SourceForge.net help you be more productive?  Does it
> > help you create better code?   SHARE THE LOVE, and help us help
> > YOU!  Click Here: http://sourceforge.net/donate/
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@[...].net
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> 
> 
> 
> 
>  -------------------------------------------------------
>  This SF.net email is sponsored by: SF.net Giveback Program.
>  Does SourceForge.net help you be more productive?  Does it
>  help you create better code?   SHARE THE LOVE, and help us help
>  YOU!  Click Here: http://sourceforge.net/donate/
>  _______________________________________________
>  Jython-users mailing list
>  Jython-users@[...].net
>  https://lists.sourceforge.net/lists/listinfo/jython-users


-- 
Nicola de Candussio
Location: Dd019, Estec/SCI-SDH
Internal extension: 56264
External Phone Number : +31 71 565 6264
www.estec.esa.nl





-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Nicola de Candussio
Nicola de Candussio
Diez B. Roggisch
Diez B. Roggisch
Kent Johnson

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved