Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

summary corrected
Source Link
zvone
  • 19.5k
  • 5
  • 53
  • 85

Python 3.8 supports using a limited set of non-ASCII Unicode characters in identifiers. So, it seems that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

The first two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3), and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII Unicode characters in identifiers. So, it seems that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

The first two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ is implicitly renamed to Σ and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII Unicode characters in identifiers. So, it seems that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

The first two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3), and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII unicodeUnicode characters in identifiers. So, it seemtsseems that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

FirstThe first two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3) and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII unicode characters in identifiers. So, it seemts that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

First two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3) and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII Unicode characters in identifiers. So, it seems that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

The first two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ is implicitly renamed to Σ and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

added 19 characters in body
Source Link
zvone
  • 19.5k
  • 5
  • 53
  • 85

Python 3.8 supports using a limited set of non-ASCII unicode characters in identifiers. So, it seemts that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

First two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3) and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII unicode characters in identifiers. So, it seemts that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

First two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ is implicitly renamed to Σ and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Python 3.8 supports using a limited set of non-ASCII unicode characters in identifiers. So, it seemts that it is valid to use Σ as a character in an identifier.

However, something is wrong...

Problem

def f(Σ):
 print(f'{Σ=}')
f(1)
f(Σ=2)
f(**{'Σ': 3})

First two calls are fine, but the third fails:

Σ=1
Σ=2
Traceback (most recent call last):
 File "sigma.py", line 24, in <module>
 f(**{'Σ': 3})
TypeError: f() got an unexpected keyword argument 'Σ'

Analysis

Let's see what is actually going on:

def f2(**kw):
 for name, value in kw.items():
 print(f'{name}={value} {ord(name)=}')
f2(Σ=2)
f2(**{'Σ': 3})

It prints:

Σ=2 ord(name)=931
Σ=3 ord(name)=120506

I called it with Σ both times, but it was changed to the very similar simpler Σ in the first call.

It seems that an argument named Σ (U+1D6BA) is implicitly renamed to Σ (U+03A3) and in every call to the function, argument Σ is also implicitly renamed to Σ, except if it is passed as **kwargs.

The Questions

Is this a bug? It does not look like it is accidental. Is it documented? Is there a set of true characters and a list of alias characters available somewhere?

Fixed typo
Source Link
Ch3steR
  • 20.8k
  • 4
  • 34
  • 66
Loading
Source Link
zvone
  • 19.5k
  • 5
  • 53
  • 85
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /