Edward K. Ream wrote:

Leo's API consists primarily of *generators*, such as c.all_positions(), 
>>> p.self_and_subtree(), etc. and *properties*, such as p.b, p.h, p.gnx 
>>> and p.v.u.  
>>>
>>
>> One thing I always wondered about...is there a reason why Leos API is so 
>> unpythonic?
>>
>
> ​How are they unpythonic?​
>  
> ​How would you improve, say:
>
>     for p in c.all_positions():
>         print(p.h)
>
 
  

for position in commander.find(all=True):

print(position.headline)


or


for position in commander.walk('/**'):

print(position.headline)


or


print('\n'.join(node for node in document.walk()))

#Ok, kidding ;)


Well, going for that simple example:


Single-letter-names for objects and attributes is very bad style.


Then there is the design-flaw to use a new method for every single 
edge-case of a general functionality,

instead of using arguments and not poisoning the namespace.


The position-object for example. has at least 12(!) methods for the simple 
task of walking

the tree, not even including the methods from the commander-object.... 

Thats 11 more then neccessary, and 10 more then comfort demand. 


And then there are the broken generators like all_positions which always 
return the same object 

and just changes it's internal state.

Personally I must say it's a pain to work with Leo's API, because there is 
many unpredictable behaviour,
it's unneccessary time-consuming to find something and it's not as powerful 
as it could be. 
For me it's even even faster to use my own more pythonic API which only 
wraps some methods, 
then to always dig through that mountain.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to