google / grumpy Goto Github PK
View Code? Open in Web Editor NEWGrumpy is a Python to Go source code transcompiler and runtime.
License: Apache License 2.0
Grumpy is a Python to Go source code transcompiler and runtime.
License: Apache License 2.0
I'm trying to compile this library https://pypi.python.org/pypi/construct/, i didn't compile debug because it required pdb, if you think it's worth to implement, i'll make an issue for that stdlibrary.
This has happened on files:
core.py: line 22
lib/binary.py line 807
It would be nice if the REAME (or another file in the repo) contained comparative benchmarks, for informational purposes.
Consider the following program:
class T(object):
def __repr__(self):
return "__repr__"
def foo(self):
return "foo"
a = T()
print a.__repr__
print repr(a)
T.__repr__ = foo
print a.__repr__
print repr(a)
And the following execution of CPython and Grumpy:
$ python --version
Python 2.7.10
$ python bar.py
<bound method T.__repr__ of __repr__>
__repr__
<bound method T.foo of foo>
foo
$ ./tools/grumpc bar.py > bar.go
$ go run bar.go
<bound method T.__repr__ of __repr__>
__repr__
<bound method T.foo of __repr__>
__repr__
CPython allows for the slot method to be overriden at runtime. For the builtins where this applies (which can be determined from Objects/typeobject.c
in the CPython source), Grumpy should lookup the method by name.
That being said, I don't know how common this is in real code. I noticed it reading the CPython source while implementing __cmp__
.
How to import libraries when its path contains "." ?
For example, I can import "github.com/labstack/echo" in pure go by
import "github.com/labstack/echo"
In grumpy, I can import it like
from __go__.github.com.labstack.echo import New
But it will be compiled to something like this
import "github/com/labstack/echo"
Anyway to correct this issue?
Trying to pass ioutil.Discard
as an io.Writer
argument raises a TypeError. Here's a simple example program:
from __go__.io.ioutil import Discard as devnull
from __go__.fmt import Fprintln as fprintln
fprintln(devnull, "Hello, world")
The definition for ioutil.Discard
is var Discard io.Writer = devNull(0)
There wasn't an explicit ticket for this, so here goes π
It would be great if Grumpy could digest a python project and spit out a Go project.
I think this would make Grumpy a lot more usable in practice on existing codebases.
This means a couple things, off the top of my head:
PYTHONPATH
/ VIRTUAL_ENV
environment variables__init__.py
Might be more, let me know what you think.
It seems to me that a ticket like this could use a concrete example and target. How about PyMySQL? PyMySQL is a popular, small (5.6k LOC) project that is explicitly pure-python. I had a gander through their import statements and everything seemed pretty reasonable. Notably, there are a few instances where they snag some small things from __future__
, so that might need some implementation work. I only saw print_function
and absolute_import
which sounds straightforward.
I think this ticket would be satisfied by something like this:
git clone https://github.com/PyMySQL/PyMySQL
git clone https://github.com/google/grumpy
( cd grumpy; make )
grumpy/tools/grumpc --read PyMySQL --save $GOPATH/src/github.com/PyMySQL/PyMySQL
cd $GOPATH/src/github.com/PyMySQL/PyMySQL
go build
And now you have a Go library that you could import and use (it doesn't look like PyMySQL has a CLI).
This is just an example though, maybe there's a better litmus test to work towards.
Relates #5, #11, #23, possibly others.
Thoughts? π
how to run 'make run' in Mac os?
My steps:
failed:
sxy@Mac ~/test/grumpy$ echo 'print "hello world"' | make run
build/src/grumpy/lib/errno/module.go:174: undefined: syscall.EADV
build/src/grumpy/lib/errno/module.go:190: undefined: syscall.EBADE
build/src/grumpy/lib/errno/module.go:198: undefined: syscall.EBADFD
build/src/grumpy/lib/errno/module.go:206: undefined: syscall.EBADR
build/src/grumpy/lib/errno/module.go:210: undefined: syscall.EBADRQC
build/src/grumpy/lib/errno/module.go:214: undefined: syscall.EBADSLT
build/src/grumpy/lib/errno/module.go:218: undefined: syscall.EBFONT
build/src/grumpy/lib/errno/module.go:234: undefined: syscall.ECHRNG
build/src/grumpy/lib/errno/module.go:238: undefined: syscall.ECOMM
build/src/grumpy/lib/errno/module.go:258: undefined: syscall.EDEADLOCK
build/src/grumpy/lib/errno/module.go:258: too many errors
make: *** [build/pkg/darwin_amd64/grumpy/lib/errno.a] Error 1
Grumpy doesn't seem to be able to generate a working grumpyc in go.
$ git clone https://github.com/google/grumpy && cd grumpy
$ make
$ export GOPATH=$PWD/build
$ export PYTHONPATH=$PWD/build/lib/python2.7/site-packages
$ tools/grumpyc tools/grumypc > grumpyc.go && go build -o gorumpyc grumpyc.go
grumpc.go:4:2: cannot find package "grumpy/lib/argparse" in any of:
/usr/lib/go/src/grumpy/lib/argparse (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/argparse (from $GOPATH)
grumpc.go:5:2: cannot find package "grumpy/lib/ast" in any of:
/usr/lib/go/src/grumpy/lib/ast (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/ast (from $GOPATH)
grumpc.go:6:2: cannot find package "grumpy/lib/grumpy" in any of:
/usr/lib/go/src/grumpy/lib/grumpy (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/grumpy (from $GOPATH)
grumpc.go:7:2: cannot find package "grumpy/lib/grumpy/compiler" in any of:
/usr/lib/go/src/grumpy/lib/grumpy/compiler (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/grumpy/compiler (from $GOPATH)
grumpc.go:8:2: cannot find package "grumpy/lib/grumpy/compiler/block" in any of:
/usr/lib/go/src/grumpy/lib/grumpy/compiler/block (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/grumpy/compiler/block (from $GOPATH)
grumpc.go:9:2: cannot find package "grumpy/lib/grumpy/compiler/stmt" in any of:
/usr/lib/go/src/grumpy/lib/grumpy/compiler/stmt (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/grumpy/compiler/stmt (from $GOPATH)
grumpc.go:10:2: cannot find package "grumpy/lib/grumpy/compiler/util" in any of:
/usr/lib/go/src/grumpy/lib/grumpy/compiler/util (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/grumpy/compiler/util (from $GOPATH)
grumpc.go:12:2: cannot find package "grumpy/lib/textwrap" in any of:
/usr/lib/go/src/grumpy/lib/textwrap (from $GOROOT)
/home/omeid/go/src/github.com/google/grumpy/build/src/grumpy/lib/textwrap (from $GOPATH)
is this because third_party/stdlib
uses exec
and eval
? If that is the case, it would be nice if tools/grumpyc
actually give error or at least warnings when generating the go file.
I'm aware that not all builtins have been written yet. I tried to take a look at what has been written so far:
$ echo 'dir(__builtins__)' | make run
NameError: name '__builtins__' is not defined
exit status 1
make: *** [run] Error 1
I think there's some low-hanging fruit in writing plain Python implementations for a few builtins like sum
, map
, etc. Where's the right place to write those?
Hi Dylan,
You're a tough guy to find contact info for, so I'll file an issue for my request. :)
Would you be up for coming on https://talkpython.fm/ to talk about your project? I'd love to chat with you.
Best,
Michael
Trying to wrap my hand around the above error. Does his expect to provide grumpy math library implementation similarly to say, time.py?
Great innovative tool.
Most python code uses 3rd party modules. How to compile those?
Example: I have a tool that imports configobj, after using grumpc
on my tools .py file the go build
returns:
mytool.go:4:2: cannot find package "grumpy/lib/configobj" in any of:
/usr/local/Cellar/go/1.7.3/libexec/src/grumpy/lib/configobj (from $GOROOT)
/Users/rtoma/projects/grumpy/build/src/grumpy/lib/configobj (from $GOPATH)
File "/Users/xxx/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 302, in visit_Module
self._visit_each(node.body)
File "/Users/xxx/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 632, in _visit_each
self.visit(node)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/Users/xxx/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 270, in visit_ImportFrom
if node.module.startswith(_NATIVE_MODULE_PREFIX):
AttributeError: 'NoneType' object has no attribute 'startswith'
For example, http.Response object fields like Body should be accessible from *Response objects. The following should work:
from __go__.net.http import Get
from __go__.io import Copy
from __go__.os import Stdout
rsp, _ = Get("http://example.com/")
Copy(Stdout, rsp.Body)
What the title says. :)
It doesn't take much to make grumpy work under a non-default installation of 2.7, so I thought it could be somehow supported or at least described in the README.
I have Python 3 as my default (as in, python
or /usr/bin/env python
will invoke Python 3), but I do have python2.7 installed as well. I presume this is a setup common for a lot of people, so I thought grumpy could be supported on system configurations like this.
There are only two changes needed:
Makefile
, all calls to @python
need to be @python2.7
- but to make this universal, the invocation of python
here could be parametrised by using a variable, so that one could set the python version of choice in the Makefile
header.tools/*
use #!/usr/bin/env python
, which will point to Python 3, so I had to change this to /usr/bin/env python2.7
and I'm not quite sure what's the best way to make this parametrised. Perhaps using the aforementioned variable and using find/replace when copying the tool scripts to the build folderI hardcoded these two changes and tested it out, worked like a charm.
Hi,
Very cool project.
I grepped the code, but couldn't find a mention of channels or goroutines.
Are they available, either directly or via the python stdlib?
Thanks
Going through the README it seems like the project is in a more-or-less complete state. However, this blog post indicates that isn't the case:
There are still holes to fill β many built-in types are missing methods and attributes, built-in functions are absent and the standard library is virtually empty.
It would be good to clarify that in the README to avoid confusion.
$ make run
import sys
sys.stdout.write("hi")
^D
AttributeError: 'module' object has no attribute 'stdout'
exit status 1
make: *** [run] Error 1
This error is returned at runtime: TypeError: string indices must be integers, not slice
.
I read that you don't want to have things exec
ing. Here's a rough sketch of what a namedtuple might look like without exec
.
class NamedTuple(tuple):
'tuple with named attribute aliases for elements'
def __new__(cls, *args, **kwds):
'Create new instance of {typename}'
excess = set(kwds) - set(cls._fields)
if excess:
raise TypeError('Unexpected keyword arguments %r' % excess)
kwds = sorted(kwds.items(), key=lambda pair: cls._fields.index(pair[0]))
return tuple.__new__(cls, args + tuple(v for k, v in kwds))
@classmethod
def _make(cls, iterable, new=tuple.__new__, len=len):
'Make a new {typename} object from a sequence or iterable'
n = len(cls._fields)
result = new(cls, iterable)
if len(result) != n:
raise TypeError('Expected %d arguments, got %d' % (n, len(result)))
return result
def __repr__(self):
'Return a nicely formatted representation string'
names = self._fields
values = [getattr(self, name) for name in self._fields]
attrstring = ', '.join('%s=%r' % (k, v) for k, v in zip(names, values))
return '%s(%s)' % (type(self).__name__, attrstring)
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self))
def _replace(_self, **kwds):
'Return a new {typename} object replacing specified fields with new values'
result = _self._make(map(kwds.pop, _self._fields, _self))
if kwds:
raise ValueError('Got unexpected field names: %r' % kwds.keys())
return result
def __getnewargs__(self):
'Return self as a plain tuple. Used by copy and pickle.'
return tuple(self)
__dict__ = property(_asdict)
def __getstate__(self):
'Exclude the OrderedDict from pickling'
pass
def namedtuple(typename, field_names, verbose=False, rename=False):
"""Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # indexable like a plain tuple
33
>>> x, y = p # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessible by name
33
>>> d = p._asdict() # convert to a dictionary
>>> d['x']
11
>>> Point(**d) # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100) # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
"""
# Validate the field names. At the user's option, either generate an error
# message or automatically replace the field name with a valid name.
if isinstance(field_names, basestring):
field_names = field_names.replace(',', ' ').split()
field_names = map(str, field_names)
typename = str(typename)
if rename:
seen = set()
for index, name in enumerate(field_names):
if (not all(c.isalnum() or c=='_' for c in name)
or iskeyword(name)
or not name
or name[0].isdigit()
or name.startswith('_')
or name in seen):
field_names[index] = '_%d' % index
seen.add(name)
for name in [typename] + field_names:
if type(name) != str:
raise TypeError('Type names and field names must be strings')
if not all(c.isalnum() or c=='_' for c in name):
raise ValueError('Type names and field names can only contain '
'alphanumeric characters and underscores: %r' % name)
if iskeyword(name):
raise ValueError('Type names and field names cannot be a '
'keyword: %r' % name)
if name[0].isdigit():
raise ValueError('Type names and field names cannot start with '
'a number: %r' % name)
seen = set()
for name in field_names:
if name.startswith('_') and not rename:
raise ValueError('Field names cannot start with an underscore: '
'%r' % name)
if name in seen:
raise ValueError('Encountered duplicate field name: %r' % name)
seen.add(name)
if verbose:
raise NotImplementedError('verbose mode irrelevant to this implementation')
bases = (NamedTuple,)
field = lambda i: property(itemgetter(i), doc='Alias for field number %d' % i)
attributes = {name: field(i) for i, name in enumerate(field_names)}
attributes['__slots__'] = ()
attributes['_fields'] = tuple(field_names)
attributes['__doc__'] = '%s(%s)' % (typename, str(field_names).replace("'", '')[1:-1])
result = type(typename, bases, attributes)
return result
I copy-pasted from the CPython stdlib, deleted the exec
and fiddled until it seemed to work.
None of the future features are implemented, including the print function.
[@localhost grumpy]$ make
build/src/grumpy/lib/itertools/module.go:5: can't find import: "grumpy/lib/sys"
make: *** [build/pkg/linux_amd64/grumpy/lib/itertools.a] Error 1
I'm trying to implement a simple HTTP server, but it seems I can't send a python function as a go function to HandleFunc.
from __go__.net.http import ListenAndServe
from __go__.githubcom.gorilla.mux import NewRouter
from __go__.fmt import Fprintf
def HomeHandler(w, r):
Fprintf(w, "Hello world")
r = NewRouter()
r.HandleFunc("/", HomeHandler)
ListenAndServe(":8000", r)
I'm receiving this error:
$ cat web.py | make run
TypeError: cannot convert grumpy.Object to func(http.ResponseWriter, *http.Request)
exit status 1
make: *** [run] Error 1
The following code fails with the error message: AttributeError: '*Response' object has no attribute 'Body'
from __go__.os import Stdout as stdout
from __go__.net.http import DefaultClient as client
rsp, err = client.Get("http://www.google.com")
if err is not None:
raise Exception(err.Error())
_, err = Copy(stdout, rsp.Body)
if err is not None:
raise Exception(err.Error())
we can import standard go packages, but how to add a package from a github reference ?
For example for github.com/gorilla/mux
I don't think the syntax is supported in grumpc
The following gets parsed but is wrong:
from __go__.net.http import ListenAndServe, RedirectHandler
from __go__.github.com.gorilla.mux import NewRouter
it leads to:
import (
Ο_githubΞcomΞgorillaΞmux "github/com/gorilla/mux"
I tried running the following python code:
print("before assert")
assert False
print("after assert")
Output:
mths@MTHS-T450s:~/go/grumpy$ ./test
before assert
mths@MTHS-T450s:~/go/grumpy$ echo $?
0
Assert exited the program silently and the return code was 0.
If i changed the code to the following it works like i would expect it.
print("before assert")
try:
assert False
except:
raise AssertionError
print("after assert")
Output:
mths@MTHS-T450s:~/go/grumpy$ ./test
before assert
AssertionError
mths@MTHS-T450s:~/go/grumpy$ echo $?
1
Shouldn't this also happen in the first example? Am i missing something?
try to compile
MAX_TCP_PORT = (2 ** 16) - 1
it compiles
line 3: binary op not implemented: Pow
On the current Readme it states:
"But there are also a number of libraries in CPython that are C extension modules that need to be rewritten. This includes re, itertools and others."
I think that at least itertools is implemented in app level python on PyPy, why not just use them instead of rewriting modules?
Traceback (most recent call last):
File "./tools/grumpc", line 25, in <module>
from grumpy.compiler import block
ImportError: No module named grumpy.compiler
Is this expected? Are these tests not run on Travis for some reason?
Exception: foo
--- FAIL: TestNativeFuncName (0.00s)
native_test.go:106: func1(<func(*T) github.com/google/grumpy/runtime.TestNativeFuncName at 0xc4204dd440>,) = 'runtime.TestNativeFuncName', want 'grumpy.TestNativeFuncName'
--- FAIL: TestNativeFuncStrRepr (0.00s)
native_test.go:128: str(<func(*T) github.com/google/grumpy/runtime.TestNativeFuncStrRepr at 0xc4203f02d0>) = '<func(*T) github.com/google/grumpy/runtime.TestNativeFuncStrRepr at 0xc4203f02d0>', want <func\(\*T\) .*grumpy\.TestNativeFuncStrRepr at 0x[a-f0-9]+>
native_test.go:135: repr(<func(*T) github.com/google/grumpy/runtime.TestNativeFuncStrRepr at 0xc4203f02d0>) = '<func(*T) github.com/google/grumpy/runtime.TestNativeFuncStrRepr at 0xc4203f02d0>', want <func\(\*T\) .*grumpy\.TestNativeFuncStrRepr at 0x[a-f0-9]+>
native_test.go:128: str(<func() github.com/google/grumpy/runtime.TestNativeFuncStrRepr.func1 at 0xc4203f03f0>) = '<func() github.com/google/grumpy/runtime.TestNativeFuncStrRepr.func1 at 0xc4203f03f0>', want <func\(\) .*grumpy\.TestNativeFuncStrRepr\.\w+ at 0x[a-f0-9]+>
native_test.go:135: repr(<func() github.com/google/grumpy/runtime.TestNativeFuncStrRepr.func1 at 0xc4203f03f0>) = '<func() github.com/google/grumpy/runtime.TestNativeFuncStrRepr.func1 at 0xc4203f03f0>', want <func\(\) .*grumpy\.TestNativeFuncStrRepr\.\w+ at 0x[a-f0-9]+>
native_test.go:128: str(<func(*Frame, *Object) (*Str, *BaseException) github.com/google/grumpy/runtime.Repr at 0xc4203f0450>) = '<func(*Frame, *Object) (*Str, *BaseException) github.com/google/grumpy/runtime.Repr at 0xc4203f0450>', want <func\(\*Frame, \*Object\) .*grumpy\.Repr at 0x[a-f0-9]+>
native_test.go:135: repr(<func(*Frame, *Object) (*Str, *BaseException) github.com/google/grumpy/runtime.Repr at 0xc4203f0450>) = '<func(*Frame, *Object) (*Str, *BaseException) github.com/google/grumpy/runtime.Repr at 0xc4203f0450>', want <func\(\*Frame, \*Object\) .*grumpy\.Repr at 0x[a-f0-9]+>
RuntimeError: foo
FAIL
FAIL github.com/google/grumpy/runtime 1.149s
I need BrainFuck to go.
Is possible to showing me how writing my own lexer, parser and making AST for runing go?
I am using the python io libraries to read and write files in py python script and I'm getting an erorr trying to import io. Below is a simplified version that demonstrates the error. Is the python io library supported?
$ echo "import io" | make run
/tmp/tmpdlxl4K.go:4:2: cannot find package "grumpy/lib/io" in any of:
/usr/local/go/src/grumpy/lib/io (from $GOROOT)
/opt/home/daden/dev/grumpy/build/src/grumpy/lib/io (from $GOPATH)
Makefile:78: recipe for target 'run' failed
make: *** [run] Error 1
when we open a file to read by fd, the NewFileFromFD in runtime/file.go will return a new File object file, but it did not call fileInit, due to this, the file.reader will be still nil, but then if we call file.read(num) to read num bytes, the in fileRead it will call file.reader.Read, and this will cause nil pointer dereference.
poc:
add a test method in sys module:
def test():
# take stdin as an example
fpd = NewFileFromFD(0)
data = fpd.read(10)
print data
then use grumpy run this:
import sys
sys.test()
got this error:
Alright, I'll straight up ask: What's the status of Python 3 compatibility for this runtime? Never/Maybe someday/Working on it?
Is it possible to use Grumpy to convert eligible python packages for use from Go?
bytes = bytes * 10 ** 9
Error message:
binary op not implemented: Pow
jyf@pc:~/repo/git/grumpy$ make
build/src/grumpy/lib/itertools/module.go:4: can't find import: "grumpy/lib/_collections"
Makefile:192: recipe for target 'build/pkg/linux_amd64/grumpy/lib/itertools.a' failed
make: *** [build/pkg/linux_amd64/grumpy/lib/itertools.a] Error 1
jyf@pc:~/repo/git/grumpy$ git log -n 1
commit 61bd06c7f51fcbb0668ea32dddb71fc41e3c612e
Author: Alex Koren <[email protected]>
Date: Wed Jan 4 17:47:52 2017 -0800
more itertools defined (#15)
* added compress, cycle, dropwhile, from_iterable, ifilter, ifilterfalse, and takewhile in itertools
* added itertools tests for cycle, dropwhile, from_iterable, ifilter, ifilterfalse, takewhile
jyf@pc:~/repo/git/grumpy$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
jyf@pc:~/repo/git/grumpy$ go version
go version go1.6.2 linux/amd64
Not a issue, but just sharing my grumpy docker image
https://hub.docker.com/r/syou/alpine-grumpy/
echo 'print "hello, world"' | docker run -i --rm \
syou/alpine-grumpy grumprun
hello, world
docker run -it --rm syou/alpine-grumpy sh
echo 'print "hello, world"' > hello.py
grumpc hello.py > hello.go
go run hello.go
hello, world
cd /tmp/
echo 'print "hello, world"' > hello.py
docker run -it --rm -v $PWD:/src/app syou/alpine-grumpy \
grumpc hello.py > hello.go
docker run -it --rm -v $PWD:/src/app syou/alpine-grumpy \
go run hello.go
hello, world
docker run -it --rm -v $PWD:/src/app syou/alpine-grumpy \
go build -ldflags "-extldflags -static" \
-o hello hello.go
./hello
hello, world
Note that $PWD should be writable or use /tmp folder to write file from docker,
since final image not using root user, but you can specify --user 0 if you insist, but not recommended.
Is it possible to launch a python interactive shell?
Hi guys,
I translate my python script to go with grumpy and it shows:
cannot find package "grumpy/lib/argparse"
And argparse
did not list in the Missing-Features, how to resolve this problem ?
This looks fantastic.
@JukkaL on the mypy team is looking at a static compile capability using mypy here : python/mypy#1862
Referencing pyir ideas here: https://docs.google.com/document/d/1jGksgI96LdYQODa9Fca7EttFEGQfNODphVmbCX0DD1k/edit
Perhaps these efforts could be combined so that a standard mypy/python typed IR can be emmited that grumpy can consume?
This would have the following advantages:
I might be dreaming but perhaps Pyjion (@brettcannon et al) and Numba (@seibert, @pzwang et al) can get in on this as well. I think it would be mutually beneficial for python and it's users.
#--coding:utf-8--
#import urllib
import sys
print "++++++++++++++++++++++++++++++++++++"
#ζ΅θ―θΎεΊε―ζ§θ‘η¨εΊθͺθΊ«
with open(sys.argv[0],'r') as f:
for line in f.readlines():
print line
Everthing seems to be ok before I run the target go exe file,When I run it in my terminal ,it just print out a lot of unreadable charactersοΌand the history command is also unreadable,my OS is mac OS 10.12.2 . The output looks like below:
β€βΌβββΊββ.β½ββββββββ»_610β€βΌβββΊββ.β½ββββββββ»_62β€βΌβββΊββ.β½ββββββββ»_63β€βΌβββΊββ.β½ββββββββ»_64β€βΌβββΊββ.β½ββββββββ»_65β€βΌβββΊββ.β½ββββββββ»_66β€βΌβββΊββ.β½ββββββββ»_67β€βΌβββΊββ.β½ββββββββ»_68β€βΌβββΊββ.β½ββββββββ»_69β€βΌβββΊββ.β½ββββββββ»_70β€βΌβββΊββ.β½ββββββββ»_71β€βΌβββΊββ.β½ββββββββ»_72β€βΌβββΊββ.β½ββββββββ»_73β€βΌβββΊββ.β½ββββββββ»_74β€βΌβββΊββ.β½ββββββββ»_75β€βΌβββΊββ.β½ββββββββ»_76β€βΌβββΊββ.β½ββββββββ»_77β€βΌβββΊββ.β½ββββββββ»_79β€βΌβββΊββ.β½ββββββββ»_80β€βΌβββΊββ.β½ββββββββ»_81β€βΌβββΊββ.β½ββββββββ»_82β€βΌβββΊββ.β½ββββββββ»_83β€βΌβββΊββ.β½ββββββββ»_84β€βΌβββΊββ.β½ββββββββ»_85β€βΌβββΊββ.β½ββββββββ»_86β€βΌβββΊββ.β½ββββββββ»_87β€βΌβββΊββ.β½ββββββββ»_88β€βΌβββΊββ.β½ββββββββ»_89β€βΌβββΊββ.β½ββββββββ»_90β€βΌβββΊββ.β½ββββββββ»_91β€βΌβββΊββ.β½ββββββββ»_92β€βΌβββΊββ.β½ββββββββ»_93β€βΌβββΊββ.β½ββββββββ»_94β€βΌβββΊββ.β½ββββββββ»_95β€βΌβββΊββ.β½ββββββββ»_96β€βΌβββΊββ.β½ββββββββ»_97β€βΌβββΊββ.β½ββββββββ»_98β€βΌβββΊββ.β½ββββββββ»_99β€βΌβββΊββ.ββΊβ€βΌβββΊββ/β€βΒ°8.DβββΊββLββ½βRβ€βΌββ€βΌβββΊββ/β€βΒ°8.DβββΊββLββ½βRβ€βΌβIβΌSββΌββΌΒ±β€βΌβββΊββ/β€βΒ°8.DβββΊββRβ€βΌββ€βΌβββΊββ/β€βΒ°8.DβββΊββRβ€βΌββΌSββΌββΌΒ±β€βΌβββΊββ/β€βΒ°8.EβΌββΊββRβ€βΌββ€βΌβββΊββ/β€βΒ°8.Fβ€ββRβ€βΌββ€βΌβββΊββ/β€βΒ°8.Rβ€βΌβCβΊβ€βΌββ€βΌβββΊβββ€βΒ°8.Rβ€βΌβCβΊβ€βΌβIβΌSββΌββΌΒ±β€βΌβββΊββ/β€βΒ°8.βββββ»βRββΌΒ±ββ½β€βΌβββΊββ/β€βΒ°8.Β°ββΌβ½β_ββββΌ
++++++++++++++++++++++++++++++++++++
BββΌDββΌPββΌββMββBβΊβΊβ-PβΌβΊ:PββCβΊββ BββΌDββΌPββΌ$ 1;2β1;2β1;2β1;2β
-βββ½β€: 1: ββΊββββΌβ βΌβΊβ Β°βΊβ€βΌβ
-βββ½β€: 2β1: ββΊββββΌβ βΌβΊβ Β°βΊβ€βΌβ
-βββ½β€: 2β1: ββΊββββΌβ βΌβΊβ Β°βΊβ€βΌβ
-βββ½β€: 2β1: ββΊββββΌβ βΌβΊβ Β°βΊβ€βΌβ
-βββ½β€: 2β: ββΊββββΌβ βΌβΊβ Β°βΊβ€βΌβ
BββΌDββΌPββΌββMββBβΊβΊβ-PβΌβΊ:PββCβΊββ BββΌDββΌPββΌ$
BββΌDββΌPββΌββMββBβΊβΊβ-PβΌβΊ:PββCβΊββ BββΌDββΌPββΌ$
BββΌDββΌPββΌββMββBβΊβΊβ-PβΌβΊ:PββCβΊββ BββΌDββΌPββΌ$
BββΌDββΌPββΌββMββBβΊβΊβ-PβΌβΊ:PββCβΊββ BββΌDββΌPββΌ$
I thought it's caused by special characters οΌbut when I try to make it all ASCII,it's also output something strange ,but better .and this is a part of the output:
mp_604unicode.statictmp_605unicode.statictmp_606unicode.statictmp_607unicode.statictmp_608unicode.statictmp_609unicode.statictmp_61unicode.statictmp_610unicode.statictmp_62unicode.statictmp_63unicode.statictmp_64unicode.statictmp_65unicode.statictmp_66unicode.statictmp_67unicode.statictmp_68unicode.statictmp_69unicode.statictmp_70unicode.statictmp_71unicode.statictmp_72unicode.statictmp_73unicode.statictmp_74unicode.statictmp_75unicode.statictmp_76unicode.statictmp_77unicode.statictmp_79unicode.statictmp_80unicode.statictmp_81unicode.statictmp_82unicode.statictmp_83unicode.statictmp_84unicode.statictmp_85unicode.statictmp_86unicode.statictmp_87unicode.statictmp_88unicode.statictmp_89unicode.statictmp_90unicode.statictmp_91unicode.statictmp_92unicode.statictmp_93unicode.statictmp_94unicode.statictmp_95unicode.statictmp_96unicode.statictmp_97unicode.statictmp_98unicode.statictmp_99unicode.tounicode/utf8.DecodeLastRuneunicode/utf8.DecodeLastRuneInStringunicode/utf8.DecodeRuneunicode/utf8.DecodeRuneInStringunicode/utf8.EncodeRuneunicode/utf8.FullRuneunicode/utf8.RuneCountunicode/utf8.RuneCountInStringunicode/utf8.acceptRangesunicode/utf8.first_main
BenDerPandeMacBook-Pro:test BenDerPan$ 1;2c1;2c1;2c1;2c
It would be great if someone can write up the installation steps and how to use/test grumpy!
Per justinsaccount on HN:
$ make run
c = {}
top = sorted(c.items(), key=lambda (k,v): v)
^D
Traceback (most recent call last):
File "./tools/grumpc", line 102, in
sys.exit(main(parser.parse_args()))
File "./tools/grumpc", line 60, in main
visitor.visit(mod)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 302, in visit_Module
self._visit_each(node.body)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stmt.py", line 632, in _visit_each
self.visit(node)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/stin visit_Assign
with self.expr_visitor.visit(node.value) as value:
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/expr_visitor.py", line 101, in visit_Call
values.append((util.go_str(k.arg), self.visit(k.value)))
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 241, in visit
return visitor(node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/expr_visitor.py", line 246, in visit_Lambda
return self.visit_function_inline(func_node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/expr_visitor.py", line 388, in visit_function_inline
func_visitor = block.FunctionBlockVisitor(node)
File "/Users/foo/src/grumpy/build/lib/python2.7/site-packages/grumpy/compiler/block.py", line 432, in init
args = [a.id for a in node_args.args]
AttributeError: 'Tuple' object has no attribute 'id'
What are the plans for missing stdlib modules.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.