-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hy as a Python syntax extension #368
Conversation
no effing way |
This is awesome. I'll get on reviewing this tonight. Steller work, @lmatthieu ! |
self.module_name = module_name | ||
if not module_name.startswith("hy.core"): | ||
# everything in core needs to be explicit. | ||
load_stdlib() | ||
|
||
def getContext(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any chance we could move this to get_context
? We use underscores consistently :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prod. I'd love to get this in if you don't mind fixing this (otherwise I can fix it and open a new PR)
This is great. Code changes look good. Let's get an ack, @hylang/core |
""" | ||
Inspired by PyXL, register.py. | ||
""" | ||
from __future__ import with_statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support Python versions older than 2.7. You can safely remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do support Python 2.6 if we can avoid breaking it. Don't you run tox?
On Sat, Jan 4, 2014 at 7:39 AM, Berker Peksag [email protected]:
In hy/contrib/hysyntax.py:
@@ -0,0 +1,89 @@
+"""
- Inspired by PyXL, register.py.
+"""
+from future import with_statementWe don't support Python versions older than 2.7. You can safely remove
this line.—
Reply to this email directly or view it on GitHubhttps://github.com//pull/368/files#r8651563
.
:wq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right :(
I have updated the hy extension with your comments. In the repo https://github.com/lmatthieu/myemacs, you will find an example of emacs configuration handling hy/python code-mixing. |
import shutil | ||
from distutils.sysconfig import get_python_lib | ||
python_lib = get_python_lib() | ||
print "Installing Hy syntax extension" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks Python 3 :)
I'd just remove the print
Nice work so far! |
ping @lmatthieu! |
It's been a few months since we had any activity on this :( I'm going to close this for now, please do reopen it if we can get it rebased on master and stuff. ❤️ |
I was just reminded of this Using this approach, it also seems like we could nicely determine Hy vs. Python source strings based on a custom encoding (see my comment here regarding the use of source type delineation of strings). |
It's not something I'd invest effort in, personally, but I guess it could be cool to have. The devil's in the details. |
Hi,
A test, inspired by Pyxl of using hy as a syntax extension.
It uses Python support for specifying source code encodings (PEP 263).
How to use it
All python files with inline Hy code must have the following first line
coding: hy
You can mix Python and Hy code with this syntax:
After installing Hy, you must install the syntax extension with:
This step add a file hy.pth in your python site-package directory (allows hy syntax extension to be loaded on Python startup).
A test file is provided in tests/contrib/hysyntax.
Any questions, bug reports, and other feedback on this code are welcomed !
Matthieu