Author Topic: Coding and Scripting > Learning Python  (Read 8267 times)

Online gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3881
Re: Coding and Scripting > Learning Python
« Reply #30 on: December 10, 2009, 07:43:06 PM »
I won't be able to look at this until about Saturday, but it looks like all good stuff!

Galen

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6470
  • I'm going South
Re: Coding and Scripting > Learning Python
« Reply #31 on: December 10, 2009, 07:48:39 PM »
it looks like all good stuff!

It is!  ;D
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline Andy Axnot

  • Hero Member
  • *****
  • Posts: 695
Re: Coding and Scripting > Learning Python
« Reply #32 on: December 12, 2009, 05:12:17 PM »
Whoo!  I feel a bit like a python myself.  One who has just ingested a rather large chocolate bunny for dinner.  Excellent segment!

Digestion time.   ;D

Andy
Greetings from beautiful downtown Brooklyn, NY   USA
  Still searching for a replacement for KDE3; E17 is looking good; LXDE, too

"all will be fine soon, once kde3 is back on the main repos" - Titus T6us    :o

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12657
Re: Coding and Scripting > Learning Python
« Reply #33 on: December 12, 2009, 05:16:57 PM »
Whoo!  I feel a bit like a python myself.  One who has just ingested a rather large chocolate bunny for dinner.  Excellent segment!

Digestion time.   ;D

Andy


*BURP*

Thanks to everyone who donates. You keep the servers running.
Follow me on Twitter for the latest development info.

Offline Andy Axnot

  • Hero Member
  • *****
  • Posts: 695
Re: Coding and Scripting > Learning Python
« Reply #34 on: December 12, 2009, 08:07:54 PM »
Whoo!  I feel a bit like a python myself.  One who has just ingested a rather large chocolate bunny for dinner.  Excellent segment!

Digestion time.   ;D

Andy


*BURP*

Yes, indeed!   ;D

Andy
Greetings from beautiful downtown Brooklyn, NY   USA
  Still searching for a replacement for KDE3; E17 is looking good; LXDE, too

"all will be fine soon, once kde3 is back on the main repos" - Titus T6us    :o

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Coding and Scripting > Learning Python
« Reply #35 on: December 12, 2009, 09:46:55 PM »
How about opening another thread for questions so that this one does not get clogged?



As this thread is already quickly filling with questions / comments, I took the liberty to compile the lessons in a seperate thread:

http://www.pclinuxos.com/forum/index.php/topic,66292.0.html

..perhaps Neal, O-P, or any of the other mods could help in this effort, as I may not be very timely over the next few weeks..   (..holiday travel  :-X :o).  Neptune, please PM any one (or more) of us as the lessons are posted and we will add them to the locked thread. 

For those only interested in new lessons and not the associated chatter, take note that you can subscribe to notifications for the locked "lessons only" thread, and you will be notified only when new lessons are available.. just use the notify button on the thread to subscribe / unsubscribe.
 ;) ;D
« Last Edit: December 12, 2009, 09:52:56 PM by travisn000 »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Coding and Scripting > Learning Python
« Reply #36 on: December 13, 2009, 04:52:56 AM »
Thanks, Travis. :)

Offline Andy Axnot

  • Hero Member
  • *****
  • Posts: 695
Re: Coding and Scripting > Learning Python
« Reply #37 on: December 19, 2009, 08:31:09 AM »
It looks like we are on Winter Break.

Just as I did in school (OK, unlike what I did from grade school to grad school), I'm going to use this time to review and read ahead so as to be better able to cope with new material.  I even dug out my Python book and I've read the first two pages of chapter one.

Well, it's a start.   :-[

Andy


Greetings from beautiful downtown Brooklyn, NY   USA
  Still searching for a replacement for KDE3; E17 is looking good; LXDE, too

"all will be fine soon, once kde3 is back on the main repos" - Titus T6us    :o

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Coding and Scripting > Learning Python
« Reply #38 on: December 19, 2009, 11:57:27 PM »
While you are studying, see if you can become a pyQT master...  if so I have a project for you:

http://mypclinuxos.com/forum/index.php?topic=2670.0

 ;) ;D 8)

Offline Andy Axnot

  • Hero Member
  • *****
  • Posts: 695
Re: Coding and Scripting > Learning Python
« Reply #39 on: December 20, 2009, 06:41:02 AM »
While you are studying, see if you can become a pyQT master...  if so I have a project for you:

http://mypclinuxos.com/forum/index.php?topic=2670.0

 ;) ;D 8)

Travis, I will be delighted to help out...

...
I even dug out my Python book and I've read the first two pages of chapter one.
...


but it may take a little while.   ;D

Actually, since you're scouting Hungarian Mandriva-based distros for pyQT scripts and are able to modify them, it may take a long time before I can catch up enough to help.   ;)

Andy
Greetings from beautiful downtown Brooklyn, NY   USA
  Still searching for a replacement for KDE3; E17 is looking good; LXDE, too

"all will be fine soon, once kde3 is back on the main repos" - Titus T6us    :o

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Coding and Scripting > Learning Python
« Reply #40 on: December 20, 2009, 08:31:43 AM »
The modificatiion part came by google and trial and error..   It took me days just to get a single button to display...  

...days later I gave up on making it actually do anything useful!

:D
« Last Edit: December 20, 2009, 09:39:43 AM by travisn000 »

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Coding and Scripting > Learning Python
« Reply #41 on: December 22, 2009, 06:19:20 PM »
Some interesting python code for Amazon Kindle users..  purely for educational purposes!  ;D ::)

http://pastie.org/753699


Offline coolbreeze

  • Hero Member
  • *****
  • Posts: 2682
  • Error #152 - Windows not found: (C)heer (P)arty (D
Re: Coding and Scripting > Learning Python
« Reply #42 on: December 30, 2009, 11:59:30 AM »
Just had a look at the tute at the top, tried the examples but on one something not right, at the bottom the returns are different to what i should have got. Am i missing something?, i copy/pasted so not to make a mistake.


[micheal@localhost ~]$ cd ~
[micheal@localhost ~]$ mkdir -p pyedu/{lesson01/notes,lesson02/notes,lesson03/notes,lesson04/notes,lesson05/notes}                                                                                                         
[micheal@localhost ~]$ cd pyedu/lesson01                                                                     
[micheal@localhost lesson01]$ python                                                                         
Python 2.5.2 (r252:60911, Jun 28 2008, 14:11:09)                                                             
[GCC 4.1.1 20060724 (prerelease) (4.1.1-4pclos2007)] on linux2                                               
Type "help", "copyright", "credits" or "license" for more information.
>>> 'abcde'[ 0 ]
'a'
>>> 'abcde'[ 3 ]
'd'
>>> 'abcde'[ 9 ]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> 'abcde'[-1]
'e'
>>> 'abcde'[-3]
'c'
>>>  'abcde'[-9]
  File "<stdin>", line 1
    'abcde'[-9]
    ^
IndentationError: unexpected indent
>>> abcde'[-0]
  File "<stdin>", line 1
    abcde'[-0]
             ^
SyntaxError: EOL while scanning single-quoted string
>>>
Linux user #440309
PCLOS IS THE KING  Please Donate to the cause. PCLinuxOS
Asinus caput tuum a te: et esto vigilans!
M5A78L-M mobo, AMD Phenom IIx 6 1055T, 4Gig ram,nvidia GeForce GT 240 1 Gig, Netgear DGN2200

Online gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3881
Re: Coding and Scripting > Learning Python
« Reply #43 on: December 30, 2009, 12:10:01 PM »
I got the same as you. But the errors come from exceeding the array. I think that error catching of some kind is necessary for python to recover from inappropriate values.

Galen

Offline Andy Axnot

  • Hero Member
  • *****
  • Posts: 695
Re: Coding and Scripting > Learning Python
« Reply #44 on: December 30, 2009, 04:14:08 PM »
coolbreeze, check your entries in the Python interpreter.  It is quite unforgiving in some ways.

If you check the entry above "IndentationError: unexpected indent" you'll see you have a  space  before the  'abcde'[-9], that is,
>>>  'abcde'[-9]
when it should be
>>> 'abcde'[-9]
Python considers this an indentation which would mark the beginning of a new block of code.  It's sometimes difficult for us humans to notice these things but computers just love that stuff and never miss a thing.

The other problem entry (>>> abcde'[-0]), if you look closely you'll notice there is no single quote  before  the abcde.  So the computer is right, there is a "SyntaxError: EOL while scanning single-quoted string".

So the code in the tutorial seems to work just fine, but we neophytes have to be careful to enter it exactly as it was presented.

Now, is a neophyte better or worse than a newbie?   ;D ;D

Andy
Greetings from beautiful downtown Brooklyn, NY   USA
  Still searching for a replacement for KDE3; E17 is looking good; LXDE, too

"all will be fine soon, once kde3 is back on the main repos" - Titus T6us    :o