[Tutor] compiled Python Files ?? and a little OO
Andrei Kulakov
ak@silmarill.org
Sun, 09 Dec 2001 13:57:47 -0500
On Sun, Dec 09, 2001 at 10:54:10AM -0800, Frank Peavy wrote:
> I created three simple files to test with:
> *************************************************************
> F1.py file and all it contains is:
>
> print "Hello"
> *************************************************************
> Another file F2.py that contains:
>
> print "JSmith"
> *************************************************************
> I have one more FX.py file that contains:
>
> import F1.py
> import F2.py
> *************************************************************
> My end result was:
>
> Hello
> JSmith
>
> The results seem correct, in my opinion.
> So, here are my questions. Although I didn't request it, Python did a line
> feed between Hello and JSmith, is this normal?
You did request it by using print statement - it prints a newline as a
default, because in most cases you want it there. To have a space
instead of a newline, put a comma after the first print:
print "blah",
print "trah"
>
> After I ran this, I noticed that I had two new versions of F1 and F2; the
> directory showed "Compiled Python file" as a description and they had .pyc
> extensions. Why didn't I see this happening with my other tests? Is it
> because the other tests imported Tkinter?
>
> I understand I can run the .pyc files, instead of the .py files. Is this
> true?
>
> Why didn't I get a FX.pyc file also... ? The first two files compiled but
> the third file that imported the other two didn't.
>
> A little confused... :-)
They get compiled to .pyc when they're imported.
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org