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

关键字冲突 #104

Closed
dakezuo opened this issue Nov 5, 2018 · 7 comments
Closed

关键字冲突 #104

dakezuo opened this issue Nov 5, 2018 · 7 comments

Comments

@dakezuo
Copy link

dakezuo commented Nov 5, 2018

当我使用图灵机器人时,在返回值中有字段与内建函数名重复,这时使用点语法会报错,请问该如何避免呢

@mewwts
Copy link
Owner

mewwts commented Nov 5, 2018

Hey @dakezuo, any chance you could type this in English?

From what I can tell from google translate, I think you're asking about using built in names with the dot syntax. This won't work!

You can not use the dot syntax for keys that collide with builtins. You would have to use the getitem syntax instead e.g. my_addict['keys']

@dakezuo
Copy link
Author

dakezuo commented Nov 6, 2018

@mewwts Yes, that's exactly what I'm doing right now, and I'm wondering if there's a way to identify these system keywords internally and make an escape substitution in string form to allow the outside world to continue implementing a bit of syntax, which of course is just a suggestion, because I'm new to python, so I don't know if it's possible

@mewwts
Copy link
Owner

mewwts commented Nov 8, 2018

Hey @dakezuo - thanks for commenting!

I won't say it's impossible, but I'm not sure it's something I'd like to do, unfortunately. What's your specific usecase for this?

@dakezuo
Copy link
Author

dakezuo commented Nov 10, 2018

@mewwts I've only recently used it, and I happen to encounter this return in a request.

@mewwts
Copy link
Owner

mewwts commented Dec 20, 2018

Right, so you're using addict with arbitrary returns from http request is that so, @dakezuo?

@dakezuo
Copy link
Author

dakezuo commented Dec 20, 2018

@mewwts Yes, the key and keyword of the field returned by the server coincidentally are duplicated in the HTTP return

@mewwts
Copy link
Owner

mewwts commented Feb 11, 2019

@dakezuo I would fetch data residing on keys corresponding to builtin keywords using the getitem syntax i.e. mydict['keys'].

@mewwts mewwts closed this as completed Feb 11, 2019
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