how to debug this distributed program?
https://drive.google.com/open?id=0Bxs_ao6uuBDUSEc5S3U3Nko5ZjA A. i am not sure whether parameter start from 0 or 1 n[0] or n[1] in compute function B. it run a very long time and nothing to see in amazon linux instance there is no python program in top command C. in distributed programming web site, there is no authentication method using private key in python program, how do distributed program access the nodes in amazon cloud when run python program below in window locally? import random, dispy def compute(n): # executed on nodes import random, time, socket name = socket.gethostname() cur_best = 1 for ii in range(n[0],n[0]): for jj in range(n[1],n[1]): for kk in range(n[2],n[3],100): dispy_provisional_result((name, r)) cur_best = r time.sleep(0.1) # final result return (name, cur_best) def job_callback(job): # executed at the client if job.status == dispy.DispyJob.ProvisionalResult: #if job.result[1] < 0.005: # acceptable result; terminate jobs print('%s computed: %s %s %s %s' % (job.result[0], job.result[1], job.result[2], job.result[3], job.result[4])) # 'jobs' and 'cluster' are created in '__main__' below for j in jobs: if j.status in [dispy.DispyJob.Created, dispy.DispyJob.Running, dispy.DispyJob.ProvisionalResult]: cluster.cancel(j) if __name__ == '__main__': #cluster = dispy.JobCluster(compute, callback=job_callback) cluster = dispy.JobCluster(compute, nodes=['ec2-100-162-137-237.us-west-2.compute.amazonaws.com'], callback=job_callback) jobs = [] prevk = 1 count = 0 for ii in range(1,2): for jj in range(1,2000): for kk in range(1,2000,100): if ii < jj and jj < kk: job = cluster.submit([ii,jj,prevk,kk]) prevk = kk if job is None: print('creating job %s failed!' % n) continue job.id = count count = count + 1 jobs.append(job) cluster.wait() cluster.print_status() cluster.close() -- https://mail.python.org/mailman/listinfo/python-list
Re: how to debug this distributed program?
On Tue, 1 Nov 2016 06:40 pm, meInvent bbird wrote: > how to debug this distributed program? The same way you would debug any other program. http://sscce.org/ -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to debug this distributed program?
i follow documentation and add keyfile to indicate the path of private key but still no response from program, what is the correct way to do? cluster = dispy.JobCluster(compute, nodes=['ec2-35-162-137-237.us-west-2.compute.amazonaws.com'], callback=job_callback, keyfile=r"C:\Users\martlee2\Downloads\datacenterusekey.ppk") On Tuesday, November 1, 2016 at 3:58:24 PM UTC+8, Steve D'Aprano wrote: > On Tue, 1 Nov 2016 06:40 pm, meInvent bbird wrote: > > > how to debug this distributed program? > > > The same way you would debug any other program. > > http://sscce.org/ > > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Announcement: PythonQL - An integrated query language for Python
Hi Folks, We have released PythonQL, a query language extension to Python (we have extended Python’s comprehensions with a full-fledged query language, drawing from the useful features of SQL, XQuery and JSONiq). Take a look at the project here: http://www.pythonql.org and lets us know what you think! The way PythonQL currently works is you mark PythonQL files with a special encoding and the system runs a preprocessor for all such files (this is similar to how pyxl project has been done). We have an interactive interpreter and Jupyter support planned. Best regards! PythonQL team -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
Pavel Velikhov wrote: > We have released PythonQL, a query language extension to Python (we have > extended Python’s comprehensions with a full-fledged query language, > drawing from the useful features of SQL, XQuery and JSONiq). Take a look > at the project here: http://www.pythonql.org and lets us know what you > think! I would really like Python to get seamless integration of SQL, so I applaud your effort! The demo on your web page is too noisy for my taste, so I went ahead and installed the python3 version in a virtual env. My first attempt failed because of a missing ply; maybe you can fix that. Now off to the tutorial... > The way PythonQL currently works is you mark PythonQL files with a > special encoding and the system runs a preprocessor for all such files > (this is similar to how pyxl project has been done). We have an > interactive interpreter and Jupyter support planned. > > Best regards! > PythonQL team -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help with coding a function in Python
On 31 October 2016 at 23:09, wrote: > http://imgur.com/a/rfGhK#iVLQKSW > How do I code a function that returns a list of the first n elements > of the sequence defined in the link? I have no idea! For those who didn't open the page (that you should have linked at least as direct link to the image rather than to the javascript based frontend of imgur) here's the description: there's a mathematical sequence where a_0 = 0 a_n = a_{n-1} - nif a_{n-1} is positive and not already in the sequence a_{n-1} + notherwise so it's based off a simple sequence of kind a_n = a_{n-1} + n with a conditional that brings the value back at times. > So far this is my best shot at it (the problem with it is that the n that > i'm subtracting or adding in the if/else part does not represent the > element's position, but just the n that I am plugging into the function): Since I've been lately trying to tackle small problems in the most idiomatic way I can (much to Raymond Hettinger's enjoyable talks' fault) I had my attempt at it. You tried to build a list and return it while I make a function whose return value is then iterated upon: def sequence(n): """Returns a generator for the mathematical sequence a_0 = 0 a_n = a_{n-1} - nif a_{n-1} is positive and not already in the sequence a_{n-1} + notherwise """ value, past = 0, {} for c in range(n): t = value - c value = t if (t > 0 and t not in past) else (value + c) past[value] = True yield value I'm not sure this can be made without the past state in the closure since the sequence conditional rule depends on it. Any hints on how to make it better are welcome. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list
Re: how to compile this code
You want to replace the `Add` ast with a `Call` ast rather than just calling your function. Something like: if isinstance(node.op, ast.Add): return ast.Call(some_ast_expression_that_will_evaluate_to_op, [node.left, node.right], []) You'll have to replace some_ast_expression_... to something like Name(id="op2", ctx=ast.Load()) and inject op2 in the globals when you call `exec`. On Tue, Nov 1, 2016, 06:36 meInvent bbird wrote: > would like to change Add operator to custom function op2 in solve function > and then this solve([x*y - 1, x + 2], x, y) > during solve, the parameters also change Add to custom function op2 > > import ast > from __future__ import division > from sympy import * > x, y, z, t = symbols('x y z t') > k, m, n = symbols('k m n', integer=True) > f, g, h = symbols('f g h', cls=Function) > import inspect > > def op2(a,b): > return a*b+a > > class ChangeAddToMultiply(ast.NodeTransformer): > """Wraps all integers in a call to Integer()""" > def visit_BinOp(self, node): > print(dir(node)) > print(dir(node.left)) > if isinstance(node.op, ast.Add): > node.op = op2(node.left, node.right) > return node > > code = inspect.getsourcelines(solve) > tree = ast.parse(code) > tree = ChangeAddToMultiply().visit(tree) > ast.fix_missing_locations(tree) > co = compile(tree, '', "exec") > > exec(code) > exec(co) > -- > https://mail.python.org/mailman/listinfo/python-list > -- Yann Kaiser kaiser.y...@gmail.com yann.kai...@efrei.net +33 6 51 64 01 89 https://github.com/epsy -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python
On 2016-11-01, Steve D'Aprano wrote: > On Tue, 1 Nov 2016 04:00 pm, Wildman wrote: > >> You are correct about that but, in this case grep never "sees" the '$' >> sign. Bash expands $USER to the actual user name beforehand. If you >> are on a Linux system, enter this into a terminal to illustrate: >> >> sudo grep ^$USER\: /etc/shadow > > Bash is not involved here. Python is calling grep directly. He's already been told this 6 times, and is willfully ignoring it. Just give up. -- Grant Edwards grant.b.edwardsYow! With YOU, I can be at MYSELF ... We don't NEED gmail.comDan Rather ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python
On Tue, 01 Nov 2016 16:23:08 +1100, Ben Finney wrote: > Wildman via Python-list writes: > >> […] in this case grep never "sees" the '$' sign. Bash expands $USER to >> the actual user name beforehand. > > I understand how Bash substitutes variables on the command line. > > What I need to repeat, though: In this case, no, Bash doesn't do that > because Bash isn't getting involved. Grep does in fact see the “$” in > the command argument, because nothing ever replaces it. I understand now. Thank you. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python
On Tue, 01 Nov 2016 16:52:18 +1100, Steve D'Aprano wrote: > On Tue, 1 Nov 2016 04:00 pm, Wildman wrote: > >> You are correct about that but, in this case grep never "sees" the '$' >> sign. Bash expands $USER to the actual user name beforehand. If you >> are on a Linux system, enter this into a terminal to illustrate: >> >> sudo grep ^$USER\: /etc/shadow > > Bash is not involved here. Python is calling grep directly. > > > You don't have to believe us, you can test this yourself. Create a simple > text file with a single line containing your username, and a simple Python > script that calls grep as you have been: > > > [steve@ando ~]$ echo $USER > steve > [steve@ando ~]$ cat foo.txt > blah blah steve blah blah > [steve@ando ~]$ cat greptest.py > import subprocess > cmdlist = ['grep', '$USER', 'foo.txt'] > p = subprocess.Popen(cmdlist, stdout=subprocess.PIPE,stderr=subprocess.PIPE) > line, err = p.communicate() > print err, line > > [steve@ando ~]$ python2.7 greptest.py > > [steve@ando ~]$ > > > > So there you have it: categorical proof that bash does not expand the > string '$USER'. It cannot: bash is not involved in the subprocess call. > Python calls grep directly. > > If you want to expand the '$USER' string from Python, do it yourself: I understand now. That explains more clearly why my original code did not work. Thank you. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python
On Tue, 01 Nov 2016 13:42:03 +, Grant Edwards wrote: > On 2016-11-01, Steve D'Aprano wrote: >> On Tue, 1 Nov 2016 04:00 pm, Wildman wrote: >> >>> You are correct about that but, in this case grep never "sees" the '$' >>> sign. Bash expands $USER to the actual user name beforehand. If you >>> are on a Linux system, enter this into a terminal to illustrate: >>> >>> sudo grep ^$USER\: /etc/shadow >> >> Bash is not involved here. Python is calling grep directly. > > He's already been told this 6 times, and is willfully ignoring it. > > Just give up. That was not my intention. I was trying to understand that which I did not understand. Ever been there? -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python
On 2016-11-01 01:23 AM, Ben Finney wrote: Wildman via Python-list writes: So the way your script was invoked has no bearing on whether Bash will get involved in what your script does. Your script is *directly* invoking programs, and if you don't ask for a shell to be involved you won't get it. In other words, the OP's script *is* bash in this scenario or a reasonable facsimile thereof. The subject probably should have been "Emulating a shell in Python." Of course, if the OP knew to use that subject he probably would have already had the answer. :-) -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
On Tuesday, 1 November 2016 12:50:37 UTC+3, Peter Otten wrote: > Pavel Velikhov wrote: > > > We have released PythonQL, a query language extension to Python (we have > > extended Python’s comprehensions with a full-fledged query language, > > drawing from the useful features of SQL, XQuery and JSONiq). Take a look > > at the project here: http://www.pythonql.org and lets us know what you > > think! > > I would really like Python to get seamless integration of SQL, so I applaud > your effort! > > The demo on your web page is too noisy for my taste, so I went ahead and > installed the python3 version in a virtual env. > Great! Yes, we're hoping this will be useful to folks that like SQL and other query languages. > My first attempt failed because of a missing ply; maybe you can fix that. > Now off to the tutorial... Oops, I have tested with virtual env and ply was installing just fine, wierd. Any hints on why it didn't pick it up during the installation? > > The way PythonQL currently works is you mark PythonQL files with a > > special encoding and the system runs a preprocessor for all such files > > (this is similar to how pyxl project has been done). We have an > > interactive interpreter and Jupyter support planned. > > > > Best regards! > > PythonQL team -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
Pavel Velikhov wrote: > On Tuesday, 1 November 2016 12:50:37 UTC+3, Peter Otten wrote: >> Pavel Velikhov wrote: >> >> > We have released PythonQL, a query language extension to Python (we >> > have extended Python’s comprehensions with a full-fledged query >> > language, >> > drawing from the useful features of SQL, XQuery and JSONiq). Take a >> > look at the project here: http://www.pythonql.org and lets us know what >> > you think! >> >> I would really like Python to get seamless integration of SQL, so I >> applaud your effort! >> >> The demo on your web page is too noisy for my taste, so I went ahead and >> installed the python3 version in a virtual env. >> > > Great! Yes, we're hoping this will be useful to folks that like SQL and > other query languages. > >> My first attempt failed because of a missing ply; maybe you can fix that. >> Now off to the tutorial... > > Oops, I have tested with virtual env and ply was installing just fine, > wierd. Any hints on why it didn't pick it up during the installation? I don't know enough about pip to make sense of it, but here's what I see: $ virtualenv -p python3 tmp_pyql Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in tmp_pyql/bin/python3 Also creating executable in tmp_pyql/bin/python Installing setuptools, pip...done. $ cd tmp_pyql/ $ . bin/activate If at this point I first run (tmp_pyql)$ run pip install ply installing pythonql3 will succeed. Otherwise: (tmp_pyql)$ pip install pythonql3 Downloading/unpacking pythonql3 Downloading pythonql3-0.9.43.tar.gz (41kB): 41kB downloaded Running setup.py (path:/home/peter/tmp_pyql/build/pythonql3/setup.py) egg_info for package pythonql3 Downloading/unpacking ply>=3.9 (from pythonql3) Downloading ply-3.9.tar.gz (150kB): 150kB downloaded Running setup.py (path:/home/peter/tmp_pyql/build/ply/setup.py) egg_info for package ply warning: no previously-included files matching '*.pyc' found anywhere in distribution Installing collected packages: pythonql3, ply Running setup.py install for pythonql3 Running post install task Running setup.py install for ply Failed to import the site module Traceback (most recent call last): File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 703, in main() File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 683, in main paths_in_sys = addsitepackages(paths_in_sys) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 282, in addsitepackages addsitedir(sitedir, known_paths) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 204, in addsitedir addpackage(sitedir, name, known_paths) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 173, in addpackage exec(line) File "", line 1, in File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/codec/register.py", line 5, in from pythonql.parser.Preprocessor import makeProgramFromString File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/parser/Preprocessor.py", line 3, in from pythonql.parser.PythonQLParser import Parser, Node, print_program File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/parser/PythonQLParser.py", line 1, in import ply.yacc as yacc ImportError: No module named 'ply' Complete output from command /home/peter/tmp_pyql/bin/python3 -c "import setuptools, tokenize;__file__='/home/peter/tmp_pyql/build/ply/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3yg_3xh1-record/install-record.txt --single- version-externally-managed --compile --install-headers /home/peter/tmp_pyql/include/site/python3.4: Failed to import the site module Traceback (most recent call last): File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 703, in main() File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 683, in main paths_in_sys = addsitepackages(paths_in_sys) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 282, in addsitepackages addsitedir(sitedir, known_paths) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 204, in addsitedir addpackage(sitedir, name, known_paths) File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 173, in addpackage exec(line) File "", line 1, in File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/codec/register.py", line 5, in from pythonql.parser.Preprocessor import makeProgramFromString File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/parser/Preprocessor.py", line 3, in from pythonql.parser.PythonQLParser import Parser, Node, print_program File "/home/peter/tmp_pyql/lib/python3.4/site- packages/pythonql/parser/PythonQLParser.py", line 1, in import ply.yacc as yacc ImportError: No module named 'ply' --
Re: Announcement: PythonQL - An integrated query language for Python
On 11/01/2016 02:56 AM, Pavel Velikhov wrote: > Hi Folks, > > We have released PythonQL, a query language extension to Python (we > have extended Python’s comprehensions with a full-fledged query > language, drawing from the useful features of SQL, XQuery and > JSONiq). Take a look at the project here: http://www.pythonql.org and > lets us know what you think! Sounds interesting. Hope you'll accept a wee bit of criticism of the web page, though. Why not put the examples clearly on the front page, along with output? Took me a while to find the examples, and it wasn't obvious what to do with the examples matrix. I'd prefer to just see them straight away without too much digging. I'm glad you had a link to your github repo right on the main page. I found your Github markdown files to be far more informative than your web page. -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
On Tuesday, 1 November 2016 20:16:43 UTC+3, Michael Torrie wrote: > On 11/01/2016 02:56 AM, Pavel Velikhov wrote: > > Hi Folks, > > > > We have released PythonQL, a query language extension to Python (we > > have extended Python’s comprehensions with a full-fledged query > > language, drawing from the useful features of SQL, XQuery and > > JSONiq). Take a look at the project here: http://www.pythonql.org and > > lets us know what you think! > > Sounds interesting. Hope you'll accept a wee bit of criticism of the > web page, though. Why not put the examples clearly on the front page, > along with output? Took me a while to find the examples, and it wasn't > obvious what to do with the examples matrix. I'd prefer to just see > them straight away without too much digging. > > I'm glad you had a link to your github repo right on the main page. I > found your Github markdown files to be far more informative than your > web page. Hi Michael! Thanks for the feedback, will try to make the examples easier to find, definitely! Not too happy with the site layout myself... Was it obvious that you can play around with the examples - i.e. edit them and run modified versions? Will keep on improving the documentation too! -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
On Tuesday, 1 November 2016 20:09:14 UTC+3, Peter Otten wrote: > Pavel Velikhov wrote: > > > On Tuesday, 1 November 2016 12:50:37 UTC+3, Peter Otten wrote: > >> Pavel Velikhov wrote: > >> > >> > We have released PythonQL, a query language extension to Python (we > >> > have extended Python’s comprehensions with a full-fledged query > >> > language, > >> > drawing from the useful features of SQL, XQuery and JSONiq). Take a > >> > look at the project here: http://www.pythonql.org and lets us know what > >> > you think! > >> > >> I would really like Python to get seamless integration of SQL, so I > >> applaud your effort! > >> > >> The demo on your web page is too noisy for my taste, so I went ahead and > >> installed the python3 version in a virtual env. > >> > > > > Great! Yes, we're hoping this will be useful to folks that like SQL and > > other query languages. > > > >> My first attempt failed because of a missing ply; maybe you can fix that. > >> Now off to the tutorial... > > > > Oops, I have tested with virtual env and ply was installing just fine, > > wierd. Any hints on why it didn't pick it up during the installation? > > I don't know enough about pip to make sense of it, but here's what I see: > > $ virtualenv -p python3 tmp_pyql > Running virtualenv with interpreter /usr/bin/python3 > Using base prefix '/usr' > New python executable in tmp_pyql/bin/python3 > Also creating executable in tmp_pyql/bin/python > Installing setuptools, pip...done. > $ cd tmp_pyql/ > $ . bin/activate > > > If at this point I first run > > (tmp_pyql)$ run pip install ply > > installing pythonql3 will succeed. Otherwise: > > > (tmp_pyql)$ pip install pythonql3 > Downloading/unpacking pythonql3 > Downloading pythonql3-0.9.43.tar.gz (41kB): 41kB downloaded > Running setup.py (path:/home/peter/tmp_pyql/build/pythonql3/setup.py) > egg_info for package pythonql3 > > Downloading/unpacking ply>=3.9 (from pythonql3) > Downloading ply-3.9.tar.gz (150kB): 150kB downloaded > Running setup.py (path:/home/peter/tmp_pyql/build/ply/setup.py) egg_info > for package ply > > warning: no previously-included files matching '*.pyc' found anywhere in > distribution > Installing collected packages: pythonql3, ply > Running setup.py install for pythonql3 > > Running post install task > Running setup.py install for ply > Failed to import the site module > Traceback (most recent call last): > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 703, in > > main() > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 683, in main > paths_in_sys = addsitepackages(paths_in_sys) > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 282, in > addsitepackages > addsitedir(sitedir, known_paths) > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 204, in > addsitedir > addpackage(sitedir, name, known_paths) > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 173, in > addpackage > exec(line) > File "", line 1, in > File "/home/peter/tmp_pyql/lib/python3.4/site- > packages/pythonql/codec/register.py", line 5, in > from pythonql.parser.Preprocessor import makeProgramFromString > File "/home/peter/tmp_pyql/lib/python3.4/site- > packages/pythonql/parser/Preprocessor.py", line 3, in > from pythonql.parser.PythonQLParser import Parser, Node, > print_program > File "/home/peter/tmp_pyql/lib/python3.4/site- > packages/pythonql/parser/PythonQLParser.py", line 1, in > import ply.yacc as yacc > ImportError: No module named 'ply' > Complete output from command /home/peter/tmp_pyql/bin/python3 -c "import > setuptools, > tokenize;__file__='/home/peter/tmp_pyql/build/ply/setup.py';exec(compile(getattr(tokenize, > > 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" > install --record /tmp/pip-3yg_3xh1-record/install-record.txt --single- > version-externally-managed --compile --install-headers > /home/peter/tmp_pyql/include/site/python3.4: > Failed to import the site module > > Traceback (most recent call last): > > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 703, in > > main() > > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 683, in main > > paths_in_sys = addsitepackages(paths_in_sys) > > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 282, in > addsitepackages > > addsitedir(sitedir, known_paths) > > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 204, in addsitedir > > addpackage(sitedir, name, known_paths) > > File "/home/peter/tmp_pyql/lib/python3.4/site.py", line 173, in addpackage > > exec(line) > > File "", line 1, in > > File "/home/peter/tmp_pyql/lib/python3.4/site- > packages/pythonql/codec/register.py", line 5, in > > from pythonql.parser.Preprocessor import makeProgramFromString > > File "/home/peter/tmp_pyq
Re: Call a shell command from Python
On Tue, 01 Nov 2016 11:23:09 -0400, D'Arcy Cain wrote: > On 2016-11-01 01:23 AM, Ben Finney wrote: >> Wildman via Python-list writes: >> So the way your script was invoked has no bearing on whether Bash will >> get involved in what your script does. Your script is *directly* >> invoking programs, and if you don't ask for a shell to be involved you >> won't get it. > > In other words, the OP's script *is* bash in this scenario or a > reasonable facsimile thereof. > > The subject probably should have been "Emulating a shell in Python." Of > course, if the OP knew to use that subject he probably would have > already had the answer. :-) You are absolutely correct. And thank you for your understanding. -- GNU/Linux user #557453 Keyboard not detected! Press any key to continue... -- https://mail.python.org/mailman/listinfo/python-list
[New Release] PyFTPD - an FTP server with GUI and CLI versions
Hello, i have just released the brand new FTP server based on pyftpdlib, named PyFTPD. You can run it from CLI with PyFTPD-cli.py or if you like GUIs run the PyFTPD.py It is written on PyQT4 and Python 2.7.12 More at https://github.com/demosthenesk/PyFTPD Regards, Dim -- https://mail.python.org/mailman/listinfo/python-list
Re: Announcement: PythonQL - An integrated query language for Python
On 11/01/2016 12:46 PM, Pavel Velikhov wrote: > Thanks for the feedback, will try to make the examples easier to find, > definitely! > Not too happy with the site layout myself... Was it obvious that you can play > around > with the examples - i.e. edit them and run modified versions? After I clicked on the example and then saw the output, it became clear. Not a bad feature. Maybe showing the input in one area and the output in another area of the same page would be clearer, and make it easier to tweak things and see the results without having to go back to the previous page to edit the code again. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to compile this code
>>> class ChangeAddToMultiply(ast.NodeTransformer, ast2.NodeTransformer): ... """Wraps all integers in a call to Integer()""" ... def visit_BinOp(self, node): ... print(dir(node)) ... print(dir(node.left)) ... if isinstance(node.op, ast.Add): ... ast.Call(Name(id="op2", ctx=ast2.Load()), [node.left, node.right ], []) ... return node ... Traceback (most recent call last): File "", line 1, in NameError: name 'ast2' is not defined >>> >>> code = inspect.getsourcelines(solve) >>> tree = ast.parse(code) Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\ast.py", line 37, in parse return compile(source, filename, mode, PyCF_ONLY_AST) TypeError: expected a readable buffer object >>> tree2 = ast.parse("def op2(a,b): return a*b+a") >>> tree = ChangeAddToMultiply().visit(tree,tree2) Traceback (most recent call last): File "", line 1, in NameError: name 'tree' is not defined >>> ast.fix_missing_locations(tree) Traceback (most recent call last): File "", line 1, in NameError: name 'tree' is not defined >>> co = compile(tree, '', "exec") Traceback (most recent call last): File "", line 1, in NameError: name 'tree' is not defined >>> >>> exec(code) Traceback (most recent call last): File "", line 1, in TypeError: exec: arg 1 must be a string, file, or code object >>> exec(co) * def op2(a,b): return a*b+a class ChangeAddToMultiply(ast.NodeTransformer, ast2.NodeTransformer): """Wraps all integers in a call to Integer()""" def visit_BinOp(self, node): print(dir(node)) print(dir(node.left)) if isinstance(node.op, ast.Add): ast.Call(Name(id="op2", ctx=ast2.Load()), [node.left, node.right], []) return node code = inspect.getsourcelines(solve) tree = ast.parse(code) tree2 = ast.parse("def op2(a,b): return a*b+a") tree = ChangeAddToMultiply().visit(tree,tree2) ast.fix_missing_locations(tree) co = compile(tree, '', "exec") exec(code) exec(co) On Tuesday, November 1, 2016 at 9:04:43 PM UTC+8, Yann Kaiser wrote: > You want to replace the `Add` ast with a `Call` ast rather than just > calling your function. > > Something like: > > if isinstance(node.op, ast.Add): > return ast.Call(some_ast_expression_that_will_evaluate_to_op, > [node.left, node.right], []) > > You'll have to replace some_ast_expression_... to something like > Name(id="op2", ctx=ast.Load()) and inject op2 in the globals when you call > `exec`. > > On Tue, Nov 1, 2016, 06:36 meInvent bbird wrote: > > > would like to change Add operator to custom function op2 in solve function > > and then this solve([x*y - 1, x + 2], x, y) > > during solve, the parameters also change Add to custom function op2 > > > > import ast > > from __future__ import division > > from sympy import * > > x, y, z, t = symbols('x y z t') > > k, m, n = symbols('k m n', integer=True) > > f, g, h = symbols('f g h', cls=Function) > > import inspect > > > > def op2(a,b): > > return a*b+a > > > > class ChangeAddToMultiply(ast.NodeTransformer): > > """Wraps all integers in a call to Integer()""" > > def visit_BinOp(self, node): > > print(dir(node)) > > print(dir(node.left)) > > if isinstance(node.op, ast.Add): > > node.op = op2(node.left, node.right) > > return node > > > > code = inspect.getsourcelines(solve) > > tree = ast.parse(code) > > tree = ChangeAddToMultiply().visit(tree) > > ast.fix_missing_locations(tree) > > co = compile(tree, '', "exec") > > > > exec(code) > > exec(co) > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > -- > Yann Kaiser > kaiser.y...@gmail.com > yann.kai...@efrei.net > +33 6 51 64 01 89 > https://github.com/epsy -- https://mail.python.org/mailman/listinfo/python-list
cx_freeze_zipimporter_instance
can anybody help me in this problem... -- https://mail.python.org/mailman/listinfo/python-list
Re: cx_freeze_zipimporter_instance
No, because you've not provided anything resembling a question or a problem. Please provide a minimal example set of code that exposes the problem you are encountering, and describe the problem you are having. And note that we will not write code for you if it ends up looking like a homework problem. Regards On Tue, Nov 1, 2016 at 10:55 PM, wrote: > can anybody help me in this problem... > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: cx_freeze_zipimporter_instance
On Wednesday 02 November 2016 14:55, the.ar...@gmail.com wrote: > can anybody help me in this problem... What problem? -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list