[英]Naming issue with REST wrapper hammock in Python
I'm using a REST wrapper in Python called Hammock. 我在Python中使用一个称为Hammock的REST包装器。 Better than I can explain "Hammock is a fun module lets you deal with rest APIs by converting them into dead simple programmatic APIs. It uses popular requests module in backyard to provide full-fledged rest experience."
比我能解释的要好得多:“ Hammock是一个有趣的模块,可让您通过将REST API转换为简单的编程API来处理它们。它使用后院中流行的请求模块来提供完整的REST体验。”
It will turn api.website/end/point/ into website.end.point which makes working with the API pretty simple. 它将api.website/end/point/转换为website.end.point,这使得使用API变得非常简单。 The issue I've run into is when an endpoint has a character in it that Python does not allow in names, '-' in this case (ex api.website/end-point/).
我遇到的问题是端点中包含Python不允许使用的字符(在这种情况下为“-”)(例如api.website/end-point/)。 Accessing an endpoint like this turns into website.end-point, which is invalid python code.
像这样访问一个端点将变成website.end-point,这是无效的python代码。
I looked and '-' is a totally valid character to have in a REST endpoint name. 我看了一下,“-”是REST端点名称中的一个完全有效的字符。 Is there a way to allow this character, maybe the equivalent of a character escape or something?
有没有办法允许这个角色,也许等同于一个角色转义之类的东西? I think I could fix it in the inner code of the module, but figure that's probably a bad way to go about this.
我认为我可以在模块的内部代码中对其进行修复,但是考虑到这样做可能是一种不好的方法。 Any ideas?
有任何想法吗?
I was able to fix this by using 'website("end-point")' instead of 'website.end-point'. 我能够通过使用'website(“ end-point”)'而不是'website.end-point'来解决此问题。 I hope this helps someone else out.
我希望这可以帮助其他人。
https://github.com/kadirpekel/hammock/issues/20 https://github.com/kadirpekel/hammock/issues/20
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.