What is a Python module?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

What is a Python module?

Vernon D. Cole
On Tue, May 3, 2011 at 4:00 AM, <[hidden email]> wrote:
[Edu-sig] What is a Python module?
I posed this question before.  The usual answer is:  a file containing
Python source code.

Kirby:
  The "usual" answer is almost the correct answer.
I quote from http://docs.python.org/py3k/tutorial/modules.html which was written by GvR himself.  A higher authority than BDFL cannot exist.
"A module is a file containing Python definitions and statements. "
I note that GvR does not mention that it must be in source form, only that it contain definitions and statements.  The tutorial continues to give much more information about what modules are and how they work.

In fact, one could argue a Python module is precisely *not* the
readable source code .py file, as that *must* be compiled to byte
codes first, and saved in the .pyc.

One could make such an argument, but one would be incorrect.  IronPython, for example,  _never_ compiles to .pyc byte code, but the modules I write using it are still Python modules, and still do what modules are supposed to do.
--
Vernon Cole


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: What is a Python module?

Kirby Urner-6
I appreciate your quoting GvR and continue to note that the source might already be yummy byte code in whatever target VM language, be that Java's or Mono's or some VM not yet written.

"Source code is one step away from runtime digestible, in still needing to be parsed, and as such need not be distributed with compiled Python modules" would seem to be a true statement.

One might imagine a "Python chat window" showing up as a chat service (shell) and behaving much as an ordinary Python interpreter in REPL mode (great for learning, we all agree).

But behind the scenes, there's a lot of cloudy stuff, with some algorithms implemented in what looks to be LISP or Scheme.  Obviously the CLR byte codes are runnable, but the source is mostly not even Python.

So you go

>>> import math

but behind the scenes it's like J or something, with some bytecodes to a local engine via JSON perhaps, for AJAXy fun.

Kirby


On Tue, May 3, 2011 at 10:14 AM, Vernon Cole <[hidden email]> wrote:
On Tue, May 3, 2011 at 4:00 AM, <[hidden email]> wrote:
[Edu-sig] What is a Python module?
I posed this question before.  The usual answer is:  a file containing
Python source code.

Kirby:
  The "usual" answer is almost the correct answer.
I quote from http://docs.python.org/py3k/tutorial/modules.html which was written by GvR himself.  A higher authority than BDFL cannot exist.
"A module is a file containing Python definitions and statements. "
I note that GvR does not mention that it must be in source form, only that it contain definitions and statements.  The tutorial continues to give much more information about what modules are and how they work.

In fact, one could argue a Python module is precisely *not* the
readable source code .py file, as that *must* be compiled to byte
codes first, and saved in the .pyc.

One could make such an argument, but one would be incorrect.  IronPython, for example,  _never_ compiles to .pyc byte code, but the modules I write using it are still Python modules, and still do what modules are supposed to do.
--
Vernon Cole


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig



_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: What is a Python module?

Vernon D. Cole
Don't just imagine Python on a web site ... Try it.
(load Silverlight first if you don't already have it. http://www.silverlight.net/

--
Vernon

On Tue, May 3, 2011 at 11:53 AM, Kirby Urner <[hidden email]> wrote:
[...]
One might imagine a "Python chat window" showing up as a chat service (shell) and behaving much as an ordinary Python interpreter in REPL mode (great for learning, we all agree).



_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: What is a Python module?

Kirby Urner-6
No good experience so far, using Chrome on XP.

Anyway, sounds like we agree that Cloud Python might allow importing of modules the original source code language of which is indeterminant.

A module is more a namespace, which students tend to say when still in beginner mind.

Kirby


On Tue, May 3, 2011 at 12:58 PM, Vernon Cole <[hidden email]> wrote:
Don't just imagine Python on a web site ... Try it.
(load Silverlight first if you don't already have it. http://www.silverlight.net/

--
Vernon

On Tue, May 3, 2011 at 11:53 AM, Kirby Urner <[hidden email]> wrote:
[...]
One might imagine a "Python chat window" showing up as a chat service (shell) and behaving much as an ordinary Python interpreter in REPL mode (great for learning, we all agree).




_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: What is a Python module?

kirby urner-4
Wait, OK, there we go, Silverlight installed.

OK, cool, a handsome Python REPL.  At OST we use server hosted Eclipse
with remote desktop, pretty off the shelf but with some custom guts.

Kirby


On Tue, May 3, 2011 at 2:23 PM, Kirby Urner <[hidden email]> wrote:

> No good experience so far, using Chrome on XP.
> Anyway, sounds like we agree that Cloud Python might allow importing of
> modules the original source code language of which is indeterminant.
> A module is more a namespace, which students tend to say when still in
> beginner mind.
> Kirby
>
> On Tue, May 3, 2011 at 12:58 PM, Vernon Cole <[hidden email]> wrote:
>>
>> Don't just imagine Python on a web site ... Try it.
>> (load Silverlight first if you don't already have
>> it. http://www.silverlight.net/
>> or for Linux http://www.mono-project.com/Moonlight )
>> http://www.trypython.org/
>> --
>> Vernon
>>
>> On Tue, May 3, 2011 at 11:53 AM, Kirby Urner <[hidden email]>
>> wrote:
>>>
>>> [...]
>>> One might imagine a "Python chat window" showing up as a chat service
>>> (shell) and behaving much as an ordinary Python interpreter in REPL mode
>>> (great for learning, we all agree).
>>
>
>
> _______________________________________________
> Edu-sig mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/edu-sig
>
>
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig