Fwd: argparse modify

2022-06-23 Thread נתי שטרן
 הודעה שהועברה --
מאת: *Dieter Maurer* 
תאריך: יום שישי, 24 ביוני 2022
נושא: argparse modify
אל: נתישטרן 
עותק: "python-list-requ...@python.org" , "
python-list@python.org" 


נתי שטרן wrote at 2022-6-24 08:28 +0300:
>I copied code from argparse library and modified it
>
>בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer :
>
>> נתי שטרן wrote at 2022-6-23 15:31 +0300:
>> >how to solve this (argparse)
>> >
>> >
>> >traceback:
>> >Traceback (most recent call last):
>> >  File "u:\oracle\RTR.py", line 10, in 
>> >class sre_constants():
>> >  File "u:\oracle\RTR.py", line 77, in sre_constants
>> >MAXREPEAT = _NamedIntConstant(32,name=str(32))
>> >TypeError: 'name' is an invalid keyword argument for int()

The exception information tells you:
` _NamedIntConstant(32,name=str(32))` raises a `TypeError`:
`_NamedIntConstant` does not know the keyword parameter `name`.
Thus, something is wrong with the `_NamedIntConstant` definition.
Do you have an idea for fixing it?

-- 

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


Re: argparse modify

2022-06-23 Thread Dieter Maurer
נתי שטרן wrote at 2022-6-24 08:28 +0300:
>I copied code from argparse library and modified it
>
>בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer :
>
>> נתי שטרן wrote at 2022-6-23 15:31 +0300:
>> >how to solve this (argparse)
>> >
>> >
>> >traceback:
>> >Traceback (most recent call last):
>> >  File "u:\oracle\RTR.py", line 10, in 
>> >class sre_constants():
>> >  File "u:\oracle\RTR.py", line 77, in sre_constants
>> >MAXREPEAT = _NamedIntConstant(32,name=str(32))
>> >TypeError: 'name' is an invalid keyword argument for int()

The exception information tells you:
` _NamedIntConstant(32,name=str(32))` raises a `TypeError`:
`_NamedIntConstant` does not know the keyword parameter `name`.
Thus, something is wrong with the `_NamedIntConstant` definition.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: argparse modify

2022-06-23 Thread נתי שטרן
I copied code from argparse library and modified it

בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer :

> נתי שטרן wrote at 2022-6-23 15:31 +0300:
> >how to solve this (argparse)
> >
> >
> >traceback:
> >Traceback (most recent call last):
> >  File "u:\oracle\RTR.py", line 10, in 
> >class sre_constants():
> >  File "u:\oracle\RTR.py", line 77, in sre_constants
> >MAXREPEAT = _NamedIntConstant(32,name=str(32))
> >TypeError: 'name' is an invalid keyword argument for int()
>
> This does not look like an `argparse` problem:
> the traceback comes from `oracle/RTR.py`.
>


-- 

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


Re: argparse modify

2022-06-23 Thread Chris Angelico
On Fri, 24 Jun 2022 at 09:03, Mats Wichmann  wrote:
> Also note that while it's claimed to be fine These Days, inheriting from
> a base type like this is sometimes tricky, sometimes broken... be
> somewhat aware.

Depends on your definition of "broken". If you want to make a custom
integer type, you'll probably find that arithmetic operations on it
just return vanilla ints again, but in this case, it seems to be more
akin to IntEnum than to an arithmetic type. so it should be safe.

But that said: why not just use IntEnum? It looks like the purpose of
it is simply to be a name for a number, and that's something that an
enum does well (even if it's not strictly "enumerated" in that sense).

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


Re: argparse modify

2022-06-23 Thread Mats Wichmann
On 6/23/22 16:32, Dennis Lee Bieber wrote:
> On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer" 
> declaimed the following:
> 
>> ???  wrote at 2022-6-23 15:31 +0300:
>>> how to solve this (argparse)
> 
>>>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>>> TypeError: 'name' is an invalid keyword argument for int()
>>
>> This does not look like an `argparse` problem:
>> the traceback comes from `oracle/RTR.py`.
> 
>   And the listed code looks quite suspicious to me...
> 
>>> class _NamedIntConstant(int):
>>> def __init__(cls, value):
>>> self = super(_NamedIntConstant, cls).__init__(cls, value)
>>> self.name = name
>>> return self
> 
>   There does not appear to be any provision for keyword arguments at all.
> The only use of "name" is to an undefined object.

Indeed... a more typical version of this might be something like:

class _NamedIntConstant(int):
def __init__(self, name, **kwargs):
self.name = name
super().__init__(**kwargs)

Assuming: that the "value" in your init method signature was supposed to
be 'name' since that's what you use later - and would explain your
exception!

In Python init methods are initializers, not creators (despite that many
materials call them constructors) - when you get to it, "self" already
exists, so you don't want to assign to it. And you don't return it -
again, it already exists, all you're doing here is setting it up, and
part of that you delegated to the parent class's initializer.

Also note that while it's claimed to be fine These Days, inheriting from
a base type like this is sometimes tricky, sometimes broken... be
somewhat aware.

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


Re: argparse modify

2022-06-23 Thread Dennis Lee Bieber
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer" 
declaimed the following:

>???  wrote at 2022-6-23 15:31 +0300:
>>how to solve this (argparse)

>>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>>TypeError: 'name' is an invalid keyword argument for int()
>
>This does not look like an `argparse` problem:
>the traceback comes from `oracle/RTR.py`.

And the listed code looks quite suspicious to me...

>> class _NamedIntConstant(int):
>> def __init__(cls, value):
>> self = super(_NamedIntConstant, cls).__init__(cls, value)
>> self.name = name
>> return self

There does not appear to be any provision for keyword arguments at all.
The only use of "name" is to an undefined object.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: argparse modify

2022-06-23 Thread Dieter Maurer
נתי שטרן wrote at 2022-6-23 15:31 +0300:
>how to solve this (argparse)
>
>
>traceback:
>Traceback (most recent call last):
>  File "u:\oracle\RTR.py", line 10, in 
>class sre_constants():
>  File "u:\oracle\RTR.py", line 77, in sre_constants
>MAXREPEAT = _NamedIntConstant(32,name=str(32))
>TypeError: 'name' is an invalid keyword argument for int()

This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "CPython"

2022-06-23 Thread Avi Gross via Python-list
David,
I am curious why you are undertaking the effort to take a language already 
decades old and showing signs of being a tad rusty into a language that 
suggests further oxidation.
More seriously, I am interested in what this can gain and the intended user 
base. I studied Rust for a while and it has it's features but have had no 
opportunity to use it. Is it expected to make a faster version of Python, or 
enable better connections to libraries and so on? 
What I mean is that if you are planning on making it pass all tests for python 
functionality, are you also adding unique features or ... ?
My preference is to have names that fully include what they are about. So the 
name "python" would be left intact rather than mangled, even if the name itself 
happens to be totally meaningless. So may I suggest something like 
"""rustic-python""" ?


-Original Message-
From: David J W 
To: python-list@python.org
Sent: Thu, Jun 23, 2022 10:29 am
Subject: Re: "CPython"

>> Let's say they reimplement "reference python" CPython in Rust. What is
>> better? Change the "reference python" CPython name to RPython, for
>> example, or let it as CPython?

>The C implementation would still be called CPython, and the new
>implementation might be called RPython, or RustyPython, or whatever.
>The names are independent of which one is currently blessed as the
>reference implementation.

I am at the pre planning stages of making a Rust implementation of the
Python virtual machine and to avoid ambiguity I've been working with Rython
as the name.  I tried looking for a Monty Python themed name but the good
ones seem to be taken.

Otherwise as for a timeline, solo I figure it's going to take me a couple
years to get something that actually passes cpython's python unit-tests.
-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


argparse modify

2022-06-23 Thread נתי שטרן
how to solve this (argparse)


traceback:
Traceback (most recent call last):
  File "u:\oracle\RTR.py", line 10, in 
class sre_constants():
  File "u:\oracle\RTR.py", line 77, in sre_constants
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()

code:
class sre_constants():
#
# Secret Labs' Regular Expression Engine
#
# various symbols used by the regular expression engine.
# run this script to update the _sre include files!
#
# Copyright (c) 1998-2001 by Secret Labs AB.  All rights reserved.
#
# See the sre.py file for information on usage and redistribution.
#

"""Internal support module for sre"""

# update when constants are added or removed

MAGIC = 20171005

from _sre import MAXREPEAT, MAXGROUPS

# SRE standard exception (access as sre.error)
# should this really be here?

class error(Exception):
"""Exception raised for invalid regular expressions.

Attributes:

msg: The unformatted error message
pattern: The regular expression pattern
pos: The index in the pattern where compilation failed (may be
None)
lineno: The line corresponding to pos (may be None)
colno: The column corresponding to pos (may be None)
"""

__module__ = 're'

def __init__(self, msg, pattern=None, pos=None):
self.msg = msg
self.pattern = pattern
self.pos = pos
if pattern is not None and pos is not None:
msg = '%s at position %d' % (msg, pos)
if isinstance(pattern, str):
newline = '\n'
else:
newline = b'\n'
self.lineno = pattern.count(newline, 0, pos) + 1
self.colno = pos - pattern.rfind(newline, 0, pos)
if newline in pattern:
msg = '%s (line %d, column %d)' % (msg, self.lineno,
self.colno)
else:
self.lineno = self.colno = None
super().__init__(msg)

class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self

def __repr__(self):
return self.name


__reduce__ = None

MAXREPEAT = _NamedIntConstant(32,name=str(32))


def _makecodes(names):
names = names.strip().split()
items = [_NamedIntConstant(i, name) for i, name in enumerate(names)]
globals().update({item.name: item for item in items})
return items





-- 

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


3.11.0b4?

2022-06-23 Thread Richard David
Is there a new scheduled date for releasing 3.11.0b4?  Are there issues with b4 
that have implications for b3?

I realize it will be released when ready and am not trying to push or harass 
anyone involved. It just seems that versions are usually released on schedule 
so I'm wondering if there's some problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "CPython"

2022-06-23 Thread David J W
>> Let's say they reimplement "reference python" CPython in Rust. What is
>> better? Change the "reference python" CPython name to RPython, for
>> example, or let it as CPython?

>The C implementation would still be called CPython, and the new
>implementation might be called RPython, or RustyPython, or whatever.
>The names are independent of which one is currently blessed as the
>reference implementation.

I am at the pre planning stages of making a Rust implementation of the
Python virtual machine and to avoid ambiguity I've been working with Rython
as the name.   I tried looking for a Monty Python themed name but the good
ones seem to be taken.

Otherwise as for a timeline, solo I figure it's going to take me a couple
years to get something that actually passes cpython's python unit-tests.
-- 
https://mail.python.org/mailman/listinfo/python-list