jinja2.exceptions.TemplateNotFound: templates/PatientView.html
I'm trying to create a simple Web App, fetching data from a MySQL table and displaying it on an HTML page. However, when I try running the .py file, I get the error: **jinja2.exceptions.TemplateNotFound: templates/Patient\View.html even though there is a Patient_View.html file in the templates folder.
Here is my .py file and the code in it:
from flask import Flask, rendertemplate, request, redirect, urlfor, flash
from flasksqlalchemy import SQLAlchemy
from import generatepasswordhash, checkpasswordhash
from flasklogin import UserMixin, LoginManager, loginuser, logoutuser, currentuser, loginrequired
from datetime import datetime
import pymysql
import logging
pymysql.installasMySQLdb()
app = Flask(name)
app.secretkey = 'Krish'
app.config['SQLALCHEMYDATABASEURI'] = 'mysql://root:@localhost/medical'
app.config['SQLALCHEMYTRACKMODIFICATIONS'] = False
db = SQLAlchemy(app)
# Set up logging
logging.basicConfig(level=logging.INFO)
# Initialize Flask-Login
loginmanager = LoginManager(app)
loginmanager.loginview = 'home' # when
/r/Python
https://redd.it/1echwyc
I'm trying to create a simple Web App, fetching data from a MySQL table and displaying it on an HTML page. However, when I try running the .py file, I get the error: **jinja2.exceptions.TemplateNotFound: templates/Patient\View.html even though there is a Patient_View.html file in the templates folder.
Here is my .py file and the code in it:
from flask import Flask, rendertemplate, request, redirect, urlfor, flash
from flasksqlalchemy import SQLAlchemy
from import generatepasswordhash, checkpasswordhash
from flasklogin import UserMixin, LoginManager, loginuser, logoutuser, currentuser, loginrequired
from datetime import datetime
import pymysql
import logging
pymysql.installasMySQLdb()
app = Flask(name)
app.secretkey = 'Krish'
app.config['SQLALCHEMYDATABASEURI'] = 'mysql://root:@localhost/medical'
app.config['SQLALCHEMYTRACKMODIFICATIONS'] = False
db = SQLAlchemy(app)
# Set up logging
logging.basicConfig(level=logging.INFO)
# Initialize Flask-Login
loginmanager = LoginManager(app)
loginmanager.loginview = 'home' # when
/r/Python
https://redd.it/1echwyc
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Having Multiple Models Upload Files to Different Paths
I have 2 main entities, a Pharmacy and a Hospital, each of them can have one-or-multiple attachments, those attachments can be photos or PDFs.
Here's my Attachment model
and as an example here are my Pharmacy and Hospital models
My goal is to be able to put the attachments of a Pharmacy into a subfolder inside attachments/ and that subfolder should be pharmacy/, so everything lives in attachments/pharmacy/. And the same applies for a hospital.
I couldn't figure out the proper way to do this I even did a Google search which turned out with nothing. Any ideas?
/r/django
https://redd.it/1ecj5pb
I have 2 main entities, a Pharmacy and a Hospital, each of them can have one-or-multiple attachments, those attachments can be photos or PDFs.
Here's my Attachment model
class Attachment(Base):
file = models.FileField(upload_to='attachments/')
def __str__(self):
return f'{self.created_at}'
and as an example here are my Pharmacy and Hospital models
class Pharmacy(Base):
attachments = models.ManyToManyField(Attachment)
...
class Hospital(Base):
attachments = models.ManyToManyField(Attachment)
...
My goal is to be able to put the attachments of a Pharmacy into a subfolder inside attachments/ and that subfolder should be pharmacy/, so everything lives in attachments/pharmacy/. And the same applies for a hospital.
I couldn't figure out the proper way to do this I even did a Google search which turned out with nothing. Any ideas?
/r/django
https://redd.it/1ecj5pb
Reddit
From the django community on Reddit
Explore this post and more from the django community
Analytics?
I still have third party cookies on my website is because I'm using Google analytics. Is it possible to use a internal module of Django to do this instead?
/r/django
https://redd.it/1ecj33e
I still have third party cookies on my website is because I'm using Google analytics. Is it possible to use a internal module of Django to do this instead?
/r/django
https://redd.it/1ecj33e
Reddit
From the django community on Reddit
Explore this post and more from the django community
I made a command-line tool that gives you granular control over bulk deleting your Github gists
Source code: https://github.com/ben-n93/gists-gone/
What my Project Does: From the command-line you can bulk delete Github gists. You can be specific about the type of Gists you want deleted - what language, when they were created, whether they are public or private.
Target Audience
Github users/anyone who uses Github gists!
/r/Python
https://redd.it/1eclzmr
Source code: https://github.com/ben-n93/gists-gone/
What my Project Does: From the command-line you can bulk delete Github gists. You can be specific about the type of Gists you want deleted - what language, when they were created, whether they are public or private.
Target Audience
Github users/anyone who uses Github gists!
/r/Python
https://redd.it/1eclzmr
GitHub
GitHub - ben-n93/gists-gone: A CLI that gives you more granular control over bulk deletion of your Github gists.
A CLI that gives you more granular control over bulk deletion of your Github gists. - ben-n93/gists-gone
D Every annotator has a guidebook, but the reviewers don't
I submitted to the ACL rolling review in June and found the reviewers' evaluation scores very subjective.
Although the ACL committee has an instruction on some basic reviewing guidelines, there lacks of a preliminary test for the reviewers to explicitly show the evaluation standards. Maybe we should provide some paper-score examples to prompt the reviewers for more objective reviews? Or build a test before they make reviews to make sure they fully understand the meaning of soundness and overall assessment, rather than giving some random scores based on their personal interests.
/r/MachineLearning
https://redd.it/1ecnxng
I submitted to the ACL rolling review in June and found the reviewers' evaluation scores very subjective.
Although the ACL committee has an instruction on some basic reviewing guidelines, there lacks of a preliminary test for the reviewers to explicitly show the evaluation standards. Maybe we should provide some paper-score examples to prompt the reviewers for more objective reviews? Or build a test before they make reviews to make sure they fully understand the meaning of soundness and overall assessment, rather than giving some random scores based on their personal interests.
/r/MachineLearning
https://redd.it/1ecnxng
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community
Included template has a script tag that should be executed at the end of body
Usually you extend
Right now I want to do something slightly different. I use a component in multiple places, it calls a function that gets included in a script tag at the bottom of
Possible component with script tag that should be executed after the script tag in
I can't extend the block
/r/flask
https://redd.it/1ecatbv
Usually you extend
layout.html or something similar and just add a block for scripts.{% extends "layout.html" %}
{% block scripts %}
{% endblock scripts %}
Right now I want to do something slightly different. I use a component in multiple places, it calls a function that gets included in a script tag at the bottom of
layout.html. So I have to execute the components script tag after the include in layout.html.{% extends "layout.html" %}
{% block content %}
{% include 'component-with-function-call-that-should-happen-later' %}
{% endblock content %}
Possible component with script tag that should be executed after the script tag in
layout.html.<script>
someFuncCall();
</script>
I can't extend the block
scripts because it's an include. Do you have a solution for me?/r/flask
https://redd.it/1ecatbv
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Beginners Walkthrough/Guide for setting up Virtual Environments and IDE in MacOS & Windows.
Written this for some students and thought others might find it useful.
WINDOWS - https://cybernestlabs-my.sharepoint.com/:w:/p/ben\_m/EU1Zv-0suI1Nssv2gK0wmgQBYZJsYA1bYkqL-av5wODDjg?e=VBaeay
MacOS - https://cybernestlabs-my.sharepoint.com/:w:/p/ben\_m/EejYMTJMU8JCh8\_otBv9aOwB3B6NESvwPpTFTDWsXRgeMw?e=CY5oOs
/r/Python
https://redd.it/1ectloa
Written this for some students and thought others might find it useful.
WINDOWS - https://cybernestlabs-my.sharepoint.com/:w:/p/ben\_m/EU1Zv-0suI1Nssv2gK0wmgQBYZJsYA1bYkqL-av5wODDjg?e=VBaeay
MacOS - https://cybernestlabs-my.sharepoint.com/:w:/p/ben\_m/EejYMTJMU8JCh8\_otBv9aOwB3B6NESvwPpTFTDWsXRgeMw?e=CY5oOs
/r/Python
https://redd.it/1ectloa
Free and open-source landing pages
Hi all,
I have been working on building a list of landing pages for independent developers and wanted to share it with the community.
You can browse and download the templates here: https://awesome-landingpages.vercel.app/
Github page: Free landing pages Github
Why use this templates?
Honestly to save time. Besides, it can be hard to develop everything by yourself, especially if you are freelancer or developing solo SaaS project. So you can use this templates to make it easier and quicker.
Features:
Responsive.
Technical SEO optimized (uses correct tags, like h1, h2, section etc)
Tailwind built in, for rapid development (uses `tw-` prefix to separate tailwind classes)
Quick customization, just change texts.
Frontend framework independent: Comes with basic html, css just enough for your perfect landing page, you are free to modify and use any frontend framework (React, Vue) if required.
Whom is this meant for?
Developers who have tight deadlines.
Freelancers looking to show a prototype or use a template to build faster.
SaaS Developers who don't want to spend too much time focusing on landing page, but instead want to ship more.
App developer who wants to have a web landing page. (helps with your SEO game)
People looking for inspiration and ideas.
Will there be new templates?
Yes, new templates
/r/django
https://redd.it/1eco51d
Hi all,
I have been working on building a list of landing pages for independent developers and wanted to share it with the community.
You can browse and download the templates here: https://awesome-landingpages.vercel.app/
Github page: Free landing pages Github
Why use this templates?
Honestly to save time. Besides, it can be hard to develop everything by yourself, especially if you are freelancer or developing solo SaaS project. So you can use this templates to make it easier and quicker.
Features:
Responsive.
Technical SEO optimized (uses correct tags, like h1, h2, section etc)
Tailwind built in, for rapid development (uses `tw-` prefix to separate tailwind classes)
Quick customization, just change texts.
Frontend framework independent: Comes with basic html, css just enough for your perfect landing page, you are free to modify and use any frontend framework (React, Vue) if required.
Whom is this meant for?
Developers who have tight deadlines.
Freelancers looking to show a prototype or use a template to build faster.
SaaS Developers who don't want to spend too much time focusing on landing page, but instead want to ship more.
App developer who wants to have a web landing page. (helps with your SEO game)
People looking for inspiration and ideas.
Will there be new templates?
Yes, new templates
/r/django
https://redd.it/1eco51d
awesome-landingpages.vercel.app
Landing page templates
Free and open-source landing pages for your next project
Any Django-focused agency owners here? How do you find your leads?
Not asking about insights, but just curious in general. We are actively searching for customers on LinkedIn and Upwork. Upwork works sometimes, but it's very unreliable. LinkedIn is quiet as hell. PPC marketing is extremely expensive, like tens of dollars per click.
The best way to get new customers appears to be to do a good job and make your customers recommend you to somebody else. It's kinda cool when your customers enjoy results, but sucks if you want to scale. So what are your thoughts?
/r/django
https://redd.it/1ecp5t7
Not asking about insights, but just curious in general. We are actively searching for customers on LinkedIn and Upwork. Upwork works sometimes, but it's very unreliable. LinkedIn is quiet as hell. PPC marketing is extremely expensive, like tens of dollars per click.
The best way to get new customers appears to be to do a good job and make your customers recommend you to somebody else. It's kinda cool when your customers enjoy results, but sucks if you want to scale. So what are your thoughts?
/r/django
https://redd.it/1ecp5t7
Reddit
From the django community on Reddit
Explore this post and more from the django community
BitZoo: My first Python project.
# Backstory
Skip this if you're busy. Scroll down to the main part.
Hey y'all! It's been a few years since I learnt the basics of python, and then came a brief pause in my learning journey. I have coded a lot before this, in python, but never really been serious about stuff. Anyways, I recently decided to get back to it and started working on my first ever Python project.
I can't submit a GIF here somehow, so here's a sped-up Gameplay of it.
# What My Project Does
This program is a terminal based (TUI) game, inspired by the common lifesim games all around (like InstLife, Bitlife, AltLife, etc), but in no way, close to them. A lot is basic in here, and a lot is missing. I've tried to use this project as an opportunity to test my programming skills.
The game comes with basic lifesim elements like:
Home Screen: Where most of the gameplay takes place.
Profile: The player's profile.
Activities tab: Where the player can choose to do something.
Relations tab: Where the player can view their relations.
Career: Where the player can look for jobs.
Lifestyle: Where the player can buy different lifestyles.
# Target Audience
This is a toy project
/r/Python
https://redd.it/1ecwe3o
# Backstory
Skip this if you're busy. Scroll down to the main part.
Hey y'all! It's been a few years since I learnt the basics of python, and then came a brief pause in my learning journey. I have coded a lot before this, in python, but never really been serious about stuff. Anyways, I recently decided to get back to it and started working on my first ever Python project.
I can't submit a GIF here somehow, so here's a sped-up Gameplay of it.
# What My Project Does
This program is a terminal based (TUI) game, inspired by the common lifesim games all around (like InstLife, Bitlife, AltLife, etc), but in no way, close to them. A lot is basic in here, and a lot is missing. I've tried to use this project as an opportunity to test my programming skills.
The game comes with basic lifesim elements like:
Home Screen: Where most of the gameplay takes place.
Profile: The player's profile.
Activities tab: Where the player can choose to do something.
Relations tab: Where the player can view their relations.
Career: Where the player can look for jobs.
Lifestyle: Where the player can buy different lifestyles.
# Target Audience
This is a toy project
/r/Python
https://redd.it/1ecwe3o
Imgur
Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
Free asynchronous coding course
Harlem Coding Kids is a free virtual program that teaches Python coding to middle and high school students.
During the 2024 summer session, the program will be run asynchronously over Slack where students from anywhere in the world can access the free lesson videos and homework, as well as ask questions that will be answered by the program instructors.
To sign up, register at this google form: https://forms.gle/Srx7CXmsuf715ce68
/r/Python
https://redd.it/1eczbhg
Harlem Coding Kids is a free virtual program that teaches Python coding to middle and high school students.
During the 2024 summer session, the program will be run asynchronously over Slack where students from anywhere in the world can access the free lesson videos and homework, as well as ask questions that will be answered by the program instructors.
To sign up, register at this google form: https://forms.gle/Srx7CXmsuf715ce68
/r/Python
https://redd.it/1eczbhg
Google Docs
Harlem Coding Kids
Harlem Coding Kids is a free virtual program that teaches Python coding to middle and high school students.
During the 2023-2024 Winter Break session, the program will be run asynchronously over Slack where students can access the free lesson videos and…
During the 2023-2024 Winter Break session, the program will be run asynchronously over Slack where students can access the free lesson videos and…
Add a profile model to a custom user model
How do I add a profile model to a custom user model?
I have a working custom user model `A`. It is working in that sense that after registration, a database entry is established. Now, I want to extend `A` with a profile model `AProfile`. For ordinary user models, one uses `user = models.OneToOneField(User, on_delete=models.CASCADE)`, hence I typed `user = models.OneToOneField(A, on_delete=models.CASCADE)` but it doesn't work. Accessing the profile via `request.user.aprofile` yields `RelatedObjectDoesNotExist: A has no aprofile.` What am I doing wrong?
I basically followed: https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#a-full-example but replaced/inserted the information I need, fi. removing `date_of_birth` and adding `first_name`, `last_name`.
Custom user models are hard and unintuitive.
Edit: The Code:
```python
from django.db import models
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
class SurffreundUserManager(BaseUserManager):
def create_user(self, email, first_name, last_name, password=None):
"""
Creates and saves a User with the given email, date of
birth and password.
"""
if not email:
raise ValueError("Users must have an email address")
/r/django
https://redd.it/1ecyor7
How do I add a profile model to a custom user model?
I have a working custom user model `A`. It is working in that sense that after registration, a database entry is established. Now, I want to extend `A` with a profile model `AProfile`. For ordinary user models, one uses `user = models.OneToOneField(User, on_delete=models.CASCADE)`, hence I typed `user = models.OneToOneField(A, on_delete=models.CASCADE)` but it doesn't work. Accessing the profile via `request.user.aprofile` yields `RelatedObjectDoesNotExist: A has no aprofile.` What am I doing wrong?
I basically followed: https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#a-full-example but replaced/inserted the information I need, fi. removing `date_of_birth` and adding `first_name`, `last_name`.
Custom user models are hard and unintuitive.
Edit: The Code:
```python
from django.db import models
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
class SurffreundUserManager(BaseUserManager):
def create_user(self, email, first_name, last_name, password=None):
"""
Creates and saves a User with the given email, date of
birth and password.
"""
if not email:
raise ValueError("Users must have an email address")
/r/django
https://redd.it/1ecyor7
Django Project
Customizing authentication in Django | Django documentation
The web framework for perfectionists with deadlines.
How to debug in Flask
As there are many files which we create while building an application using flask. Each file is dependent on other in this case how to debug a code? How to find where exactly we are getting stuck?
Thanks for your help in advance.
/r/flask
https://redd.it/1ecwh1b
As there are many files which we create while building an application using flask. Each file is dependent on other in this case how to debug a code? How to find where exactly we are getting stuck?
Thanks for your help in advance.
/r/flask
https://redd.it/1ecwh1b
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
How you customise & simplify the Django admin so your non tech savvy client can use it like a CMS?
The title.
/r/django
https://redd.it/1ed2ifj
The title.
/r/django
https://redd.it/1ed2ifj
Reddit
From the django community on Reddit
Explore this post and more from the django community
I've noticed when I try to update my flask database structure it takes much longer than it used to. Why is that?
I just added a model to my Flask project and updated it by running `flask db migrate` and it hangs for a long time here. It happened the last time I changed the project too. The time it takes is about five minutes. `flask db upgrade` is zippy as usual.
Anything I should be checking for?
The table I added just now is a super simple one. A couple small integer and string fields.
/r/flask
https://redd.it/1ed5m45
I just added a model to my Flask project and updated it by running `flask db migrate` and it hangs for a long time here. It happened the last time I changed the project too. The time it takes is about five minutes. `flask db upgrade` is zippy as usual.
Anything I should be checking for?
The table I added just now is a super simple one. A couple small integer and string fields.
/r/flask
https://redd.it/1ed5m45
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
D Is it even appropriate to be comparing open source LLMs to closed models?
For example comparing LLaMA-3 to GPT-4. To me it doesn't make sense because it feels like comparing a model to an actual product. A product being a model with a bunch of other things that have been applied (e.g., pre-/post-processing techniques).
/r/MachineLearning
https://redd.it/1ed7bg7
For example comparing LLaMA-3 to GPT-4. To me it doesn't make sense because it feels like comparing a model to an actual product. A product being a model with a bunch of other things that have been applied (e.g., pre-/post-processing techniques).
/r/MachineLearning
https://redd.it/1ed7bg7
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
# Weekly Thread: Resource Request and Sharing 📚
Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!
## How it Works:
1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.
## Guidelines:
Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.
## Example Shares:
1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.
## Example Requests:
1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.
Share the knowledge, enrich the community. Happy learning! 🌟
/r/Python
https://redd.it/1ed2too
# Weekly Thread: Resource Request and Sharing 📚
Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!
## How it Works:
1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.
## Guidelines:
Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.
## Example Shares:
1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.
## Example Requests:
1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.
Share the knowledge, enrich the community. Happy learning! 🌟
/r/Python
https://redd.it/1ed2too
YouTube
Data Structures and Algorithms in Python - Full Course for Beginners
A beginner-friendly introduction to common data structures (linked lists, stacks, queues, graphs) and algorithms (search, sorting, recursion, dynamic programming) in Python. This course will help you prepare for coding interviews and assessments.
🔗 Course…
🔗 Course…
My first published FOSS | DynamicDict | Yet another dot-access dictionary wrapper.
Here's my first real contribution to the world of open source: https://github.com/gebnar/PythonDynamicDict
What My Project Does
It's a dictionary wrapper that allows attribute access and mutation using both dot notation and dictionary-style indexing.
Target Audience
Production, with caution
Comparison
I found a couple similar serious projects out there that do the same thing. I think mine approaches the space from a slightly different philosophy. My priorities were preserving namespace, making usage feel predictable in a "pythonic" way (whatever that means), and lots of dunders for high interoperability. I also added several safety/convenience features to make usage in production a bit safer, including optional strict typing, key renaming, and a bunch of unit tests.
I knew when I started this that probably a lot of someones had to have implemented something like this before me. But I wanted to learn a bit more about python internals and object behaviors, so I rolled my own version from scratch before reading any of the others.
Having now reviewed some of the competition, I do think I bring some valuable ideas to the table.
I realize this kind of thing is a bit silly. But I've actually found it quite useful. There are lots of ways to use dynamic objects wrong. We all
/r/Python
https://redd.it/1ed8jdt
Here's my first real contribution to the world of open source: https://github.com/gebnar/PythonDynamicDict
What My Project Does
It's a dictionary wrapper that allows attribute access and mutation using both dot notation and dictionary-style indexing.
Target Audience
Production, with caution
Comparison
I found a couple similar serious projects out there that do the same thing. I think mine approaches the space from a slightly different philosophy. My priorities were preserving namespace, making usage feel predictable in a "pythonic" way (whatever that means), and lots of dunders for high interoperability. I also added several safety/convenience features to make usage in production a bit safer, including optional strict typing, key renaming, and a bunch of unit tests.
I knew when I started this that probably a lot of someones had to have implemented something like this before me. But I wanted to learn a bit more about python internals and object behaviors, so I rolled my own version from scratch before reading any of the others.
Having now reviewed some of the competition, I do think I bring some valuable ideas to the table.
I realize this kind of thing is a bit silly. But I've actually found it quite useful. There are lots of ways to use dynamic objects wrong. We all
/r/Python
https://redd.it/1ed8jdt
GitHub
GitHub - gebnar/PythonDynamicDict: A dictionary wrapper that allows attribute access and mutation using both dot notation and dictionary…
A dictionary wrapper that allows attribute access and mutation using both dot notation and dictionary-style indexing. - gebnar/PythonDynamicDict
What is too much type hinting for you?
For me it's :
from typing import Self
class Foo:
def bar(self: Self) -> None:
...
The second example is acceptable in my opinion, as the parameter are one type and the type hint for the actual attributes is for their entire lifetimes within the instance :
class Foo:
def init(self, par1: int, par2: tuplefloat, float):
self.par1: int = par1
self.par2: tuplefloat, float | None = par2
/r/Python
https://redd.it/1edcel1
For me it's :
from typing import Self
class Foo:
def bar(self: Self) -> None:
...
The second example is acceptable in my opinion, as the parameter are one type and the type hint for the actual attributes is for their entire lifetimes within the instance :
class Foo:
def init(self, par1: int, par2: tuplefloat, float):
self.par1: int = par1
self.par2: tuplefloat, float | None = par2
/r/Python
https://redd.it/1edcel1
Reddit
From the Python community on Reddit
Explore this post and more from the Python community