-4

I have written quite a complex program in Python 3.7. However I am looking for a way to reduce (and later on expand again) my already functional functions. So that I don't have to scroll over 200 lines of code whenever I want to get back to the top.

As I said, I am writing my code in Python 3.7 and this seems like a pretty easy/beginner technique. However, I tried googling a lots of stuff, unfortunately English is not my native language and I have no idea of what to google. And googling for "reduce code in Python" ain't gonna work me. Thus I am hoping you Geeks could help me! :)

E.g.

Instead of

1 # This is some random code

2 print("Hello")

3 print("beautiful")

4 print("World")

5 # This is some random code

I want to have

1 # This is some random code

2-4 # Here all the other lines should be reduced to one line

5 # This is some random code
warped
  • 8,947
  • 3
  • 22
  • 49
Yannik Suhre
  • 724
  • 5
  • 21
  • Better use an IDE preferably PyCharm to do such folding and unfolding tasks. That's pretty much a click away. – Underoos May 15 '19 at 07:27
  • `reducing` to one line also mean different things in python. for example, for loops can be reduced into what we call `list` or `dictionary` comprehesion. I assume you are talking about reducing code size by refactoring – Devesh Kumar Singh May 15 '19 at 07:30
  • Use IDE PyCharm or Anaconda, that may help you – Omkar May 15 '19 at 07:31
  • Thanks for your answers. I am already using Anaconda, but haven't figured a way out. – Yannik Suhre May 15 '19 at 07:32

1 Answers1

0

Utilize code folding in an IDE. Suggested IDES for Anaconda can be found here. I'd recommend Visual Studio Code. IDE for anaconda

Daniel Legut
  • 106
  • 9