New to Python: Features

Discussion in 'Python' started by Richard Blackwood, Oct 5, 2004.

  1. Hi, I'm new to Python and I'd like to know if Python has the following
    support: *please answer to each individually, thanks*

    1. Multi line comments
    2. Functions as variables:
    a. functions can be stored in variables, passed as arguments to
    other functions, and returned as results.
    3. Function nesting with proper lexical scope (i.e. closures)
    4. Operator overloading (inc. the ability to define new operators)
    5. Can I do this? print("Hello " .. "World") --> Hello World
    6. Constructors
    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.
    8. "Repeat-Until" as in :
    repeat
    line = os.read()
    until line ~= ""
    print(line)
    9. Generic for loops where " for i=1,f(x) do print(i) end" would print i
    only once.
    10. Can I call an object's method as object:method(arg) and have that
    translate into object.method(object, arg)
    11. Can I make dynamic statements and nature like with eval() in Javascript?
    12. Can I make calls to a function with a varying number of arguments?
    13. Named arguments
    14. Tables with built-in methods for manipulation such as sort, etc.
    15. Table filters
    15. Proper Tail Call (otherwise known as Proper Tail Recursion)
    16. The ability to call a function without brackets
    17. Is the Python interpreter a JIT? Does it have a bytecode? Is it as
    fast as Java?
    18. The ability to modify the import/require functionality (how modules
    can be loaded)
    19. Coroutines and threads (non-preemptive)
    20. Date persistence and serialization
    21. May modules be stored in variables, passed to and produced from
    functions, and so forth?
    22. Is the self parameter hidden from me as a programmer? Can I
    hide/unhide it as I wish?
    23. Prototype-based OOP or the ability to extend a class without
    physically modifying it
    24. Manual garbage management
    25. A fully implemented .NET counterpart (I should be able to write
    Python scripts for both with the same code)
    26. How easily can other languages access it and vice versa?
    27. The option of mixing in static typing
    28. Automatic type coercion
    29. Is Python designed in such a way that I may merely "plugin" a
    C/C++/Java/D module which will then allow for mixing their syntax and
    perhaps even access to their facilities within Python?
    30. Messaging syntax such as : [myColor setRed:0.0 green:0.5 blue:1.0]
    or [dog bring:paper to:me] and [[myAunt phone] setTo:[myUncle phone]]
    <--- Nested messages and [dog perform:sel_get_uid("bark")] which is the
    same as [dog bark]
    31. Concepts of Protocols (whereby one may organize related methods into
    groups and check whether a particular object implements the methods
    within this protocol), or Interfaces similar to those in Java whereby
    classes or objects which implement the interface (sign the contract)
    must implement the methods and attributes as specified in the interface,
    and/or programming by contract such as in Eiffel (see:
    http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=595)
    32. Support for unplanned reuse of classes such as in TOM
    (http://www.gerbil.org/tom/)
    33. Function/Method overloading
    34. In pure Python, can I change and add new constructs to the Python
    syntax?
    35. May I modify the garbage collector?
    36. May I implement control structures as object messages?
    37. Dynamic dispatch
    38. Reflection and/or templates
    39. Unicode
    40. Ability to call external APIs and DLLs with relative ease
    41. How easy is it to port my Python code to C/C++/C# or Java?
    42. The ability to assign a method(s) to a collection/group of objects
    [with a particular signature i.e.]
    43. Embedding variables in strings like: print "Hello, World. Time:
    #{Time.now}"
    44. Case or Switch statements with functionality as such:
    case score
    when 0...40
    puts "Horrible!"
    when 40...60
    puts "Poor"
    when 60...80
    puts "You can do better!"
    when 80...95
    puts "Now that's acceptable"
    when 95..100
    puts "That the best you can do? j/k"
    else
    puts "Didn't take the test?"
    end
    45. Are all things objects in Python? Do all objects have built-in
    iterators and the like? i.e. can I do this:
    3.times { print "Ho! " }
    puts "Merry Christmas"

    That's all folks!
    Richard Blackwood, Oct 5, 2004
    #1
    1. Advertising

  2. On 2004-10-05, Richard Blackwood <> wrote:
    > Hi, I'm new to Python and I'd like to know if Python has the following
    > support: *please answer to each individually, thanks*


    Wow. Rude much?

    http://www.catb.org/~esr/faqs/smart-questions.html
    http://www.python.org/

    --
    Grant Edwards grante Yow! .. the MYSTERIANS are
    at in here with my CORDUROY
    visi.com SOAP DISH!!
    Grant Edwards, Oct 5, 2004
    #2
    1. Advertising

  3. Richard Blackwood

    Andrew Dalke Guest

    Richard Blackwood wrote:
    > Hi, I'm new to Python and I'd like to know if Python has the following
    > support: *please answer to each individually, thanks*


    Welcome to Python. I've been using it for almost a decade
    and full time for 7 years and quite enjoy it.

    However. You've asked a whole bunch of questions which
    look as if you've not done any research on your own. It
    has the feeling almost that you're asking us to do a
    homework assignment for you. Given the question

    > 39. Unicode


    it means you haven't even looked at the tutorial at
    http://docs.python.org/tut/tut.html
    with its section 3.1.3 "Unicode strings".

    much less given a cursory review of the reference manual at
    http://docs.python.org/ref/ref.html

    Given your questions about closure, tail recursion,
    JIT, prototype-based OOP, etc. you are apparently not
    new to programming. Reading through the base
    documentation should be a much better use of your time
    and ours than having people answer your questions point
    by point. After all, some of your questions require
    non-trivial amounts of contextualization to answer
    correctly. Eg, your #30 assumes a Smalltalk paradigm,
    while Python uses a different way to achieve similar
    ends, your #28 requires explaining Python's reference
    based semantics where variable have only one type,
    reference to object, and your #11 requires a stern
    warning that such behaviour is almost certainly a
    security hole waiting to happen.

    The most suspicious part about your post is your
    haphazard use of so many different programming
    paradigms combined with the almost pedigogical way
    of describing some of them.

    Please read the basic Python documentation before
    asking these questions.

    Andrew
    Andrew Dalke, Oct 5, 2004
    #3
  4. On 2004-10-05, Richard Blackwood <> wrote:
    > Grant Edwards wrote:
    >
    >>>Hi, I'm new to Python and I'd like to know if Python has the following
    >>>support: *please answer to each individually, thanks*

    >>
    >>Wow. Rude much?
    >>
    >>http://www.catb.org/~esr/faqs/smart-questions.html
    >>http://www.python.org/
    >>

    > What does "Rude much" mean?


    You've _got_ to be kidding...

    --
    Grant Edwards grante Yow! An Italian is COMBING
    at his hair in suburban DES
    visi.com MOINES!
    Grant Edwards, Oct 5, 2004
    #4
  5. Andrew Dalke wrote:

    > Richard Blackwood wrote:
    >
    >> Hi, I'm new to Python and I'd like to know if Python has the
    >> following support: *please answer to each individually, thanks*

    >
    >
    > Welcome to Python. I've been using it for almost a decade
    > and full time for 7 years and quite enjoy it.
    >
    > However. You've asked a whole bunch of questions which
    > look as if you've not done any research on your own. It
    > has the feeling almost that you're asking us to do a
    > homework assignment for you. Given the question
    >
    > > 39. Unicode

    >
    > it means you haven't even looked at the tutorial at
    > http://docs.python.org/tut/tut.html
    > with its section 3.1.3 "Unicode strings".
    >
    > much less given a cursory review of the reference manual at
    > http://docs.python.org/ref/ref.html
    >
    > Given your questions about closure, tail recursion,
    > JIT, prototype-based OOP, etc. you are apparently not
    > new to programming. Reading through the base
    > documentation should be a much better use of your time
    > and ours than having people answer your questions point
    > by point. After all, some of your questions require
    > non-trivial amounts of contextualization to answer
    > correctly. Eg, your #30 assumes a Smalltalk paradigm,
    > while Python uses a different way to achieve similar
    > ends, your #28 requires explaining Python's reference
    > based semantics where variable have only one type,
    > reference to object, and your #11 requires a stern
    > warning that such behaviour is almost certainly a
    > security hole waiting to happen.
    >
    > The most suspicious part about your post is your
    > haphazard use of so many different programming
    > paradigms combined with the almost pedigogical way
    > of describing some of them.
    >
    > Please read the basic Python documentation before
    > asking these questions.
    >
    > Andrew
    >


    Ouch! I didn't expect such harsh replies. Thanks anyways.
    Richard Blackwood, Oct 5, 2004
    #5
  6. Richard Blackwood, Oct 5, 2004
    #6
  7. Richard Blackwood

    Andrew Dalke Guest

    Richard Blackwood wrote:
    > Ouch! I didn't expect such harsh replies. Thanks anyways.


    That wasn't harsh. I answered 4 of your questions.

    39. pointer to the documentation on that topic
    30. no, Python uses a different style
    28. that question doesn't make sense for Python -- variables
    only have one type
    11. don't use eval (implying that Python has such a thing)

    and spent at least as much information in responding as
    you did in writing the questions in the first place.

    I even explained why I found your post to be problematical
    and left an opportunity for you to explain why my
    conjectures were wrong.

    Feel free to explain why we should put a lot of effort into
    replying to your email when it seems you've made no effort
    in answering the questions yourself, despite seeming to be
    quite capable of doing so.

    Andrew
    Andrew Dalke, Oct 5, 2004
    #7
  8. Grant Edwards wrote:

    >On 2004-10-05, Richard Blackwood <> wrote:
    >
    >
    >>Grant Edwards wrote:
    >>
    >>
    >>
    >>>>Hi, I'm new to Python and I'd like to know if Python has the following
    >>>>support: *please answer to each individually, thanks*
    >>>>
    >>>>
    >>>Wow. Rude much?
    >>>
    >>>http://www.catb.org/~esr/faqs/smart-questions.html
    >>>http://www.python.org/
    >>>
    >>>
    >>>

    >>What does "Rude much" mean?
    >>
    >>

    >
    >You've _got_ to be kidding...
    >
    >
    >

    I don't think that that is proper english.

    Anyhow, I wasn't trying to muster up anything or annoy anyone. My
    sincere apologies to all who were offended.
    Richard Blackwood, Oct 5, 2004
    #8
  9. On 2004-10-05, Richard Blackwood <> wrote:

    >>>>>Hi, I'm new to Python and I'd like to know if Python has the following
    >>>>>support: *please answer to each individually, thanks*
    >>>>>
    >>>>Wow. Rude much?
    >>>>
    >>>>http://www.catb.org/~esr/faqs/smart-questions.html
    >>>>http://www.python.org/
    >>>>
    >>>What does "Rude much" mean?

    >>
    >>You've _got_ to be kidding...

    >
    > I don't think that that is proper english.


    Oh. My. Gaawwwd!

    Which one, the "Rude much?" crack or the "You've got to be
    kidding..." crack? The latter isn't all that improper
    (especially not for Usenet). The former is colloqial US
    English. More specifically it's "Valley Speak" -- made popular
    outside "The Valley" by movies like "Valley Girl", "Mall Rats",
    "Heathers", and just about any John Hughes movie (especially
    Sixteen Candles). The first two are crap, but "Heathers" is a
    good movie, and I still like "Sixteen Candles".

    > Anyhow, I wasn't trying to muster up anything or annoy anyone.
    > My sincere apologies to all who were offended.


    Apology accepted on the condition that you read
    how-to-ask-smart-questions, and go browse around
    www.python.org for 15 minutes.

    --
    Grant Edwards grante Yow! Uh-oh!! I forgot
    at to submit to COMPULSORY
    visi.com URINALYSIS!


    > Anyhow, I wasn't trying to muster up anything or annoy anyone. My
    > sincere apologies to all who were offended.



    --
    Grant Edwards grante Yow! I would like to
    at urinate in an OVULAR,
    visi.com porcelain pool --
    Grant Edwards, Oct 5, 2004
    #9
  10. Andrew Dalke wrote:

    > Richard Blackwood wrote:
    >
    >> Ouch! I didn't expect such harsh replies. Thanks anyways.

    >
    >
    > That wasn't harsh. I answered 4 of your questions.
    >
    > 39. pointer to the documentation on that topic
    > 30. no, Python uses a different style
    > 28. that question doesn't make sense for Python -- variables
    > only have one type
    > 11. don't use eval (implying that Python has such a thing)
    >
    > and spent at least as much information in responding as
    > you did in writing the questions in the first place.
    >
    > I even explained why I found your post to be problematical
    > and left an opportunity for you to explain why my
    > conjectures were wrong.
    >
    > Feel free to explain why we should put a lot of effort into
    > replying to your email when it seems you've made no effort
    > in answering the questions yourself, despite seeming to be
    > quite capable of doing so.
    >
    > Andrew
    >


    OK. I idea was that someone who knew alot about one particular would
    respond to that question, and other someone who knew alot about another
    particular would respond to another question, and so forth. A poor
    idea? Seeing the result, I guess so. Sorry to have bothered anyone.

    When I said "harsh", I meant being accused of trolling, attempting to
    annoy, stir trouble, etc. None which was my intent nor did I think that
    my post would be interpreted as such (otherwise I wouldn't have posted it).

    Thank you for your help.
    Richard Blackwood, Oct 5, 2004
    #10
  11. On 2004-10-05, Richard Blackwood <> wrote:

    > When I said "harsh", I meant being accused of trolling,
    > attempting to annoy, stir trouble, etc. None which was my
    > intent nor did I think that my post would be interpreted as
    > such (otherwise I wouldn't have posted it).


    If you honestly didn't think you were being rude and weren't
    going to annoy anybody, you really, really do need to read how
    to ask questions the smart way. c.l.p is a very kind place,
    but should somebody as naive as you wander into the rest of
    Usenet... well, I just don't like to think of what might
    happen.

    --
    Grant Edwards grante Yow! HELLO, little boys!
    at Gimme a MINT TULIP!! Let's
    visi.com do the BOSSA NOVA!!
    Grant Edwards, Oct 5, 2004
    #11
  12. Grant Edwards wrote:

    >On 2004-10-05, Richard Blackwood <> wrote:
    >
    >
    >
    >>>>>>Hi, I'm new to Python and I'd like to know if Python has the following
    >>>>>>support: *please answer to each individually, thanks*
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>Wow. Rude much?
    >>>>>
    >>>>>http://www.catb.org/~esr/faqs/smart-questions.html
    >>>>>http://www.python.org/
    >>>>>
    >>>>>
    >>>>>
    >>>>What does "Rude much" mean?
    >>>>
    >>>>
    >>>You've _got_ to be kidding...
    >>>
    >>>

    >>I don't think that that is proper english.
    >>
    >>

    >
    >Oh. My. Gaawwwd!
    >
    >Which one, the "Rude much?" crack or the "You've got to be
    >kidding..." crack? The latter isn't all that improper
    >(especially not for Usenet). The former is colloqial US
    >English. More specifically it's "Valley Speak" -- made popular
    >outside "The Valley" by movies like "Valley Girl", "Mall Rats",
    >"Heathers", and just about any John Hughes movie (especially
    >Sixteen Candles). The first two are crap, but "Heathers" is a
    >good movie, and I still like "Sixteen Candles".
    >
    >
    >
    >>Anyhow, I wasn't trying to muster up anything or annoy anyone.
    >>My sincere apologies to all who were offended.
    >>
    >>

    >
    >Apology accepted on the condition that you read
    >how-to-ask-smart-questions, and go browse around
    >www.python.org for 15 minutes.
    >
    >
    >

    I'll browse around python.org for a few hours instead of throwing in the
    "how-to-ask-smart-questions" part. ;-)
    Richard Blackwood, Oct 5, 2004
    #12
  13. Grant Edwards wrote:

    >On 2004-10-05, Richard Blackwood <> wrote:
    >
    >
    >
    >>When I said "harsh", I meant being accused of trolling,
    >>attempting to annoy, stir trouble, etc. None which was my
    >>intent nor did I think that my post would be interpreted as
    >>such (otherwise I wouldn't have posted it).
    >>
    >>

    >
    >If you honestly didn't think you were being rude and weren't
    >going to annoy anybody, you really, really do need to read how
    >to ask questions the smart way. c.l.p is a very kind place,
    >but should somebody as naive as you wander into the rest of
    >Usenet... well, I just don't like to think of what might
    >happen.
    >
    >
    >

    Apparently it is not a matter of "smartly" but don't ask at all.

    I get the point, grief.
    Richard Blackwood, Oct 5, 2004
    #13
  14. Richard Blackwood

    Andrew Dalke Guest

    Richard Blackwood wrote:
    > OK. I idea was that someone who knew alot about one particular would
    > respond to that question, and other someone who knew alot about another
    > particular would respond to another question, and so forth. A poor
    > idea? Seeing the result, I guess so. Sorry to have bothered anyone.


    The reason it was poor idea was not considering that on
    a project like Python with nearly 15 years of work behind
    it, dozens of books, thousands of magazine articles,
    millions of lines of code, etc. that those answers might
    already have been collected into documentation and organized
    in such a way that a person like you could find all those
    answers, plus details you wouldn't get from such simple
    questions, plus answers to questions you haven't even
    thought of asking.

    To follow up, now that someone answered all your questions
    are you any more knowledgeable about Python? I suspect
    not because those answers don't hang together coherently
    so you'll need to read the documentation anyway.

    Andrew
    Andrew Dalke, Oct 5, 2004
    #14
  15. Richard Blackwood

    Sam Holden Guest

    On Tue, 05 Oct 2004 00:36:46 -0400,
    Richard Blackwood <> wrote:
    > Grant Edwards wrote:
    >
    >>On 2004-10-05, Richard Blackwood <> wrote:
    >>
    >>
    >>
    >>>When I said "harsh", I meant being accused of trolling,
    >>>attempting to annoy, stir trouble, etc. None which was my
    >>>intent nor did I think that my post would be interpreted as
    >>>such (otherwise I wouldn't have posted it).
    >>>
    >>>

    >>
    >>If you honestly didn't think you were being rude and weren't
    >>going to annoy anybody, you really, really do need to read how
    >>to ask questions the smart way. c.l.p is a very kind place,
    >>but should somebody as naive as you wander into the rest of
    >>Usenet... well, I just don't like to think of what might
    >>happen.
    >>
    >>
    >>

    > Apparently it is not a matter of "smartly" but don't ask at all.


    Part of asking smartly is not asking thousands of people to each spend
    time reading an possibly answering a question that you could find the
    answer to yourself with a minute of looking.

    --
    Sam Holden
    Sam Holden, Oct 5, 2004
    #15
  16. Richard Blackwood said unto the world upon 2004-10-05 00:32:
    > Grant Edwards wrote:
    >
    >> On 2004-10-05, Richard Blackwood <>
    >> wrote:


    <SNIP>

    >>> Anyhow, I wasn't trying to muster up anything or annoy anyone.
    >>> My sincere apologies to all who were offended.
    >>>

    >>
    >> Apology accepted on the condition that you read
    >> how-to-ask-smart-questions, and go browse around
    >> www.python.org for 15 minutes.
    >>
    >>

    > I'll browse around python.org for a few hours instead of throwing in the
    > "how-to-ask-smart-questions" part. ;-)


    Wrong order of priorities, methinks. Browsing python.org will help you a
    fair bit with python. Reading
    <http://www.catb.org/~esr/faqs/smart-questions.html> will help you learn
    more about Python and any other thing one might ever post to a newsgroup
    or mail-list about. From your various posts, it is clear that the
    lessons of the second piece would be much more helpful to your future
    projects than would be a browse of python.org.

    Best,

    Brian vdB
    Brian van den Broek, Oct 5, 2004
    #16
  17. On 2004-10-05, Richard Blackwood <> wrote:
    > Grant Edwards wrote:
    >
    >>On 2004-10-05, Richard Blackwood <> wrote:
    >>
    >>
    >>
    >>>When I said "harsh", I meant being accused of trolling,
    >>>attempting to annoy, stir trouble, etc. None which was my
    >>>intent nor did I think that my post would be interpreted as
    >>>such (otherwise I wouldn't have posted it).
    >>>
    >>>

    >>
    >>If you honestly didn't think you were being rude and weren't
    >>going to annoy anybody, you really, really do need to read how
    >>to ask questions the smart way. c.l.p is a very kind place,
    >>but should somebody as naive as you wander into the rest of
    >>Usenet... well, I just don't like to think of what might
    >>happen.

    >
    > Apparently it is not a matter of "smartly" but don't ask at all.


    You are expected to spend at least a few minutes of reading on
    your own before requesting that thousands of other people
    answer dozens of questions for you.

    > I get the point, grief.


    No, I don't think you do. You really ought to read the "smart
    questions" link I provided if you want to understand how the
    world works.

    --
    Grant Edwards grante Yow! PARDON me, am I
    at speaking ENGLISH?
    visi.com
    Grant Edwards, Oct 5, 2004
    #17
  18. <SNIP>

    >
    > To follow up, now that someone answered all your questions
    > are you any more knowledgeable about Python? I suspect
    > not because those answers don't hang together coherently
    > so you'll need to read the documentation anyway.
    >
    > Andrew
    >


    It gave me a good idea of whether I should use it or not. Green and Red
    lights did the trick.
    Richard Blackwood, Oct 5, 2004
    #18
  19. Richard Blackwood

    Ville Vainio Guest

    >>>>> "Richard" == Richard Blackwood <> writes:

    Richard> Hi, I'm new to Python and I'd like to know if Python has
    Richard> the following support: *please answer to each
    Richard> individually, thanks*

    Is that enough to pass the whole course, or are you going to ask for a
    "solution for this simple program" soon?

    --
    Ville Vainio http://tinyurl.com/2prnb
    Ville Vainio, Oct 5, 2004
    #19
  20. Richard Blackwood

    Dan Bishop Guest

    Richard Blackwood <> wrote in message news:<>...
    > Hi, I'm new to Python and I'd like to know if Python has the following
    > support: *please answer to each individually, thanks*


    Most of your questions are answered at http://docs.python.org/

    > 1. Multi line comments


    No. But multi-line docstrings are supported.

    > 2. Functions as variables:
    > a. functions can be stored in variables, passed as arguments to
    > other functions, and returned as results.


    Yes.

    >>> def deriv(f, x, delta=1e-8):

    .... "Centered difference approximation of f'(x)"
    .... return (f(x + delta) - f(x - delta)) / (2 * delta)
    ....
    >>> deriv(lambda x: x * x, 2)

    3.9999999756901161

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


    Yes.

    > 4. Operator overloading (inc. the ability to define new operators)


    Yes. This is done by defining the special methods __add__, __mul__,
    etc.

    > 5. Can I do this? print("Hello " .. "World") --> Hello World


    If ".." is supposed to be the string concatenation operator, then yes.

    >>> print "Hello " + "World!"

    Hello World!

    > 6. Constructors


    Yes. They're defined like this:

    class MyClass:
    def __init__(self, arg1, arg2):
    # ...

    and called like this:

    x = MyClass(arg1, arg2)

    > 8. "Repeat-Until" as in :
    > repeat
    > line = os.read()
    > until line ~= ""
    > print(line)


    There isn't a special syntax for posttest loops. You have to write
    them like

    while True:
    line = os.read()
    if not line:
    break
    print line

    > 10. Can I call an object's method as object:method(arg) and have that
    > translate into object.method(object, arg)


    >>> class MyClass:

    .... def foo(self, arg):
    .... pass
    ....
    >>> m = MyClass()
    >>> m.foo(0)
    >>> MyClass.foo(m, 0)


    > 11. Can I make dynamic statements and nature like with eval() in Javascript?


    Yes.

    >>> x = 1; y = 2
    >>> z = eval("x + y")
    >>> exec "print z"

    3

    > 12. Can I make calls to a function with a varying number of arguments?


    Yes.

    >>> def func(fixedArgA, fixedArgB, *args):

    .... print "called with", 2 + len(args), "arguments"
    ....
    >>> func(1, 2, 3, 4)

    called with 4 arguments
    >>> func(1, 2, 3, 4, 5, 6)

    called with 6 arguments

    > 13. Named arguments


    Yes.

    >>> datetime.date(month=10, day=5, year=2004)

    datetime.date(2004, 10, 5)

    > 14. Tables with built-in methods for manipulation such as sort, etc.


    Try the built-in "list" type. Also, "dict".

    > 15. Table filters


    I'm not quite sure what you're asking. Do you mean something like

    >>> [n for n in xrange(2, 20) if isprime(n)]

    [2, 3, 5, 7, 11, 13, 17, 19]

    ?

    > 15. Proper Tail Call (otherwise known as Proper Tail Recursion)


    No.

    > 16. The ability to call a function without brackets


    Fortunately, no.

    > 17. Is the Python interpreter a JIT? Does it have a bytecode? Is it as
    > fast as Java?


    For the standard interpreter: No. Yes. No.

    But try Psyco (psyco.sourceforge.net).

    > 21. May modules be stored in variables, passed to and produced from
    > functions, and so forth?


    Yes.

    >>> import sys
    >>> import os
    >>> modules = [sys, os]
    >>> modules[1].getcwd()

    '/home/dan'

    > 22. Is the self parameter hidden from me as a programmer? Can I
    > hide/unhide it as I wish?


    No.

    > 25. A fully implemented .NET counterpart (I should be able to write
    > Python scripts for both with the same code)


    It's not fully implemented yet, but there is a .NET version
    (http://www.ironpython.org).

    > 33. Function/Method overloading


    No, but it can often be simulated by default parameters, or by
    "isinstance" checks.

    > 34. In pure Python, can I change and add new constructs to the Python
    > syntax?


    No.

    > 43. Embedding variables in strings like: print "Hello, World. Time:
    > #{Time.now}"


    No, but this can be written almost as easily using the % operator.

    >>> print "Hello, World. Time: %s" % datetime.datetime.now()

    Hello, World. Time: 2004-10-05 03:12:14.750796

    or

    >>> now = datetime.datetime.now()
    >>> print "Hello, World. Time: %(now)s" % locals()

    Hello, World. Time: 2004-10-05 03:14:01.111879

    > 44. Case or Switch statements with functionality as such:
    > case score
    > when 0...40
    > puts "Horrible!"
    > when 40...60
    > puts "Poor"
    > when 60...80
    > puts "You can do better!"
    > when 80...95
    > puts "Now that's acceptable"
    > when 95..100
    > puts "That the best you can do? j/k"
    > else
    > puts "Didn't take the test?"
    > end


    Python does not have a switch/case construct. Your example would
    normally be written as an if...elif...else ladder.
    Dan Bishop, Oct 5, 2004
    #20
    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. Josiah Carlson

    Re: New to Python: Features

    Josiah Carlson, Oct 5, 2004, in forum: Python
    Replies:
    26
    Views:
    576
    Nicola Larosa
    Oct 6, 2004
  2. Richard Blackwood

    Re: New to Python: Features

    Richard Blackwood, Oct 5, 2004, in forum: Python
    Replies:
    14
    Views:
    416
    Nicola Larosa
    Oct 6, 2004
  3. Replies:
    0
    Views:
    269
  4. Jonathan Mcdougall
    Replies:
    2
    Views:
    482
    Kaz Kylheku
    Nov 3, 2005
  5. BillJosephson
    Replies:
    148
    Views:
    2,598
    peter koch
    Jan 27, 2007
Loading...

Share This Page