Re: No Thoughts about Everything

Discussion in 'Python' started by Dave Brueck, Feb 25, 2004.

  1. Dave Brueck

    Dave Brueck Guest

    Bernhard wrote:
    [snip]
    > while using Java. I kindly ask for help to transfer that simple, single
    > line intelligent to python in the best possible way:
    >
    > static final double c=2.99792458e8;
    > How can I create such a "class constant" (static final / recipe 5.15 and
    > 5.6 in one) in python as short as possible?


    class Foo:
    BAR = 10

    Voila! BAR is now a "class constant" - shared among all instances of the class
    Foo (in theory it's not a constant, but in practice it is :) ).

    HTH,
    Dave
    Dave Brueck, Feb 25, 2004
    #1
    1. Advertising

  2. Dave Brueck

    Arthur Guest

    On Wed, 25 Feb 2004 08:55:45 -0700, "Dave Brueck"
    <> wrote:

    >class Foo:
    > BAR = 10
    >
    >Voila! BAR is now a "class constant" - shared among all instances of the class
    >Foo (in theory it's not a constant, but in practice it is :) ).
    >
    >HTH,
    >Dave
    >


    But not 'final'.
    I am only anticipating a response.

    IMO - if I am understanidng the issues correctly - it is a perfectly
    adequate solution. Simple to get across to beginners..

    The issue of making the constant 'final' is a production programming
    issue. And whether Python does or does not need it is not an issue
    relative to teaching beginners. The fact that production programming
    concerns are introduced at that stage of the game is, I think, where
    many who would otherwise have an intellectual intererst in programming
    fall of the wagon. Wanting to understand programming and wanting to
    be a production programmer can be very different things.

    I know not to change "PI" into something PI isn't. No one needs to
    explain that to me. Adding that I couldn't even if I wanted to -
    that's nice.

    Though, as Dennis Miller likes to sign-off:

    I could be wrong.

    Art
    Arthur, Feb 25, 2004
    #2
    1. Advertising

  3. Dave Brueck

    Dave Brueck Guest

    Arthur wrote:
    > >class Foo:
    > > BAR = 10
    > >
    > >Voila! BAR is now a "class constant" - shared among all instances of the

    class
    > >Foo (in theory it's not a constant, but in practice it is :) ).
    > >
    > >HTH,
    > >Dave
    > >

    >
    > But not 'final'.
    > I am only anticipating a response.
    >
    > IMO - if I am understanidng the issues correctly - it is a perfectly
    > adequate solution. Simple to get across to beginners..
    >
    > The issue of making the constant 'final' is a production programming
    > issue. And whether Python does or does not need it is not an issue
    > relative to teaching beginners. The fact that production programming
    > concerns are introduced at that stage of the game is, I think, where
    > many who would otherwise have an intellectual intererst in programming
    > fall of the wagon. Wanting to understand programming and wanting to
    > be a production programmer can be very different things.


    True, but IMO this particular issue is invalid as a "production programming
    concern" as well - it doesn't prevent any problems that actually occur in
    practice, or if it does, you have bigger problems on your hands. It falls into
    the same bucket of concerns as "our programmers are untrained monkeys and/or
    are seeking to destroy our company from the inside".

    -Dave
    Dave Brueck, Feb 25, 2004
    #3
  4. On Wed, 25 Feb 2004 10:57:30 -0700, "Dave Brueck"
    <> wrote:

    >Arthur wrote:
    >> >class Foo:
    >> > BAR = 10
    >> >
    >> >Voila! BAR is now a "class constant" - shared among all instances of the

    >class
    >> >Foo (in theory it's not a constant, but in practice it is :) ).
    >> >
    >> >HTH,
    >> >Dave
    >> >

    >>
    >> But not 'final'.
    >> I am only anticipating a response.
    >>
    >> IMO - if I am understanidng the issues correctly - it is a perfectly
    >> adequate solution. Simple to get across to beginners..
    >>
    >> The issue of making the constant 'final' is a production programming
    >> issue. And whether Python does or does not need it is not an issue
    >> relative to teaching beginners. The fact that production programming
    >> concerns are introduced at that stage of the game is, I think, where
    >> many who would otherwise have an intellectual intererst in programming
    >> fall of the wagon. Wanting to understand programming and wanting to
    >> be a production programmer can be very different things.

    >
    >True, but IMO this particular issue is invalid as a "production programming
    >concern" as well - it doesn't prevent any problems that actually occur in
    >practice, or if it does, you have bigger problems on your hands. It falls into
    >the same bucket of concerns as "our programmers are untrained monkeys and/or
    >are seeking to destroy our company from the inside".
    >

    +1 on this. If the code has gotten to production, and someone is
    changing (or trying to and silently failing) a final/constant value,
    something seems a little non-production about it. What's the Wiki
    term? CodeSmell?
    --dang
    Dang Griffith, Feb 26, 2004
    #4
    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. zetasum
    Replies:
    0
    Views:
    475
    zetasum
    Feb 18, 2005
  2. zetasum
    Replies:
    0
    Views:
    452
    zetasum
    Feb 18, 2005
  3. New_aspect

    Aspect oriented Everything?

    New_aspect, Aug 22, 2003, in forum: Perl
    Replies:
    5
    Views:
    1,091
    Robert Will
    Aug 31, 2003
  4. b-blochl

    No Thoughts about Everything

    b-blochl, Feb 25, 2004, in forum: Python
    Replies:
    5
    Views:
    352
    Josiah Carlson
    Feb 29, 2004
  5. bblochl

    No Thoughts about Everything

    bblochl, Feb 26, 2004, in forum: Python
    Replies:
    1
    Views:
    283
    Paul Rubin
    Feb 26, 2004
Loading...

Share This Page