2 Python Questions

Started by
5 comments, last by Lucidquiet 18 years ago
I don't know Python all that well (just finished 2 books on it though) and I'm wonderring if its possible to have a "here document". Does anyone know of a Python source editor for windows, that allows the user to change the syntax highlight feature. (My aim is to put C code inside the hear document or the """ <text> """ delimeter). L-
"Education is when you read the fine print; experience is what you get when you don't." -Pete Seegerwww.lucid-edge.net
Advertisement
Don't know about your first question, but I use PSPad for any language Visual Studio doesn't support. It allows you to define your own highlighting really easy.
There's always Vim. OK, so there's a learning curve, but it's the only editor you'll ever need. After a little practice, you'll cut your editing times in half as well. I can work twice as fast in Vim as I can in simpler IDE-style editors. Combined with ctags and some filesystem tree browser scripts (and its built in makefile support) and it's a pretty comfortable IDE. Of course I have no idea how to set all this up on Windows :P
Actually are you saying that VIM will highlight an embedded language, or easily switch from one language to another mid stream...in one source file. What I want is to somehow embed C in Python.

I can get VI to work on a windows box -- MinGW and Cygwin work.

L-

PS. Still need to know if there is a here document syntax for Python, if anyone knows.
"Education is when you read the fine print; experience is what you get when you don't." -Pete Seegerwww.lucid-edge.net
Quote:Original post by Lucidquiet
Actually are you saying that VIM will highlight an embedded language, or easily switch from one language to another mid stream...in one source file. What I want is to somehow embed C in Python.

Oh, maybe not that, at least without editing the syntax files.

Quote:I can get VI to work on a windows box -- MinGW and Cygwin work.

There is native Vim for Windows. You can get it on Vim.org

Quote:PS. Still need to know if there is a here document syntax for Python, if anyone knows.

I don't understand the question as you used the answer to your question in your question. """ text """ is a heredoc in Python. I can span as many lines as you want, and contain any text except """.

http://docs.python.org/ref/strings.html
Quote:Original post by Lucidquiet
I don't know Python all that well (just finished 2 books on it though) and I'm wonderring if its possible to have a "here document".

In Python, triple quotes (double or single) is heredoc. Like this:
"""Exampleofheredoc"""


Quote:
Does anyone know of a Python source editor for windows, that allows the user to change the syntax highlight feature.

Personally, I like Emacs.

Quote:
(My aim is to put C code inside the hear document or the """ <text> """ delimeter).

Why? Also, are you asking for something which does C-style syntax highlighting in the heredocs, but Python-style everywhere else? I doubt you'll be able to get that, at least not easily.
Sorry, I didn't realize that the """ was a here doc. I'm sort of new to Python, and I don't have a good syntax highlighter, because I'm trying to do as I said embed C in Python... and yes Python highlighted everywhere except in the here doc which will be C.

Actually another question would be can Python be instructed to generate another attribute (similar to __doc__ ) to every module, or class, or method, etc.?

That is really my aim here, to assign the embedded C to an attribute of the Python module.

Any comments welcome,
L-
"Education is when you read the fine print; experience is what you get when you don't." -Pete Seegerwww.lucid-edge.net

This topic is closed to new replies.

Advertisement