rochacbruno,
@rochacbruno@hachyderm.io avatar

It is disappointing that TypedDict doesn't support setting default values.

from typing import TypedDict

class Con(TypedDict):  
 host: str  
 port: int = 9090

data = {"host": "test.com"}  
connection = Con(**data)  

I expected it to give me "port": 9090 by default but it does not!

Looks like building the dict as instance of Con doesn't make any difference than just building a {} and that is very confusing.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • rosin
  • magazineikmin
  • GTA5RPClips
  • khanakhh
  • InstantRegret
  • Youngstown
  • mdbf
  • slotface
  • thenastyranch
  • everett
  • osvaldo12
  • kavyap
  • cubers
  • DreamBathrooms
  • megavids
  • Durango
  • modclub
  • ngwrru68w68
  • vwfavf
  • ethstaker
  • tester
  • cisconetworking
  • tacticalgear
  • Leos
  • provamag3
  • normalnudes
  • anitta
  • JUstTest
  • All magazines