Re: php to python code converter
On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote: > if anybody needs: > http://code.google.com/p/phppython/ this link doesn't work -- https://mail.python.org/mailman/listinfo/python-list
Re: What is the meaning of Building Wheel for ?
On 2/29/2020 11:23 AM, Souvik Dutta wrote: What is the meaning of the subject I mean what does python internally do when it says this? Python does not normally 'build wheels'. So you must be running some particular program. Check the docs for that program. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Friday Finking: Poly more thick
On 2020-03-01 02:08, Christman, Roger Graydon wrote: DL Neil asked: How does one code a function/method signature so that it will accept either a set of key-value pairs, or the same data enclosed as a dict, as part of a general-case and polymorphic solution? Will this do for you? def any_as_dict(*args, **kwargs): if len(args) == 0: my_dict = kwargs elif type(args[0]) == type(dict()): my_dict = args[0] else: my_dict = dict(args) print(type(my_dict),my_dict) any_as_dict(a=1,b=2) {'a': 1, 'b': 2} any_as_dict({'a':1, 'b':2}) {'a': 1, 'b': 2} any_as_dict([('a',1), ('b',2)]) {('a', 1): ('b', 2)} any_as_dict({('a',1), ('b',2)}) {('b', 2): ('a', 1)} This seems to address your apparent definition of "key-value pairs" in the form of a=1, b=2 and my interpretation as key-value tuples, either in a list, or set, or presumably any iterable collection, in addition to taking an actual dictionary. That function can be simplified: def any_as_dict(*args, **kwargs): return dict(args[0]) if args else kwargs any_as_dict(a=1,b=2) {'a': 1, 'b': 2} any_as_dict({'a':1, 'b':2}) {'a': 1, 'b': 2} any_as_dict([('a',1), ('b',2)]) {'a': 1, 'b': 2} any_as_dict({('a',1), ('b',2)}) {'b': 2, 'a': 1} -- https://mail.python.org/mailman/listinfo/python-list
Re: Friday Finking: Poly more thick
Emending my own note from moments ago: def any_as_dict(*args, **kwargs): if len(args) == 0: my_dict = kwargs elif type(args[0]) == type(dict()): my_dict = args[0] else: my_dict = dict(args[0]) print(type(my_dict),my_dict) >>> any_as_dict(a=1,b=2) {'a': 1, 'b': 2} >>> any_as_dict({'a':1, 'b':2}) {'a': 1, 'b': 2} >>> any_as_dict([('a',1), ('b',2)]) {'a': 1, 'b': 2} >>> any_as_dict({('a',1), ('b',2)}) {'b': 2, 'a': 1} -- https://mail.python.org/mailman/listinfo/python-list
Re: Friday Finking: Poly more thick
DL Neil asked: > How does one code a function/method signature so that > it will accept either a set of key-value pairs, > or the same data enclosed as a dict, as part of > a general-case and polymorphic solution? Will this do for you? def any_as_dict(*args, **kwargs): if len(args) == 0: my_dict = kwargs elif type(args[0]) == type(dict()): my_dict = args[0] else: my_dict = dict(args) print(type(my_dict),my_dict) >>> any_as_dict(a=1,b=2) {'a': 1, 'b': 2} >>> any_as_dict({'a':1, 'b':2}) {'a': 1, 'b': 2} >>> any_as_dict([('a',1), ('b',2)]) {('a', 1): ('b', 2)} >>> any_as_dict({('a',1), ('b',2)}) {('b', 2): ('a', 1)} This seems to address your apparent definition of "key-value pairs" in the form of a=1, b=2 and my interpretation as key-value tuples, either in a list, or set, or presumably any iterable collection, in addition to taking an actual dictionary. Roger Christman Pennsylvania State University -- https://mail.python.org/mailman/listinfo/python-list
Re: Help building python application from source
Thanks for the comments. > (To make OP's requirements plainly visible, note that this appears to > be a cryptocurrency application.) Correct. It is a software that does not store private keys but acts as a server to serve lightweight wallets that would connect to it remotely. Electrumx does not store or generate private keys but my concern is running binary blobs that someone else created. The advantages of open source software only apply if you can confirm it was created from the source code. This is why I compile everything I can or use binaries based on reproducible build process. I am also wanting to run electrumx in a virtual environment under a dedicated user account on the linux box with lowest privileges. And the reason I want to be able to build from a local directory so that I can be self sufficient and be able to archive the software source code and all needed dependencies to spin up other servers or replace the server in a post disaster situation where internet or python pip package servers might be down. My bitcoin server also has very strict firewall rules that would inhibit the ability to connect to python servers. This is why I want to download the all the source code on my laptop then transfer to the server. But there are SO MANY dependencies. Electrumx has a few dependencies then each of those dependencies have more dependencies and on and on. I guess it might be possible to do what I want by manually downloading the source code of the close to 20 dependencies, manually verify the git tags and signatures. Then "python setup.py install" each one individually in the right order. This might work? I didn't know if there was an easier way. I did find out I could "pip download -r requirements.txt" but this downloads binaries specific for x86. My cpu architecture is aarch64. Is there a way to pip download -r requirements.txt source only or specify aarch64? Thank you -- lee.chif...@secmail.pro PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35 -- https://mail.python.org/mailman/listinfo/python-list
Re: Help building python application from source
On Fri, 28 Feb 2020 18:49:58 -0800, Mr. Lee Chiffre wrote: [snip] > I am a python noob. This is why I ask the python masters. There is a > python software I want to install on the server it is called Electrumx. > https://github.com/kyuupichan/electrumx is the link. I am having troubles > with installing this. > The short version is I am wanting to build this python application and > needed dependencies from source code all from a local directory without > relying on the python pip package servers. I only run software I can > compile from source code because this is the only way to trust open source > software. I also want to archive the software I use and be able to install > it on systems in a grid down situation without relying on other servers > such as python package servers. (To make OP's requirements plainly visible, note that this appears to be a cryptocurrency application.) I'd suggest that building everything from source code might not be a realistic solution to your security concerns. I don't know what your threat model is, but if it's something like, "Hackers and gangsters who scatter password-harvesting trojans across the globe and then shlurp up what they can," you might find that you get better security by generating your keys on a computer that never communicates with the outside world. Your concerns are (1) that the random numbers from which your keys have been corrupted to make them predictable, or (2) that malicious software will send your keys to the bad guys. Isolating the key-generation machine takes care of #2. If you have Python code for generating keys, something as simple as XORing a fixed value of your choice with its random numbers will take care of #1. I admit that using an isolated machine introduces a lot of inconveniences, but I bet it compares favorably with building everything from source. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
What is the meaning of Building Wheel for ?
What is the meaning of the subject I mean what does python internally do when it says this? -- https://mail.python.org/mailman/listinfo/python-list
Re: 【Regarding Performance of a Python Script....】
On 2020-02-28 19:24:18 -0500, Kenzi wrote: > I have a question regarding a simple code snippet in Python: > > from subprocess import check_output > for i in range(1024): > check_output(['/bin/bash', '-c', 'echo 42'], close_fds=True) > > *I wonder why running it in Python 3.7 is much faster than Python 2.7? * > (Python 3.7 is still faster, after I used *xrange * in Python 2.7) I think almost all of the time is spent in the child processes, so it doesn't matter whether you use range or xrange. On my laptop, the program takes about 2.1 seconds with python 2.7 and 1.6 seconds with python 3.6. So the difference is 0.5 seconds overall or about 500 µs per execution. strace shows that python 2.7 explicitely closes all unneeded file descriptors below 1024 (even though most of them aren't actually open) in the child before execing bash, python 3 doesn't do that. I can see no other obvious difference. So that's ~ 1020 extra system calls. If this is indeed the only difference, that's about 500 ns per system call. That sounds plausible. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Groovy to Python Converter ?
In my new project, I am supposed to bring the current test cases, all written in Groovy, to a Python base. We are talking about several thousand test cases that have accumulated over the last years. Since the test cases are also to be extended towards API gateway testing, and since we work with Python requests here, we want and need to convert everything. But here is the question, which I could not answer even after an intensive search: Is there a converter that can convert Groovy based test cases to Python? An example of how the tests are structured. They are pure web tests that ask for links and other questions with just one click. Actually, it's absolutely simple, but not suitable for us for broad-based tests, even in the direction of expansion. -- https://mail.python.org/mailman/listinfo/python-list