def index(self):
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Dec 19 11:04:26 EST 2006
Gert Cuykens a écrit :
>> FWIW, the first version raises an exception (unless of course the name
>> 'index' is already bound in the enclosing scope). And the second won't
>> probably work as expected with CherryPy.
>
>
> <code>
> class HelloWorld:
> def index(self):
> return "Hello world!"
> index.exposed = True #DOOOOOOH!
And the winner is....
> </code>
>
> i skipped reading the chapter about 2.1.8 Indentation. Guess how many
> hours it took to realize 2 spaces isn't the same as 1 space lol
Hint:
- use a good code editor with auto(de)indentation (emacs + python-mode
is quite nice)
- use 4 spaces for indentation
> Any other chapters i should read horizontal instead of vertical for a
> php5 htm jso wane be snake user :)
The whole thing, I guess. While Python is quite easy to get started
with, there are a few gotchas. You're above snippet should be:
class HelloWorld(object):
def index(self):
return "Hello World"
index.exposed = True
More information about the Python-list
mailing list