[TxMt] [Python Bundle] Suggestions "stolen" from Ruby Bundle and bugs from the latest SVN

Alexander Ross alex.j.ross at gmail.com
Mon Dec 11 21:17:07 UTC 2006


Ryan,

#1:	why not just use the dict command?  You can just write:
	
	dict(a=1, b=2)

#2:	Yes, folding is somewhat broken in the Python Bundle.  This is a  
limitation of Textmate, and not something we can fix currently.  When  
TM 2.0 is released, we will hopefully be able to fix the folding  
issue (and also provide block scopes, I can't wait).
	As for coloring doctests, I'm not sure if I like this idea.  I think  
that it would be somewhat distracting, and could lead to confusion.   
That said, in TM2.0 it will be relatively easy to "inject" the python  
grammar into docstrings allowing the highlighting you want to occur.

Bugs:

Thank you for reporting them, I've fixed them.

On Dec 11, 2006, at 8:09 AM, Ryan Wilcox wrote:

> Hello fellow Python Bundle users,
>
> I've been learning more about the Ruby bundle, and I have some  
> ideas on how to make the Python bundle better. Some of them are  
> blatantly stolen from the Ruby bundle, some of them I came up  
> independently myself when I was using BBEdit, and thought they  
> would be useful in the Python bundle.
>
>
> #1: Create Dictionary From:
>     I thought Ruby could take the selected text and make a hash out of
>     it. (looking in the TextMate book now of course I can't find it).
>     I wrote something similar, turning the following text into a
>     dictionary:
>
>     a = 1
>     b = 2
>
>     --> result: {'a': '1', 'b': '2'}
>
>     You'll find my script at the bottom of this email
>
> #2: Support for syntax coloring doctests
>
>     Wouldn't it be cool to have doctests syntax colored like code, and
>     not comments?
>
>     Likewise, it looks like the folding marker for Python comments
>     folds on a blank line. That means folding doesn't work very well
>     for doctests or comments with blank lines in it.
>
> #3: super() in class snippet
>
>     It would be cool if the class snippet inserted super(...) into the
>     constructor for the class. (Is this possible with clever
>     mirroring?)
>
> _______________________________
>
> Bugs:
>     * Evaluate Selection As Python doesn't work
>         (Traceback (most recent call last):
>           File "/tmp/temp_textmate.KE9sFL", line 5, in ?
>             from traceback import format_exc
>             ImportError: cannot import name format_exc
>         )
>
>     * Documentation For Current Word doesn't work
>         (global name sh is not defined)
>
> _______________________________
>
> Looking forward to everybody's thoughts on these improvements!,
> _Ryan Wilcox
>
> -- 
> Wilcox Development Solutions:          <http://www.wilcoxd.com>
> Toolsmiths for the Internet Age            PGP: 0x2F4E9C31
>
> _____________________________________________________________________
>
> #!/usr/bin/env python
>
> import fileinput
> import re
>
> """
> dictMaker takes a formatted string and generates a Python dictionary
> from it.
>
> Basically: it's easier to type in my format then to deal with all
> the quoting required for dictionary creation
>
> The Format is:
>
> key = value
>
> NOTE that at this time quotes are made around the values. So if you're
> strings just don't add them (elsewise just find and replace the extra
> quotes)
>
> """
>
> a = re.compile("(\w+) = (.+)")
> output = {}
>
> for my_line in fileinput.input():
>     mtch = a.search(my_line)
>     output[ mtch.group(1) ] = mtch.group(2)
>
> print output
>
> _____________________________________________________________________
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate




More information about the textmate mailing list