Skip to content

Python binding construction/deconstruction non-idiomatic #13

@cynthia

Description

@cynthia

The current initialization pattern looks like this:

import khaiii
api = khaiii.KhaiiiApi()
api.open()

Which effectively feels like a double construct. The issue is minor, but doesn't feel like idiomatic Python. Since calling the constructor is a contract that implies the caller is willing to do have the object ready, the second open() call feels rather odd. Same applies for the destructor, although this would be less of an issue since delete semantics are consistent and for most of the part the magical close() function will be obstructed away from the user.

What if, for example it worked like this by folding the two constructs into one?

from khaii import Khaiii
k = Khaii(library_path: str = '', resource_directory: str = '', options: dict = {})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions