Creating .exe file in Python

Chris Angelico rosuav at gmail.com
Tue Jun 16 12:03:39 EDT 2015


On Wed, Jun 17, 2015 at 1:17 AM,  <subhabrata.banerji at gmail.com> wrote:
> Thanks. The scipy issue seems solved. But this silly issue is giving so much of time. I am checking. Please see a sample code,
>
> import sys
> sys.stderr = sys.stdout
> class Colors:
>     def Blue(self):
>         self.var="This is Blue"
>         print self.var
>     def Red(self):
>         print self.var
>
>
>
> if __name__ == "__main__":
>     Colors().Blue() #THIS IS FINE
>     Colors().Red() #NOT FINE

You're still not saying what's going on. Did you try this code as a
simple Python script first, before trying to bundle it up into an .exe
file?

Fortunately, my primary crystal ball is active, and I believe what's
going on is that you expect Blue() to set something and then Red() to
see it. However, you're calling those methods on two different
throw-away objects, so they have separate state. What you expect to
happen, I honestly have no idea. (Also, why are you fiddling with
sys.stderr? You don't then appear to be using it, unless you have an
issue with exceptions getting printed to the other stream.)

ChrisA



More information about the Python-list mailing list