"I know that in your mind skipping imports is about "not repeating
yourself". But look guys: every single other Python program ever
written uses imports. By not including them you've basically made sure
that learning web2py is different from learning Python."
I would say this is incorrect, at least there are other kind of python
programs that doesn't use imports, see PL/Python, the PostgreSQL
Python procedural language:
* Executes codes (uses PyEval_EvalCode, ops, doesn't import it...)
* Doesn't need to import obvious modules (like plpy, the
PostgreSQL/Python interface)
* Uses global variables to handle persistent data storage (GD, SD,
TD: global, sessión and trigger dictionaries) and pass function
parameters! (like web2py controllers...)
Here is a minimal example:
CREATE FUNCTION say_hi (your_name TEXT) RETURNS VOID AS $$
plpy.notice("hello %s" % your_name)
$$ LANGUAGE plpythonu;
SELECT say_hi('mariano');
See the PostgreSQL documentation for detailed explanation of this "issues":
http://www.postgresql.org/docs/9.0/interactive/plpython-funcs.html
For Technical details refer to source code:
http://doxygen.postgresql.org/plpython_8c.html
With this I only want to help to demystify this negative appreciation
about web2py, surely there are many more examples like this as Python
is a dynamic language specially designed to execute and evaluate code
(i.e., OpenOffice/GIMP/etc. uses similar approach)
Anyone have more examples?
What do you think?
BTW, about the Python Zen rule "Explicit is better than implicit",
there is also "Although practicality beats purity.", and Python is a
practical language, or do we import len, list, dict...
>>> len(dir(__builtins__))
135
Best regards,
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
Indeed.
Moreover, while it's not best practice, it's certainly common enough to see
from somewhere import *
which "magically" injects a bunch of names into the namespace.
Your suggestion that web2py simply has a small set of built-ins strikes me as right on.
Lets start to write a PEP right now. LOL
That said, I can understand that perhaps explicit impeding cold have perfomanxe advantages (does it?) or that there is some perceptual value to explicitness,
Exactly right. I've removed a few of those, but it's tedious work.
I've been using pyflakes as a quick check on my Python coding. Pyflakes is very handy, but it's also fairly simpleminded. If you say "from gluon.tools import *", it doesn't look in gluon.tools to see what that might mean; it just turns off its search for undefined symbols. So to get its benefit, you have to fix the import *.
For the same reason, a lot of my code starts out with:
if False:
import request, response, session, T, (etc)
OTOH, pyflakes has built-in knowledge of built-in Python globals.
One of the things that the web2py-imports discussion tends to miss, though, is that the web2py "globals" exist precisely because they're *not* globals--they have request scope, not global scope. They can't be imported (in a straightforward way, anyway), and it would be a PITA to have to pass them around everywhere. That would have been an alternative strategy for web2py: every argument list starts with the request-global, which would include all that stuff.
On 07/01/11 18:17, Philip wrote:
> Web2py is to me the next generation of MS Access, and I mean that as a
> compliment. MS Access first opened up the world of database-driven
> applications to business people. With Access they could throw
> together a simple application to manage a database (CRUD and reports)
> without having to hire a developer or wait on their IT staff to write
> one. Web2py does the same thing. It is easy enough for a business
> user to throw something together very quickly and be up and running
> immediately. The amount of development expertise required is
> trivial. For a basic app, if you read the web2py book, you don't even
> have to understand more than the very basics of python.
>
+1
I'm database developer (going back to DataEase for DOS and FoxPro, and
the IBM S/26) in need of a data-driven front end, and I see web2py as
the perfect tool for me. I have no desire to tinker /inside/ web2py - I
just want to use it to develop apps.
Rather than competing with Django /et al/, which are defined as much by
a culture as the technology, I'd like to see some advocacy to promote
web2py to people who simply aren't in a position to use Django, but who
can get up to speed with web2py very easily.
The comment earlier about Massimo's approach being informed by his
teaching experience seemed very sharp to me.
> For really, big complex apps, there may be some reason that Django is
> preferable - I'll leave that to the professional web developers to
> figure out the tools they need - but I can't say enough about how
> great my experience has been with web2py, as a non-developer looking
> for the "tools that in the easiest manner facilitate the creation of
> what I want to do" (to use your words). I just needed to get stuff
> done, and web2py worked.
>
Just so.
--
Cheers,
PhilK
"exec ccode in ...." is not injection? It is IoC for sure.
http://en.wikipedia.org/wiki/Inversion_of_control
where is it deprecated? I cannot read it.
http://docs.python.org/reference/simple_stmts.html#the-exec-statement
remove "exec ... in ..." from python? On what basis? if you want a
static language go out of python. I wonder what GVR thinks about that.
The only good reasons at the moment to change that are:
1) exec statement bug
2) drastic performance improvement
Neither is true AFAIK, but maybe web2py's IoC will change, for testing
and debugging purposes, this is free (not as a beer) software indeed,
so a new solution would be adopted if one comes with a better one
instead of talking about plain aesthetics, which is a good thing
although it is not alway viable in this world. But if that would
happen fear not, we won't notice, we will not have to change our code.
mic/mcm
2011/1/7 Philip Kilner <phil....@gmail.com>:
On Jan 7, 11:45 pm, Michele Comitini <michele....@gmail.com>
wrote:
> I think the most misunderstood fact with web2py is that web2py
> implementation is improving every day,
Do you really think the designers of other web frameworks do not
understand how web2py works? They definitely understand, and they
probably understand better than you or I. The problem is that web2py
design is different from their own design. Because we operate in the
same space, they try to show why their decisions are better. To be
fair, Massimo has been doing exactly the same thing by comparing w2py
versus the others for years. Quid pro quo. If we get to say why ours
is better, then they get to do likewise.
+1
On Saturday, January 8, 2011 7:31:38 AM UTC-5, cjrh wrote:
On Jan 7, 11:45 pm, Michele Comitini <miche...@gmail.com>
I think we could do ourselves a favor by taking the feedback seriously and not being so dismissive of criticism. There are pros and cons of the various approaches and we happen to think Web2py's design decisions have good merit. Hiding behind DRY for the importing situation is not productive. The reality is that it is a relatively non-standard approach but one that we think makes good sense and is certainly "real" Python.
So I guess the question remains: is Web2py suitable for large, public web sites or does it max out as a rapid prototyper and smaller "intranet" type sites?
I think that's right, especially in the world of frameworks. The meaning of "enterprise" here has been established (polluted?) by Enterprise Java, which is a large and bloated framework (or pile of frameworks). (Java is the new Cobol.)
I understand what you mean by "enterprise", but it's definitely not what readers are going to understand.
At the moment, I don't have a better idea. But I'm sure we can come up with one.
For one, I don't think businesses care much about backwards compatibility. My experience in the enterprise was that vendors were constantly churning out non-backwards-compatibile updates and customers were routinely several versions behind.
I have a bit of experience with OO (truly object oriented) languages
besides python, such as lisp or scheme so I feel web2py confortable.
But with java experience and being used to the define Interface,
define Class, define Subclass of Class, instanciate Object and so on,
I understand that it is not
clear how and where you can do that. Maybe it is just a matter of
documentation, a "Library Reference" distinct from a "Tutorial" ?
Other python frameworks stick to COO so maybe more people feel
confortable, and have a API or Library Reference?
mic
2011/1/10 Anthony <abas...@gmail.com>: