Python Syntax Highlighting in Xcode - python

Is there any way to achieve better syntax highlighting in Xcode for Python? Xcode only identifies and colorizes keywords, strings, numbers and comments. It doesn't seem to be able to identify the self variable name that represents instance objects. I've experimented with other color themes but it doesn't change the fact that Xcode cannot identify names for instance objects in Python. Is there any way to achieve better syntax highlighting?

I'm using xcode12;after you have setup python properly in xcode.(refer to this if you are not sure of your setup: https://youtu.be/h8_68OONY-w)
Now to get back 'syntax highlighting' for python code.Click on the 'Editor' tab on the menu bar, click on 'syntax colouring' and choose 'python' from the list and you must be fine.

Related

Autocompletion in PyCharm based on type

I'm using PyCharm for python coding. The autocompletion in PyCharm is not as good as in IntelliJ (Java). Consider the below code
a = [1,2,3,4]
a.
In this case, after I press the dot, PyCharm gives the full set of autocompletion options. Consider the below case
def func_a(a):
a.
Here, to the function func_a I'm passing a list as an argument. But when I press dot after a, PyCharm doesn't give any autocompletion options. I know this is because Python is dynamically typed language and PyCharm has no idea to determine what type a is.
But is there any way to tell PyCharm the type of a, may be in documentation comment or something like that? So, that PyCharm can give valid autocompletion options?
Yes, Python 3.5 introduces type hinting and Pycharm utilizes that.
Use
def func_name(param: type) -> return_type:
Like
def func_a(a: list):
Note that all type hints are completely optional and ignored by the interpreter. However, Pycharm can potentially help you detect type errors if you use it as a habit.
This might not answer your question but this will be helpful for those who just started using pycharm for Django application.
PyCharm does not give (It underlines some built in functions with red) auto-completion option for Django if you have started project with Pure Python. Pure Python option comes when you click on new project option from file menu or when you run pycharm to start new project. Pure Python is the default selected option on new project page. You should choose Django (the 2nd option) to get auto-completion option in PyCharm.
Hope this would be helpful for others.
Can do : (examples using list):
def func_a(a:list):
do_this()
Or manually check:
def func_a(a):
if isinstance(a,list):
do_this
else:
raise TypeError("expected type of 'list' but got type of '%s'"%type(a).__name__)

Highlight initial variable assignment in python with VSCode

I would like to use tokenColor in Visual Studio Code to highlight the initial binding of a variable in python. That is to say, the first time a variable name appears in its scope, I would like it to have a different color. This would usually be where the keyword "let" or "var" would be used in JavaScript. How would I go about adding this to VSCode?
This is not possible using a simple language grammar as it requires understanding the structure of the program itself (i.e. understanding what are initial bindings vs re-assignments). This type of highlighting is called semantic highlighting.
As of VS Code 1.29, you can implement a custom version of semantic coloring using decorators. A proper semantic highlighting api is tracked by this issue

How do I display function arguments in ipython qtconsole?

I'm using IPython qtconsole under windows 7, and when I first write a method name and type the bracket, a popup shows method parameters.
What is the way to display that popup explicitly, once it has disappeared? This is pretty common 'show method parameters' shortcut that I'm talking about, but I've failed to find the shortcut to it after an embarrassing amount of google searches.
In Spyder, try View - Panes - Object inspector. Then type the full name of the function.
I would highly recommend relying on the Python Library Reference rather than any in-IDE tools, at least for functions and classes that are in the standard library. For objects outside those libraries however... it looks like you can type object_name followed by a question mark, that is, object_name?, to get a list of informative details about the object. (Since everything is an object, this presumably includes functions.)
For your specific question, it looks, from the iPython docs, like the TAB key is what you're looking for, but somehow I doubt you haven't already tried that.

Viewing object attributes with tab completion in sublimerepl python

In the IDLE interpreter in Python, you can see a drop-down list of an object's attributes by typing the object's name, then period, then hitting TAB.
Is it possible to get similar functionality with sublimerepl?
I've tried the different autocomplete packages, but they don't appear to make this happen.
So there are many different packages, Andy's package being my favorite. None provide every method for a given function but try hitting "ctrl-space" after the period to see what's available!
Link:
https://sublime.wbond.net/packages/AndyPython

emacs minimap: how to highlight functions using semantic/face

I am trying to customize the minimap package in emacs.
I'd like to be able to read the name of the functions, class, etc while in the minimap. The effect I am trying to achieve is this (although in python mode): (from www.emacswiki.org/emacs/MiniMap)
As far as I understand the minimap module, there are two way to enlarge the name of function, class, etc.
The first requires semantic overlays, but I am not familiar with the semantic package, and I am not sure how well it supports python.
The second (that I set as the default option from M-x customize-group minimap) should use the normal text height for all the functions - all the text with the face font-lock-function-name-face - but I can't get it to work.
Does anyone know how to use this minimap function?

Categories