[newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
Hello I'm an amateur programmer, and would like to know what the main options are to build web applications in Python instead of PHP. I notice that Python-based solutions are usually built as long-running processes with their own web server (or can run in the back with eg. Nginx and be reached th

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Alain Ketterlin
Gilles writes: > I notice that Python-based solutions are usually built as long-running > processes with their own web server (or can run in the back with eg. > Nginx and be reached through eg. FastCGI/WSGI ) while PHP is simply a > language to write scripts and requires a web server (short runni

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Chris Angelico
On Tue, Jun 12, 2012 at 7:39 PM, Gilles wrote: > Since web scripts are usually very short anyway (user sends query, > server handles request, sends response, and closes the port) because > the user is waiting and browsers usually give up after 30 seconds > anyway... why did Python solutions go for

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
On Tue, 12 Jun 2012 12:12:55 +0200, Alain Ketterlin wrote: >You misunderstand the problem here. It's not about the duration of the >actions, it's about the latency it takes to read/parse/execute the >script. HTTP is stateless anyway, so if the same "interpreter" handles >several requests, what you

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Octavian Rasnita
From: "Chris Angelico" Subject: Re: [newbie] Equivalent to PHP? > On Tue, Jun 12, 2012 at 7:39 PM, Gilles wrote: >> Since web scripts are usually very short anyway (user sends query, >> server handles request, sends response, and closes the port) because >> the user is waiting and browsers usua

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread D'Arcy Cain
On 12-06-12 06:36 AM, Gilles wrote: I enjoy writing scripts in Python much more than PHP, but with so many sites written in PHP, I need to know what major benefits there are in choosing Python (or Ruby, ie. not PHP). I think that you just answered your own question in the first line of that par

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Chris Angelico
On Tue, Jun 12, 2012 at 8:36 PM, Gilles wrote: > Thanks for the input. > > But I read that PHP-based heavy-duty web servers compile the scripts > once and keep them in a cache, so they don't have to be > read/parsed/executed with each new query. > > In that case, what is the benefit of using a lon

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Matej Cepl
On 12/06/12 11:39, Gilles wrote: I notice that Python-based solutions are usually built as long-running processes with their own web server (or can run in the back with eg. Nginx and be reached through eg. FastCGI/WSGI ) while PHP is simply a language to write scripts and requires a web server (s

using identifiers before they are defined

2012-06-12 Thread Julio Sergio
I'm puzzled with the following example, which is intended to be a part of a module, say "tst.py": a = something(5) def something(i): return i When I try: ->>> import tst The interpreter cries out: Traceback (most recent call last): File "", line 1, in File "tst.py", line 11

Re: using identifiers before they are defined

2012-06-12 Thread Jose H. Martinez
You should define the function first and then call it. def something(i): return i a = something(5) If you want a reference to the function somewhere else you can do this: global alias = something print alias(i) On Tue, Jun 12, 2012 at 1:53 PM, Julio Sergio wrote: > I'm puzzled with

Re: using identifiers before they are defined

2012-06-12 Thread Emile van Sebille
On 6/12/2012 10:53 AM Julio Sergio said... So I modified my module: global something a = something(5) def something(i): return i And this was the answer I got from the interpreter: ->>> import tst Traceback (most recent call last): File "", line 1, in File "tst.py

Re: using identifiers before they are defined

2012-06-12 Thread MRAB
On 12/06/2012 18:53, Julio Sergio wrote: I'm puzzled with the following example, which is intended to be a part of a module, say "tst.py": a = something(5) def something(i): return i When I try: ->>> import tst The interpreter cries out: Traceback (most recent call last):

Re: using identifiers before they are defined

2012-06-12 Thread Julio Sergio
Jose H. Martinez gmail.com> writes: > > > You should define the function first and then call it. > > >  def something(i):     return i > > > a = something(5) > > > If you want a reference to the function somewhere else you can do this: > I know that. That was what I meant by "changing t

Re: using identifiers before they are defined

2012-06-12 Thread Jerry Hill
On Tue, Jun 12, 2012 at 2:33 PM, Julio Sergio wrote: > Suppose I have to define two functions, aa, and, bb that are designed to call > each other: > >  def aa(): >     ... >     ... a call of bb() somewhere in the body of aa >     ... > >  def bb(): >     ... >     ... a call of aa() somewhere in

Re: using identifiers before they are defined

2012-06-12 Thread Evan Driscoll
On 01/-10/-28163 01:59 PM, Julio Sergio wrote: I know that changing the order of the definitions will work, however there are situations in which referring to an identifier before it is defined is necessary, e.g., in crossed recursion. Mutual recursion isn't a problem: the following strange exp

Re: using identifiers before they are defined

2012-06-12 Thread Ethan Furman
Julio Sergio wrote: Jose H. Martinez gmail.com> writes: You should define the function first and then call it. def something(i): return i a = something(5) If you want a reference to the function somewhere else you can do this: I know that. That was what I meant by "changing the

Re: using identifiers before they are defined

2012-06-12 Thread Jose H. Martinez
Seems like what you need is from othermodule import bb def aa(): bb() On Tue, Jun 12, 2012 at 2:51 PM, Ethan Furman wrote: > Julio Sergio wrote: > >> Jose H. Martinez gmail.com> writes: >> >> >>> You should define the function first and then call it. >>> >>> >>> def something(i): r

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-12 Thread CM
On Jun 11, 6:55 pm, Dietmar Schwertberger wrote: > But then we're back to the initial point: As long as there's no GUI > builder for Python, most people will stick to Excel / VBA / VB. Then good thing there *are* GUI builder/IDEs for Python, one of which was good enough for me to take me from es

Using pdb with greenlet?

2012-06-12 Thread Salman Malik
Hi, I am sort of a newbie to Python ( have just started to use pdb). My problem is that I am debugging an application that uses greenlets and when I encounter something in code that spawns the coroutines or wait for an event, I lose control over the application (I mean that after that point I

Re: which one do you prefer? python with C# or java?

2012-06-12 Thread Tim Johnson
* Tomasz Rola [120611 11:18]: > On Sat, 9 Jun 2012, Yesterday Paid wrote: > > > I'm planning to learn one more language with my python. > > Someone recommended to do Lisp or Clojure, but I don't think it's a > > good idea(do you?) > > So, I consider C# with ironpython or Java with Jython. > > It'

Re: using identifiers before they are defined

2012-06-12 Thread Julio Sergio
Ethan Furman stoneleaf.us> writes: > > > No. The reply from MRAB explains this. > > ~Ethan~ > Thanks, you're right! I was confusing statemens with declarations. -- http://mail.python.org/mailman/listinfo/python-list

Re: using identifiers before they are defined

2012-06-12 Thread Ethan Furman
Julio Sergio wrote: Ethan Furman stoneleaf.us> writes: No. The reply from MRAB explains this. ~Ethan~ Thanks, you're right! I was confusing statemens with declarations. Yeah, it took me a while to get that straight as well. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-lis

RE: Create directories and modify files with Python

2012-06-12 Thread Prasad, Ramit
> > Thanks for the directions. By the way, can you see my post in Google Groups? > I'm not able to, and I don't know why. > > > They may have copied the Gmail idea that you never need to see anything > anything you posted yourself. I can see all my posts in a Gmail thread/conversation but if there

multiprocessing: excepthook not getting called

2012-06-12 Thread Dave Cook
Why doesn't my excepthook get called in the child process? import sys import multiprocessing as mp def target(): name = mp.current_process().name def exceptHook(*args): print 'exceptHook:', name, args sys.excepthook = exceptHook raise ValueError if __name__=='__main__':

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-12 Thread rdsteph
On Jun 10, 12:37 pm, Dietmar Schwertberger wrote: > Personally, I prefer Python with console, wx or Qt for local > applications and Python/HTTP/HTML/Javascript for multi-user > database applications. > > Regards, > > Dietmar +1 I think this is the wave of the furture for deploying simple program

Re: Where to set default data - where received, or where used

2012-06-12 Thread Chris Angelico
On Tue, Jun 12, 2012 at 4:37 AM, Dennis Carachiola wrote: > Here's my question.  I could do this by creating the dictionary with > the default values, then read the file into it.  Or I could use a > 'get' with default values at the location in the program where those > values are used. Both optio

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
On Tue, 12 Jun 2012 07:42:56 -0400, D'Arcy Cain wrote: >I guess I am in the minority then. I do plan to turn one of my larger >projects into a standalone web server some day but so far writing >simple Python CGI scripts has served me fine. I even do some embedding >by using server side scripting

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
On Tue, 12 Jun 2012 22:01:10 +1000, Chris Angelico wrote: >Apache's mod_php partially evens out the difference, but not >completely, and of course, it's perfectly possible to write a dispatch >loop in PHP, as Octavian said. It looks like mod_php and equivalents for web servers other than Apache a

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
On Tue, 12 Jun 2012 20:18:21 +1000, Chris Angelico wrote: >Think of it as Apache + PHP versus Python. Apache keeps running, it's >only your PHP script that starts and stops. With a long-running >process, you keep everything all in together, which IMHO is simpler >and better. Why is a long-running

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Gilles
On Tue, 12 Jun 2012 14:28:22 +0300, "Octavian Rasnita" wrote: >Otherwise... if you want you can also create a web app using PHP and >CodeIgniter web framework and run it with fastcgi... Thanks for the infos. -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Chris Angelico
On Wed, Jun 13, 2012 at 9:59 AM, Gilles wrote: > On Tue, 12 Jun 2012 20:18:21 +1000, Chris Angelico > wrote: >>Think of it as Apache + PHP versus Python. Apache keeps running, it's >>only your PHP script that starts and stops. With a long-running >>process, you keep everything all in together, wh

Re: using identifiers before they are defined

2012-06-12 Thread Ben Finney
Julio Sergio writes: > Suppose I have to define two functions, aa, and, bb that are designed > to call each other: > > def aa(): > ... > ... a call of bb() somewhere in the body of aa > ... > > def bb(): > ... > ... a call of aa() somewhere in the body of bb > ..

Re: which one do you prefer? python with C# or java?

2012-06-12 Thread rusi
On Jun 12, 3:19 am, Matej Cepl wrote: > On 11/06/12 06:20, rusi wrote: > > > Hi Matěj! If this question is politically incorrect please forgive me. > > Do you speak only one (natural) language -- English? > > And if this set is plural is your power of expression identical in > > each language? > >

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread D'Arcy Cain
On 12-06-12 07:57 PM, Gilles wrote: On Tue, 12 Jun 2012 07:42:56 -0400, D'Arcy Cain wrote: I guess I am in the minority then. I do plan to turn one of my larger projects into a standalone web server some day but so far writing simple Python CGI scripts has served me fine. I even do some embedd

Internationalized domain names not working with URLopen

2012-06-12 Thread John Nagle
I'm trying to open http://пример.испытание with urllib2.urlopen(s1) in Python 2.7 on Windows 7. This produces a Unicode exception: >>> s1 u'http://\u043f\u0440\u0438\u043c\u0435\u0440.\u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435' >>> fd = urllib2.urlopen(s1) Traceback (most recent c

Re: Internationalized domain names not working with URLopen

2012-06-12 Thread Andrew Berg
On 6/13/2012 1:17 AM, John Nagle wrote: > What does "urllib2" want? Percent escapes? Punycode? Looks like Punycode is the correct answer: https://en.wikipedia.org/wiki/Internationalized_domain_name#ToASCII_and_ToUnicode I haven't tried it, though. -- CPython 3.3.0a3 | Windows NT 6.1.7601.17790

Re: Internationalized domain names not working with URLopen

2012-06-12 Thread Виталий Волков
Answer in this topic should help you to solve issue. http://stackoverflow.com/questions/8152161/open-persian-url-domains-with-urllib2?answertab=active#tab-top Regards. 2012/6/13 John Nagle > I'm trying to open > > http://пример.испытание > > with > > url