A trivial question

jitendra gupta jitu.icfai at gmail.com
Thu Sep 29 09:41:29 CEST 2011


HI
The class Foo you have defined is local NameSpace for trial functioon, for
details http://docs.python.org/tutorial/classes.html

def trial():
class Foo(object):
def __init__(self):
print("Hello, world!")
       lacalClass = Foo()
>>>trial
"Hello, world!"

Thanks
Jitendra

On Thu, Sep 29, 2011 at 3:19 AM, Tayfun Kayhan <tayfun92_kayhan at yahoo.com>wrote:

> I accidentally wrote such a code (below) while trying to write sth else for
> my application but i am now just wondering much how to run the class Foo, if
> it is possible. Is not it weird that Python does not give any error when I
> run it ? Sorry for that it's pretty unimportant question according to the
> other questions being asked here :D
>
> def trial():
> class Foo(object):
> def __init__(self):
> print("Hello, world!")
> trial() # not worked, as expected.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110929/c10c55e0/attachment.html>


More information about the Python-list mailing list