[OT] New to Python: Features

Mark English Mark.English at liffe.com
Tue Oct 5 07:18:15 EDT 2004


Ignore those unhelpful comments you've seen. You're obviously just here
to learn and learn you shall.

> Hi, I'm new to Python and I'd like to know if Python has the 
> following 
> support: *please answer to each individually, thanks*
I'm relatively new myself but just this second a large C++ program is
building and sucking up most of my CPU so I'll try to answer some of
these intriguingly well thought out questions while it does so. My
knowledge is a little sketchy but I'm sure others on the list will
clarify my many mistakes. Apologies for the length of this post.
Actually, apologies for this post.


> 1. Multi line comments
No. There are no comments in Python.

> 2. Functions as variables:
>     a. functions can be stored in variables, passed as arguments to 
> other functions, and returned as results.
Confusingly Python programmers use snake names when talking about
programming languages. Conversely, when talking about functions in
Python people are actually refering to an endangered species of
blue-winged penguin.

> 3. Function nesting with proper lexical scope (i.e. closures) 
The penguins do nest, yes.

> 4. Operator overloading (inc. the ability to define new 
> operators)
You can't define more than 5 new operators. After this it was decided
you'd really be going too far with this whole O-O thing, leading to a
quite different meaning for "overloading" in Python. Python programmers
like to be different ;)

5. Can I do this?  print("Hello " .. "World")  --> 
> Hello World
You just did it ! In Python you can do anything. Join us.

6. Constructors
In Python these are called "Buildy Things".

7. "Chunks": as in a code block 
> contained within a string, file, or 
> delimited by some sort of notation (such as brackets) which can be 
> passed to and from functions, stored in objects, with the option of 
> local scoping of variables declared within it.
Code is actually contained in special "envelopes" fed into
Python-engineered devices built into the back of most computers these
days. Hand-crafted code in Python is literally just that.

> 8. "Repeat-Until" as in :
>     repeat
>       line = os.read()
>     until line ~= ""
>     print(line)
Yes but this invokes the special Python boolean syntax where false is
"bored" and true is "interesting". You'll see a lot of "repeat until
bored" code in Python.

> 9. Generic for loops where " for i=1,f(x) do print(i) end" 
> would print i 
> only once.
No. "for" loops are branded with a tiny icon embedded in the "f".

> 10. Can I call an object's method as object:method(arg) and have that 
> translate into object.method(object, arg)
Yes but the object is actually a sub-object belonging to the object type
which is itself an instance of class object. What you need to do is:
object.type(object).method(object, arg(object,
bored)).arg.object.call(instance=object.method, arg=arg,
method=whatever, time=invented_by_Swiss).

> 11. Can I make dynamic statements and nature like with eval() 
> in Javascript?
There's a lot of nature in Python. Most programmers prefer a pastoral
setting although some are hardy sea-faring folk. You should therefore
intersperse any documentation with thoughts about your garden, when to
harvest your crops, when the tide is likely to come in this evening,
etc. Also many Python programmers consider "eval" to be evil because of
that one letter difference. It's all in the semiotics.

12. Can I make calls to a function with a varying number of arguments?
See 5. But then re-read 2.

13. Named arguments
They're all named by repetitions of spam, where argument 1 is "spam",
argument 2 is "spamspam" and so on.

14. Tables with built-in methods for manipulation such as sort, etc.
Python doesn't use tables. Ever.

15. Table filters
See 14.

15. Proper Tail Call (otherwise known as Proper 
> Tail Recursion)
That's two 15's. Is this a form of duplicit recursion ?

16. The ability to call a function without 
> brackets
You're kidding, right. Right ? Without brackets ? That's... that's just
not possible is it ?

17. Is the Python interpreter a JIT? Does it have a 
> bytecode?  Is it as 
> fast as Java?
Python is generally 2000 to 3000 times faster than Java if you run Java
on a toaster and Python on a super-cooled space computer orbiting
Saturn.


> 18. The ability to modify the import/require functionality 
> (how modules 
> can be loaded)
"Modules" are the envelopes code comes in. See 7.

Sorry, my compilation has finished. Hope that helps...



-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies.
-----------------------------------------------------------------------




More information about the Python-list mailing list