[TxMt] some Python thoughts

Allan Odgaard mailinglist at textmate.org
Wed Jun 11 22:14:32 UTC 2008

On 5 Jun 2008, at 19:29, Hans-Jörg Bibiko wrote:

> Walter Dörwald had the idea to provide exit codes similar to Ruby's  
> exit_codes.rb.
> This could be integrate in tm_helpers.py à la:
> [...]

It’s about time Python saw some love with regard to TM convenience  
functions :)

One thing I have learned from all the work put into the ruby support  
stuff is the importance of style guides, and that one should use all  
the module/namespace support from the language to keep it clear what  
is what, which stuff uses what, etc.

So before piling stuff into tm_helpers.py, one should consider these  

I will work out some style guides for ruby, though not sure exactly  
when, but that might serve as inspiration. For the curious, in TM 2 we  
will effectively create a new Support folder which has a more clear  
structure and less noise. Old commands will continue to see the old  
Support folder, but new commands will see the new one, so we can do a  
safe migration (technically this can be done by simple setting  
TM_SUPPORT_PATH based on the version found in the bundle item’s  
property list).

> Furthermore tm_helpers' sh(cmd) is not UTF-8 safe.
> If I'm using e.g. popen("grep 'ä' 'test.txt'") or  
> tm_helpers.sh("grep 'ä' 'test.txt'") I have problems with the codec.

If you embed non-ASCII in a python string, you must prefix it with u.  
That said, can you paste a more full example showing the problem?

More information about the textmate mailing list