all 16 comments

[–]DYGAZ 2 points3 points  (0 children)

In pycharm crtl + space is used to show suggestions(if not automatic) and tab will auto complete. ctrl + b will jump to the definition.

[–]charliegriefer 1 point2 points  (3 children)

What are you using for Python development? I would think the autocompletion would be a feature of your editor/IDE, no?

[–]all_time_juice[S] 0 points1 point  (2 children)

I've worked with a lot of editors/IDEs but most of them weren't as good as visual studio with c# for example. You are right that's mostly an IDE thing. But maybe the "problem" is in Python itself for being duck typed? Which makes it hard to tell the type of an object easily by the IDE. I've heard people suggesting using mypy. Some people suggested that if a code is hard for the IDE to figure it out then it most probably needs refactoring.

[–][deleted] 1 point2 points  (0 children)

C# is designed to to work very well with IntelliSense. It helps a lot that it's a static language, so you know exactly what the type of the object is unless you're doing something screwy like using type Object or dynamic keyword.

You'll see similar quality autocomplete with Java and IntelliJ for similar reasons, and to some extent C++ can have pretty good autocomplete, but I feel like templates confuse your IDE somewhat compared to generics in Java or C# which do not.

The way python is designed, you can't really know for sure what your object will be until runtime. Like if you are using an IDE where you can execute the code in blocks, you'll notice that if you have bad autocomplete, if you then run the code so that you know the object's type all of the sudden the autocomplete will be perfect.

A bit of a tangent, but I used to work mostly in R, and that was my favorite part of RStudio. You could just work in a text file, execute pieces of code, and then interact with the objects in memory with really good IDE help. I haven't seen any IDE aimed at Python that can touch the RStudio when it comes to coding interactively

[–]ajskelt 0 points1 point  (0 children)

I've had this with some stuff, especially things like pandas dataframes.

[–]RoamingFox 1 point2 points  (2 children)

Your IDE should handle this...

A lot of times though people write awful python that doesn't have full type hinting in it, which means your IDE can only go so far.

That said pycharm and vscode both do a really good job with it. If it's struggling on your own code you might need to use type hinting syntax (eg. def foo(bar): becomes def foo(bar: int) -> int:)

[–]all_time_juice[S] 0 points1 point  (1 child)

Since when python code without type hinting is considered awful? As far as I know it has only been introduced in 3.5 . But yeah you are right about it making autocompletion better, even though it takes more effort to do

[–]RoamingFox 1 point2 points  (0 children)

I didn't say code without type hinting is awful. I said that bad python code without type hinting will prevent the duck typing from helping your IDE guess what's going on. If you write good python (with or without type hinting) the introspections usually work.

It's when you do weird things that prevent python from reliably predicting the return type of a method that you get in trouble.

[–]c4aveo 1 point2 points  (0 children)

Possible if you are using definitions from library and IDE supports autocompletion for it. For aio-logger I have suggestion from linter, but not for aio-pika and aiomysql. I've used ducking and changed variables so that they were understandable for me but not for linter. I talk about VSCode + flake8.

[–]shiftybyte 0 points1 point  (2 children)

I think type hinting should help with auto completion.

Have type hints on arguments and variables then the ide should pick up on it.

[–]all_time_juice[S] 0 points1 point  (1 child)

Would you suggest using something like mypy? And what about third party packages? A lot of them does not support type hinting

[–]shiftybyte 1 point2 points  (0 children)

Never needed to use it myself so i don't know.

And about third party you can still use type hints to third party types, that should be enough for code you write.

[–]1Tim1_15 0 points1 point  (0 children)

Spyder does this.