Python: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
(→‎Reference: basic, print)
Line 7: Line 7:
== Reference ==
== Reference ==
* [http://docs.python.org/release/1.5.1p1/tut/range.html range]
* [http://docs.python.org/release/1.5.1p1/tut/range.html range]
=== Basic ===
<source lang=python>
for i in range(10):
print i # carriage return

for i in range(10):
print i, # no carriage return
</source>


== Tips ==
== Tips ==

Revision as of 08:25, 13 February 2014

Links

  • Nice example of generating / testing regex in Python (with nice / small test framework) [1]

Reference

Basic

for i in range(10):
    print i                      # carriage return

for i in range(10):
    print i,                     # no carriage return

Tips

Simple HTTP Server

It's very easy to setup an ad-hoc HTTP server with Python. Just open a shell in a folder with some contents to share, and type:

python -m SimpleHTTPServer

More available at http://docs.python.org/2/library/internet.html (see BaseHTTPServer and CGIHTTPServer).