[Tutor] Debugging While Loops for Control

2012-02-15 Thread Luke Thomas Mergner
Hi,

I've been translating and extending the Blackjack project from codeacademy.com 
into Python. My efforts so far are here: https://gist.github.com/1842131

My problem is that I am using two functions that return True or False to 
determine whether the player receives another card.  Because of the way it 
evaluates the while condition, it either prints too little information or 
previously called the hitMe() function too many times.  I am assuming that I am 
misusing the while loop in this case. If so, is there an elegant alternative 
still running the functions at least once.

e.g. 
while ask_for_raw_input() AND is_the_score_over_21():
hitMe(hand)


Any advice or observations are appreciated, but please don't solve the whole 
puzzle for me at once! And no, not all the functionality of a real game is 
implemented. The code is pretty raw. I'm just a hobbyist trying to learn a few 
things in my spare time.

Thanks in advance.

Luke
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Class definition confusion

2012-02-15 Thread Mark Lawrence

On 15/02/2012 18:35, Hugo Arts wrote:
[snip]


An __init__ might seem like it's special in some way, declaring
attributes. But it's not, really, it's just another method that gets
passed the object it is called on (that would be "self"). It's only
special because it gets called when an object is created, so generally
an object is initialized there and attributes are assigned (hence the
name "init").'

HTH,
Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


To the OP.

Note that __init__ is an initialiser and not a constructor which is 
__new__, see e.g. 
http://mail.python.org/pipermail/tutor/2008-April/061426.html


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread James Reynolds
On Wed, Feb 15, 2012 at 1:30 PM, Alan Gauld wrote:

> On 15/02/12 18:03, James Reynolds wrote:
>
>  >In you table the acc_id is 'mn0001'
>> >In your sql Acc_ID = 'MN0001'
>> >Why the difference in case?
>>
>> Normally, sql doesn't care about case with respect to table names. I
>> believe in certain implementations they are always lower case, even if
>> you pass an upper.
>>
>
> The issue is not the table (or even column name) its the value within it.
> Comparing 'mn0001' to 'MN0001' will fail.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>


I think this depends on the settings of the column and what you have set in
your sql statement.

Example:

if ('j' = 'J')
select 'True'
else
select 'False'

This comes out True

if ('j' = 'k')
select 'True'
else
select 'False'

This comes out False

I suppose this could be by implementation, but at least in sql server, I
think Oracle, and maybe some others, you have to set the database (or
column) to case sensitive by changing it through a collation statement.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Class definition confusion

2012-02-15 Thread Mark Lawrence

On 15/02/2012 18:14, Sivaram Neelakantan wrote:


I was under the impression that you have to define the attributes of
the class before using it in an instance.  Following the book
'thinking in Python',


class Point:

... """pts in 2d space"""
...

print Point

__main__.Point

b = Point()
b.x =3
b.y =4
print b.y

4




Why is it not throwing an error?  This is confusing me a bit.

  sivaram
  --

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



Your impression is incorrect.  This type of behaviour is allowed because 
of Python's dynamic nature, so the following is fine.


>>> class Point:
... """pts in 2d space"""
... 
>>> b = Point()
>>> b.x = 3
>>> b.y = 4
>>> del b.x
>>> del b.y
>>> b.l = 5
>>> b.m = 6
>>> print b, b.l, b.m
<__main__.Point instance at 0x02FB89B8> 5 6

Also be careful of your terminology.  Here we are discussing instance 
attributes.  Class attributes are different in that they are are shared 
at the class level so.


>>> class Point:
... """pts in 2d space"""
... x = 3
... y = 4
... 
>>> a = Point()
>>> b = Point()
>>> a.x
3
>>> b.y
4

HTH.

--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Class definition confusion

2012-02-15 Thread Sivaram Neelakantan
On Thu, Feb 16 2012,Alan Gauld wrote:


[snipped 19 lines]

> Python allows instance attributes to be added at runtime.
> In general this is a bad idea IMHO, a dictionary would probably
> be more appropriate, but there can, very occasionally, be valid
> uses for it.

Thanks for that, I kept thinking that the author had made some typos
in the book and was getting progressively confused, till I tried it at
the prompt.

 sivaram
 -- 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Class definition confusion

2012-02-15 Thread Hugo Arts
On Wed, Feb 15, 2012 at 7:14 PM, Sivaram Neelakantan
 wrote:
>
> I was under the impression that you have to define the attributes of
> the class before using it in an instance.  Following the book
> 'thinking in Python',
>
 class Point:
> ...     """pts in 2d space"""
> ...
 print Point
> __main__.Point
 b = Point()
 b.x =3
 b.y =4
 print b.y
> 4

>
> Why is it not throwing an error?  This is confusing me a bit.
>

Python is different from static languages like C++. You can add and
remove attributes from objects at any time. You do not have to
declare, in your class, what kind of attributes it has.

An __init__ might seem like it's special in some way, declaring
attributes. But it's not, really, it's just another method that gets
passed the object it is called on (that would be "self"). It's only
special because it gets called when an object is created, so generally
an object is initialized there and attributes are assigned (hence the
name "init").'

HTH,
Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Class definition confusion

2012-02-15 Thread Alan Gauld

On 15/02/12 18:14, Sivaram Neelakantan wrote:


I was under the impression that you have to define the attributes of
the class before using it in an instance.


Only in some languages. Python is not one of those.


class Point:

... """pts in 2d space"""
...

b = Point()
b.x =3
b.y =4
print b.y

4




Why is it not throwing an error?  This is confusing me a bit.


Python allows instance attributes to be added at runtime.
In general this is a bad idea IMHO, a dictionary would probably
be more appropriate, but there can, very occasionally, be valid
uses for it.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread Alan Gauld

On 15/02/12 18:03, James Reynolds wrote:


>In you table the acc_id is 'mn0001'
>In your sql Acc_ID = 'MN0001'
>Why the difference in case?

Normally, sql doesn't care about case with respect to table names. I
believe in certain implementations they are always lower case, even if
you pass an upper.


The issue is not the table (or even column name) its the value within 
it. Comparing 'mn0001' to 'MN0001' will fail.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] specific recommendation for a Python book, to move

2012-02-15 Thread Cranky Frankie
The book I recommend is Python Programming, Third Edition, for the
Absolute Beginner, by Michael Dawson. It's Python 3 based. You go from
knowing nothing to writing video games. I think it's great.

-- 
Frank L. "Cranky Frankie" Palmeri
Risible Riding Raconteur & Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Class definition confusion

2012-02-15 Thread Sivaram Neelakantan

I was under the impression that you have to define the attributes of
the class before using it in an instance.  Following the book
'thinking in Python',

>>> class Point:
... """pts in 2d space"""
...
>>> print Point
__main__.Point
>>> b = Point()
>>> b.x =3
>>> b.y =4
>>> print b.y
4
>>>

Why is it not throwing an error?  This is confusing me a bit.

 sivaram
 -- 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Some help Please

2012-02-15 Thread Alan Gauld

On 15/02/12 14:17, JOSEPH MARTIN MPALAKA wrote:

take an example of updating Bank Accounts,
gaving the following table:

acc_id  acc_namestanding_Balance
mn0001  computer 2




cur.execute("UPDATE accounts SET Standing_Amount =
(Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")


Note that in programming consistency is critically important.
In your table description you have standing_Balance.
In your SQL query you have Standing_Amount

Which is it?

Also the ID is mn0001 and MN0001

which is it?


You also use Acc_ID and acc_id but I believe SQL is universally
case agnostic so you probably get away with that. But its
better to be consistent.

How to format the dep will depend on the data format
of your database. If we assume it's an integer then
you have several options:

1) Calculate the total and insert it into the SQL statement (may require 
a select first to retrieve the current value)


2) Replace dep with the value using a MySql format operation. This 
allows you to validate the value before inserting it.


3) Replace dep with the input string as is (slightly harder to do 
validation)


There are probably more...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread James Reynolds
On Wed, Feb 15, 2012 at 12:13 PM, bob gailer  wrote:

> Welcome to python help. We are a few volunteers who donate time to assist.
>
> To assist you better:
> 1 - provide a meaningful subject line - such as "formatting sql"
> 2 - tell us what OS and Python version you are using.
> 3 - what is your prior Python experience?
>
>
> On 2/15/2012 9:17 AM, JOSEPH MARTIN MPALAKA wrote:
>
>> take an example of updating Bank Accounts,
>> gaving the following table:
>>
>> acc_id  acc_namestanding_Balance
>> mn0001  computer 2
>>
>> my problem is how can i credit the standing balance from user data,as
>> in making a deposit onto the computer account, using the code below:-
>>
>>
>>
>> import MySQLdb as mdb
>> import sys
>>
>> con = mdb.connect('localhost', 'joseph', 'jmm20600', 'savings');
>>
>> dep = input('Enter Amount: ')
>>
>> cur.execute("UPDATE accounts SET Standing_Amount =
>> (Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")
>>
> In you table the acc_id is 'mn0001'
> In your sql Acc_ID = 'MN0001'
> Why the difference in case?
> Why the () around Standing_Amount + dep?
>
>
>>conn.commit()
>>
>> HOw do i format "dep" in order to be added onto the standing_Amount,to
>> make an increment?
>>
>> Please, is it the same thing with the withdrawing format, in case i
>> want to decrement the account as in withdrawing??
>>
>>
>> joseph
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
> --
> Bob Gailer
> 919-636-4239
> Chapel Hill NC
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>


Normally, sql doesn't care about case with respect to table names. I
believe in certain implementations they are always lower case, even if you
pass an upper.

The problem, as Bob pointed out above, cur.execute("UPDATE accounts SET
Standing_Amount =
(Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")

here, specifically, (Standing_Amount + dep)

Sql isn't going to have any idea what "dep" is when passed, because it is
going to see a string called "Dep". Well, it will know what it is, it will
be a string and will through an error that it can't add a string and
integer.
When i want to update a value in sql, normally i extract to python, do the
math there, and then update. You can do this in sql if you prefer and I'm
sure there are good reasons for doing it, I'm just more comfortable working
in python than I am sql.

Also, when passing variables to SQL, if you are doing raw queries and not
using some ORM, I would get used to using the "?" within the sql string and
then passing your variables in the following list. Otherwise, you are going
to leave yourself open to injection attacks (provided you are doing direct
string manipulations).

To do this in sql, you need to run a select statement first, saving the
results to a @variable. use that @variable later (after passing in an
integer) to add the two numbers.

To do this in python, also run a select statement, save it to some python
variable. Add your new result to it, and send that new result along to the
DB using your update query.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] formatting sql Was: Some help Please

2012-02-15 Thread bob gailer

Welcome to python help. We are a few volunteers who donate time to assist.

To assist you better:
1 - provide a meaningful subject line - such as "formatting sql"
2 - tell us what OS and Python version you are using.
3 - what is your prior Python experience?


On 2/15/2012 9:17 AM, JOSEPH MARTIN MPALAKA wrote:

take an example of updating Bank Accounts,
gaving the following table:

acc_id  acc_namestanding_Balance
mn0001  computer 2

my problem is how can i credit the standing balance from user data,as
in making a deposit onto the computer account, using the code below:-



import MySQLdb as mdb
import sys

con = mdb.connect('localhost', 'joseph', 'jmm20600', 'savings');

dep = input('Enter Amount: ')

 cur.execute("UPDATE accounts SET Standing_Amount =
(Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")

In you table the acc_id is 'mn0001'
In your sql Acc_ID = 'MN0001'
Why the difference in case?
Why the () around Standing_Amount + dep?



conn.commit()

HOw do i format "dep" in order to be added onto the standing_Amount,to
make an increment?

Please, is it the same thing with the withdrawing format, in case i
want to decrement the account as in withdrawing??


joseph












--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread Mark Lawrence

On 15/02/2012 02:16, Tamar Osher wrote:


Hello!  I have finished reading some Python tutorials.  My favorite tutorial is 
the official tutorial at Python.org.

I
  am hoping to find a professionally designed, serious, university level book 
(with exercises, with
a learning disc, and answers, and an elaborately helpful website) that will 
carefully and surely guide me through
learning computer programming with Python version 3.  I want to be lifted up 
from a baby-level to an intermediate
level.

I
  don't want to spend a lot of time casually browsing through the
websites, trying out different things.  I am in a rush to become a
Python expert, I need a job!  I enjoy computer programming.  Python is my only 
programming language.

A note to Python Teachers:
  I downloaded Python version 3.2.2 on my computer.  Most Python books and tutorials 
are several years old, for older, outdated versions.  My learning Python got off to a 
slow start: Initially, I had spent over a week trying to figure out the (version 2) 
tutorial for "Hello, World!", and the print/print() situation.
  Today, there is a huge and growing number of online Python tutorials and 
websites.  My request is that the list of recommended tutorials be revised and 
updated.  There is a sizable amount of learning and tutorial info at Python.org 
that seems to be valuable historical information rather than 
urgent-read-now-tutorials for new beginning programmers.  For instance, there 
are some very well written Python tutorials from years 2009, 2007, and 2005.  
An idea: Delete all references to tutorials that are not version 2 or 3.  And 
clearly label all the well-written version 2 tutorials, as being outdated 
version 2.
  For me, learning computer programming is easy, so far.  What is difficult 
is finding the proper tutorials, and learning how to manage the difference 
between version 3.2.2 and older versions.  For someone new to programming, the 
difference between version 3.2.2 and the older versions is enormous.  (I have a 
background as a professional classroom teacher.)

I am very eager to get kind help and wise counsel from others.  If I need to 
install install Python version 2, buy a version 2 university-level book, read 
some version 2 tutorials, and do some version 2 exercises, please let me know.  
I want to quickly move myself from a baby-level to a capable, 
intermediate-level Python programmer.

Please contact me when you have time.  I am eager to connect with everyone and 
hear each person's comments.  Have a GREAT day!


From Your Friend: Tamar Osher

Skype: tamarosher
Email: emeraldoff...@hotmail.com
Message Phone: 011- 1- 513-252-2936
www.HowToBeGifted.com - marketing communication, web design, and much more

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


For an unbiased set of book reviews search the book reviews here 
http://accu.org/index.php?module=bookreviews&func=search


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread Brett Ritter
On Wed, Feb 15, 2012 at 7:46 AM, Joel Goldstick
 wrote:
> Programming is all about doing it -- over and over.  I think Malcolm
> Gladwell proposed that it takes 10,000 hours to get good at anything.
> Its great to be smitten, but there is no shortcut.

Jumping in because this is a favorite topic of mine.

The 10,000 hours has been followed-up on a lot, and as a I recall (I'm
no expert) it varies considerably.  Experts (meaning that they have an
intuitive approach to problems) can arise in much less time, while
others (with a rule-based understanding only) can put in far more than
10,000 hours and still not become experts.

What I've found works for me personally is to combine _doing_ (which
is essential and unavoidable) with _variety_ in the tasks and also to
google the heck out of "best practices", "anti-patterns", and "tips"
on the topic.  Make sure to get a feel for the reliability of the
source of these tips, and don't trust them blindly, instead try to
understand them.

For example, there are three levels of progression in handling how
Python uses "self" in objects:

1) This is stupid, other languages are smarter than this.
2) I do it without worrying about it because I'm used to it, but I
don't really get why it works that way.
3) I understand how "obvious" alternatives won't work as Python is
modeled and have come to appreciate the way it works.

You can't jump straight to #3, but if you know it's there you can
regularly poke at the issue as you're otherwise learning (via doing)
and get closer to a higher understanding more quickly than writing
10,000 hours of "To Do" lists will get you there.

Other common enlightenments to strive for:
* I grok list comprehensions
* I understand generators
* I understand decorators
(where understand is more than "can use")

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Some help Please

2012-02-15 Thread Evert Rol
  Hi Joseph,

> take an example of updating Bank Accounts,
> gaving the following table:
> 
> acc_idacc_namestanding_Balance
> mn0001computer 2
> 
> my problem is how can i credit the standing balance from user data,as
> in making a deposit onto the computer account, using the code below:-
> 
> 
> 
> import MySQLdb as mdb
> import sys
> 
> con = mdb.connect('localhost', 'joseph', 'jmm20600', 'savings');
> 
> dep = input('Enter Amount: ')
> 
>cur.execute("UPDATE accounts SET Standing_Amount =
> (Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")
> 
>   conn.commit()
> 
> HOw do i format "dep" in order to be added onto the standing_Amount,to
> make an increment?

First of all, what have you tried? And what problems or errors are you getting?
Then people on the list know better how to reply, and what details you may need 
to know.
For example, the above code is not code that will run: the cur and conn 
variables are undefined, and the indentation appears to be messed up. So it 
would appear you have not tried things out yet.

If I understand your question correctly, however, it is probably fairly 
straightforward: you need to replace the 'dep' variable inside the string with 
a %-sequence, and add the dep inside a tuple as the second argument of the 
execute statement.
An example is probably better:

cur.execute("UPDATE accounts SET Standing_Amount = (Standing_Amount + %s) WHERE 
Acc_ID = 'MN0001'", (dep,))

That will take the value of the variable dep and put it at the %s. Note that 
trailing ',', to make the second argument a tuple.
Note that you may want to first validate that dep is actually a number, not 
some string like "a lot of money"…

But, in fact, this should all be reasonably clear with the help of the MySQLdb 
documentation. From a quick search, I can find: 
http://mysql-python.sourceforge.net/MySQLdb.html#some-examples , which explains 
the above.
For some other details, there is the Python DB API description: 
http://www.python.org/dev/peps/pep-0249/


  Evert


> Please, is it the same thing with the withdrawing format, in case i
> want to decrement the account as in withdrawing??
> 
> 
> joseph

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Some help Please

2012-02-15 Thread JOSEPH MARTIN MPALAKA
take an example of updating Bank Accounts,
gaving the following table:

acc_id  acc_namestanding_Balance
mn0001  computer 2

my problem is how can i credit the standing balance from user data,as
in making a deposit onto the computer account, using the code below:-



import MySQLdb as mdb
import sys

con = mdb.connect('localhost', 'joseph', 'jmm20600', 'savings');

dep = input('Enter Amount: ')

cur.execute("UPDATE accounts SET Standing_Amount =
(Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")

conn.commit()

HOw do i format "dep" in order to be added onto the standing_Amount,to
make an increment?

Please, is it the same thing with the withdrawing format, in case i
want to decrement the account as in withdrawing??


joseph









-- 
MY BEING was HIS BEING.  Of what is magnificent and liked of me, this
was him too. In VAIN, I will always miss u,thou i live with YOU in
vain.
   Lt.Col.Sam .E. Lukakamwa  (DADDY)



-- 
MY BEING was HIS BEING.  Of what is magnificent and liked of me, this
was him too. In VAIN, I will always miss u,thou i live with YOU in
vain.
   Lt.Col.Sam .E. Lukakamwa  (DADDY)



-- 
MY BEING was HIS BEING.  Of what is magnificent and liked of me, this
was him too. In VAIN, I will always miss u,thou i live with YOU in
vain.
   Lt.Col.Sam .E. Lukakamwa  (DADDY)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread Joel Goldstick
On Wed, Feb 15, 2012 at 7:35 AM, leam hall  wrote:
> I will have to agree with both Wes and Alan, they provide great
> resources. However, the issue you will face is three-fold. You need
> to:
>
> 1. Write lots of good code.
> 2. Write lots more good code.
> 3. Show a whole lot of good code you've written.
>
> If you want to program professionally I suggest getting a job in
> computers that is near where you want to be. Develop your programming
> skills and your work reputation at the same time. Your porfolio of
> lots of good code will require more than one language, software
> lifecycle and version control, specification writing,
> etc...etc...etc...
>
> To write good code you need books, experience, and lots of critical
> review. Otherwise you'll be writing lots of bad code that won't get
> you anywhere. Feedback is critical to growth.
>
> Leam
>
> --
> Mind on a Mission 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Programming is all about doing it -- over and over.  I think Malcolm
Gladwell proposed that it takes 10,000 hours to get good at anything.
Its great to be smitten, but there is no shortcut.

Aside from Brooks, I really loved reading a two volume set called
Programming Practice by Henry Ledgard.  It was published in 1987, but
its timeless.

These authors don't write 'how to' books on coding, but they get to
the core of the software engineering profession.

-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread leam hall
I will have to agree with both Wes and Alan, they provide great
resources. However, the issue you will face is three-fold. You need
to:

1. Write lots of good code.
2. Write lots more good code.
3. Show a whole lot of good code you've written.

If you want to program professionally I suggest getting a job in
computers that is near where you want to be. Develop your programming
skills and your work reputation at the same time. Your porfolio of
lots of good code will require more than one language, software
lifecycle and version control, specification writing,
etc...etc...etc...

To write good code you need books, experience, and lots of critical
review. Otherwise you'll be writing lots of bad code that won't get
you anywhere. Feedback is critical to growth.

Leam

-- 
Mind on a Mission 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread wesley chun
tooting my own horn, http://corepython.com gets good reviews too. however,
it does target existing programmers who want to learn Python as quickly and
as comprehensively as possible. it's not a good book if you're a beginner
to programming or are looking for a pure reference like PER or Nutshell.

if you really need a learning disc, a subset of my book and the slides i
use to teach with can be found in the Python Fundamentals DVD that i
authored as well, however it is *not* a "showmedo" video of Python hacking.
rather, it's a subset of my lectures that come from my Python courses.

i'm also book-agnostic but am concerned that readers get the right book for
their needs, so i would be glad to recommend other books outside of my own.

cheers,
--wesley



On Wed, Feb 15, 2012 at 1:28 AM, Alan Gauld wrote:

> On 15/02/12 02:16, Tamar Osher wrote:
>
>  I am hoping to find a professionally designed, serious, university level
>> book (with exercises, with a learning disc, and answers, and an
>> elaborately helpful website) that will carefully and surely guide me
>> through learning computer programming with Python version 3. I want to
>> be lifted up from a baby-level to an intermediate level.
>>
>
> I don;t know about a CD etc but its a good book:
>
> Programming in Python 3 by Summerfield.
>
> And as a general intermediate book I like
>
> Programming Python by Lutz (not in v3 yet but as an
> intermediate programmer that won't make any difference
> to you, your past worrying about that)
>
>
>  I don't want to spend a lot of time casually browsing through the
>> websites, trying out different things.
>>
>
> A pity, its the best way to learn.
>
>
> > I am in a rush to become a Python expert, I need a job!
>
> Go write lots of code.
>
>
>  I enjoy computer programming. Python is my only programming language.
>>
>
> To get and keep a job you will need more than one.
> As a minimum you will probably need SQL and nowadays
> at least some JavaScript will be useful. And an OS shell
> language would be useful too. As a minimum.
>
>
>  A note to Python Teachers:
>> I downloaded Python version 3.2.2 on my computer. Most Python books and
>> tutorials are several years old, for older, outdated versions.
>>
>
> Yes, because to produce them takes a lot of time. And most online
> tutorials are done by volunteers with another lifew - the one that earns
> them money. So they can't write tutorials as fast as the language evolves.
> Or they only have time to write a tutorial once, not to update it. The good
> news is that Python is fairly stable and most things still work even from
> version 1.
>
>
>  learning Python got off to a slow start: Initially, I had spent over a
>> week trying to figure out the (version 2) tutorial for "Hello, World!",
>> and the print/print() situation.
>>
>
> Really? If you had asked here. or even read the v3 documentation you would
> have had print()  explained in great detail.
>
>
>  Today, there is a huge and growing number of online Python tutorials and
>> websites. My request is that the list of recommended tutorials be
>> revised and updated. There is a sizable amount of learning and tutorial
>> info at Python.org that seems to be valuable historical information
>> rather than urgent-read-now-tutorials for new beginning programmers.
>>
>
> Remember that many - most? - professional Python programmers are still
> using Python v2 not v3. There are still some critical third party libraries
> to be ported to v3. It is getting better but we are not there yet. At the
> very least they are maintaining v2 code. I use both versions but only about
> 20-25% of my time is spent in v3. v2 is not only of "historical" interest,
> its what the majority of Python code is written in, even today.
>
>
>  instance, there are some very well written Python tutorials from years
>> 2009, 2007, and 2005. An idea: Delete all references to tutorials that
>> are not version 2 or 3.
>>
>
> v1 Python is possibly a valid point. But most v1 tutorials are still valid
> in v2, there was much less change from v1 to v2.
>
>
>  And clearly label all the well-written version 2 tutorials, as
>>
> > being outdated version 2.
>
> Who determines what is "well written"? And if a tutorial is based on v2.7
> is it really outdated?
>
>
>  For me, learning computer programming is easy, so far.
>>
>
> That's good, so you will have realized that the language, and especially
> the language version is largely irrelevant. What is important is structure,
> algorithm, data and I/O.
>
>  What is difficult is ...learning how to manage the
>>
>> difference between version 3.2.2 and older versions.
>>
>
> No, that's trivially easy. If you think that's difficult then you haven't
> begun to understand computer science. I strongly suggest you search for and
> read the classic paper by Fred Brooks called "No silver bullet"
> There he describes the "essential" problems at the heart of programming
> and why there are no easy answers. Languages included.
>
>
>  For

Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread Alan Gauld

On 15/02/12 02:16, Tamar Osher wrote:


I am hoping to find a professionally designed, serious, university level
book (with exercises, with a learning disc, and answers, and an
elaborately helpful website) that will carefully and surely guide me
through learning computer programming with Python version 3. I want to
be lifted up from a baby-level to an intermediate level.


I don;t know about a CD etc but its a good book:

Programming in Python 3 by Summerfield.

And as a general intermediate book I like

Programming Python by Lutz (not in v3 yet but as an
intermediate programmer that won't make any difference
to you, your past worrying about that)


I don't want to spend a lot of time casually browsing through the
websites, trying out different things.


A pity, its the best way to learn.

> I am in a rush to become a Python expert, I need a job!

Go write lots of code.


I enjoy computer programming. Python is my only programming language.


To get and keep a job you will need more than one.
As a minimum you will probably need SQL and nowadays
at least some JavaScript will be useful. And an OS shell
language would be useful too. As a minimum.


A note to Python Teachers:
I downloaded Python version 3.2.2 on my computer. Most Python books and
tutorials are several years old, for older, outdated versions.


Yes, because to produce them takes a lot of time. And most online 
tutorials are done by volunteers with another lifew - the one that earns 
them money. So they can't write tutorials as fast as the language 
evolves. Or they only have time to write a tutorial once, not to update 
it. The good news is that Python is fairly stable and most things still 
work even from version 1.



learning Python got off to a slow start: Initially, I had spent over a
week trying to figure out the (version 2) tutorial for "Hello, World!",
and the print/print() situation.


Really? If you had asked here. or even read the v3 documentation you 
would have had print()  explained in great detail.



Today, there is a huge and growing number of online Python tutorials and
websites. My request is that the list of recommended tutorials be
revised and updated. There is a sizable amount of learning and tutorial
info at Python.org that seems to be valuable historical information
rather than urgent-read-now-tutorials for new beginning programmers.


Remember that many - most? - professional Python programmers are still 
using Python v2 not v3. There are still some critical third party 
libraries to be ported to v3. It is getting better but we are not there 
yet. At the very least they are maintaining v2 code. I use both versions 
but only about 20-25% of my time is spent in v3. v2 is not only of 
"historical" interest, its what the majority of Python code is written 
in, even today.



instance, there are some very well written Python tutorials from years
2009, 2007, and 2005. An idea: Delete all references to tutorials that
are not version 2 or 3.


v1 Python is possibly a valid point. But most v1 tutorials are still 
valid in v2, there was much less change from v1 to v2.



And clearly label all the well-written version 2 tutorials, as

> being outdated version 2.

Who determines what is "well written"? And if a tutorial is based on 
v2.7 is it really outdated?



For me, learning computer programming is easy, so far.


That's good, so you will have realized that the language, and especially 
the language version is largely irrelevant. What is important is 
structure, algorithm, data and I/O.



What is difficult is ...learning how to manage the
difference between version 3.2.2 and older versions.


No, that's trivially easy. If you think that's difficult then you 
haven't begun to understand computer science. I strongly suggest you 
search for and read the classic paper by Fred Brooks called "No silver 
bullet"
There he describes the "essential" problems at the heart of programming 
and why there are no easy answers. Languages included.



For someone new to programming, the difference between version 3.2.2

> and the older versions is enormous.

I agree and thats why I still tend to recommend a newcomer stick to v2 
for now. There are more tutorials and they are more mature and there are 
more practitioners using it than v3. All of which makes it easier to get 
answers for v2 than for v3. The situation is changing but v3 is not 
mainstream yet.



please let me know. I want to quickly move myself from a baby-level to a
capable, intermediate-level Python programmer.


It depends on your expectations but the quickest way to get competent in 
any programming language is through use. Once you have written several 
tens of thousands of lines of code you will be well on your way. But 
that will take quite a few months and that may not align with your 
expectations.


Reading books will teach you the theory (but for that you would be 
better off reading books like The Structure and Interpretation of 
Computer Programs (aka SICP) by Suss