Re: [Beginer Question] I heard about python needing some sortof_VariableName_ boiler plate?

Discussion in 'Python' started by bradenf@hotmail.com, Nov 1, 2010.

  1. Guest

    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:
    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.
    , Nov 1, 2010
    #1
    1. Advertising

  2. rantingrick Guest

    Re: I heard about python needing some sort of_VariableName_ boiler plate?

    On Oct 31, 10: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?


    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, Nov 1, 2010
    #2
    1. Advertising

  3. rantingrick Guest

    Re: I heard about python needing some sort of_VariableName_ boiler plate?

    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?
    rantingrick, Nov 1, 2010
    #3
  4. Tim Chase Guest

    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
    Tim Chase, Nov 1, 2010
    #4
  5. MRAB Guest

    Re: [Beginer Question] I heard about python needing somesort of_VariableName_ boiler plate?

    On 01/11/2010 04:51, Ben Finney wrote:
    > 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, Nov 1, 2010
    #5
  6. MRAB Guest

    Re: [Beginer Question] I heard about pythonneeding somesort of_VariableName_ boiler plate?

    On 01/11/2010 18:18, wrote:
    > Sorry that is what I mean. What is it for?
    > Sent wirelessly from my BlackBerry.
    >
    > -----Original Message-----
    > From: MRAB<>
    > Sender: python-list-bounces+bradenf=
    > Date: Mon, 01 Nov 2010 17:33:22
    > To:<>
    > Reply-To:
    > Subject: Re: [Beginer Question] I heard about python needing some
    > sort of_VariableName_ boiler plate?
    >
    > On 01/11/2010 04:51, Ben Finney wrote:
    >> 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__
    MRAB, Nov 1, 2010
    #6
  7. Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    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 <>
    > Sender: python-list-bounces+bradenf=
    > Date: Mon, 01 Nov 2010 17:33:22
    > To: <>
    > Reply-To:
    > Subject: Re: [Beginer Question] I heard about python needing some
    >        sort    of_VariableName_ boiler plate?
    >
    > On 01/11/2010 04:51, Ben Finney wrote:
    >> 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
    >
    Benjamin Kaplan, Nov 1, 2010
    #7
  8. Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    On Mon, 1 Nov 2010 18:18:45 +0000 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.
    Andreas Waldenburger, Nov 1, 2010
    #8
  9. Terry Reedy Guest

    Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    On 11/1/2010 2:18 PM, 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
    Terry Reedy, Nov 1, 2010
    #9
  10. Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    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.
    Grant Edwards, Nov 1, 2010
    #10
  11. Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    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 :
    > Sorry that is what I mean. What is it for?
    > Sent wirelessly from my BlackBerry.
    >
    > -----Original Message-----
    > From: MRAB<>
    > Sender: python-list-bounces+bradenf=
    > Date: Mon, 01 Nov 2010 17:33:22
    > To:<>
    > Reply-To:
    > Subject: Re: [Beginer Question] I heard about python needing some
    > sort of_VariableName_ boiler plate?
    >
    > On 01/11/2010 04:51, Ben Finney wrote:
    >> 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.
    Paul Kölle, Nov 2, 2010
    #11
  12. Re: [Beginer Question] I heard about python needing somesortof_VariableName_ boiler plate?

    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 :
    > Sorry that is what I mean. What is it for?
    > Sent wirelessly from my BlackBerry.
    >
    > -----Original Message-----
    > From: MRAB<>
    > Sender: python-list-bounces+bradenf=
    > Date: Mon, 01 Nov 2010 17:33:22
    > To:<>
    > Reply-To:
    > Subject: Re: [Beginer Question] I heard about python needing some
    > sort of_VariableName_ boiler plate?
    >
    > On 01/11/2010 04:51, Ben Finney wrote:
    >> 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.
    Paul Kölle, Nov 2, 2010
    #12
    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. jackal
    Replies:
    8
    Views:
    7,259
    aa123
    Sep 8, 2006
  2. Jim
    Replies:
    1
    Views:
    750
    bruno modulix
    Apr 14, 2005
  3. rh0dium
    Replies:
    2
    Views:
    459
    Adriano Ferreira
    May 20, 2005
  4. =?Utf-8?B?R3V5IFRob3JudG9u?=

    Needing some help with Business Objects in ASP.Net PLEASE

    =?Utf-8?B?R3V5IFRob3JudG9u?=, Nov 9, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    328
    =?Utf-8?B?R3V5IFRob3JudG9u?=
    Nov 9, 2006
  5. Pieter

    Making a zone plate in C++

    Pieter, Apr 1, 2008, in forum: C++
    Replies:
    4
    Views:
    313
    Pieter
    Apr 2, 2008
Loading...

Share This Page