Skip to content

Improve discoverability of options in builtins.open #57

@alfonsogarciacaro

Description

@alfonsogarciacaro

I've been trying to write a simple script to get data from a file and process it. It's very nice to have the availability to call Python's open directly and even use use (pun unintended). But both I and a colleague had some issues to discover the correct way to pass the arguments. The fact you need to pass two nested options for OpenMode is a bit unexpected and makes it difficult to know how you need to pass the parameters unless you check the source code for Fable.Python.

Although it's nice to have a typed API, given that users may refer to Python documentation, it may be ok here to just let the user pass a string directly, although we can provide some literals with a meaningful name. For a similar reason I would avoid having to wrap the path (we can provide an overload for int file descriptors).

use file1 = builtins.``open``("myfile.txt", "xt")
use file1 = builtins.``open``("myfile.txt", OpenMode.CreateText)

What do you think @dbrattli?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions