package python; import python.lib.Dict; /** This type represents python `**kwargs` feature, supporting passing named arguments to a function. Example: function f(kwargs:KwArgs<{a:Int}>) {} f({a: 10}); **/ abstract KwArgs(Dict) { inline function new (d:Dict) { this = d; } @:to public inline function toDict():Dict { return this; } @:from static inline function fromDict(d:Dict):KwArgs { return new KwArgs(d); } @:from static inline function fromT(d:T):KwArgs { return new KwArgs(Lib.anonAsDict(d)); } public inline function typed():T { return Lib.dictAsAnon(toDict()); } public inline function get(key:String, def:V):V { return this.get(key, def); } }