Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Python already provides both 'flat' and 'vector' interfaces #21

Open
jonathanfine opened this issue Sep 30, 2014 · 2 comments
Open

Comments

@jonathanfine
Copy link
Contributor

We can have Python provide both 'flat' and 'vector' interfaces, using a single code-base.

Let world denote the Minecraft world we are connected to. Python translates

world[1, 2, 3]

into

world.__getitem__((1, 2, 3))

Now write

vec = (1, 2, 3)

Python translates

world[pos]

to exactly the same as before, namely

world.__getitem__((1, 2, 3))

What's more, Python translates

world[pos1:pos2]

into

world.__getitem__(slice(pos1, pos2))

where the slice has start and stop attributes pos1 and pos2. From this we can have __getitem__ do what we think is the right thing.

We can even write, if there is need for it

world[pos1, pos2:pos3]
@doismellburning
Copy link
Member

Can you please clarify the issue here?

@jonathanfine
Copy link
Contributor Author

Some may think we have to choose between a vector or flat interface. I'm noting here that we do not. I'm also noting that this capability is build into Python's language API for container[...].

In short we have a real opportunity here to be Pythonic, and doing so would provide many benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants