kkinder / puepy

Python+Webassembly Frontend Framework via PyScript
https://puepy.dev
Apache License 2.0
193 stars 8 forks source link

Update core.py - rename t to builder #44

Closed kishankarun closed 1 month ago

kishankarun commented 1 month ago

Rename t to builder

kishankarun commented 1 month ago

Can the singleton be named builder similar to the class name Builder itself?

Could you please let me know why did you chose t as the name?

kkinder commented 1 month ago

The reason I choose one letter is that it's used to populate all kinds of things in populate(). Eg,

def populate(self):
    t.h1('Hello!')
    with t.ul():
        t.li('List item 1')
        t.li('List item 2')
        t.li('List item 3')

is a lot less verbose than:

def populate(self):
    builder.h1('Hello!')
    with builder.ul():
        builder.li('List item 1')
        builder.li('List item 2')
        builder.li('List item 3')

⬆️ Way too much typing.

kishankarun commented 1 month ago

Makes sense, but I was thinking from an IDE perspective (like VSCode), where most code would be copy-pasted or done much faster with other shortcuts?

kkinder commented 1 month ago

I'm still just inclined to think that brevity and readability are best. If you want to use builder on your own projects, you could alias it like this:

from puepy.core import t as builder

But for the main project docs, tutorials, etc, I think a canonical t. makes the most sense. It's small, readable, avoids conflicts, etc.