Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Cameron Simpson Newsgroups: comp.lang.python Subject: Re: Understanding Python from a PHP coder's perspective Date: Tue, 8 Dec 2015 08:33:57 +1100 Lines: 50 Message-ID: References: Reply-To: python-list@python.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed X-Trace: news.uni-berlin.de 2ghIqk1m+6xvDm2la6+4DgGd8RuqPWGst5pwfqOdZFAg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.05; 'differently': 0.07; 'php.': 0.07; 'tool,': 0.07; 'cc:addr:python-list': 0.09; 'appropriate.': 0.09; 'file"': 0.09; 'php,': 0.09; 'script,': 0.09; 'snippet': 0.09; 'visited': 0.09; 'python': 0.10; 'output': 0.13; 'apache': 0.14; '(django,': 0.16; '.py': 0.16; 'accesses': 0.16; 'break!': 0.16; 'different?': 0.16; 'extensions,': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hits': 0.16; 'json,': 0.16; 'macro': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:io': 0.16; 'received:optusnet.com.au': 0.16; 'received:psf.io': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'something.': 0.16; 'subject:perspective': 0.16; 'url.': 0.16; 'url:example': 0.16; 'url:py': 0.16; 'wsgi': 0.16; 'wrote:': 0.16; 'obviously': 0.16; 'switched': 0.18; 'typical': 0.18; 'runs': 0.18; 'language': 0.19; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'extension': 0.20; 'file:': 0.22; 'suppose': 0.22; 'cheers,': 0.22; 'cc:no real name:2**0': 0.22; 'code,': 0.23; 'code.': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'command': 0.26; 'mostly': 0.27; 'pieces': 0.27; 'etc).': 0.29; 'expose': 0.29; 'initiated': 0.29; 'loop,': 0.29; 'websites.': 0.29; 'code': 0.30; 'web.': 0.30; 'writes': 0.30; 'certain': 0.31; 'getting': 0.33; 'run': 0.33; 'useful': 0.33; 'usually': 0.33; 'driven': 0.33; 'html,': 0.33; 'received:com.au': 0.33; 'stream': 0.33; 'similar': 0.33; 'languages': 0.34; 'file': 0.34; 'running': 0.34; 'server': 0.34; 'maps': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'depends': 0.36; 'framework': 0.36; 'urls': 0.36; 'subject:: ': 0.37; 'aspects': 0.37; 'missing': 0.37; 'charset:us-ascii': 0.37; 'wanted': 0.37; 'seem': 0.37; 'things': 0.38; 'associate': 0.38; 'mean': 0.38; 'does': 0.39; 'subject:from': 0.39; 'called': 0.40; 'some': 0.40; 'ever': 0.60; 'your': 0.60; 'suitable': 0.61; 'email addr:gmail.com': 0.62; 'back': 0.62; 'more': 0.63; 'excited': 0.63; 'interest': 0.64; 'accessed': 0.66; 'cameron': 0.66; 'header :Reply-To:1': 0.67; 'manner': 0.69; 'targeted': 0.70; 'reply-to:no real name:2**0': 0.71; 'obvious': 0.76; 'saw': 0.77; 'browser.': 0.81; '>how': 0.84; 'all!': 0.84; 'extensions.': 0.84; 'ostensibly': 0.84; 'reply-to:addr:python.org': 0.84; 'dirty': 0.93 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=cK4dyQqN c=1 sm=1 tr=0 a=kPLexIa+XrsL4mdc8kxeNA==:117 a=kPLexIa+XrsL4mdc8kxeNA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=vrnE16BAAAAA:8 a=8AHkEIZyAAAA:8 a=kj9zAlcOel0A:10 a=wUQvQvOEmiQA:10 a=pGLkceISAAAA:8 a=A1X0JdhQAAAA:8 a=kBnvn5P8kgABYl76Pi4A:9 a=CjuIK1q_8ugA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100107 On 07Dec2015 13:07, villascape@gmail.com wrote: >Hello all! Just started getting into Python, and am very excited about the prospect. > >I am struggling on some general concepts. My past experience with server-side code is mostly limited to PHP and websites. I have some file called "whatever.php", the browser accesses it, and PHP parses it and returns HTML, JSON, etc. Every now and then, I need to run some background PHP script, or have some PHP script initiated by a CRON job, or have some PHP script initiated by the command line running in an endless loop, and while it works, feel other languages might be more appropriate. > >So, my interest in Python... > >I've read up on Python, and while some aspects seem similar to PHP, some don't. I have learned how to create Python script, have run it from the command line, and have even accessed it with Apache by placing http://example.com/myscript.py in the browser. I am used to seeing .php extensions, but never .py extentions, and even visited multiple sites which I knew were written in Python, but never saw the browser expose the .py extensions. I am obviously missing something. The most obvious thing is: a well produced website does not expose its implementation language in the URL. All those .php URLs? Sloppy! Suppose you wanted to change the implementation and switched languages? All your users' bookmarks would break! >Why don't I see the .py extension in my browser? Usually Python is used in a web server via a WSGI plugin and a framework of some kind (Django, Flask, CheryPy etc). All of these allow you to associate any URL with any piece of Python code. So you don't have that simple but also inflexible "map this URL to a specific .php file" model that you have with typical PHP. >Is Python event driven like PHP, or is it somehow different? Depends what you mean by "event driven". I suspect you mean "accessing a web page runs a python program". A .php file is a kind of macro file: it is ostensibly HTML until one hits the How should I view Python differently than PHP? It is more useful and nicer to work in. For a quick and dirty web page PHP is a handy tool, but almost entirely for the web. Python is not targeted specificly at web output. Cheers, Cameron Simpson