68

If yes are there any frameworks/Tutorials/tips/etc recommended?

N00b at Python but I have tons of PHP experience and wanted to expand my skill set.

I know Python is great at server side execution, just wanted to know about client side as well.

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
  • 6
    client-side = browser or client-side = soap / json ... ? – Blauohr Oct 08 '09 at 20:36
  • 1
    sorry, Yes browser. Like .html .php for example. – Phill Pafford Oct 09 '09 at 12:16
  • 4
    I'm a Pythonista myself, but have found CoffeeScript to be very pleasant. While it isn't Python, it seems to have adopted some of Python's nicer features and compiles to JavaScript. Not sure how it compares to Pyjamas though, I'll have to look into that myself. – Adam Fraser Mar 06 '12 at 23:40
  • 1
    Checkout python's thorough wiki on the topic, particularly, check "Brython" https://wiki.python.org/moin/WebBrowserProgramming – percebus Jul 27 '15 at 13:09

8 Answers8

48

Have you seen Skulpt?

Skulpt is an entirely in-browser implementation of Python.

No preprocessing, plugins or server-side support required, just write Python and reload.

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
easement
  • 6,119
  • 3
  • 29
  • 36
  • Very good.. My first thought when i saw this question is. NO IT CAN RUN. I guess i was wrong. – Fábio Antunes Oct 08 '09 at 20:36
  • Well it can, it's just painfully slow. – Lennart Regebro Oct 08 '09 at 20:49
  • 4
    Use a javascript interpreter to write a python interpreter! BRILLANT! Well I bet it was fun to write at least. – Byron Whitlock Oct 08 '09 at 20:58
  • 6
    Well it's not that long ago that javascript was painfully slow. Javascript got better, CPUs got faster. Something like skulpt can work as a foot in the door. If clientside Python became popular enough the browsers would begin to support it natively – John La Rooy Oct 08 '09 at 21:11
  • Skulpt looks like it could do something like I want in the future but it seems to be in the early Alpha stage right now. I will keep my eyes on it though, thnx – Phill Pafford Oct 09 '09 at 12:32
  • 3
    @gnibbler In the 3 years since I answered this, javascript engines and hardware has have gotten much faster. This isn't as ugly as it once seems – Byron Whitlock Aug 06 '12 at 18:27
  • 13
    Today, there is also [**Brython**](http://www.brython.info) which, unlike Skulpt, **supports Python 2.7+**. – K3---rnc Jan 05 '15 at 20:00
  • Python implementation for client-side web programming [skulpt](https://skulpt.org/), [brython](https://brython.info/), [pyscript](https://pyscript.net/) and [anvil.works](https://anvil.works/) – bl3ssedc0de May 05 '22 at 04:45
21

You can use pyjamas to convert Python code to JS code that runs in the browser (note that pyjamas also offers much more). So YES, you can use Python for client side web development.

Pyjamas is basically a port of the Google Web Toolkit, which allows you to write client side code in Java.

nikow
  • 21,190
  • 7
  • 49
  • 70
  • But that's pretty much the same as python to generate HTML. Python is NOT on the client side. It is only used to generate client-side code, in this case js. So, I don't think it applies – OscarRyz Oct 08 '09 at 20:45
  • No, not really, but it helps. :) – Lennart Regebro Oct 08 '09 at 20:48
  • 18
    @Oscar: That's a bit like saying that C++ does not run on computers, because it is compiled to machine code first ;-) – nikow Oct 08 '09 at 21:01
  • 2
    @nikow: Well yes, everything could be assembler syntactic sugar in some sense. But in this particular example, you are definitely NOT running python in the client side. If that would be the case you'll need a python interpreter right? But the js generated has nothing to do with python ( in the same fashion js generated by GWT has very no java in it ) It does help, definitely. – OscarRyz Oct 08 '09 at 21:07
  • interesting, but just shy of what I'm looking for – Phill Pafford Oct 09 '09 at 12:27
8

Python isn't really used for client side, because no major web browsers have Python built in.

However, Javascript has become more and more Python-like as it has evolved. You might want to study Python and Javascript together.

Take a look at https://developer.mozilla.org/en/New_in_JavaScript_1.7 and notice the Python-like nature of the new features. "array comprehensions" are just like Python list comprehensions; iterators and generators are straight out of Python; "destructuring assignments" are a standard Python idiom.

Javascript is kind of like Python with curly braces. It uses a very different inheritance model, but libraries are available that implement a more Python-like class system on top of the built-in system in Javascript.

steveha
  • 74,789
  • 21
  • 92
  • 117
  • 1
    Yes, sorry, but since I’m not yet at 125 rep I had to show my anger somehow. Why isn’t Javascript like python? I like to reference to this: https://www.destroyallsoftware.com/talks/wat – Profpatsch Mar 11 '13 at 12:11
  • 1
    Okay, that reference (which was funny!) shows that Javascript has horrible weird brokenness. That just means that you need to make sure you never do any of those broken things. That's lame, but if you are doing browser scripting, you just have to deal with it. And my original claim, which you shouldn't take too seriously, was that Javascript is "kind of" (not the hand-waving qualifier there) like Python with curly braces, which I think is clearly true, at least for some values of "kind of". And if you read my link, you will see that JS has intentionally copied a lot of stuff from Python. – steveha Mar 11 '13 at 18:23
  • 3
    I’m okay with that but still wait for browsers to finally add client-side Python support… – Profpatsch Mar 11 '13 at 21:12
  • 2
    Python is my favorite language, so *of course* I would like to see it supported as a first-class browser-side language. Right now Python is too slow, but PyPy with a JIT promises to make Python really fast. But we can't even get non-broken implementations of Javascript that all work correctly, so client-side Python will just be a pipe dream for the near future. And I'm afraid that the significant white space might be a problem for web. (And if we continue this back-and-forth, StackOverflow will start nagging us to take it to chat, so this is my last non-chat comment on this.) – steveha Mar 12 '13 at 02:04
  • 1
    Javascript? Python-like? I don't think so. For me, javascript is very very very frustrating. – skywalker Dec 13 '15 at 16:16
  • Any minor web browsers? – Brōtsyorfuzthrāx Jan 25 '18 at 03:51
7

Silverlight can run IronPython, so you can make Silverlight applications. Which is client-side.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
6

Noone has mentioned it yet, but grail is/was pretty cool

Grail was a free extensible multi-platform web browser written in the Python programming language. The project was started in August 1995, with its first public release in November of that year. [1] The .3 beta contained over 27,000 lines of Python.[1] Its last release was of version 0.6 in 1999, with latest version under development.

GingerPlusPlus
  • 5,336
  • 1
  • 29
  • 52
John La Rooy
  • 295,403
  • 53
  • 369
  • 502
3

On Windows, any language that registers for the Windows Scripting Host can run in IE. At least the ActiveState version of Python could do that; I seem to recall that has been superseded by a more official version these days.

But that solution requires the user to install a python interpreter and run some script or .reg file to put the correct "magic" into the registry for the hooks to work.

Tor Iver
  • 39
  • 1
2

Python is available for the client: skulpt

If its client side your interested may be worth checking out

http://jqueryui.com/

Andrew
  • 9,967
  • 10
  • 64
  • 103
-1

No. Browsers don't run Python.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
  • 1
    Why the down vote, its absolutely true? Show me a mainstream browser with a native python interpreter. – micmcg Oct 08 '09 at 23:23
  • 9
    I didn't vote you down, but other people have posted at least two ways to run Python within a browser, using additional code. Windows doesn't let you run Python without additional code, but you wouldn't say 'Windows doesn't run Python' – Will Dean Oct 09 '09 at 10:40
  • 3
    In the context of the original question, I think this is still the right answer. No sane developer would recommend TO A NEW DEVELOPER running python in the browser when there are so many better alternatives. Despite the hype, the browser isn't an os so you are constrained by available technology. – Byron Whitlock Oct 09 '09 at 18:37
  • 1
    Today there are ways to run Python in the browser (native or not is a different question). http://www.skulpt.org/ http://www.brython.info/ http://transcrypt.org/ http://rapydscript.com/ http://pyjs.org/ https://trinket.io/ ... BUT me as a programming noob (learning Python) is still not fully happy with that! If I was a millionaire I would start a project on Github to invent PROWSER - a next gen browser with native Python support ... https://github.com/prowser/prowser – Wlad Feb 10 '17 at 15:04
  • No interpreted programming or scripting language can be run "natively". The question specifically mentioned frameworks, so there is an understanding of different execution levels. Other answers posted viable methods to use Python code for client side web projects. – Gerald Dec 18 '19 at 09:35