Hi Michel! > On 25 Mar 2017, at 22:43, Michel Desmoulin <desmoulinmic...@gmail.com> wrote: > > Hello, > > I've been following PythonQL with interest. I like the clever hack using > Python encoding. It's definitely not something I would recommend to do > for an inclusion in Python as it hijack the Python encoding method, > which prevent your from... well choosing an encoding. And requires to > have a file.
This was done as a temporary hack, we definitely want to move away from this at some point. > > However, I find the idea great for the demonstration purpose. Like LINQ, > the strength of your tool is the integrated syntax. I myself found it > annoying to import itertools all the time. I eventually wrote a wrapper > so I could use slicing on generators, callable in slicing, etc for this > very reason. > > However, I have good news. > > When the debate about f-strings was on this list, the concept has been > spitted in several parts. The f-string currently implemented in Python > 3.6, and an more advanced type of string interpolation: the i-string > from PEP 501 (https://www.python.org/dev/peps/pep-0501/) that is still > to be implemented. > > The idea of the i-string was to allow something like this: > > mycommand = sh(i"cat {filename}") > myquery = sql(i"SELECT {column} FROM {table};") > myresponse = html(i"<html><body>{response.body}</body></html>") > > Which would then pass an object to sql/sh/html() with the string, the > placeholders and the variable context then allow it to do whatever you > want. Evaluation of the i-string would of course be lazy. > > So while I don't thing PythonQL can be integrated in Python the way it > is, you may want to champion PEP 501. This way you will be able to > provide a PQL hook allowing you to do something like: > > pql(i"""select (x, sum_y) > for x in range(1,8), > y in {stuff} > where x % 2 == 0 and y % 2 != 0 and x > y > group by x > let sum_y = sum(y) > where sum_y % 2 != 0 > """) > > Granted, this is not as elegant as your DSL, but that would make it > easier to adopt anywhere: repl, ipython notebook, files in Python with a > different encoding, embeded Python, alternative Python implementations > compiled Python, etc. > > Plus the sooner we start with i-string, the sooner editors will > implement syntax highlighting for the popular dialects. > > This would allow you to spread the popularity of your tool and maybe > change the way it's seen on this list. Hmm, I don’t quite understand what’s the difference here with regular string and executing them, i.e. I think we can do this right now without i-strings. > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/