Re: Why is the program not printing three lines?

2020-03-19 Thread Souvik Dutta
Ooo thanks I understood. On Thu, 19 Mar, 2020, 8:10 pm Pieter van Oostrum, wrote: > Souvik Dutta writes: > > > I should have been more clear > > class first(): > > print("from first") > > def second(): > > print("from second") > > first() > > > > When I run the above code the

Re: Why is the program not printing three lines?

2020-03-19 Thread Pieter van Oostrum
Souvik Dutta writes: > I should have been more clear > class first(): > print("from first") > def second(): > print("from second") > first() > > When I run the above code the output is > "from first" And where do you think this comes from? Are you thinking this comes from the

Re: Why is the program not printing three lines?

2020-03-19 Thread Rhodri James
On 19/03/2020 13:58, Souvik Dutta wrote: I should have been more clear class first(): print("from first") def second(): print("from second") first() When I run the above code the output is "from first" (2ND CODE) class first(): print("from first") def second():

Re: Why is the program not printing three lines?

2020-03-19 Thread Chris Angelico
On Fri, Mar 20, 2020 at 1:04 AM Souvik Dutta wrote: > > I should have been more clear > class first(): > print("from first") > def second(): > print("from second") > first() > > When I run the above code the output is > "from first" > (2ND CODE) > Try this *without* the call to

Re: Why is the program not printing three lines?

2020-03-19 Thread Souvik Dutta
I should have been more clear class first(): print("from first") def second(): print("from second") first() When I run the above code the output is "from first" (2ND CODE) class first(): print("from first") def second(): print("from second") first.second() When I

Re: Why is the program not printing three lines?

2020-03-19 Thread Pieter van Oostrum
Chris Angelico writes: > Creating the class runs all the code in the class block, including > function definitions, assignments, and in this case, a print call. > > Classes are not declarations. They are executable code. Demo: In [26]: class first(): ... print("From first") ...

Re: Why is the program not printing three lines?

2020-03-18 Thread Chris Angelico
On Thu, Mar 19, 2020 at 12:30 PM Souvik Dutta wrote: > > Hi, > I wrote a purposeless code today. > > class first(): > print("From first") > def second(): > print("From second") > first() > first.second() > > > Now the output I get is > From first > From second > > But when I

Why is the program not printing three lines?

2020-03-18 Thread Souvik Dutta
Hi, I wrote a purposeless code today. class first(): print("From first") def second(): print("From second") first() first.second() Now the output I get is >From first >From second But when I comment the call of first that is the comment the second last line of the code