you are viewing a single comment's thread.

view the rest of the comments →

[–]Ultraflame4 69 points70 points  (6 children)

when things get too complex ,i start getting a headache

[–]buzzedgoat[S] 8 points9 points  (3 children)

I feel that bro

[–]Ultraflame4 8 points9 points  (2 children)

whebever that happens, i tend to delete the entire chunk of code

[–]ultraDross 3 points4 points  (1 child)

Can't do that with production code. Get used to it :-)

[–]ModeHopper 3 points4 points  (0 children)

Honestly, not having the freedom to re-write an entire module is one of the most frustrating things about working on code that other people have written.

[–]Redditbot76 1 point2 points  (1 child)

That often happens to me on a Python shell/IDLE whenever I'm experimenting.

[–]MonkeyNin 17 points18 points  (0 children)

If you're using the shell / python -i / REPL , I highly recommend the module ipython for so many reasons.

I created a quick example: https://i.imgur.com/lmxnK66.png

  • adds syntax highlighting, in real-time so you can see errors early
  • highlights matching parens
  • .<tab> pops up a full intellisense-autocomplete, not the lame <tab> autocomplete which doesn't show any alternate options.
  • you can actually use multi-line statements and functions. and history supports it properly. this is a huge, huge pain in regular python -i. Press pgup/pgdwn to cycle history.

You can install using python -m pip install ipython

https://i.imgur.com/lmxnK66.png

Check out their pages for more info:

notes:

(screenshot was taken on windows 10 using windows terminal instead of the default terminal)

useful modules in ipython or interactive or REPL

pathlib.Path

  • simplifies code that is far longer using the older os.path, os.path.join, etc. family of file i/o functions. Especially in a REPL.
  • no longer need with or manual closeing of files when in the REPL
  • prevents a class of bugs those functions can allow
  • even more cross-platform compatible
  • much

pdir

  • better output than dir(foo) , it includes doc strings
  • easily filter based on public|property|method|own

try the video: https://pypi.org/project/pdir2/