Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Shrinivas Kulkarni
Hello Everyone

While writing python code, I frequently come across the need to do
certain tasks based on combined conditions.

Much of the task for all the sub-conditions are common but some are
specific to one or more of these sub-conditions.

A simplified example:

## Code ##
if (color == BLUE and count == 20) or (color == RED and count % 5 == 0):
rotate_the_wheel() # Common to the two sub-conditions
if(color == BLUE and count == 20): # First sub-condition
set_signal()
if(color == RED and count % 5 == 0): # Second sub-condition
clear_signal()
proc_post_rotate() # Common to the two sub-conditions

I am not sure if there is a better way to do this. If not, maybe there
can be an extension to the language, which would allow marking a
sub-condition just like we mark a sub-expression in a regular
expression.

Tentative syntax for this could be ({} marks the sub-condition and
\number refers back to it):

## Code ##
if {(color == BLUE and count == 20)} or {(color == RED and count % 5 == 0)}:
rotate_the_wheel()
if(\1): # First marked condition
set_signal()
if(\2): # Second marked condition
unset_signal()
proc_post_rotate()

And like sub-expressions, the nesting of marked sub-condions should
also be possible:

## Code ##
if {{(color == BLUE and count == 20)} and {value == 20}} or {(color ==
RED and count % 5 == 0)}:
if(\1):# Refers to the entire subcondition {{(color == BLUE and
count == 20)} and {value = 20}}
proc1()
if(\2):# Refers to sub-subcondition {value == 20}

This will not only avoid the repetition of sub-conditions, but make
code readable since something like \1 will give an immediate
indication of a sub-condition that's defined earlier.

Please let me know something similar is already implemented.
Even otherwise, all your thoughts, inputs and criticism are welcome.

Thanks and best regards
Shrinivas Kulkarni
-- 
https://mail.python.org/mailman/listinfo/python-list


EuroPython 2020: Launching the conference website

2020-03-08 Thread M.-A. Lemburg
We are very excited to announce the launch of our website for
EuroPython 2020:

 * EuroPython 2020 Website *

https://ep2020.europython.eu/


Our web WG worked hard on putting the finishing touches on the website
and many other team members helped update the content.

We have ported the accounts from last year to the new website, so you
should be able to login with last year’s details. That said, we’d
recommend changing your password as best practice.

Please note that we have also updated the profile page, so after login
you will be redirected to the profile page to make any necessary
adjustments.


More updates:
-

- The CFP will launch as planned on Monday, March 9th.

- We are also considering to open early bird sales on Wednesday, March
  11 at 12:00 CET. However, since we’re still waiting for the VAT ID
  registration, we won’t be able to produce invoices yet. Those will
  get delivered later when we have the VAT ID - much like in
  Edinburgh, where we had similar delays.

- Ticket prices are already available on the registration page. Unlike
  in previous years, we are publishing all prices at once, so that you
  can get a better overview.

- As you probably know, the Corona virus has hit Europe and we are
  closely monitoring the situation. We will publish separate blog
  posts on this topic. So far, we are hopeful that the situation will
  have calmed down by July.

- We have prepared the sponsorship packages and will announce these in
  separate blog post. Early bird sponsors will again receive a 10%
  discount on the package price. If you’re interested in becoming a
  sponsor, please contact our sponsor team at
  [email protected].


Help spread the word


Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/611955238740557824/europython-2020-launching-the-conference-website

Tweet:

https://twitter.com/europython/status/1236620559443800066


Enjoy,
--
EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Paul Moore
On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni  wrote:
>
> Hello Everyone
>
> While writing python code, I frequently come across the need to do
> certain tasks based on combined conditions.
>
> Much of the task for all the sub-conditions are common but some are
> specific to one or more of these sub-conditions.
>
> A simplified example:
>
> ## Code ##
> if (color == BLUE and count == 20) or (color == RED and count % 5 == 0):
> rotate_the_wheel() # Common to the two sub-conditions
> if(color == BLUE and count == 20): # First sub-condition
> set_signal()
> if(color == RED and count % 5 == 0): # Second sub-condition
> clear_signal()
> proc_post_rotate() # Common to the two sub-conditions
>
> I am not sure if there is a better way to do this. If not, maybe there
> can be an extension to the language, which would allow marking a
> sub-condition just like we mark a sub-expression in a regular
> expression.

I would have thought that simply naming the sub-conditions would be sufficient.

blue_20 = (color == BLUE and count == 20)
red_5 = (color == RED and count % 5 == 0)
if blue_20 or red_5:
rotate_the_wheel() # Common to the two sub-conditions
if blue_20: # First sub-condition
set_signal()
if red_5: # Second sub-condition
clear_signal()
proc_post_rotate() # Common to the two sub-conditions

I don't know how experienced you are with Python programming, but if
you had framed your question as "how do I modify this code to avoid
repeating the conditions?" you would likely have been given this
advice on the python-list mailinglist, or other similar Python
programming help resources.

Starting with a proposed language change before you've explored the
existing options isn't likely to be the best approach (and would
likely have meant you could resolve your issue without needing to
bring it to python-ideas at all).

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread MRAB

On 2020-03-08 10:05, Shrinivas Kulkarni wrote:

Hello Everyone

While writing python code, I frequently come across the need to do
certain tasks based on combined conditions.

Much of the task for all the sub-conditions are common but some are
specific to one or more of these sub-conditions.

A simplified example:

## Code ##
if (color == BLUE and count == 20) or (color == RED and count % 5 == 0):
 rotate_the_wheel() # Common to the two sub-conditions
 if(color == BLUE and count == 20): # First sub-condition
 set_signal()
 if(color == RED and count % 5 == 0): # Second sub-condition
 clear_signal()
 proc_post_rotate() # Common to the two sub-conditions

I am not sure if there is a better way to do this. If not, maybe there
can be an extension to the language, which would allow marking a
sub-condition just like we mark a sub-expression in a regular
expression.

Tentative syntax for this could be ({} marks the sub-condition and
\number refers back to it):

## Code ##
if {(color == BLUE and count == 20)} or {(color == RED and count % 5 == 0)}:
 rotate_the_wheel()
 if(\1): # First marked condition
 set_signal()
 if(\2): # Second marked condition
 unset_signal()
 proc_post_rotate()


An expression { ... } is already defined as a set.


And like sub-expressions, the nesting of marked sub-condions should
also be possible:

## Code ##
if {{(color == BLUE and count == 20)} and {value == 20}} or {(color ==
RED and count % 5 == 0)}:
 if(\1):# Refers to the entire subcondition {{(color == BLUE and
count == 20)} and {value = 20}}
 proc1()
 if(\2):# Refers to sub-subcondition {value == 20}

This will not only avoid the repetition of sub-conditions, but make
code readable since something like \1 will give an immediate
indication of a sub-condition that's defined earlier.

Please let me know something similar is already implemented.
Even otherwise, all your thoughts, inputs and criticism are welcome.

In Python 3.8+ there's the "walrus operator" which lets you assign 
within an expression:


if (first := (color == BLUE and count == 20)) or (second := (color == 
RED and count % 5 == 0)):

rotate_the_wheel()
if first:
set_signal()
if second:
unset_signal()
 proc_post_rotate()

However, this has the problem that if the first subexpression is true, 
the second will not be evaluated, so 'second' would not be set.


The simplest and clearest solution is just to write:

first = color == BLUE and count == 20
second = color == RED and count % 5 == 0
if first or second:
rotate_the_wheel()
if first:
set_signal()
if second:
unset_signal()
 proc_post_rotate()
--
https://mail.python.org/mailman/listinfo/python-list


Re: EuroPython 2020: Launching the conference website

2020-03-08 Thread Souvik Dutta
I have a suggestion. It would be better if you could have made a packaging
software that could package not only the dependencies but also the python
interpreter so that we could just plug and play the application in a
computer that does not has a python interpreter pre installed. The
installer that would be the final product could also check if there is any
pre installed python interpreter so we don't just end up having lots of
python interpreters at the same time. Thank you

On Sun, 8 Mar, 2020, 8:34 pm M.-A. Lemburg,  wrote:

> We are very excited to announce the launch of our website for
> EuroPython 2020:
>
>  * EuroPython 2020 Website *
>
> https://ep2020.europython.eu/
>
>
> Our web WG worked hard on putting the finishing touches on the website
> and many other team members helped update the content.
>
> We have ported the accounts from last year to the new website, so you
> should be able to login with last year’s details. That said, we’d
> recommend changing your password as best practice.
>
> Please note that we have also updated the profile page, so after login
> you will be redirected to the profile page to make any necessary
> adjustments.
>
>
> More updates:
> -
>
> - The CFP will launch as planned on Monday, March 9th.
>
> - We are also considering to open early bird sales on Wednesday, March
>   11 at 12:00 CET. However, since we’re still waiting for the VAT ID
>   registration, we won’t be able to produce invoices yet. Those will
>   get delivered later when we have the VAT ID - much like in
>   Edinburgh, where we had similar delays.
>
> - Ticket prices are already available on the registration page. Unlike
>   in previous years, we are publishing all prices at once, so that you
>   can get a better overview.
>
> - As you probably know, the Corona virus has hit Europe and we are
>   closely monitoring the situation. We will publish separate blog
>   posts on this topic. So far, we are hopeful that the situation will
>   have calmed down by July.
>
> - We have prepared the sponsorship packages and will announce these in
>   separate blog post. Early bird sponsors will again receive a 10%
>   discount on the package price. If you’re interested in becoming a
>   sponsor, please contact our sponsor team at
>   [email protected].
>
>
> Help spread the word
> 
>
> Please help us spread this message by sharing it on your social
> networks as widely as possible. Thank you !
>
> Link to the blog post:
>
>
> https://blog.europython.eu/post/611955238740557824/europython-2020-launching-the-conference-website
>
> Tweet:
>
> https://twitter.com/europython/status/1236620559443800066
>
>
> Enjoy,
> --
> EuroPython 2020 Team
> https://ep2020.europython.eu/
> https://www.europython-society.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread DL Neil via Python-list

On 8/03/20 11:05 PM, Shrinivas Kulkarni wrote:

Hello Everyone

While writing python code, I frequently come across the need to do
certain tasks based on combined conditions.

Much of the task for all the sub-conditions are common but some are
specific to one or more of these sub-conditions.


The specification is incomplete.

In a real-time system, one has to decide whether the cascade of 
decisions is to be taken with a single set of data taken at a single 
point-in-time (suggestions for which appear in earlier replies), *or* if 
the nature of the system requires that the values within the 
sub-conditions might change between the various stages of the 
program(me). In which case, there would be no alternative to taking 
multiple samples from the signal-sources, as-and-when required.


Either way, Python is capable of handling the situation.

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to POST html data to be handled by a route endpoint

2020-03-08 Thread DL Neil via Python-list

On 8/03/20 8:47 AM, Richard Damon wrote:

On 3/7/20 5:15 AM, Νίκος Βέργος wrote:

When superhost.gr/test tries to post html form data to the route endpoint 
'/mailform' it sends it to superhost.gr/mailform and NOT at 
superhost.gr/test/mailform as it should have done.


The HTML path /mailform means server relative path, so the path is
relative to the SERVER, not the current page, so it would be
superhost.gr/mailform

The other format goes through a function which might re-interpret the
path and either make it page relative or add in the path of the current
page to get to /test/mailform


+1

May I recommend two techniques:

1 before using a URL from Python, check what happens in your favorite 
web browser (with exactly the same values - not what you might 
think/expect as an expansion). This helps narrow-down the problem 
between the two choices (in this case) - the language or the web-server.


2 use your logging system for testing/debugging, ie build-in logging 
'early' rather than retro-fitting it to a newly-working system (as seems 
to be the habit amongst some of my colleagues). Thus, a glance at the 
log would tell you the *exact* URL that Python has attempted to use - 
and likely, much more besides...
(remember that the logging library has 'levels' of logging, eg DEBUG, 
built-in and available to you 'for free'; so encoding it 'earlier' 
rather than 'later' also gives you debug-print-style intelligence for-free!)

Remember also, to configure the web server to provide similarly...

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Terry Reedy

On 3/8/2020 12:07 PM, MRAB wrote:

In Python 3.8+ there's the "walrus operator" which lets you assign 
within an expression:


if (first := (color == BLUE and count == 20)) or (second := (color == 
RED and count % 5 == 0)):

     rotate_the_wheel()
     if first:
     set_signal()
     if second:
     unset_signal()
  proc_post_rotate()

However, this has the problem that if the first subexpression is true, 
the second will not be evaluated, so 'second' would not be set.


One can use '|' instead of 'or' to force evaluation of the second.

>>> if (first := True) | (second := False):
second

False


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python question

2020-03-08 Thread Peter J. Holzer
On 2020-03-05 20:49:14 -0800, Mr. Lee Chiffre wrote:
> > 2. he does not trust binaries from pip.
> 
> What is the point of open source if you cannot compile from source code?

You can get the source code from pypi. I don't see any option for pip to
do that, but you can easily do it manually.

If you don't trust the binaries from pypi, don't trust the source code
either! Malware has been found on npm, for example. So to be sure there
are no backdoors you have to (carefully) read the source of each module
you use (which makes the time for downloading them manually trivial).

Oh, and you have read "Reflections on Trusting Trust", I presume?


> Not unusual. People use open source because they dont trust closed source.
> Binaries that someone else compiled is not open source.

It's still open source if the source is available (under the usual
conditions). Whether you trust somebody else to compile the software is
a question of trust, not of openness. Do you trust the person who
compiled your compiler?

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | [email protected] |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list