Jump to content
  • Advertisement
Sign in to follow this  

2 Python Questions

This topic is 4435 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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-

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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:

"""Example
of
heredoc"""


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.

Share this post


Link to post
Share on other sites
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-

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!