Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

python-typing

How do I add default parameters to functions when using type hinting?

August 15, 2022 by Magenaut

If I have a function like this:

Categories Python, Q&A Tags python, python-typing, type-hinting Leave a comment

What’s the difference between a constrained TypeVar and a Union?

August 13, 2022 by Magenaut

If I want to have a type that can be multiple possible types, Unions seem to be how I represent that:

Categories Python, Q&A Tags python, python-typing, type-hinting, type-variables, union-types Leave a comment

Type hints when unpacking a tuple?

August 13, 2022 by Magenaut

Is it possible to use type hinting when unpacking a tuple? I want to do this, but it results in a SyntaxError:

Categories Python, Q&A Tags iterable-unpacking, python, python-3.x, python-typing, type-hinting Leave a comment

typing: Dynamically Create Literal Alias from List of Valid Values

August 13, 2022 by Magenaut

I have a function which validates its argument to accept only values from a given list of valid options. Typing-wise, I reflect this behavior using a Literal type alias, like so:

Categories Python, Q&A Tags python, python-typing, type-hinting Leave a comment

Exclude type in Python typing annotation

August 13, 2022 by Magenaut

I wrote the following function:

Categories Python, Q&A Tags mypy, python, python-3.x, python-typing, type-hinting Leave a comment

Generic[T] base class – how to get type of T from within instance?

August 13, 2022 by Magenaut

Assume you have a Python class that inherits from Generic[T]. Is there any way to get a hold of the actual type passed in from within the class/instance?

Categories Python, Q&A Tags generics, python, python-3.x, python-typing Leave a comment

Can you annotate return type when value is instance of cls?

August 13, 2022 by Magenaut

Given a class with a helper method for initialization:

Categories Python, Q&A Tags oop, pycharm, python, python-typing, type-hinting Leave a comment

Python type hinting with exceptions

August 12, 2022 by Magenaut

I have a function that looks like this:

Categories Python, Q&A Tags exception, python, python-3.x, python-typing, type-hinting Leave a comment

Python type hinting without cyclic imports

August 12, 2022 by Magenaut

I’m trying to split my huge class into two; well, basically into the “main” class and a mixin with additional functions, like so:

Categories Python, Q&A Tags python, python-3.4, python-3.5, python-typing, type-hinting Leave a comment

Difference between defining typing.Dict and dict?

August 12, 2022 by Magenaut

I am practicing using type hints in Python 3.5. One of my colleague uses typing.Dict:

Categories Python, Q&A Tags dictionary, python, python-typing, type-hinting Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress