Learning Python

Are you turning into a developer?
A colleague I respect asked me if I was learning to code because of fear/money/jobs. That is a very valid question. I'm working on a project that I'm more effective at testing with more scripts. I am a tester. This means I do my best to use all of the skills and tools that apply to do the best testing I possibly can. I also continue to grow as a tester. I am not a naturally talented coder, and as a creative person at times I've wanted to give up. Luckily, I've had some patient mentors willing to talk me down from the ledge at those moments. I'm proud of the work I'm doing because it is right for this project and also because I feel like what I am learning is making me a better tester. It is not making me a developer.

Since I've been working more with Python I can now understand Java better! I can read other people's code and follow it more often. I'm pleased that I can get test ideas from what I think is missing in the code, not just what I see that is there. I see why peer reviews work because when I code my focus is on making it work. Being good at testing does not mean you automatically test your own code. It is hard to learn good practices even when writing small test scripts. The good news is a CAN test my code, I just need to set aside a different time to do it and focus all of my energy on that. The trick to wearing multiple hats is to not try to wear them all at once. It makes your head overheat and looks silly.

In the past month I've gone from putting together scripts other people wrote and making a few edits to making some of my own scripts and pairing with other people so that I can collaborate on scripts. I'm at the point where I can make a function, then write a small test that uses that function. Later I can hook them all together without getting lost as easily as I was before. I am not making custom classes yet, but I can follow scripts that do without much trouble. Lists and arrays are making more sense to me. I am understanding appending lists and I can handle some strings now. I also am doing a bit of using numbers as strings and I can keep track of them now without a headache. I am at the point where I giggle at jokes from Pycon about lingerie because I remember typing Pythong at the command line on accident. I'm still early on in my script writing, but it has been an intense and productive month for me.

Numbers
Math in Python is easy to read, easy to do, and generally has been a joy!
Example:
def passFailResults(builds):
    if len(completed) > 0:
        myNum = len(completed)/len(sentBuild)
        perCom=myNum*100
        print "%.2f" % perCom, "%"
    else:
        print "No builds have a job status of completed."

Rounding
Rounding sucks so much. It confuses me and I never ever want to do it again. In fact, I hope to avoid it for my next project if I can at all. Deciding when you need to round and when you can just use the real number and only SHOW the rounded part is confusing to me still. It took me way too much time to figure out I wanted %.2f and not to really round.

Documentation
I wish that there was a line in the documentation or a warning that said: "This is possible. We include it because Python can do this. However, if you read it it will confuse you right now and it isn't likely you need this in MOST situations. It could be a photo of a girl in glasses with crossed eyes and her tongue hanging out in exhaustion. The "stay away" sign. Some of my worst mistakes have been making things too complicated and trying things I didn't need to do myself. Python isn't a big problem, but I certainly am. I can take something easy and over think it without much encouragement.

What Now?
Well, I'm working on some testing. I did coding for about 4 weeks straight with very little testing and I gained some new skills. I am glad I did so and I hope to work on some more evenly paced projects. I'd like to leave feeling like it was fun instead of beaten down and glad to survive. Sort of like singing and dancing though, you have to have some skills and know the basics before it starts to be fun. I realize this and if you don't practice you'll never be good enough to join the group in song, let alone contribute a memorable solo. I'm getting better at naming and keeping track of variables and scope. The key to me learning is having a real project that adds value to my testing. I'm learning only because I don't give up when it gets difficult.

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments

  • 22 Feb 2010 Ted M. Young wrote:
    Keep on learning, Lanette -- sounds like you're having fun despite the frustrations. And those frustrations are something all coders go through, especially rounding/formatting numbers. Wait until you get to dates.

    As for documentation, every language has those "concise" ways of doing things that end up being unreadable. I try and stop before I hit that point. As they say, you'll write it once, but read it forever, so optimize for reading.
    Reply to this
    1. 23 Feb 2010 Lanette wrote:
      You may be shocked to find out that I got some experience working with date/time, but I had to get help. We did everything in seconds until the end, which helped. Time is a constant source of agony for us when predicting "duration".
      Reply to this
  • 22 Feb 2010 Pekka Klarck wrote:
    For me the easiest way to test my own code is using TDD. With it I switch my tester and coder hats all the time.

    To get more use for your new Python skills, you might want to take a look at Robot Framework (http://robotframework.org). Also non-programmers can use it, but Python and Java are the languages you can use to extend it.

    PS: It seems someone has forgotten to test the code used to verify the above name field with non-ASCII characters. When trying to use my real family name "Klärck" I got an error that the name must be alpha-numeric.
    Reply to this
    1. 23 Feb 2010 Lanette wrote:
      Cool observation! You'll be happy to know that we have a whole other script that checks for proper naming conventions (which do not allow non-ASCII characters) that reports an error nicely before this script is run.

      I'm not doing full TDD yet, but I'm taking steps toward it as I gain more skill. Slowly. I think it is really useful but not always practical for all projects. The context and intended use of the script matters. For example, my calculations go to me only, so formatting isn't as important as if others relied on them. Some test scripts just need to work well enough to perform the check where others can do serious damage to real data if incorrect. I've learned now to be very explicit in the script about working with staging servers vs production.

      I've heard good things about Robot Framework and also I may have a chance to work on a small Iron Python project with Craig to allow me to learn about making custom classes which I've not done yet.
      Reply to this
      1. 23 Feb 2010 Pekka Klarck wrote:
        TDD isn't always the right tool--no tool or approach ever is. In those cases where you after-the-fact realize that you aren't sure how to test your code, it probably would've have helped.

        It would be great to get more users interested in running Robot Framework on IronPython. None of the core devs know that platform too well so we would be grateful from help making RF fully compatible with it. Happy to hear about positive feedback!

        Phil Kirkham asked about Python resources. These two open source books are ones I normally recommend:
        1) Dive Into Python (http://diveintopython.org) for experiences programmers.
        2) Think Python (http://www.greenteapress.com/thinkpython/thinkpython.html) for people w/o previous programming experience.
        Reply to this
        1. 24 Feb 2010 Phil Kirkham wrote:
          Thanks for the book recommendations, I'll check them out
          Reply to this
  • 23 Feb 2010 phil kirkham wrote:
    what resources have you found useful helping to learn Python ?
    Reply to this
    1. 23 Feb 2010 Lanette wrote:
      I'm very lucky to be able to ask questions to people who've got experience. That is more useful than anything else I've tried.
      Reply to this
Leave a comment

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.