1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] "if" condition for boolean settings: == 1, == True or just omit?

Discussão em 'Python' iniciado por Stack, Janeiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    Here is simple ST plugin. Is there a difference between commented lines? Personally, I don't see any difference in how they work, just a difference in visual appearance.

    However, some plugin developers prefer second version (== 1), which looks just useless and ugly for me. Probably there are some reasons to prefer it?

    import sublime_plugin

    class ExpandUnexpandTabsCommand(sublime_plugin.EventListener):
    def on_pre_save(self, view):

    # if view.settings().get("translate_tabs_to_spaces"):
    # if view.settings().get("translate_tabs_to_spaces") == 1:
    # if view.settings().get("translate_tabs_to_spaces") == True:
    view.run_command("expand_tabs")
    else:
    view.run_command("unexpand_tabs")

    Continue reading...

Compartilhe esta Página