Up to date Python highlighting

Syntax highlighting, code folding, brace matching, code indenting, and function list

Up to date Python highlighting

Postby mrp » Sat Mar 08, 2008 2:39 pm

Hi all. I am hoping somebody has a more up to date Python syntax highlighting file (2.5) that they wouldn't mind sharing?

Also I am a little disappointed that UltraEdit 14 still does not include Python highlighting by default when it includes Ruby and MySQL, etc.

Many thanks in advance.

Morgan
mrp
Newbie
 
Posts: 1
Joined: Sat Mar 08, 2008 2:29 pm

Re: Up to date Python highlighting

Postby pietzcker » Sat Mar 08, 2008 3:37 pm

Well, I use the following one - it's not perfect but works well enough for me. Since I couldn't find a way to attach it as a file ("The extension txt is not allowed"), I have pasted it below:

Code: Select all
OLD version deleted - check below for new, correct version


Best regards,
Tim

P.S.: One thing that bugs me is that ":" will cause indentation even it occurs within a slice. I (and several other people) have asked IDM to create a configuration option that an indent string should only work if it's the last thing on the line (except for whitespace and comments). This would require indent strings to allow regexes like :[ \t]*($|#.*$), but so far no luck. Maybe if some more people ask IDM (support@idmcomp.com) for this feature, it will get bumped up on the wish list...so please chime in if you at all agree that that would be a good idea. If it works for function strings, why not for indent strings. (Why not for the entire wordfile, come to that. Other editors can do it, too).
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Up to date Python highlighting

Postby flxkid » Sun Mar 16, 2008 6:41 pm

I just asked about the python indent string issue last week. There are other things too...but this is one of the biggest pains...please Ian....put it in there!

OLIVER
flxkid
Newbie
 
Posts: 1
Joined: Sun Mar 16, 2008 6:37 pm

Re: Up to date Python highlighting

Postby pietzcker » Mon Mar 17, 2008 2:36 am

Just FYI:

I'm currently working on a completely new Python wordfile that will include a lot more methods, attributes and modules. I will send it to IDM for inclusion in the download area soon. One question to the forum:

There are some modules within modules (like distutils.dist) in Python's "Global module index". If I put distutils.dist (next to distutils) into the wordfile, only distutils will be "colored". I guess that the dot (delimiter) causes the highlighting engine to stop after the distutils part already matched a definition in the wordfile.

So the alternative is to include all the submodules as "normal" modules, i.e., put "dist distutils" into the wordfile. This will, of course, lead to highlighting the word "dist" even if it's not in a distutils.dist context. So what do you think is the lesser of two evils? Dropping the submodules and have them un-highlighted - or including them and have them highlighted in places where they shouldn't be?

Thanks for your input,
Tim

P.S.: Of course, if regular expressions were allowed here, if wouldn't be a problem. Again...
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Up to date Python highlighting

Postby Mofi » Mon Mar 17, 2008 3:28 am

I have 2 suggestions:

1) Remove . from the delimiters and specify distutils distutils.dist.

2) Since UE v10.00 it is allowed that a word in the word lists starts with a delimiter. So you can specify

.dist
distutils


to highlight only ".dist" but not "dist".
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Up to date Python highlighting

Postby pietzcker » Mon Mar 17, 2008 4:08 am

Hi Mofi,

thanks a lot! Suggestion #2 sounds very good for my needs.

It seems that definitions without a delimiter will overrule ones with a delimiter regardless of the order of the sections in which they turn up in the wordfile. Sometimes there are function names that are identical to method names, so I would have liked to define "dist" (as in dist()) separately from ".dist" (as in distutils.dist). But the highlighting scheme for the section in which "dist" is defined always overrides the definition for ".dist" - probably no way around that, is there - other than following suggestion #1? Because if I do that, all the highlighting for methods gets lost, so that's not a viable option...

Thanks,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Up to date Python highlighting

Postby Mofi » Mon Mar 17, 2008 6:30 am

You are absolutely right with your observation. I don't have any idea how to solve your problem with identical function and method names with the current available syntax highlighting rules.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Up to date Python highlighting

Postby pietzcker » Tue Mar 18, 2008 3:03 pm

OK, I've updated my wordfile and used Mofi's wordfile tools to sort it, check for duplicates and invalid strings. This was enormously helpful since the original wordfile I had started working on had quite a few errors and omissions that I had never looked at in more detail. So I guess this one is quite a lot better than the old one posted above. I have refrained from adding too many modules, attributes and methods since a "comprehensive" wordfile created from the Python documentation would have been vast but still incomplete, not to mention fraught with problems arising from duplicate words.

The wordfile can be downloaded at http://www.ultraedit.com/files/wf/python25.uew

HTH,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Up to date Python highlighting

Postby petertable » Fri Dec 12, 2008 5:22 pm

I've taken your wordfile and enriched it with mine.

Folding somehow works, but as python doesn't has a closing tag, the closing boundary is not exact. And don't bug me about it.

enjoy
Attachments
wordfile_python.zip
Enriched Python syntax highlighting wordfile (with corrections from Mofi).
(3.07 KiB) Downloaded 1214 times
petertable
Newbie
 
Posts: 1
Joined: Fri Dec 12, 2008 5:19 pm

Re: Up to date Python highlighting

Postby Mofi » Sat Dec 13, 2008 6:12 am

Hi petertable,

I have made some corrections in your version of the syntax highlighting wordfile for Python and attached this version compressed with ZIP to your post. Compare it with your version on your hard disk to see what I have changed.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Syntax Highlighting