[Python-announce] CodraFT v2.1.1

2022-07-20 Thread Pierre Raybaut
Hi all, CodraFT is an open-source generic signal and image processing software, based on Python, Qt, NumPy, SciPy and others: https://codra-ingenierie-informatique.github.io/CodraFT/ I am pleased to announce that CodraFT v2.1.1 has been released. This is the second public release of version 2,

Re: list indices must be integers or slices, not str

2022-07-20 Thread Roel Schroeven
Frank Millman schreef op 20/07/2022 om 13:04: >> On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: >>>   >>> >>>   >>> x = list(range(10)) >>>   >>> >>>   >>> '{x[1]}'.format(**vars()) >>> '1' >>>   >>> >>>   >>> '{x[-1]}'.format(**vars()) >>> Traceback (most recent call last): >>>     File

Re: exec() an locals() puzzle

2022-07-20 Thread Martin Di Paola
I did a few tests # test 1 def f(): i = 1 print(locals()) exec('y = i; print(y); print(locals())') print(locals()) a = eval('y') print(locals()) u = a print(u) f() {'i': 1} 1 {'i': 1, 'y': 1} {'i': 1, 'y': 1} {'i': 1, 'y': 1, 'a': 1} 1 # test 2 def f(): i =

Re: list indices must be integers or slices, not str

2022-07-20 Thread Martin Di Paola
offtopic If you want a pure-python but definitely a more hacky implementation, you can play around with inspect.stack() and get the variables from the outer frames. # code: x = 32 y = 42 printf("Hello x={x}, y={y}", x=27) # output: Hello x=27, y=42 The implementation of printf() was never

Re: exec() an locals() puzzle

2022-07-20 Thread Eryk Sun
On 7/20/22, george trojan wrote: > > 1. This works as I expect it to work: > > def f(): > i = 1 > print(locals()) > exec('y = i; print(y); print(locals())') > print(locals()) > exec('y *= 2') > print('ok:', eval('y')) > f() In CPython, the locals of a function scope (as

Re: Are there any benefits of a shared build python, compared to a static build python?

2022-07-20 Thread Barry
> On 20 Jul 2022, at 18:09, Tianhe wrote: > > Python by default builds the library `libpythonMAJOR.MINOR.a` and > statically links it into the interpreter. Also it has an `--enable-shared`, > (https://docs.python.org/3/using/configure.html#cmdoption-enable-shared) > flag, which will build a

exec() an locals() puzzle

2022-07-20 Thread george trojan
I wish I could understand the following behaviour: 1. This works as I expect it to work: def f(): i = 1 print(locals()) exec('y = i; print(y); print(locals())') print(locals()) exec('y *= 2') print('ok:', eval('y')) f() {'i': 1} 1 {'i': 1, 'y': 1} {'i': 1, 'y': 1} ok: 2

Re: list indices must be integers or slices, not str

2022-07-20 Thread Mats Wichmann
On 7/20/22 05:04, Frank Millman wrote: > I think the preferred style these days is f'{x[-1]}' which works." > > Unfortunately the 'f' option does not work for me in this case, as I am > using a string object, not a string literal. For that you could consider https://pypi.org/project/f-yeah/

Re: list indices must be integers or slices, not str

2022-07-20 Thread Chris Angelico
On Wed, 20 Jul 2022 at 23:50, Peter Otten <__pete...@web.de> wrote: > > I found > > https://peps.python.org/pep-3101/ > > """ > PEP 3101 – Advanced String Formatting > ... > An example of the ‘getitem’ syntax: > > "My name is {0[name]}".format(dict(name='Fred')) > > It should be noted that the use

Re: list indices must be integers or slices, not str

2022-07-20 Thread MRAB
On 20/07/2022 12:08, Chris Angelico wrote: On Wed, 20 Jul 2022 at 20:55, Frank Millman wrote: On 2022-07-20 11:37 AM, Chris Angelico wrote: > On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: >> >> Hi all >> >> C:\Users\E7280>python >> Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021,

Re: list indices must be integers or slices, not str

2022-07-20 Thread Peter Otten
On 20/07/2022 11:37, Chris Angelico wrote: On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

[Python-announce] structlog 22.1.0

2022-07-20 Thread Hynek Schlawack
I’m happy to announce a new release of structlog! With more than 4 million downloads per month, structlog is the most popular solution for structured logging in Python. It doesn’t just allow you to log key-value pairs in a structured manner, it also makes it EASIER and FASTER. Check out

Re: list indices must be integers or slices, not str

2022-07-20 Thread Chris Angelico
On Wed, 20 Jul 2022 at 21:06, Frank Millman wrote: > I saw this from Paul Rubin - for some reason his posts appear in google > groups, but not python-list. > > "It seems to only want integer constants. x[2+2] and x[k] where k=2 > don't work either. Yes, that's for the same reason that x[spam]

Re: list indices must be integers or slices, not str

2022-07-20 Thread Chris Angelico
On Wed, 20 Jul 2022 at 20:55, Frank Millman wrote: > > On 2022-07-20 11:37 AM, Chris Angelico wrote: > > On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: > >> > >> Hi all > >> > >> C:\Users\E7280>python > >> Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 > >> bit

Re: list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
On 2022-07-20 12:31 PM, Frank Millman wrote: On 2022-07-20 11:37 AM, Chris Angelico wrote: On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help",

Re: list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
On 2022-07-20 11:37 AM, Chris Angelico wrote: On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Re: Pip upgrade causing issues in 3.10

2022-07-20 Thread Eryk Sun
On 7/20/22, Mike Dewhirst wrote: > On 20/07/2022 4:43 am, David Raymond wrote: >> C:\Program Files\Python310\Scripts>..\python.exe -m pip install --upgrade >> pip >> ERROR: Could not install packages due to an OSError: [WinError 32] The >> process cannot access the file because it is being used

Re: list indices must be integers or slices, not str

2022-07-20 Thread Chris Angelico
On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: > > Hi all > > C:\Users\E7280>python > Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 > bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> > >>> x = list(range(10)) >

list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> x = list(range(10)) >>> >>> '{x[1]}'.format(**vars()) '1' >>> >>>

Re: Pip upgrade causing issues in 3.10

2022-07-20 Thread Mike Dewhirst
On 20/07/2022 4:43 am, David Raymond wrote: C:\Program Files\Python310\Scripts>..\python.exe -m pip install --upgrade pip ERROR: Could not install packages due to an OSError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\program