Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    But if you define function1 inside function2 when function1 is only used in function2, you will have a cleaner global namespace. Commented Jan 2, 2013 at 12:56
  • 1
    @nima Yes, but if you have that many functions it matters, you should probably be splitting them up into modules - which is far clearer than making lots of deeply nested functions in functions. Commented Jan 2, 2013 at 13:00
  • 1
    Then you'll have to import multiple modules when you want to use a simple feature. If you use nested functions you can import * a single module and only add a few important functions to your namespace. But that's only a personal preference I guess ;) Commented Jan 2, 2013 at 13:49
  • 1
    import * is almost always a bad idea, as it pollutes your namespace. Importing a few more modules isn't a bad thing if it gives you useful structure. Commented Jan 2, 2013 at 13:51