How to get/set class attributes in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Hancock

    #31
    Re: How to get/set class attributes in Python

    On Monday 13 June 2005 03:50 pm, Kalle Anke wrote:[color=blue]
    > On Mon, 13 Jun 2005 20:41:48 +0200, Terry Hancock wrote
    > (in article <mailman.391.11 18687097.10512. python-list@python.org >):
    >[color=green]
    > > 1) Assume the variables are of a sensible type (not
    > > necessarily the one you expected, though), and provide
    > > exception handling to catch the case where their interface
    > > does not match what you expect.[/color]
    >
    > The problem I have with this is that I might discover an error at runtime
    > instead of compile time, this means that I need to really exercise all
    > possible test cases to make sure that I've covered everything (which of
    > course is a good thing) but it would be easier to discover this at "compile
    > time".[/color]

    The Python solution to this problem is called "unittest". It is
    at least as easy to do unit testing in Python as it is to properly
    handle type-checking in C or Java.
    [color=blue][color=green]
    > > Let's face it -- should it matter if you "are a programmer"
    > > or only if you "can program"? This is the difference in
    > > philosophy behind a dynamically-typed language like
    > > Python and a statically typed one like Java.[/color]
    >
    > I don't really understand what you're meaning (English isn't my native
    > language as you probably already have discovered)[/color]

    (Actually no, you're quite fluent, AFAICT). I was making
    an analogy:

    Requiring a variable to be, say, a "float" is like insisting that
    only people with the job title "Programmer " be allowed to
    see the language documentation.

    In both situations, real life will confront you with situations
    where you will wish that you had been more tolerant. Lots
    of us are not "Programmer s", but we do quite a bit of programming.

    Likewise, you'll be happier to discover that ints or complex
    numbers work with your code too, without having to jump
    through hoops to make it happen.

    I find the biggest problem coming to Python from a language
    like C, C++, or Java is that you overthink things and try to
    do them the hard way. A lot of times, you find out that the
    "Python way" to do the thing is so blindingly obvious that
    it just didn't occur to you that it could be that simple.

    --
    Terry Hancock ( hancock at anansispacework s.com )
    Anansi Spaceworks http://www.anansispaceworks.com

    Comment

    • Kalle Anke

      #32
      Re: How to get/set class attributes in Python

      On Tue, 14 Jun 2005 06:40:51 +0200, Terry Hancock wrote
      (in article <mailman.407.11 18723034.10512. python-list@python.org >):
      [color=blue]
      > I find the biggest problem coming to Python from a language
      > like C, C++, or Java is that you overthink things and try to
      > do them the hard way. A lot of times, you find out that the
      > "Python way" to do the thing is so blindingly obvious that
      > it just didn't occur to you that it could be that simple.[/color]

      It's very possible that this is the case, I'm not experienced enough in
      Python yet to have a opinion on this yet. I tend to think in terms of larger
      systems with several programmers ... instead of what I'm actually doing
      writing code for my own pleasure.

      But I'm learning new stuff every day ... so in 6 months I'll probably have an
      opinion.


      Comment

      • Simon Brunning

        #33
        Re: How to get/set class attributes in Python

        On 6/12/05, Steve Jorgensen <nospam@nospam. nospam> wrote:[color=blue]
        > Oops - I thought I cancelled that post when I relized I was saying nothing,[/color]

        Would that everyone cancelled their posts when they realised that they
        weren't saying anything. ;-)

        --
        Cheers,
        Simon B,
        simon@brunningo nline.net,

        Comment

        Working...