![]() |
|
[Python] Rewrite/Convert Javascript to Python possible? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Rewrite/Convert Javascript to Python possible? (/showthread.php?tid=6022327) |
Rewrite/Convert Javascript to Python possible? - Beyonder - Nov 5, 2019 Hello HF I really suck at javascript and I am trying to focus on one language at a time and that is python, but I found a script I need for something and I was wondering if someone can help me rewrite it to Python if its possible. The javscript/html: if I understand the script correct it will start the javascript when the body is being loaded and then it will sent a RNKEY cookie. What I would like is to make my python script generate the same value and print it out as a string, but I am not sure how to convert the script and I dont even know if its possible. π§ Thanks in advance π RE: Rewrite/Convert Javascript to Python possible? - Nachfolger - Nov 5, 2019 https://stackoverflow.com/questions/58712944/converting-javscript-to-python-possible The answers in the comment section help out. RE: Rewrite/Convert Javascript to Python possible? - Beyonder - Nov 5, 2019 (Nov 5, 2019 09:49 AM)Nachfolger Wrote: javascript - Converting Javscript to Python possible? - Stack Overflow Thanks I asked both places to get a faster response. I'll read the comments and see if I can figure it out. π€ RE: Rewrite/Convert Javascript to Python possible? - Kallu609 - Nov 7, 2019 Here you go! π€ RE: Rewrite/Convert Javascript to Python possible? - Beyonder - Nov 7, 2019 (Nov 7, 2019 11:56 AM)Kallu609 Wrote: Here you go! π€ You are a life saver, will check this out when I am on my desktop PC !! RE: Rewrite/Convert Javascript to Python possible? - Beyonder - Nov 16, 2019 (Nov 7, 2019 11:56 AM)Kallu609 Wrote: Here you go! π€ I got an error, but all I did was to make sure the range() was an integer. error: TypeError: 'float' object cannot be interpreted as an integer Fix: PHP Code RE: Rewrite/Convert Javascript to Python possible? - Kallu609 - Nov 17, 2019 (Nov 16, 2019 06:22 AM)Beyonder Wrote: I got an _error_, but all I did was to make sure the range() was an integer. Oh yeah, I didn't really test it out. Glad you got it sorted out. RE: Rewrite/Convert Javascript to Python possible? - Beyonder - Nov 17, 2019 (Nov 17, 2019 08:08 AM)Kallu609 Wrote: Oh yeah, I didn't really test it out. Glad you got it sorted out. The javscript code and the python code does not give the same output. Do you have an idea what might be wrong? :) Thanks again for the help. RE: Rewrite/Convert Javascript to Python possible? - Kallu609 - Nov 17, 2019 (Nov 17, 2019 08:10 AM)Beyonder Wrote: The javscript code and the python code does not give the same output. No idea, I tried my best to code it 1:1, throw some console.logs in JS and prints in Python to see where the breaking point is. JS and Python share the same operators so the code is nearly identical. RE: Rewrite/Convert Javascript to Python possible? - vorticalbox - Nov 19, 2019 (Nov 17, 2019 08:10 AM)Beyonder Wrote: The javascript code and the python code does not give the same output. It is probably down to the IEEE 754 spec[1] used in javascript. This is why 0.1 + 0.2 === 0.30000000000000004 in javascript there is a great video[2] about it on low level javascript channel [1] https://ieeexplore.ieee.org/document/30711 [2] https://www.youtube.com/watch?v=wPBjd-vb9eI |