Home Download Buy Blog Forum Support

Python Improved - a better Python language definition

Re: Python Improved - a better Python language definition

Postby facelessuser on Sat Nov 02, 2013 8:11 am

def greet(name: str, age: int) -> str:
print('Hello {0}, you are {1} years old'.format(name, age))
# instead of the standard
def greet(name, age):
print(...)


How does it look?
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python Improved - a better Python language definition

Postby facelessuser on Sat Nov 02, 2013 4:11 pm

These theme files always make my head hurt, but here is a more complicated example; comments and all:

def foo(
(x1, y1: expression), # Is this a comment?
(
x2: 3 + 2, # why yes, that is a comment!
y2: "some random string" # Yet another
) = (None, None)
) -> "yes this is the result annotation as a string":
print('Hello {0}, you are {1} years old'.format(name, age))
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python Improved - a better Python language definition

Postby MattDMo on Sat Nov 02, 2013 4:45 pm

That definitely looks like a start. Can you send me a pull request?

I just saw you fixed the `<string>` issue in the comments at the top - I meant to do that with my last release, but must have missed it. Thanks!
MattDMo
 
Posts: 36
Joined: Thu Jan 17, 2013 3:15 am
Location: near Boston

Re: Python Improved - a better Python language definition

Postby facelessuser on Sat Nov 02, 2013 4:57 pm

facelessuser wrote:I just saw you fixed the `<string>` issue in the comments at the top - I meant to do that with my last release, but must have missed it. Thanks!

I always convert my themes to json, and the syntax broke my plugin's conversion, so I went ahead and patched it.

I will issue a pull request within the hour. I will document the new scopes for the annotation separators as well.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python Improved - a better Python language definition

Postby facelessuser on Sat Nov 02, 2013 6:02 pm

Pull request made.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python Improved - a better Python language definition

Postby FichteFoll on Sun Nov 03, 2013 6:34 pm

Just stepping into this (and promoting): There is also the possibility to convert syntax definitions to YAML instead of JSON which is much more flexible, doesn't require {} all over the place, does not require "" all over the place and does not require you to escape everything all over the place. Oh, and it supports multi-line strings and stuff. Here is an example: https://github.com/SublimeText/AAAPacka ... tmLanguage

If you encounter any bugs (especially with the syntax highlighting, because YAML is a beast to highlight with regular expressions), please report them on the repo.
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Python Improved - a better Python language definition

Postby facelessuser on Mon Nov 04, 2013 4:24 am

One thing I would love to see is a simple plist to yaml and yaml to plist plugin (without all of the other AAAPackageDev stuff I don't use). Maybe I will take a look and strip it out for personal use. I haven't played with yaml much, but I think I would like to.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python Improved - a better Python language definition

Postby FichteFoll on Mon Nov 04, 2013 5:27 pm

The only relevant files are `file_conversion.yaml` and `fileconv/` for conversion. The other syntax definition-helping stuff is in `syntax_dev.py` and `Support` and `Syntax Definitions` subdirs. Only downside is that it's currently only for ST2 (because I have problems). But well, that's not in the scope of this thread.
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Python Improved - a better Python language definition

Postby quodlibet on Tue Nov 05, 2013 2:11 pm

(Off-topic vote for YAML support)

I have been following along to this thread, chiefly because I am working on an improved Markdown syntax. I have gotten used to writing in JSON, chiefly because of the economy of the syntax. But the lack of multiline strings is an issue, as I'd like to annotate my regular expressions before I forget what it is they do :)

I have failed (angrily) to use AAAPackageDev in the past and am a happy devotee of PlistJsonConverter -- especially the on-save conversion. I would like to see YAML supported in the hope that it might be a more efficient format to work in.
quodlibet
 
Posts: 543
Joined: Sat Jun 18, 2011 5:53 pm

Re: Python Improved - a better Python language definition

Postby facelessuser on Tue Nov 05, 2013 4:35 pm

@quodlibet I am considering ripping the yaml portion out and creating a plugin. I mainly use JSON because the plugin was easy to throw together, and it was "good enough". But if getting yaml module up and running from AAAPackageDev isn't too bad, this might be a very nice alternative. If I did this, I would construct it similar to the PlistJsonConverter. I just haven't had the time to look into it yet.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 8 guests