Questions tagged [python-3.9]

A version of the Python programming language, first released on October 5, 2020. This tag is for issues that are specific to Python 3.9. For general questions use the more generic [python] and [python-3.x] tags.

3.9 was released on October 5, 2020 (PEP 596).


Use this tag if your question is specifically related to Python 3.9. Otherwise, use the following guidelines to determine which tag(s) you should add to your question:

  • If your question applies to Python in general, use only the tag.
  • If your question applies to Python 3.x but not to Python 2.x, add the tag .
  • If you aren't sure, tag your question with and mention which version you're using in the post.

References

1128 questions
5
votes
3 answers

Installed python3.9 not showing in linux

I installed python 3.9 following the steps in this link. sudo apt update sudo apt install python3.9 python3.9 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1 sudo update-alternatives --install…
abhi
  • 337
  • 1
  • 3
  • 12
5
votes
2 answers

pip install py-find-1st fails on ubuntu20 & centos with python3.9

This is my process. I start a new aws t2.micro ec2 on ubuntu20 and run this script sudo apt-get update sudo apt-get install gcc sudo apt-get install python3.9 sudo apt-get install python3.9-venv curl --silent --show-error --retry 5…
Sam
  • 1,765
  • 11
  • 82
  • 176
5
votes
2 answers

Type hinting: Check if types are compatible

I'm using type annotatiots to do some basic type checking and automated type conversions. As part of that, I'm looking to check if a given type should be assignable to some field of a data class, i.e. if the type is "compatible" with the type…
Bogey
  • 4,926
  • 4
  • 32
  • 57
5
votes
1 answer

Django MSSQL: Override Foreign Key Constraint Name Generation

I am attempting to create a database model in Django 3.0 using django-mssql-backend as by db backend for SQL Server 2019. The database uses multiple schemas for the tables included in it with some of the tables being non-managed (already exist), and…
5
votes
1 answer

How to mock a method within an async unit test?

I have a class called database.py with a function called generate_token(). I would like to mock it and return a fixed value 321. So that I can see that the method was called and the return value returned. How do I mock that? This is what I have…
Houman
  • 64,245
  • 87
  • 278
  • 460
5
votes
2 answers

What is __phello__ for in Python 3?

I imported __phello__ in the terminal: >>> import __phello__ Hello world! What is __phello__ for? Or is it just an Easter Egg?
abhigyanj
  • 2,355
  • 2
  • 9
  • 29
4
votes
1 answer

How to install Python 3.9.14 on Windows?

Python 3.9.14 has been released on Sept. 6, 2022. As I can see written on https://www.python.org/downloads/release/python-3914/: According to the release calendar specified in PEP 596, Python 3.9 is now in the "security fixes only" stage of its…
Uri
  • 2,992
  • 8
  • 43
  • 86
4
votes
3 answers

Passing the arguments to dataclass causes TypeError

I've been having an issue with dataclasses, despite using the decorator and passing the arguments to the dataclass, I will get a TypeError stating that the object does not take any arguments. This seems quite temperamental and doesn't seem to be…
4
votes
1 answer

How to control which Python version plpython3 uses?

I have a postgres 11 database running on CentOS 7 and am trying to use PL/python, but need to point to a specific version of the python interpreter. I need to use python3.9 whereas it is using python3.6. I am not able to uninstall python3.6 at the…
refriedjello
  • 657
  • 8
  • 18
4
votes
1 answer

os.PathLike[Any] vs os.PathLike[str]

I've seen lines like that in typeshed: https://github.com/python/typeshed/blob/994b69ef8f18e76689daca3947879c3d7f76173e/stdlib/_typeshed/__init__.pyi#L77 But os.PathLike doesn't appear to be generic. It doesn't let strings be passed. import…
Greedo
  • 4,967
  • 2
  • 30
  • 78
4
votes
3 answers

Issue while trying to set enum data type in MySQL database

What am I trying to do? Django does not support setting enum data type in mysql database. Using below code, I tried to set enum data type. Error Details _mysql.connection.query(self, query) django.db.utils.ProgrammingError: (1064, "You have an…
Pankaj
  • 9,749
  • 32
  • 139
  • 283
4
votes
1 answer

How to properly type hint a class decorator?

Assume we have some function func that maps instances of class A to instances of class B, i.e. it has the signature Callable[[A], B]. I want to write a class decorator autofunc for subclasses of A that automatically applies func to instances as they…
Hyperplane
  • 1,422
  • 1
  • 14
  • 28
4
votes
2 answers

python 3.9 and rdflib keep changing slashes in a url

I am completely new in Python . I am using 3.9.2 and rdflib . I try to execute the first example, from rdflib import Graph g = Graph() g.parse('http://dbpedia.org/resource/Semantic_Web') for s, p, o in g: print(s, p, o) I create a py file ,…
codebot
  • 517
  • 8
  • 29
  • 55
4
votes
1 answer

Parenthesized context managers work in python 3.9 but not 3.8

So I have this simple example of a with statement. It works in Python 3.8 and 3.9: class Foo: def __enter__(self, *args): print("enter") def __exit__(self, *args): print("exit") with Foo() as f, Foo() as b: …
mogoh
  • 992
  • 2
  • 7
  • 27
4
votes
1 answer

Error message received when trying to import turtle (python 3.9, m1 Mac)

When I try to import the python 3 graphical library, turtle, on my m1 MacBook, I get an error message: david@Davids-MacBook-Air Python Coding Files % /opt/homebrew/bin/python3 "/Users/david/Desktop/Python Coding Files/hello.py" Traceback (most…
user16669629