[Python-announce] Pyparsing 3.1.0b2 released (final beta!)

2023-05-20 Thread Paul McGuire
I just pushed release 3.1.0b2 of pyparsing. 3.1.0 with some fixes to bugs that 
came up in the past few weeks - testing works!

If your project uses pyparsing, please please *please* download this beta 
release (using "pip install -U pyparsing==3.1.0b2") and open any compatibility 
issues you might have at the pyparsing GitHub repo 
(https://github.com/pyparsing/pyparsing).

In the absence of any dealbreakers, I'll make the final release in June.

You can view the changes here: 
https://github.com/pyparsing/pyparsing/blob/master/CHANGES
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


Re: Addition of a .= operator

2023-05-20 Thread Greg Ewing via Python-list

On 21/05/23 9:18 am, Richard Damon wrote:
This just can't happen (as far as I can figure) for .= unless the object 
is defining something weird for the inplace version of the operation, 


Indeed. There are clear use cases for overriding +=, but it's hard to
think of one for this. So it would just be syntactic sugar, which is
harder to justify.

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


Re: Addition of a .= operator

2023-05-20 Thread Greg Ewing via Python-list

On 21/05/23 5:54 am, Alex Jando wrote:


hash.=hexdigest()


That would be a very strange and unprecedented syntax that
munges together an attribute lookup and a call.

Keep in mind that a method call in Python is actually two
separate things:

y = x.m()

is equivalent to

f = x.m
y = f()

But it would not be possible to break down your .= syntax
in that way.

Another oddity is that these are equivalent:

x += y
x += (y)

i.e. the RHS is evaluated as usual before doing the +=.

But these would not be equivalent:

hash .= hexdigest()
hash .= (hexdigest())

In fact the latter would probably have to be disallowed, as it's
not at all clear what it should mean.

--
Greg

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


Re: Addition of a .= operator

2023-05-20 Thread Richard Damon

On 5/20/23 4:15 PM, Peter J. Holzer wrote:

On 2023-05-20 10:54:59 -0700, Alex Jando wrote:

I have many times had situations where I had a variable of a certain
type, all I cared about it was one of it's methods.

For example:


hash = hash.hexdigest()

num = num.value


So what I'm suggesting is something like this:


hash.=hexdigest()

num.=value


I actually needed to read those twice to get their meaning. I think

hash .= hexdigest()
num .= value

would have been clearer (yes, I nag my colleagues about white-space,
too).

Do you have any examples (preferably from real code) where you don't
assign to a simple variable? I feel that
 x += 1
isn't much of an improvement over
 x = x + 1
but
 self.data[line+len(chars)-1] += after
is definitely an improvement over
 self.data[line+len(chars)-1] + self.data[line+len(chars)-1] + after

 hp


For immutable types, it is just syntactic sugar, but for mutable type 
there is an important difference



x = []

y = x

x += [1]

changes the list named by y, but

x = []

y = x

x = x + []

does not.


The key is that if a type actually implements the inplace operator, then 
using the op= version doesn't bind the name to a new object but mutates 
the object to a new value.


This just can't happen (as far as I can figure) for .= unless the object 
is defining something weird for the inplace version of the operation, 
which is probably best to not actually allow.


--
Richard Damon

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


Re: Error installing packages or upgrading pip

2023-05-20 Thread Mats Wichmann

On 5/18/23 04:30, Test Only wrote:

Hi there, I hope you are in a great health

I am having a problem with python even though I uninstall and reinstall it
again multiple times


Ummm... there's usually not a great reason to do that. I know it's the 
traditional "Windows Way" of the past, but usually looking for actual 
solutions first is better than "reinstall because it might be 
corrupted". To put it in snarky terms: reach for the sledgehammer only 
once you know the use of a sledge is warranted.


Have you tried searching for this through a search engine?  A really 
quick try shows several hits, including some StackOverflow articles. 
There's no way for us to judge if any of those scenarios actually would 
apply to your case, so suggesting you take a look first.




the error I get when I try to upgrade or install a package for example

pip install requests

I get this error which I could not find a solution for



pip install requests
Requirement already satisfied: requests in
c:\users\uly\appdata\local\programs\python\python310\lib\site-packages\requests-2.30.0-py3.10.egg
(2.30.0)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/charset-normalizer/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/charset-normalizer/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/charset-normalizer/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/charset-normalizer/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/charset-normalizer/
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/requests/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/requests/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/requests/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/requests/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None,
status=None)) after connection broken by 'ProtocolError('Connection
aborted.', FileNotFoundError(2, 'No such file or directory'))':
/simple/requests/
ERROR: Could not find a version that satisfies the requirement
charset_normalizer<4,>=2 (from requests) (from versions: none)
ERROR: No matching distribution found for charset_normalizer<4,>=2
WARNING: There was an error checking the latest version of pip.


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


Re: Addition of a .= operator

2023-05-20 Thread Peter J. Holzer
On 2023-05-20 10:54:59 -0700, Alex Jando wrote:
> I have many times had situations where I had a variable of a certain
> type, all I cared about it was one of it's methods.
> 
> For example:
> 
> 
> hash = hash.hexdigest()
> 
> num = num.value
> 
> 
> So what I'm suggesting is something like this:
> 
> 
> hash.=hexdigest()
> 
> num.=value
> 

I actually needed to read those twice to get their meaning. I think

hash .= hexdigest()
num .= value

would have been clearer (yes, I nag my colleagues about white-space,
too).

Do you have any examples (preferably from real code) where you don't
assign to a simple variable? I feel that
x += 1
isn't much of an improvement over
x = x + 1
but
self.data[line+len(chars)-1] += after
is definitely an improvement over
self.data[line+len(chars)-1] + self.data[line+len(chars)-1] + after

hp

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


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


RE: Addition of a .= operator

2023-05-20 Thread avi.e.gross
I would suggest thinking carefully about ramifications as well as any benefits 
of adding some or .=operator.

It sounds substantially different than the whole slew of +=, *= and so on  
types of operators. The goal some would say of those is to either allow the 
interpreter optimize by not evaluating twice as in x = x + 1 or python 
extensions of the dunder type like __iadd__() that allow you to control what 
exactly is done and which sometimes make a += b do things a bit different than 
a= a+b.

So what would a __i_invoke_method__() function look like? It seems you want the 
command to sort of replace
Object = Object.method(args)

But for any method whatsoever.

But Python objects can have methods all over the place as they may be 
subclasses that inherit methods, or may implement an abstract method or use 
multiple inheritance. All that searching happens in the current way, so if 

Object.method(args))

Works as expected, would your new method be just syntactic sugar, or would it 
look for a dunder method that may have no idea initially what you want?

Just curious.

Is there an alternative way you could get the functionality without using the 
same way that is used for a very different circumstance?


-Original Message-
From: Python-list  On 
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Saturday, May 20, 2023 2:49 PM
To: python-list@python.org
Subject: Re: Addition of a .= operator

On 2023-05-21 at 06:11:02 +1200,
dn via Python-list  wrote:

> On 21/05/2023 05.54, Alex Jando wrote:
> > I have many times had situations where I had a variable of a certain type, 
> > all I cared about it was one of it's methods.
> > 
> > For example:
> > 
> > 
> > import hashlib
> > hash = hashlib.sha256(b'word')
> > hash = hash.hexdigest()
> > 
> > import enum
> > class Number(enum.Enum):
> >  One: int = 1
> >  Two: int = 2
> >  Three: int = 3
> > num = Number.One
> > num = num.value
> > 
> > 
> > Now to be fair, in the two situations above, I could just access the method 
> > right as I declare the object, however, sometimes when passing values into 
> > functions, it's a lot messier to do that.

Can you give an example, preferably one from an actual program, that
shows the mess?  Is it More Messierâ„¢ than the difference between the
following examples?

# example 1
hash = hashlib.sha256(b'word')
f(hash.hexdigest()) # call f with hash's hexdigest

# example 2
hash = hashlib.sha256(b'word')
hash = hash.hexdigest() # extract hash's hexdigest
f(hash) # call f with hash's hexdigest

Can you also show what your code would look like with a .= operator?

> > So what I'm suggesting is something like this:
> > 
> > 
> > import hashlib
> > hash = hashlib.sha256(b'word')
> > hash.=hexdigest()
> > 
> > import enum
> > class Number(enum.Enum):
> >  One: int = 1
> >  Two: int = 2
> >  Three: int = 3
> > num = Number.One
> > num.=value
> > 
> 
> A custom-class wrapper?
> Even, a decorator-able function?
-- 
https://mail.python.org/mailman/listinfo/python-list

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


Re: Addition of a .= operator

2023-05-20 Thread 2QdxY4RzWzUUiLuE
On 2023-05-21 at 06:11:02 +1200,
dn via Python-list  wrote:

> On 21/05/2023 05.54, Alex Jando wrote:
> > I have many times had situations where I had a variable of a certain type, 
> > all I cared about it was one of it's methods.
> > 
> > For example:
> > 
> > 
> > import hashlib
> > hash = hashlib.sha256(b'word')
> > hash = hash.hexdigest()
> > 
> > import enum
> > class Number(enum.Enum):
> >  One: int = 1
> >  Two: int = 2
> >  Three: int = 3
> > num = Number.One
> > num = num.value
> > 
> > 
> > Now to be fair, in the two situations above, I could just access the method 
> > right as I declare the object, however, sometimes when passing values into 
> > functions, it's a lot messier to do that.

Can you give an example, preferably one from an actual program, that
shows the mess?  Is it More Messierâ„¢ than the difference between the
following examples?

# example 1
hash = hashlib.sha256(b'word')
f(hash.hexdigest()) # call f with hash's hexdigest

# example 2
hash = hashlib.sha256(b'word')
hash = hash.hexdigest() # extract hash's hexdigest
f(hash) # call f with hash's hexdigest

Can you also show what your code would look like with a .= operator?

> > So what I'm suggesting is something like this:
> > 
> > 
> > import hashlib
> > hash = hashlib.sha256(b'word')
> > hash.=hexdigest()
> > 
> > import enum
> > class Number(enum.Enum):
> >  One: int = 1
> >  Two: int = 2
> >  Three: int = 3
> > num = Number.One
> > num.=value
> > 
> 
> A custom-class wrapper?
> Even, a decorator-able function?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Addition of a .= operator

2023-05-20 Thread dn via Python-list

On 21/05/2023 05.54, Alex Jando wrote:

I have many times had situations where I had a variable of a certain type, all 
I cared about it was one of it's methods.

For example:


import hashlib
hash = hashlib.sha256(b'word')
hash = hash.hexdigest()

import enum
class Number(enum.Enum):
 One: int = 1
 Two: int = 2
 Three: int = 3
num = Number.One
num = num.value


Now to be fair, in the two situations above, I could just access the method 
right as I declare the object, however, sometimes when passing values into 
functions, it's a lot messier to do that.

So what I'm suggesting is something like this:


import hashlib
hash = hashlib.sha256(b'word')
hash.=hexdigest()

import enum
class Number(enum.Enum):
 One: int = 1
 Two: int = 2
 Three: int = 3
num = Number.One
num.=value



A custom-class wrapper?
Even, a decorator-able function?

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


Addition of a .= operator

2023-05-20 Thread Alex Jando
I have many times had situations where I had a variable of a certain type, all 
I cared about it was one of it's methods.

For example:


import hashlib
hash = hashlib.sha256(b'word')
hash = hash.hexdigest()

import enum
class Number(enum.Enum):
One: int = 1
Two: int = 2
Three: int = 3
num = Number.One
num = num.value


Now to be fair, in the two situations above, I could just access the method 
right as I declare the object, however, sometimes when passing values into 
functions, it's a lot messier to do that.

So what I'm suggesting is something like this:


import hashlib
hash = hashlib.sha256(b'word')
hash.=hexdigest()

import enum
class Number(enum.Enum):
One: int = 1
Two: int = 2
Three: int = 3
num = Number.One
num.=value

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