Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REST code-golf: How concisely can you expose and consume services?

37 views
Skip to first unread message

Alec Taylor

unread,
Sep 28, 2012, 1:41:32 AM9/28/12
to comp.lang.python
web2py (7 lines): https://gist.github.com/3798093

Includes creation of models, validator, controllers and urls.

Rules:
- Must have [at least] the same functionality as my 7-line example
- Imports are allowed and not taken into line count, on the condition
that everything remains generic. I.e.: one can change model and
controller names &etc without modifying imported libraries
- Can't import/take the code from web2py (e.g.:
https://github.com/web2py/web2py/blob/master/gluon/tools.py#L4098)

(feel free to write them in reply to this email and/or as gist comments =])

Good luck!

Chris Angelico

unread,
Sep 28, 2012, 3:39:08 AM9/28/12
to pytho...@python.org
On Fri, Sep 28, 2012 at 3:41 PM, Alec Taylor <alec.t...@gmail.com> wrote:
> web2py (7 lines): https://gist.github.com/3798093

I love the idea, even though I shan't be entering. Code golf is awesome fun!

My latest golf game involved importing code comments and text-file
annotations into autodoc markup... with two one-liners. And it only
needed two because I did it in two parts (wasn't even aware of the
text file until I'd done the code comments).

Of course, a real RESTful API is likely to have rather more guts in
it, but it's cool how little you need of structure!

ChrisA

Demian Brecht

unread,
Sep 28, 2012, 10:17:15 AM9/28/12
to pytho...@python.org
(A little OT so my apologies up front)

On 12-09-28 12:39 AM, Chris Angelico wrote:
> I love the idea, even though I shan't be entering. Code golf is awesome fun!

Code golf is indeed awesome fun and I usually enjoy taking part as well.
However, I'm not a fan of code golf such as this, that uses a framework
and then defines a rule that you *can't* hack on the same framework.

In the framework/external module spirit, I *could* write a module that
does *all* of this for me (in Pyramid, Django, web2py, etc) and then
enter with a simple method call in another module.

Done. One liner. I win ;)

I much prefer code golf that tests algorithmic/core language feature
knowledge. Of course, that's entirely only my opinion.

--
Demian Brecht
@demianbrecht
http://demianbrecht.github.com

Alec Taylor

unread,
Sep 28, 2012, 12:25:31 PM9/28/12
to Demian Brecht, pytho...@python.org
> --
> http://mail.python.org/mailman/listinfo/python-list

Well I suppose I could lax that same requirement. I.e.: if you can get
these decorators (also working with RBAC) in, for example: Django;
then it still satisfied the rules :)
0 new messages