4 ms·
That honestly looks more like a failure on the part of the Python library maintainer to create a pleasant way to create record prototypes. I mean, all you're d
by DannoHung 16y ago
That honestly looks more like a failure on the part of the Python library maintainer to create a pleasant way to create record prototypes.
I mean, all you're doing in your list example is creating dictionary and list examples of the mapping you want. There is literally nothing stopping you from doing that in Python.
- swannodette 16y agocreators = [{"name" :{"name_authority" :TextField, "name_authority_id" :IntegerField, "display_string" :TextField}, "user_id" :IntegerField, "roles" :[TextField], "attrs" :[TextField], "xts" :[TextField]}] Yes you could do something like this. But the lack of keywords does reintroduces some noise via the quotes around strings. Moving the colons around like this to give visual alignment would probably be frowned upon. So my sense is that this would be considered "un-Pythonic" but I could be wrong.
- cma 16y agoUse single quotes; less noise.
- DisposaBoy 16y agowho writes code like that? creators = [ { "name": { "name_authority": TextField, "name_authority_id": IntegerField, "display_string": TextField }, "user_id" :IntegerField, "roles": [TextField], "attrs": [TextField], "xts": [TextField] } ] anyway
- swannodette 16y agoI certainly don't write Python code that looks like what I wrote. My point was that the various idiomatic versions, including yours, certainly isn't any more readable than the Clojure version.
- DisposaBoy 16y agoI don't speak for everyone but the reason I see lisp code as unreadable is that most of what I've seen is written like your example. That is, there is some indentation which helps, but it's as-if the coder is afraid to utilise vertical space so they put all the closing brackets on the same line, most of the opening ones in the middle of some lines. With that kind of formatting (for me at-least), it's not immediately clear which.