RE: [OT] New to Python: Features

Discussion in 'Python' started by Mark English, Oct 5, 2004.

  1. Mark English

    Mark English Guest

    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.
    -----------------------------------------------------------------------
     
    Mark English, Oct 5, 2004
    #1
    1. Advertising

  2. Mark English wrote:
    > 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.


    QOTW!

    And thanks for the gut-wrenching laughs, Mark. :) My doctor
    will be sending you his bill...

    -Peter
     
    Peter L Hansen, Oct 5, 2004
    #2
    1. Advertising

  3. Mark English <> wrote:
    ...
    > > 1. Multi line comments

    > No. There are no comments in Python.


    No comment.


    > > 3. Function nesting with proper lexical scope (i.e. closures)

    > The penguins do nest, yes.


    But with a lexical scope that's often shockingly improper.


    > 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 ?


    In fact, it works better if you use parentheses, except when the
    function you're calling is the __getitem__ method of an object.


    > 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.


    Roughly correct, though the exact number depends on the model of
    toaster. But in the next release of Python, we're going to extend the
    validity of this observation to computers orbiting Neptune (assuming
    NASA does approve the grant being we're lobbyi^H^H^H^H humbly requesting
    of them).


    Alex
     
    Alex Martelli, Oct 5, 2004
    #3
  4. Mark English

    Greg Ewing Guest

    Alex Martelli wrote:
    > Mark English <> wrote:
    >>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.

    >
    > Roughly correct, though the exact number depends on the model of
    > toaster. But in the next release of Python, we're going to extend the
    > validity of this observation to computers orbiting Neptune


    The disadvantage being that you have to get the results back
    via the Deep Space Network, which at that distance is limited
    to about 3 bits per second. Fine for functions with a boolean
    result, though.

    --
    Greg Ewing, Computer Science Dept,
    University of Canterbury,
    Christchurch, New Zealand
    http://www.cosc.canterbury.ac.nz/~greg
     
    Greg Ewing, Oct 7, 2004
    #4
  5. Greg Ewing wrote:
    > Alex Martelli wrote:
    >
    >> Mark English <> wrote:
    >>
    >>> 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.

    >>
    >> Roughly correct, though the exact number depends on the model of
    >> toaster. But in the next release of Python, we're going to extend the
    >> validity of this observation to computers orbiting Neptune

    >
    > The disadvantage being that you have to get the results back
    > via the Deep Space Network, which at that distance is limited
    > to about 3 bits per second. Fine for functions with a boolean
    > result, though.


    .... except for the 8+ hour (minimum!) round-trip time for your
    signal to get to Neptune and back. Ha, you thought internet latency
    was a pain? Yes, boys and girls, Neptune be eight light-*hours*
    away. Earth small; space *BIG*! (Even in our own tiny little
    neighborhood. ;)

    Steve
     
    Stephen Waterbury, Oct 7, 2004
    #5
  6. Mark English

    Jorge Godoy Guest

    Stephen Waterbury <> writes:

    > ... except for the 8+ hour (minimum!) round-trip time for your
    > signal to get to Neptune and back. Ha, you thought internet latency
    > was a pain? Yes, boys and girls, Neptune be eight light-*hours*
    > away. Earth small; space *BIG*! (Even in our own tiny little
    > neighborhood. ;)


    Do you mean that the "You have 5s to stop the nuclear reactor meltdown
    in Neptune" message I got doesn't really mean 5s? ;-) Hmm... I hope
    somebody added a time machine protocol to Python. Some neptunians will
    be really angry.... ;-)

    --
    Godoy. <>
     
    Jorge Godoy, Oct 8, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Blackwood

    New to Python: Features

    Richard Blackwood, Oct 5, 2004, in forum: Python
    Replies:
    29
    Views:
    819
    Richard Blackwood
    Oct 7, 2004
  2. Josiah Carlson

    Re: New to Python: Features

    Josiah Carlson, Oct 5, 2004, in forum: Python
    Replies:
    26
    Views:
    588
    Nicola Larosa
    Oct 6, 2004
  3. Replies:
    0
    Views:
    278
  4. Jonathan Mcdougall
    Replies:
    2
    Views:
    500
    Kaz Kylheku
    Nov 3, 2005
  5. BillJosephson
    Replies:
    148
    Views:
    2,668
    peter koch
    Jan 27, 2007
Loading...

Share This Page