TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python alternatives for PHP functions

129 pointsby wesllyover 12 years ago

9 comments

mambodogover 12 years ago
I think in some cases, it would be better to explain why the PHP function was a bad idea to begin with, rather than letting people bring it's mess over to Python. For example, Python doesn't need dumb shit like nl2br() [1].<p>[1] <a href="http://www.php2python.com/wiki/function.nl2br/" rel="nofollow">http://www.php2python.com/wiki/function.nl2br/</a>
评论 #4968451 未加载
评论 #4965611 未加载
评论 #4965677 未加载
评论 #4965617 未加载
评论 #4966722 未加载
kijinover 12 years ago
Thought for a second that somebody had invented a Python library with functions that work identically with their PHP counterparts. Like php.js [1].<p>Turns out it's much more than that. Rather than handing out ready-made functions to make Python behave like PHP, this site actually teaches you how to write Python like a real Pythonista. For example, str[2:5] instead of substr(str, 2, 3). Well done!<p>[1] <a href="http://phpjs.org/" rel="nofollow">http://phpjs.org/</a>
评论 #4965739 未加载
jeffisabelleover 12 years ago
cool job right there, but just curious, why this is php &#62;&#62; python and not php &#60;&#60; &#62;&#62; phython ? does that need a lot more work?
评论 #4965301 未加载
agentultraover 12 years ago
I actually found this quite useful today. A rare case where I needed to translate the Wordpress post decoding function to get the rendered HTML form from a post into Python. Soon pelican's importer will be better able to preserve content from Wordpress blogs.
tomjakubowskiover 12 years ago
I was pleasantly surprised to see this wasn't a link to php.py, the somewhat bizarre port of the PHP standard library to python:<p><a href="http://code.google.com/p/php-py/source/browse/trunk/src/php/php.py" rel="nofollow">http://code.google.com/p/php-py/source/browse/trunk/src/php/...</a>
评论 #4966626 未加载
nigglerover 12 years ago
Just like with PHPJS (an effort to bring PHP standard library to JS) there are missing implementations:<p><a href="http://www.php2python.com/wiki/function.mt-rand/" rel="nofollow">http://www.php2python.com/wiki/function.mt-rand/</a>
RossMover 12 years ago
I suffer from the 'does everything in PHP because it's comfortable' habit, and this guide always helps when translating.
nodesocketover 12 years ago
Very nice and useful.
eriksankover 12 years ago
PHP may have its flaws, but Python does not seem to be the answer either. By the way, have they already found a fail-safe way to visually represent the difference between a space and a tab? Since space is a keyword and a tab too, how does the programming with invisible differences in whitespace combinations work? Does it already support all possible unicode whitespace? I guess I should ask a high priest in Python whitespace calculus ... Why not simplify the whole thing and use brainfuck characters instead?
评论 #4965796 未加载
评论 #4965807 未加载
评论 #4965682 未加载
评论 #4967852 未加载