te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>How to compile Python with Brython to Javascript (to run with nodejs)? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to compile Python with Brython to Javascript (to run with nodejs)? - Stack Overflow

programmeradmin4浏览0评论

How can I use Brython to pile Python to Javascript? I want to do this on my puter, so I can the run Javascript with nodejs, eg.

$ python hello.py
Hello world
$ brython hello.py -o hello.js
$ node hello.js
Hello world

The examples on the Brython website only explain how do this in the browser .html

How can I use Brython to pile Python to Javascript? I want to do this on my puter, so I can the run Javascript with nodejs, eg.

$ python hello.py
Hello world
$ brython hello.py -o hello.js
$ node hello.js
Hello world

The examples on the Brython website only explain how do this in the browser http://www.brython.info/index_en.html

Share Improve this question edited May 17, 2021 at 14:01 Colonel Panic asked Feb 20, 2013 at 13:29 Colonel PanicColonel Panic 138k97 gold badges417 silver badges479 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

It seems they are very browser oriented, there is no mand line option out of the box.

You can try to use their code youself from node.js, perhaps it will work easily. It seems the $py2js(src, module) function does the actual conversion so maybe you can just run it with the python code string as first parameter.

Another option is to use pyjs: http://pyjs/ which does something similar and has mand line tool to do the conversion.

It is possible to pile Python code to javascript and load it afterwards using import statement . See brython:ticket:222 for further details. You'll have to load brython js lib in advance because , in the end, Python semantics are quite different from Javascript's . You can include piled .pyc.js code in .vfs.js files in order to speed up module import times.

Disclaimer : I'm a mitter of Brython project .

Brython has a console that runs in the browser, but not a piler. It is meant for you to either import your python scripts into the html file, or write your python code into the html file. See pyjs if you wish a conversion tool before the page loads.

发布评论

评论列表(0)

  1. 暂无评论