FAQ
Sorry, to clarify I heard that when you declare a variable in python you have to use some sort of standard boiler plate _variable_ however this has not been my experience using IDLE so is this even true?

Thanks!

------Original Message------
From: Chris Rebert
Sender: chris at rebertia.com
To: Braden Faulkner
Cc: Python List
Subject: Re: [Beginer Question] I heard about python needing some sort of_VariableName_ boiler plate?
Sent: Oct 31, 2010 11:18 PM
On Sun, Oct 31, 2010 at 7:09 PM, Braden Faulkner wrote:
I heard about python needing some sort of _VariableName_ boiler plate?
Can anyone explain to me how this works, I don't seem to have to do it in
IDLE?
Your question is extremely vague. Please give more details.

Regards,
Chris



Sent wirelessly from my BlackBerry.

Search Discussions

  • Rantingrick at Nov 1, 2010 at 4:34 am

    On Oct 31, 10:37?pm, brad... at hotmail.com wrote:
    Sorry, to clarify I heard that when you declare a variable in python you have to use some sort of standard boiler plate _variable_ however this has not been my experience using IDLE so is this even true?
    Halloween night and i am bored... hmm... i know!

    plan A: Ask a really perplexing and insane question on c.l.p.

    ...hmm, well i did not get the answer i wanted so i'll just open a new
    thread and...

    plan B: Ask ask the same question again!

    ...surely i'll get a better answer with this plan!!

    urm, rinse and repeat maybe?
  • Rantingrick at Nov 1, 2010 at 4:37 am
    Brad,

    Serously, i have never heard of any boilerplate variables in Python.
    Could you show us an example using Python code that compiles? Of could
    you even show us some puesdo that resembles any thing that you are
    suggesting? I am perplexed! Is this a troll or are you really serious?
  • James Mills at Nov 1, 2010 at 4:50 am

    On Mon, Nov 1, 2010 at 1:37 PM, wrote:
    Sorry, to clarify I heard that when you declare a variable in python you have to use some sort of standard boiler plate _variable_ however this has not been my experience using IDLE so is this even true?
    Boilerplate, what boilerplate ?

    To define variables, just assign a value to a name:
    x = 1
    x
    1

    cheers
    James

    --
    -- James Mills
    --
    -- "Problems are solved by method"
  • Ben Finney at Nov 1, 2010 at 4:51 am

    bradenf at hotmail.com writes:

    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?

    --
    \ ?With Lisp or Forth, a master programmer has unlimited power |
    `\ and expressiveness. With Python, even a regular guy can reach |
    _o__) for the stars.? ?Raymond Hettinger |
    Ben Finney
  • Tim Chase at Nov 1, 2010 at 12:10 pm

    On 10/31/10 23:51, Ben Finney wrote:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.
    With the same lack of context as everybody else, two ideas occur
    to me, both involve thinking the OP means "__variable__" (with
    the double-underscores) instead of with single underscores:

    1) the *completely optional and certainly not manditory
    CONVENTION* of using things like __author__ or __version__ in a
    module for various meta-data. For some projects, these sorts of
    faux-special-variables may be more demanded, but that's a
    project-thing, not a Python-thing

    2) the use of the __foo__ magic methods such as __init__ or
    __add__ to hook into language bindings/functionality. In this
    case, there's not a lot of use a boiler-plate template would do
    for you...what? perhaps create

    def __|__(self):
    """Docstring"""

    (leaving the cursor on the "|") But this isn't really much
    different from a generic function template with extra underscores
    and automatically adding "self" as the first parameter.

    But I've never found that terribly hard to type in the first
    place -- this is Python, not Pascal (where I'd have to
    distinguish between "procedure" and "function" and remember to
    correctly spell both)


    Or, it could be way too early on a Monday morning and I don't
    have a clue what the OP is talking about...which doesn't put me
    any further behind the other folks on the list. :*)

    -tkc
  • MRAB at Nov 1, 2010 at 5:33 pm

    On 01/11/2010 04:51, Ben Finney wrote:
    bradenf at hotmail.com writes:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?
    Perhaps the OP means:

    if __name__ == "__main__":
    ...

    although the "declare a variable" bit has me puzzled.
  • Bradenf at Nov 1, 2010 at 6:18 pm
    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.

    -----Original Message-----
    From: MRAB <python at mrabarnett.plus.com>
    Sender: python-list-bounces+bradenf=hotmail.com at python.org
    Date: Mon, 01 Nov 2010 17:33:22
    To: <python-list at python.org>
    Reply-To: python-list at python.org
    Subject: Re: [Beginer Question] I heard about python needing some
    sort of_VariableName_ boiler plate?
    On 01/11/2010 04:51, Ben Finney wrote:
    bradenf at hotmail.com writes:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?
    Perhaps the OP means:

    if __name__ == "__main__":
    ...

    although the "declare a variable" bit has me puzzled.
  • MRAB at Nov 1, 2010 at 6:40 pm

    On 01/11/2010 18:18, bradenf at hotmail.com wrote:
    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.

    -----Original Message-----
    From: MRAB<python at mrabarnett.plus.com>
    Sender: python-list-bounces+bradenf=hotmail.com at python.org
    Date: Mon, 01 Nov 2010 17:33:22
    To:<python-list at python.org>
    Reply-To: python-list at python.org
    Subject: Re: [Beginer Question] I heard about python needing some
    sort of_VariableName_ boiler plate?
    On 01/11/2010 04:51, Ben Finney wrote:
    bradenf at hotmail.com writes:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?
    Perhaps the OP means:

    if __name__ == "__main__":
    ...

    although the "declare a variable" bit has me puzzled.
    When a module is imported __name__ is bound to the name of the module,
    but when the module is run directly __name__ is bound to "__main__".

    See: http://docs.python.org/faq/programming.html?highlight=__name__
  • Benjamin Kaplan at Nov 1, 2010 at 6:45 pm

    On Mon, Nov 1, 2010 at 2:18 PM, wrote:
    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.
    What is what for? There is no boiler plate on variable names. *BY
    CONVENTION*, variables and methods with a special meaning will start
    and end with two underscores. *BY CONVENTION* something that you want
    to identify as an internal variable (what would be private in
    languages that enforce this) is prefixed with a single underscore. But
    neither of these are actually enforced by the language.

    For instance, an object's doc-string is stored as it's __doc__
    attribute. The constructor is the __init__ method. The method that
    controls attribute access (which you can override) is __getattr__.
    Using str(object) to get the string representation works by calling
    the object's __str__ method. a + b is the same thing as a.__add__(b)

    -----Original Message-----
    From: MRAB <python at mrabarnett.plus.com>
    Sender: python-list-bounces+bradenf=hotmail.com at python.org
    Date: Mon, 01 Nov 2010 17:33:22
    To: <python-list at python.org>
    Reply-To: python-list at python.org
    Subject: Re: [Beginer Question] I heard about python needing some
    ? ? ? ?sort ? ?of_VariableName_ boiler plate?
    On 01/11/2010 04:51, Ben Finney wrote:
    bradenf at hotmail.com writes:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?
    Perhaps the OP means:

    ? ? if __name__ == "__main__":
    ? ? ? ? ...

    although the "declare a variable" bit has me puzzled.
    --
    http://mail.python.org/mailman/listinfo/python-list
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Terry Reedy at Nov 1, 2010 at 7:42 pm

    On 11/1/2010 2:18 PM, bradenf at hotmail.com wrote:
    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.
    Does it require you to toppost? Understanding the above requires one to
    guess what 'that' forward references.
    Perhaps the OP means:

    if __name__ == "__main__":
    I presume that this is the 'that' which you forward-referenced. If so...

    Python reserves names of the form __xyz__ for itself. This is
    intentionally a bit awkward so as to stand out in code and not conflict
    with names a programmer might choose. This form is used for names that
    programmers *mostly* do not need to use. The system names that we do
    need to use constantly, like 'None', 'def', and 'int' have normal
    spellings. These are easy to type, but may conflict with a name that a
    programmer might be using.

    Every module has a name stored in its __name__ attribute. The the
    interpreter starts, it names the top level module, which is run directly
    instead of being imported, as '__main__'. When a module is run
    indirectly, by being imported, its name is what you expect from the docs
    or from the name of its file.

    So:
    1. a module can have one of two runtime names (as defined by it __name__
    attribute): '__main__' or its proper name.
    2. a module's runtime name depends on whether it is run directly or
    imported.
    3. a module can therefor tell how it is being run; this is usually done
    with "if __name__ == '__main__'.
    4. a module can change its behavior depending on how it is run by
    putting code in the body of the conditional statement. Such a
    conditional statement is entirely OPTIONAL.

    There are two things people do in such a body.
    a. If the module is meant either imported or run as a useful standalone
    program (such as the stdlib trace module), check for arguments in
    sys.argv, do some useful work, and report.
    b. If the module is normally only meant to be imported, run a test.

    If a module is only meant to run as a program, or if it is only meant to
    be imported and all its tests are in a separate file, there there is no
    need for the conditional statement.

    --
    Terry Jan Reedy
  • Grant Edwards at Nov 1, 2010 at 8:57 pm

    On 2010-11-01, Benjamin Kaplan wrote:
    On Mon, Nov 1, 2010 at 2:18 PM, wrote:

    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.
    What is what for?
    I think I smell troll...

    --
    Grant Edwards grant.b.edwards Yow! hubub, hubub, HUBUB,
    at hubub, hubub, hubub, HUBUB,
    gmail.com hubub, hubub, hubub.
  • Paul Kölle at Nov 2, 2010 at 9:37 am
    Its the entry point if the script is executed directly.
    This message was sent from my 7 years old Dell D800 (without cables)

    Am 01.11.2010 19:18, schrieb bradenf at hotmail.com:
    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.

    -----Original Message-----
    From: MRAB<python at mrabarnett.plus.com>
    Sender: python-list-bounces+bradenf=hotmail.com at python.org
    Date: Mon, 01 Nov 2010 17:33:22
    To:<python-list at python.org>
    Reply-To: python-list at python.org
    Subject: Re: [Beginer Question] I heard about python needing some
    sort of_VariableName_ boiler plate?
    On 01/11/2010 04:51, Ben Finney wrote:
    bradenf at hotmail.com writes:
    Sorry, to clarify I heard that when you declare a variable in python
    you have to use some sort of standard boiler plate _variable_ however
    this has not been my experience using IDLE so is this even true?
    I don't know what ?some sort of boiler plate _variable_? might mean.

    Can you point to someone's actual message saying this, so we can see
    what they might be talking about?
    Perhaps the OP means:

    if __name__ == "__main__":
    ...

    although the "declare a variable" bit has me puzzled.
  • Andreas Waldenburger at Nov 1, 2010 at 7:38 pm

    On Mon, 1 Nov 2010 18:18:45 +0000 bradenf at hotmail.com wrote:

    Sorry that is what I mean. What is it for?
    Sent wirelessly from my BlackBerry.
    andreas.quick_hot_anger = True
    Braden! Stop Top-Posting already! Please. If your BlackBerry makes this
    hard, then get another mail client. It gets confusing. And thereby,
    annoying.
    andreas.quick_hot_anger = False
    /W

    --
    To reach me via email, replace INVALID with the country code of my home
    country. But if you spam me, I'll be one sour Kraut.
  • Ben Finney at Nov 1, 2010 at 10:46 pm

    bradenf at hotmail.com writes:

    Sorry that is what I mean. What is it for?
    Branden, you're welcome to ask questions about Python here.

    But please, help us help you:

    Don't top-post. It makes the flow of conversation difficult to follow.

    Instead, respond in-line beneath the point you're responding to, and
    remove extraneous quoted material that you're not responding to (this
    message is an example). That way, references like ?that is what I mean?
    make a whole lot more sense.
    Sent wirelessly from my BlackBerry.
    If you are using a mail client that spams us with its advertising, and
    makes normal message composition difficult, then please don't; instead
    compose your messages using a better mail client.

    Hope that helps, and good hunting to you as you learn Python :-)

    --
    \ ?What if the Hokey Pokey IS what it's all about?? ?anonymous |
    `\ |
    _o__) |
    Ben Finney

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 1, '10 at 3:37a
activeNov 2, '10 at 9:37a
posts15
users11
websitepython.org

People

Translate

site design / logo © 2022 Grokbase