[developers] RESTful ERG parsing

Ned Letcher ned at nedned.net
Mon Apr 18 08:25:46 CEST 2016


>
> The ideal world you described is probably the 3rd-party Requests package:
>
> >>> import requests
> >>> resp = requests.get('http://erg.delph-in.net/rest/0.9/parse?input=あ
> is a Japanese character.')
> >>> resp.json()['input']
> 'あ is a Japanese character.'
>
> (notice the あ is returned in the response; i.e. it was encoded in the
> request AND decoded in the response; furthermore, this works unmodified for
> both Python 2 and 3)
>
> But I share your desire for a simple solution that has no dependencies
> outside of the standard libraries, so I'll see if I can make it work.
>

I have but a minor contribution to this discussion: my understanding is
that the Requests package has been effectively officially sanctioned as way
to do HTTP in Python (as Mike alluded to), and the reason it has not been
rolled into the standard library is to facilitate faster security updates
through PyPI than would occur with the official Python distribution.

So if there was going to be an exception to the maxim of having minimal
dependencies, this would be a good candidate.

Also, I'm looking forward to trying out the API soon, thanks very much for
all the work Stephan!

Ned


> —once you have had a chance to look at RESTful client implementation
>> yourself, i will be curious to see which solution you adopt!
>>
>
> Python has a nice ImportError that you can catch, and since Python2
> doesn't have the urllib.request or urllib.parse sub-packages, I exploit
> this to write custom pre-encoding code for Python2. It sounds a little
> hacky, but it's a pretty common pattern for code meant to work with both
> versions. But given that Python3's quote function takes either bytes or
> unicode strings, I might not need to do this. More soon.
>
> Btw, in the current version of the MRS-JSON format, I noticed that handles
> had no "type", where I expected {"type": "h"}.
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.delph-in.net/archives/developers/attachments/20160418/126c1bd5/attachment.html>


More information about the developers mailing list