Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Python in One Easy Lesson  (Read 17641 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Python in One Easy Lesson
« Reply #30 on: January 10, 2014, 08:56:00 AM »
Thanks Allen. The post was about somebody who made a real serious effort to teach Python quickly  to programmers that already have some skills.

Older programming tools are very strict about making declarations as to date type and functions. Python belongs to a set of tools that makes the right guess as to what a human wants n do do with code.

The Arduino controller, and other s like it, is programmed mostly in C.  And sometimes in Tiny BASIC or Java.  But for many, the style of a language is not as important as to its libraries. Python has a rich set o libraries and is easy to learn.

EDIT: Relevant to Python and Arduino.
Recent articles about Arduino  and Python

http://makezine.com/projects/arduino-and-python-learn-serial-programming/

http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial

http://www.wired.co.uk/news/archive/2013-12/06/micro-python

« Last Edit: January 10, 2014, 09:23:17 AM by Geek-9pm »

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Python in One Easy Lesson
« Reply #31 on: January 10, 2014, 08:58:18 AM »
For those of you who don't know what Snake Wrangling is, here is the link to it.
http://www.briggs.net.nz/snake-wrangling-for-kids.html

It is a FREE E-BOOK that helps teach kids to program in python.  It makes it very fun for them to learn it.  I have my two boys using it.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Python in One Easy Lesson
« Reply #32 on: January 10, 2014, 10:35:46 AM »
For those of you who don't know what Snake Wrangling is, here is the link to it.
http://www.briggs.net.nz/snake-wrangling-for-kids.html

It is a FREE E-BOOK that helps teach kids to program in python.  It makes it very fun for them to learn it.  I have my two boys using it.

Perhaps I'm too pedantic but I'd avoid any source that uses Snake metaphors with Python, because the language was not actually named after the animal, but rather Monty Python's flying Circus. Though in retrospect that's a dumb reason not to use a specific source. I guess it's just liable to make me wonder what else they got wrong. On the other hand I imagine retconning the name temporarily makes it more kid-friendly.

One thing nice about Python is that it is actually pretty tricky to make unreadable. You'd have to put effort into it, because readability constraints are part of the syntax (eg. the spacing for control flow).

On the other hand, one weird thing is that the self reference has to be specified explicitly (I guess since the methods don't have modifiers, it's the only way to differentiate a class method from an instance method), and "special" methods like __getitem__ have those funky underscores to flag them as a special function, but because those are usually accessed using something else they don't typically appear except at declaration. (And they have to be tagged somehow).


Quote
second, the OP does not specifically state its only for Python discussion.

Title: About Python
Reply #1: Python.
Reply #2: Python.
Reply #3: Python.
Reply #4: Python.
Reply #5: Perl.

Thread subjects are not a game of Duck, Duck, Goose.

I was trying to dereference Null Pointers before it was cool.

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Python in One Easy Lesson
« Reply #33 on: January 10, 2014, 10:54:07 AM »
Perhaps I'm too pedantic but I'd avoid any source that uses Snake metaphors with Python, because the language was not actually named after the animal, but rather Monty Python's flying Circus. Though in retrospect that's a dumb reason not to use a specific source. I guess it's just liable to make me wonder what else they got wrong. On the other hand I imagine retconning the name temporarily makes it more kid-friendly.

Page 3 of the book.
Quote
Apart from being a snake, Python is also a programming language. However,
it was not named after a legless reptile; rather it is one of the few programming
languages named after a TV show. Monty Python was a British comedy show
popular during the 1970’s (and still popular now, actually), which you have to be a
certain age to find amusing. Anyone below the age of about. . . let’s say 12. . . will
wonder what all the fuss is all about

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Python in One Easy Lesson
« Reply #34 on: January 10, 2014, 11:00:37 AM »
Page 3 of the book.

Cool, it was a purposeful/temporary retcon to make it more accessible.
I was trying to dereference Null Pointers before it was cool.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Python in One Easy Lesson
« Reply #35 on: January 10, 2014, 11:27:51 AM »

briandams



    Beginner

    Thanked: 2
    • Experience: Guru
    • OS: Unknown
    Re: Python in One Easy Lesson
    « Reply #36 on: January 10, 2014, 06:34:48 PM »
    One thing nice about Python is that it is actually pretty tricky to make unreadable. You'd have to put effort into it, because readability constraints are part of the syntax (eg. the spacing for control flow).
    well, because its object oriented, most often times you can write code like this
    Code: [Select]
    method1(**args).method2( **args ).somethingelse( **args)
    still, it depends on programmer. If he chooses to write something like this
    Code: [Select]
    f=lambda x="8<:477\02092020162\020\037",y="01001000110100101":reduce(lambda
    x,y:x+y,map(lambda y,x:chr(ord(y)*2+x),x,map(int,y)));print f();
    or this
    Code: [Select]
      print ''.join('%(pre)s%(num)s %(bot)s on the wall, %(nul)s %(bot)s,\n%(tak)s\n' % (lambda c,b:
      {'pre':['','%s %s on the wall.\n\n' % (c,b)][abs(cmp(c,'Ninety-nine'))],
     'num':c, 'nul':c.lower(), 'bot':b,
     'tak':['Go to the store and buy some more... Ninety-nine %s.' % b,'Take one down, pass it around,'][abs(cmp(x,0))]
      })((lambda x,o: [(['Twenty','Thirty','Forty','Fifty',
      'Sixty','Seventy','Eighty','Ninety'][x/10-2]+'-'+o.lower()).replace('-no more',''), o][int(x<20)])(x, ['No more','One','Two',
      'Three','Four','Five','Six','Seven','Eight',
      'Nine','Ten','Eleven','Twelve','Thirteen','Fourteen',
      'Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'][[x,x%10][int(x>=20)]]),'bottle%s of beer' % ['','s'][abs(cmp(x,1))])
      for x in xrange(99,-1,-1))

    some of the things that can lead to unread Python code
     - nested lambdas
     - redefine functions by assignment
     - make an single instance of the % operator used for both modulus and string formatting
     - same with +, * for addition, string concatenation, etc.
     - evade indentation enforcement by writing things in recursive pseudo-functional ways
     - do something like foo(bar(), baz()) where bar() redefines foo() and baz()
     - litter the code with numeric and string literals that look like they're doing something (but don't)
     - cause exceptions solely for the purpose of later extracting obscure data from them

    Copied from here

    Python code, can be made unreadable! Its all about the programmer! No one can deny that, not even Quantos.
    and not to mention, because languages that doesn't have static typing often make it not easy to understand what variables stand for, unless we have good naming convention. eg myvar_int , myvar_str 

    On the other hand, one weird thing is that the self reference has to be specified explicitly (I guess since the methods don't have modifiers, it's the only way to differentiate a class method from an instance method), and "special" methods like __getitem__ have those funky underscores to flag them as a special function, but because those are usually accessed using something else they don't typically appear except at declaration. (And they have to be tagged somehow).
    all language have their quirks. What matters is, use their syntax correctly and make it do the job. That's more important than ranting.


    Title: About Python
    Reply #1: Python.
    Reply #2: Python.
    Reply #3: Python.
    Reply #4: Python.
    Reply #5: Perl.

    Thread subjects are not a game of Duck, Duck, Goose.
    wrong. #2 is game. I didn't post any Perl code , or Java code, or Ruby code, or PHP code. Please, if you want to start this, I am game. The thread just  merely says "Python in one easy lesson". Thread author didn't say anything else with regards to discusson on other languages. Why are all these assumptions made that only Python can be discussed. This is a fact. Don't deny it. If you people don't like my comments, then debate it and refute my points like a knowledgable adult, don't keep giving the excuse that "this thread is only for Python" and only Python can be discussed. FYI, this thread is in a Computer programming forum. Its not in a purely Python forum. And this is also a fact.

    What is so hard to understsand that I merely posted a factual comment, that most languages with good RS232 libraries can also do the job ? So difficult to understand that its a general observable, factual comment and you people have to make it sound like a language war.
    « Last Edit: January 10, 2014, 06:54:03 PM by briandams »

    Geek-9pm

      Topic Starter

      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Python in One Easy Lesson
    « Reply #37 on: January 10, 2014, 07:50:30 PM »
    Quote
    most languages with good RS232 libraries can also do the job
    That is true. Nowadays a serial library ought  also have other serial standards. USB 2.0 ought to be in the library for applications using embedded devices. I was mildly pressurized that good libraries on now available in Python and other popular computer languages. In the days of my youth I had write code at the lowest level and integrate it into a higher language. 

    briandams



      Beginner

      Thanked: 2
      • Experience: Guru
      • OS: Unknown
      Re: Python in One Easy Lesson
      « Reply #38 on: January 10, 2014, 08:13:25 PM »
      That is true. Nowadays a serial library ought  also have other serial standards. USB 2.0 ought to be in the library for applications using embedded devices. I was mildly pressurized that good libraries on now available in Python and other popular computer languages. In the days of my youth I had write code at the lowest level and integrate it into a higher language.

      at last, some decent discussion. Last time there was cheeseshop, now they call it pypi , the "CPAN" of Python.