Questions tagged [python-3.10]

A version of the Python programming language, first released on October 4, 2021. This tag is for issues that are specific to Python 3.10. For general questions use the more generic [python] tags.

Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation.

References

782 questions
7
votes
2 answers

How to use match case to check for variable type in python?

I have this code to check for whether or not a variable is a number or a Vector2 in my Vector2 class when multiplying. def __mul__(self, other): match type(other): case int | float: pass case Vector2: …
Zachary Milner
  • 153
  • 1
  • 6
7
votes
2 answers

How can I decompile .pyc files from Python 3.10?

I did try uncompyle6, decompyl3, and others, but none of them worked with 3.10. Is it even possible to do this right now?
Rana
  • 81
  • 1
  • 1
  • 3
7
votes
3 answers

how to fix TypeError: called match pattern must be a type in Python 3.10

Trying to learn Python 3.10 pattern matching. Tried this example after reading 8.6.4.9. Mapping Patterns >>> match 0.0: ... case int(0|1): ... print(1) ... Traceback (most recent call last): File "", line 2, in TypeError:…
user1443098
  • 6,487
  • 5
  • 38
  • 67
7
votes
2 answers

Unable to import freegames python package : AttributeError: module 'collections' has no attribute 'Sequence'

Python version : 3.10 I was trying to install the freegames python package using the following pip command C:\Users\praty>pip install freegames Defaulting to user installation because normal site-packages is not writeable Collecting freegames …
Himanshu Poddar
  • 7,112
  • 10
  • 47
  • 93
7
votes
1 answer

How does Python 3.10 match compares 1 and True?

PEP 622, Literal Patterns says the following: Note that because equality (__eq__) is used, and the equivalency between Booleans and the integers 0 and 1, there is no practical difference between the following two: case True: ... case 1: …
umitu
  • 2,423
  • 1
  • 10
  • 28
7
votes
4 answers

Doesn't Python 3.10 support pygame?

I just installed the beta version of Python 3.10, opened VS Code, changed the Python Interpreter to Python 3.10 64 bit (my PC works with 64 bit) and managed to continue working on my Pygame Project. Yet, as I runned the code, I faced the…
Developeeer
  • 110
  • 1
  • 1
  • 10
7
votes
1 answer

Python 3.10 match/case with constants

I tried to replace an if/elif/elif/.../else code block with the shorter match/case from Python 3.10. I have three constants defined and want to do something different for each one, so my code looks roughly like this: >>> const_a = 1 >>> const_b =…
mara004
  • 1,435
  • 11
  • 24
6
votes
0 answers

SSLZeroReturnError error only in python 3.10

I use that code to connect for ssl server import socket import ssl import sys sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ssl_socket = ssl.wrap_socket(sock) ssl_socket.connect((sys.argv[1], int(sys.argv[2]))) When I run this code with…
python3.789
  • 164
  • 9
6
votes
1 answer

How do I get Python dataclass InitVar fields to work with typing.get_type_hints while also using annotations?

When messing with Python dataclasses, I ran into this odd error that's pretty easy to reproduce. from __future__ import annotations import dataclasses as dc import typing @dc.dataclass class Test: foo:…
6
votes
1 answer

Parenthesized context managers

I'm trying to understand what is new with the new parenthesized context managers feature in Python 3.10 (top item in new features here). My test example was to try and write: with (open('file1.txt', 'r') as fin, open('file2.txt', 'w') as fout): …
James Briggs
  • 854
  • 6
  • 13
5
votes
1 answer

Implement seek in read-only gzip stream

I have an app that seeks within a .gz file-like object. Python's gzip.GzipFile supports this, but very inefficiently – when the GzipFile object is asked to seek back, it will rewind to the beginning of the stream (seek(0)) and then read and…
user124114
  • 8,372
  • 11
  • 41
  • 63
5
votes
1 answer

asyncio: works in Python 3.10 but not in Python 3.8

Consider the following code: import asyncio sem: asyncio.Semaphore = asyncio.Semaphore(2) async def async_run() -> None: async def async_task() -> None: async with sem: await asyncio.sleep(1) print('spam') …
StSav012
  • 776
  • 5
  • 15
5
votes
0 answers

Is there any difference between using mock.patch.object with wraps vs side_effect?

What is the difference between the following two tests? (if any) ** in python 3.10 import unittest from unittest.mock import Mock, patch class Potato(object): def spam(self, n): return self.foo(n=n) def foo(self, n): …
Marcel Wilson
  • 3,842
  • 1
  • 26
  • 55
5
votes
1 answer

How to solve JSONDecodeError when using Poetry in Github Actions?

Issue I've got a problem using poetry install in my CI/CD pipeline (Github Actions), on any GitHub runner, since I migrated from Python 3.8 to Python 3.10. Installing dependencies from lock file Package operations: 79 installs, 0 updates, 0…
GuiFalourd
  • 15,523
  • 8
  • 44
  • 71
5
votes
3 answers

After upgrading PySide6 gives error No module named 'PySide6.QtWidgets'

After upgrading to PySide6.3.0 getting error ModuleNotFoundError: No module named 'PySide6.QtWidgets' source import sys from PySide6.QtWidgets import QApplication, QLabel app = QApplication(sys.argv) label = QLabel("Hello…
Udesh
  • 2,415
  • 2
  • 22
  • 32
1 2
3
51 52