It is not obvious to me how to use RopeVim's code assist feature.
I was using Vim at the terminal in mac os x.
I moved to MacVim and the GUI does help b/c I do see a Ropevim menu option now.
I have Ropevim set up correctly I'm fairly sure.
I want to test the code assist feature out, so I type in self.asser
and nothing happens. I've tried tab and control + space.
I sometimes see basically a history of what I've typed, more along the lines of auto-complete, b/c I have a plugin for that, but I want to see that code assist shows me what possible options are.
When I type in from django.contrib.
I want to know if code assist will be able to show me things like mail, syndication, etc, modules that I've never even typed in this project before.
Of course pycharm certainly does this flawlessly, but I am still partial to vim. Can't quite let it go, but most definitely can not afford the time to continue to fiddle with this tinkering b/c I need to get coding. The Rope library seems like it can do what I need: code assist and basic refactoring, but how?
I use jedi-vim and code assist works perfectly. https://github.com/davidhalter/jedi-vim.
Update:
I uploaded a short video. http://youtu.be/5lgbV8iY8-Q
Did you look at the code? Code assist seems to be mapped to <M-/>.
Related
I want to create a program with a GUI using Python. This program should show a list of nodes somewhere and allow me to insert them on a working diagram. I also need this nodes connected in some sequence. The following image is similar to what I need, it's from Orange3.
I come from a web development background and I've used Python for some Data Science but all using Terminal so right now I feel a little lost on where to get started.
I would much appreciate some help on where to look. Also I would like to use, if possible, existing tools instead of having to develop everything from scratch. Maybe there even is a project that does what I need and I could fork it from Github.
Thanks a lot for the help.
Check out Tkinter. Its great for GUI. Hard to add in images though. You could use Base64 to add in images.
There are plenty but it's best to create it yourself. There are infinite tutorials. Besides its gonna be full of bugs if you try to alter code that isn't yours.
My current makeshift approach is logging to a textfile, but that isn't very interactive. I've tried using pdb, but that doesn't seem to get along with urwid, pdb doesn't take any input once it hits a breakpoint.
A couple of practices down the line... Debugging urwid is strange and not really well possible in the classical sense, most of the time after rendering the canvas you can't really check things anymore.
What helped me:
Routing errors into a file. If you get exceptions and want to understand what, where and how, nice implementation is given here: https://stackoverflow.com/a/12877023/5058041
Really try to understand what your modules are and how you want to achieve things. Reading the documentation for the n+1-time is a good idea.
Look at the implementation of the widgets you use. Often they have some more information.
I know that doesn't really count as debugging, but it helped me a lot in finding errors or strange behavior.
One thing I've found myself doing is to add a text widget just to display debugging messages.
I haven't built many complicated apps (a solitaire game was the biggest app i wrote with it), so this approach was good enough.
In some specific cases, you might still be able to get away using PUDB -- but since it's also using Urwid, it will steal the output from the app. In practice, after you go from your app to pudb (maybe from a pudb.set_trace() breakpoint added to your code), then you won't be able to get back to your app.
For more complex applications it might be interesting to build a "debug mode", or maybe you could try using remote pudb? Haven't tried that yet, but it looks useful. =)
just in case anyone's searching for a better answer, I can report that VSCode's Python debugger debugpy is excellent for debugging urwid applications (and for debugging Python generally.) Your debugger is entirely separate from the console and doesn't interfere with drawing.
i have been delving into ida Pro for the last couple of weeks to get a bit of a background.
Something that has been bugging me for a long time though is the seemingly lack of support for pulling out the imported functions.
All i want is a script that can copy the entire imports window and paste into a text file, but I am having serious trouble finding anything in the API's that can help me do this. It should be very simple, yet I find it impossible. I have managed to find things to pull out the library's from this window, but nothing to pull out everything.
any help or direction would be much appreciated.
I agree with the assertion that you should use Ctrl+Ins or dumpbin.
However, what you ask has been solved already by the IDAPython project and I suggest you head over and look at their examples (here and here), especially this one.
The relevant idaapi functions are:
idaapi.get_import_module_qty
idaapi.enum_import_names
GUI Solution:
You can copy the entire contents of the imports window by placing focus on that window and hitting Ctrl+Ins.
IDAPython Solution:
This may need to be tweaked to your liking, but this should hopefully get you started:
text = ""
seg = SegByName(".idata")
for i in xrange(seg, SegEnd(seg), 4):
text += "%08x %s\r\n" % (i, Name(i))
open(r"c:\imports.txt", "wb").write(text)
I've looked at most of the IDE's out there. I've set up vim to use autocompletion and I'm using it right now. However, I can't seem to get it to work like Visual Studio with .NET. Autocompletion seems to work only in certain cases and it only shows methods and not what parameters they take. It's pretty much unusable to me.
What I'm after is a pop-up that will show me all methods available and the parameters they take. Pretty much the feel of VS2010 when you're programming .NET.
You won't get the kind of autocompletion in a dynamic language like Python that you get in more explicitly typed languages. Consider:
def MyFunction(MyArg):
MyArg.
When you type the "." in MyArg., you expect the editor to provide a list of methods with arguments. That can't happen in Python because the editor has absolutely no way of knowing what type (or types) MyArg could possibly be. Even the Python compiler doesn't have that information when it's compiling the code. That's why, if you put MyArg.SomeNonExistentFunction() you won't get any kind of error message until runtime.
If you wrote something like:
def MyFunction:
MyObject = MyClass(SomeArg)
MyObject.
then a smart enough editor can supply a list of methods available after that final ".".
You'll find that those editors that are supplying autocomplete "sometimes" are doing so in cases similar to my second example, and not doing so in cases similar to the first. With Python, that's as good as you can get.
I've been using Eclipse with the PyDev extension for some time now. The auto-completion there is really quite impressive, I highly recommend it.
Gedit has a developer plugin which tries to do some syntax completion. For reasons already mentioned, it doesn't work very well. I found it more annoying than helpful and disabled it after a few weeks trial.
ipython's new Qt console has tab completion and you can have some tooltip sort of popups with syntax help and docstrings. See screenshot below for example..
But as most people have already pointed out, this kind of thing you are asking for is really more appropriate for less dynamic languages.
I often use ipython (or the regular python shell) to test python code snippets while coding, and it's been very useful. One shortcoming of this, though, is that if I want to test a multi-line segment of code, or want to write multiple lines of code before running, it isn't very convenient to have to do it "line by line". And even going back to change some of the lines is cumbersome because you have to re-type all the code that comes after it.
I'm playing with Groovy right now and I find that it has an excellent solution to this problem: the Groovy Console. You just write all the code you want, it's just like a regular editor; and then you hit run Ctrl+R (Cmd+R actually since I'm on a Mac) and it runs everything at once. If you want to change something (e.g. if there are errors), then that's easy too -- just change it and Ctrl+R again.
Is there an equivalent of this available for python? Or do you have any recommendations on a way to achieve similar behavior? I could just create a new file, save it, and then python <filename>.py from the shell. But that's just too many steps and would be cumbersome. Eclipse may be an option, but it's too heavyweight. I'm really looking for something lightweight that I can just spin up when I want to test something and then get rid of it just as quickly.
I'd be interested to hear any ideas/suggestions!
Thanks
You might give DreamPie a try. As far as I can tell from a quick read of the groovyConsole page you linked to, DreamPie features a similar input area/output area division (they call it "code box" and "history box"). The code you execute is by default cleared from the code box - which groovyConsole apparently doesn't do - but you can easily retrieve it (Ctrl+Up), or change a preference setting to "Leave code in the code box after execution".
Have you tried using IDLE, the standard Python IDE? You'd have to save the code as <filename>.py within IDLE, but after that you can run it using F5.
The Python docs link to this intro to IDLE, which may be helpful even if it's a little outdated.
I am using emacs and its python-mode.
C-c C-c: evals the current buffer
but you can also eval region (ie selection), functions etc ...
You can even make python-mode use ipython (like I do).
See http://ipython.scipy.org/dist/ipython.el . It works nicely
Did you try PyCrust? It has excellent multi-line editing, copy/paste support.
PyCrust can be found in wxPython Docs and Demos.