Re: [tryton] pyson and '~'

2016-07-25 Thread Cédric Krier
On 2016-07-25 13:07, Marko Randjelovic wrote:
> But there is no mention of the '~' symbol in whole this file. How do we 
> connect this code to the '~' symbol?

Please read carefully:
https://docs.python.org/2/library/operator.html#operator.__invert__

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20160725225102.GM16698%40tetsuo.


Re: [tryton] pyson and '~'

2016-07-25 Thread Marko Randjelovic


On Monday, July 25, 2016 at 9:14:53 AM UTC+2, Sergi Almacellas Abellana 
wrote:
>
> El 23/07/16 a les 19:02, Marko Randjelovic ha escrit: 
> > 
> > 
> > On Friday, July 22, 2016 at 9:25:09 AM UTC+2, Cédric Krier wrote: 
> > 
> > On 2016-07-21 12:40, Marko Randjelovic wrote: 
> > > Of course, but in examples I have neither ~ nor Not is imported 
> from 
> > > trytond.pyson. How Python knows about new character of '~'? Also, 
> > how is 
> > > achieved possible to use ~ as an operator (there are no 
> parenthesis)? 
> > 
> > '~' is a standard python operator so it does not need to be 
> imported. 
> > See 
> > https://docs.python.org/2/library/operator.html#operator.__invert__ 
> >  
>
> > 
> > 
> > ~ is a standard operator but it's purpose is bitwise inversion. How did 
> > we make it become logical negation? 
> Because we define the __invert__ operator of every PYSON object: 
>
> http://hg.tryton.org/trytond/file/9a65b63b90f4/trytond/pyson.py#l40


But there is no mention of the '~' symbol in whole this file. How do we 
connect this code to the '~' symbol?

Regards,
Marko
 

>
>
> -- 
> Sergi Almacellas Abellana 
> www.koolpi.com 
> Twitter: @pokoli_srk 
>

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/6b116e56-629c-4fa7-a1fd-2611e4b5908c%40googlegroups.com.


Re: [tryton] pyson and '~'

2016-07-25 Thread Sergi Almacellas Abellana

El 23/07/16 a les 19:02, Marko Randjelovic ha escrit:



On Friday, July 22, 2016 at 9:25:09 AM UTC+2, Cédric Krier wrote:

On 2016-07-21 12:40, Marko Randjelovic wrote:
> Of course, but in examples I have neither ~ nor Not is imported from
> trytond.pyson. How Python knows about new character of '~'? Also,
how is
> achieved possible to use ~ as an operator (there are no parenthesis)?

'~' is a standard python operator so it does not need to be imported.
See
https://docs.python.org/2/library/operator.html#operator.__invert__



~ is a standard operator but it's purpose is bitwise inversion. How did
we make it become logical negation?

Because we define the __invert__ operator of every PYSON object:

http://hg.tryton.org/trytond/file/9a65b63b90f4/trytond/pyson.py#l40

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/9b690de2-ef0a-2711-1167-c2f41a5e4a31%40koolpi.com.


Re: [tryton] pyson and '~'

2016-07-23 Thread Marko Randjelovic


On Friday, July 22, 2016 at 9:25:09 AM UTC+2, Cédric Krier wrote:
>
> On 2016-07-21 12:40, Marko Randjelovic wrote: 
> > Of course, but in examples I have neither ~ nor Not is imported from 
> > trytond.pyson. How Python knows about new character of '~'? Also, how is 
> > achieved possible to use ~ as an operator (there are no parenthesis)? 
>
> '~' is a standard python operator so it does not need to be imported. 
> See https://docs.python.org/2/library/operator.html#operator.__invert__


~ is a standard operator but it's purpose is bitwise inversion. How did we 
make it become logical negation?
 

>
>
> -- 
> Cédric Krier - B2CK SPRL 
> Email/Jabber: cedric...@b2ck.com  
> Tel: +32 472 54 46 59 
> Website: http://www.b2ck.com/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/73a735e7-89e2-4448-b49c-39752f80d60a%40googlegroups.com.


Re: [tryton] pyson and '~'

2016-07-22 Thread Cédric Krier
On 2016-07-21 12:40, Marko Randjelovic wrote:
> Of course, but in examples I have neither ~ nor Not is imported from 
> trytond.pyson. How Python knows about new character of '~'? Also, how is 
> achieved possible to use ~ as an operator (there are no parenthesis)? 

'~' is a standard python operator so it does not need to be imported.
See https://docs.python.org/2/library/operator.html#operator.__invert__

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20160722072450.GZ6791%40tetsuo.


Re: [tryton] pyson and '~'

2016-07-21 Thread Marko Randjelovic
On Thursday, July 21, 2016 at 10:05:02 AM UTC+2, Sergi Almacellas Abellana 
wrote:
>
> El 20/07/16 a les 17:11, Marko Randjelovic ha escrit: 
> > Let us look at pyson expresson: 
> > 
> > If(~Eval('end_date', None) 
> > 
> > What is ~? Experimenting with Python interpreter, ~True is -2 and ~False 
> > is -1. I thought ~ is for negation, but -1 and -2 are not boolean values 
> > even in C they are 0 or >0. 
>
> In python ~ is the shourcut of Bitwise Inversion [1]. 
> In PySON is the shourtcut of the Not operator: So your statement means: 
>
>  > If(Not(Eval('end_date', None)) 
>
> Which I think you will understand :) 
>

Of course, but in examples I have neither ~ nor Not is imported from 
trytond.pyson. How Python knows about new character of '~'? Also, how is 
achieved possible to use ~ as an operator (there are no parenthesis)? 
 

>
> [1] 
>
> https://docs.python.org/2/library/operator.html#mapping-operators-to-functions
>  
> -- 
> Sergi Almacellas Abellana 
> www.koolpi.com 
> Twitter: @pokoli_srk 
>

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/97880cab-998b-446a-8112-159452ba72d5%40googlegroups.com.


Re: [tryton] pyson and '~'

2016-07-21 Thread Sergi Almacellas Abellana

El 20/07/16 a les 17:11, Marko Randjelovic ha escrit:

Let us look at pyson expresson:

If(~Eval('end_date', None)

What is ~? Experimenting with Python interpreter, ~True is -2 and ~False
is -1. I thought ~ is for negation, but -1 and -2 are not boolean values
even in C they are 0 or >0.


In python ~ is the shourcut of Bitwise Inversion [1].
In PySON is the shourtcut of the Not operator: So your statement means:

> If(Not(Eval('end_date', None))

Which I think you will understand :)

[1] 
https://docs.python.org/2/library/operator.html#mapping-operators-to-functions

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/c459b6c8-f66a-f17b-9bb9-9c453da3967c%40koolpi.com.


[tryton] pyson and '~'

2016-07-21 Thread Marko Randjelovic
Let us look at pyson expresson:

If(~Eval('end_date', None)

What is ~? Experimenting with Python interpreter, ~True is -2 and ~False is 
-1. I thought ~ is for negation, but -1 and -2 are not boolean values even 
in C they are 0 or >0.

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/b0d6996a-a6da-48c2-8d80-ec1f3f3c8511%40googlegroups.com.