SSort is currently used for several hundred kilobytes of python so I'm wary, but if I'm going to make a breaking change before 1.0 then I think this is likely to be it.
I tried it on one of my Django `admin.py` files and it created NameErrors.
class TestAdmin(admin.ModelAdmin):
list_filter = ("foo_method",)
def foo_method(self, obj):
return "something"
foo_method.short_description = "Foo method"
# It turned it into this:
class TestAdmin(admin.ModelAdmin):
list_filter = ("foo_method",)
# NameError
foo_method.short_description = "Foo method"
def foo_method(self, obj):
return "something"Which is preferable, and why?
With backwards sorting you know that, unless there is a cycle, you can always scroll up from a call site to find the definition or down from a definition to see where it is used. With forwards sorting you can scroll down to find a definition, unless the function was imported, or used as a decorator somewhere, or called by something that was used as a decorator, or used in some other way that I haven't thought of.
My personal experience is that this predictability is hugely useful. It almost entirely obviates the need for jump-to-definition within a module, and gives modules a very obvious shape and structure.
I just wish sometimes they were more configurable. For example, the Elixir formatter is quite opinionated on things but is generally not configurable.
For example, if I use the pipe example on Elixir's landing page and add comments to it (obviously a contrived example):
"Elixir" # string to get frequencies for
|> String.graphemes() # Get all graphemes (i.e., character units)
|> Enum.frequencies() # Get the number of occurrences of each grapheme
This gets formatted by the Elixir formatter to: # string to get frequencies for
"Elixir"
# Get all graphemes (i.e., character units)
|> String.graphemes()
# Get the number of occurrences of each grapheme
|> Enum.frequencies()
This is a rather strongly opinionated format stance, and as far as I know, it's not configurable.def myfunc(): global globalvar str(globalvar)
globalvar='abc'
myfunc()
will be transfered to
globalvar='abc'
def myfunc(): global globalvar str(globalvar)
myfunc()
I understand why is it done but i dont want to have function definition block filled with this declaration of variables (which i do later) since it has no impact to my code and it makes is just a bit "cleaner". Dont tell me to not use global variables :D