architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
492 stars 112 forks source link

Wrap lines in console #58

Closed htlcnn closed 6 years ago

htlcnn commented 7 years ago

@daren-thomas Please add an option to enable/disable line wrapping in the RPS console

Thank you very much.

daren-thomas commented 6 years ago

@htlcnn could you please make a case? What is the current behaviour? What is the desired behaviour? Why?

Also, please consider sending a pull request if possible - that is the quickest way to get new functionality into the tool :)

htlcnn commented 6 years ago

@daren-thomas this image shows the current behaviour. I'm sorry I don't know any programming language other than python so I couldn't have made a pull request.

image

daren-thomas commented 6 years ago

I'd prefer not to fix that. Ideally, you shouldn't be writing looooooong lines anyway (PEP8 says 80 characters, 120 often works) so for the few times where it goes too far, I think scrolling is good enough.

Thank you for the suggestion, though! I appreciate the time you took to point this out :)

Unless... do you have a really good use case? something that showed up in real-life programming that made not having line-wraps unbearable for you?

htlcnn commented 6 years ago

I often use dir to print type and members of elements I chose to ensure what I got. Printing all members of an element will make a really long line. In this image I chose 24 wall instances.

image

PMoureu commented 6 years ago

We all like checking what's inside objects, but in this case of introspection, the console may not be the ideal tool to print so many members.

Even with wrapping, the output will not be much more readable with some huge objects, maybe worse if you print a list of elements.

first i used loops to get this kind of output vertically, it allows to add the value or any member you want :

for el in dir(some_elem):
    try:
        print(el, getattr(some_elem, el)) # or el.__doc__
    except:
        print(el)

and then some months ago, i began to work on a tool to list all members in a separate GUI and display type, value and doc. The project is kinda paused but i often use it to flesh out any object ( click on grid's icons opens a new tab to flesh out a member : no need to execute print again and again..).

daren-thomas commented 6 years ago

You could always check out the pprint library: https://docs.python.org/2/library/pprint.html

Also, if you have RevitLookup installed, try doing snoop(element) (or was it lookup(element)?)