Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using idle on windows 7 as I've just come from a mac and the text editor I was using highlighted different keywords then what idle does. I know that I can change the colour of the current syntax like print and def but can I add other keywords to highlight as well? Thanks
Unfortunately, I don't think Idle is extensible in that way, without hacking on its source code. I believe that it currently highlights only a specific set of names (plus other easily identifiable things like string literals).
It highlights in orange (by default) all of the keywords of the Python language.
It highlights in magenta all of the built-in functions, types and other objects that are available from the standard library without doing any import statements. (You can see a list of them by running dir(__builtins__) in a Python interpreter, or by browsing sections 2-6 of the Library Reference.)
Idle does not do much code analysis. This means that it can't tell what most other names represent. It can't give specific highlighting colors to, for example, class names, because there's no requirement for them to be named in any particular way. Does foo in your code refer to a class, a module, a function or something else? Idle can't tell.
If you want more serious highlighting, you may need to find a more sophisticated IDE. I've recently been pretty happy with Spyder (though I'm not sure if its syntax highlighting is any more capable than Idle's), and there are lots of others. The official Python wiki has a list of IDEs which might help you find the one that is best for you.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Disclaimer:
I've just started researching this area/domain of knowledge; so I have no idea what exactly it's called; but through a google search, I believe it has to do with (static code analysis, or at least it's related to it).
My question is:
Given a python code - file - script - module - package. Is there a tool that can produce a report out of it detailing:
how many classes are used, functions, built-in functions; decorators ;if/for/while statements etc?
To give you an analogy most of us can relate to:
Given a text file: find all the verbs / nouns / adjectives / adverbs / proper noun.
NLP tools like spaCy or NLTK have the ability to do that for natural languages.
But what about programming languages? Is there a tool for that?
Can a tool like pylint do that?
UPDATE
As I expected such tools exist; one of them as #BoarGules suggested in his comment is the ast module ... It's the hint I needed to go further in my research; any further suggestions are welcome. BTW ast stands for abstract syntax tree.
Given a python code - file - script - module - package. Is there a tool that can produce a report out of it detailing: how many classes are used...
There cannot be an exact tool for that, since Python has an eval primitive.
When that primitive is executed, the set of classes or functions of your Python program can increase.
Be aware of Rice's theorem.
Consider using abstract interpretation and type inference techniques in your Python static analyzer.
Consider also using (painfully) Frama-C on the source code (the code written in C) of the Python interpreter. With a lot of work, Frama-C could be extended to analyze Python source code.
(but someone needs to do that work, or to pay for it)
Read also recent proceedings of ACM SIGPLAN conferences.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In a Windows 7 system you can right-click the sort columns to look at the details you want to view for a file and you get the following:
Question: Is there a way to access all of the attributes on that list for a given file using Python?
This is a bit long for a comment.
You are not likely to get a good answer because Microsoft makes this way too complicated, and their documentation on this topic is some of the worst that they have.
Everything is wrapped up in COM interfaces, and you really need the SDK installed to get all of the headers file needed to access these interfaces from a C style API.
To understand how it really works, you really need to start the Property System Overview
You will also want to read Property System Developers Guid
There is one C language answer that I know of for this topic on S/O, though clearly there could be others.
I know it is not a real answer, and it is certainly not Python -- but if you have the real motivation to dig into this, hopefully this is at least a little helpful.
Also not that these extended properties are poorly supported, and tend to disappear under many common usage patterns since they are not really part of the file -- e.g., copy the file using ftp -- lose the extended file attributes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have been looking around but haven't found an example of this. I'd like to write out a few long/tedious python scripts using Clojure. Just because I happen to enjoy Clojure a bit more and they are not full on programs.
This site makes me think it is possible:
http://jkkramer.com/sudoku.html
For example if I have script.clj, I'd like to be able to convert it to script.py - not by hand of course.
Is it possible to do this? If so, what tool/library/script should I use? If its not possible not, why not?
[Edit] I edited this because the wording mistakenly gave the impression I was looking for a detailed lesson on writing my own solution. I was just curious if the tools were out there to answer my question and if not then why not.
Yes. Write a compiler that takes Clojure syntax and outputs valid Python syntax.
How to do that is well outside of the ability/scope of a StackOverflow answer.
Also note that if you do this for the general case of compiling any piece of Clojure code to Python you will have implemented quite a bit of Clojure in Python (especially when you implement defmacro and generic methods).
You actually don't have to do a source to source translation in order to write Clojure that will interact with python libraries. Just see clojure-py which allows you to write regular Clojure syntax and run it under the Python interpreter and call Python libraries.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm preparing to make a little IDE that allows to expand function/macro calls to their definitions right in the place they are called (and do that recursively if needed, so that if funciton A calls B, I expand B, then B calls C - I expand C in the code of B etc.):
Question 1: do you know of existing IDEs with this feature?
Question2: How would you implement that? My approach is as follows: I'd like to have the IDE being able to understand various programming languages. In order to extract function definitions, I'll seemingly have to use parsers. Is there any collection of parsers for various languages? I've looked into Ctags and Pygments lexers, but their output is insufficient to accomplish this task.
Preferable language for IDE is Python (although Java and C suggestions are ok, too), graphial library - gtk+2. Thanks.
Question 1: do you know of existing IDEs with this feature?
Not perhaps quite what you describe, but Visual Studio's Code Definition Window shows the definition of any symbol at the current cursor position. It differs of course in that it shows the definition in a separate window to the editor window, but to be honest I would find your proposition somewhat jarring and counter-intuitive since the calls are not semantically in-line.
What you want is called "goto definition" in most IDEs. Granted, they don't expand inline, but you have to put the definition somewhere.
As a general rules, many IDEs have split windows so the definition can be seen at the same time with the original call. It seems to me that you essentially want to automate the setup of splitting the windows, and going the definition point.
Many IDEs contain internally programmable interfaces. You can probably do with with Eclipse; you could certainly do this with Emacs, if M-x goto-definition-in-new-window isn't already built in :-}
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am new to programming. I decided to stick with Python after messing around with objective-c.
I'm beginning to get a grasp on most of the basic concepts, but as an artist, I think visually. This said, I would like to attempt to work in reverse. In other words, I'd like to start out with a complete, functional piece of software and look at the code and mess around with it to see what does what. This is kind of a similar approach to CAD modeling, where you can see which features in the model affect it, and how. This may not make sense to those who are not familiar with CAD, but I hope someone out there can relate?
Exploring existing projects is an excellent way to learn programming. Breaking existing code and fixing it is an even better way.
There are many open source projects out there that you might want to explore. Some of them are code libraries, while others are entire applications. As you are new to programming, you may want to consider looking at projects that are not too gigantic as it might be overwhelming.
Additionally, it may be even more helpful for you to dissect a program that you would actually use. I have not used this program, but PythonCAD might interest you:
http://sourceforge.net/projects/pythoncad/
This most likely does not fall into the small or simple category of open source projects but it sounds like you may already understand the intended functionality which should be of considerable aid to you in your exploration.
Browse through Google Code for open source Python projects that are of interest to you:
http://code.google.com/query/#q=python
I recommend to take a look at the PyRoom project, a no non-sense text editor for writing without distractions. It's barely 2K lines of code and seems simple to understand. You can access the repository here.