Re: Most "pythonic" syntax to use for an API client library

2019-05-14 Thread Dotan Cohen
I highly recommend going with the last approach. With the last approach you can pass around objects in proper OOP fashion. This will be familiar to most contributors to your project and most devs that you hire. foo = api.customers(1) if bar==baz: foo.update(Name='Leroy') else: foo.delete(

Re: Most "pythonic" syntax to use for an API client library

2019-05-14 Thread Jonathan Leroy - Inikup via Python-list
Le dim. 28 avr. 2019 à 20:58, Jonathan Leroy - Inikup a écrit : > Which of the following syntax do you expect an API client library to > use, and why? Thank you all for your feedbacks! I will go with #2. Le lun. 29 avr. 2019 à 05:43, DL Neil a écrit : > Doesn't the framework you are using have

Re: Most "pythonic" syntax to use for an API client library

2019-04-30 Thread Thomas Jollans
On 30/04/2019 09.52, Peter Otten wrote: > Thomas Jollans wrote: > >> On 29/04/2019 09.18, Peter Otten wrote: >>> Jonathan Leroy - Inikup via Python-list wrote: >>> alice.name = "Bob" # __setattr__ >>> >>> del customers[42] # __delitem__ >> >> do you want this sort of thing to update the upstream

Re: Most "pythonic" syntax to use for an API client library

2019-04-30 Thread Peter Otten
Thomas Jollans wrote: > On 29/04/2019 09.18, Peter Otten wrote: >> Jonathan Leroy - Inikup via Python-list wrote: >> >>> Hi all, >>> >>> I'm writing a client library for a REST API. The API endpoints looks >>> like this: /customers >>> /customers/1 >>> /customers/1/update >>> /customers/1/delete

Re: Most "pythonic" syntax to use for an API client library

2019-04-29 Thread Thomas Jollans
On 29/04/2019 09.18, Peter Otten wrote: > Jonathan Leroy - Inikup via Python-list wrote: > >> Hi all, >> >> I'm writing a client library for a REST API. The API endpoints looks like >> this: /customers >> /customers/1 >> /customers/1/update >> /customers/1/delete >> >> Which of the following synta

Re: Most "pythonic" syntax to use for an API client library

2019-04-29 Thread Peter Otten
Jonathan Leroy - Inikup via Python-list wrote: > Hi all, > > I'm writing a client library for a REST API. The API endpoints looks like > this: /customers > /customers/1 > /customers/1/update > /customers/1/delete > > Which of the following syntax do you expect an API client library to > use, and

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread Albert-Jan Roskam
On 29 Apr 2019 07:18, DL Neil wrote: On 29/04/19 4:52 PM, Chris Angelico wrote: > On Mon, Apr 29, 2019 at 2:43 PM DL Neil > wrote: >> >> On 29/04/19 3:55 PM, Chris Angelico wrote: >>> On Mon, Apr 29, 2019 at 1:43 PM DL Neil >>> wrote: Well, seeing you ask: a more HTTP-ish approach *mi

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread DL Neil
On 29/04/19 4:52 PM, Chris Angelico wrote: On Mon, Apr 29, 2019 at 2:43 PM DL Neil wrote: On 29/04/19 3:55 PM, Chris Angelico wrote: On Mon, Apr 29, 2019 at 1:43 PM DL Neil wrote: Well, seeing you ask: a more HTTP-ish approach *might* be: api.update.customer( 1, name='Bob' ) ie api.verb.s

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread Chris Angelico
On Mon, Apr 29, 2019 at 2:43 PM DL Neil wrote: > > On 29/04/19 3:55 PM, Chris Angelico wrote: > > On Mon, Apr 29, 2019 at 1:43 PM DL Neil > > wrote: > >> Well, seeing you ask: a more HTTP-ish approach *might* be: > >> > >> api.update.customer( 1, name='Bob' ) > >> > >> ie > >> api.verb.subject(

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread DL Neil
On 29/04/19 3:55 PM, Chris Angelico wrote: On Mon, Apr 29, 2019 at 1:43 PM DL Neil wrote: Well, seeing you ask: a more HTTP-ish approach *might* be: api.update.customer( 1, name='Bob' ) ie api.verb.subject( adjectives and adverbs ) Thus: api_label/intro/ID.what_we're_going_to_do.who/what_we'

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread Chris Angelico
On Mon, Apr 29, 2019 at 1:43 PM DL Neil wrote: > Well, seeing you ask: a more HTTP-ish approach *might* be: > > api.update.customer( 1, name='Bob' ) > > ie > api.verb.subject( adjectives and adverbs ) > > Thus: > api_label/intro/ID.what_we're_going_to_do.who/what_we'll_do_it_to( > customerID, supp

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread DL Neil
On 29/04/19 6:58 AM, Jonathan Leroy - Inikup via Python-list wrote: 1/ api.customers_list() api.customers_info(1) api.customers_update(1, name='Bob') api.customers_delete(1) Dislike this because it mixes point and underscore - easy to mistake! 2/ api.customers.list() api.customers.info(1) ap

Re: Most "pythonic" syntax to use for an API client library

2019-04-28 Thread Chris Angelico
On Mon, Apr 29, 2019 at 11:44 AM Jonathan Leroy - Inikup via Python-list wrote: > > Hi all, > > I'm writing a client library for a REST API. The API endpoints looks like > this: > /customers > /customers/1 > /customers/1/update > /customers/1/delete > > Which of the following syntax do you expect

Most "pythonic" syntax to use for an API client library

2019-04-28 Thread Jonathan Leroy - Inikup via Python-list
Hi all, I'm writing a client library for a REST API. The API endpoints looks like this: /customers /customers/1 /customers/1/update /customers/1/delete Which of the following syntax do you expect an API client library to use, and why? 1/ api.customers_list() api.customers_info(1) api.customers_u