PDA

View Full Version : Teaching Python to C/C++ users



P1C0
November 4th, 2011, 09:41 PM
I have 2 to 3 hours to introduce Python to C/C++, decent, users. I suppose I have to focus on the main differences between Python and C/C++, but I'm a bit lost..

I was thinking something like:


Showing how you declare variables in Python and what a Python code snippet looks like (indentation, reserved words, function declarations, assignments, e.t.c).
Explaining how everything is an object, and what immutable and mutable objects are.
Introducing them to lists, tuples, dictionaries, sets, and closures.
Showing some looping techniques (also do-while doesn't exist in python), list comprehensions, and generators maybe.
Introducing them to Lambda functions
Showing some OOP features, by constructing some classes and instances, and also demonstrating the link between class methods and closures.
Explaining exception handling.
Closing up with some examples.


The students will have to write some Python code for a project, but nth extreme, really.

I would appreciate any advice or comments :)

Lucradia
November 4th, 2011, 11:46 PM
You don't have to teach them outright. Use Python.Boost.

http://www.boost.org/doc/libs/1_47_0/libs/python/doc/

if you need to transition them to 3D on top of that, use Python Ogre. Also a note, Python is inherently made and optimized for human-readability.

gsmanners
November 5th, 2011, 12:10 AM
I have 2 to 3 hours to introduce Python to C/C++, decent, users. I suppose I have to focus on the main differences between Python and C/C++, but I'm a bit lost..

I was thinking something like:


Showing how you declare variables in Python and what a Python code snippet looks like (indentation, reserved words, function declarations, assignments, e.t.c).
Explaining how everything is an object, and what immutable and mutable objects are.
Introducing them to lists, tuples, dictionaries, sets, and closures.
Showing some looping techniques (also do-while doesn't exist in python), list comprehensions, and generators maybe.
Introducing them to Lambda functions
Showing some OOP features, by constructing some classes and instances, and also demonstrating the link between class methods and closures.
Explaining exception handling.
Closing up with some examples.


The students will have to write some Python code for a project, but nth extreme, really.

I would appreciate any advice or comments :)

Sounds like an entire semester, to me. How many sessions do you have?

t0p
November 5th, 2011, 12:11 AM
Every coding tuition book or site I've seen starts with a "hello world" program. So make sure you include a hello_world.py. )

JDShu
November 5th, 2011, 12:13 AM
Probably also something on scoping, which is a bit weird in Python, as well as duck typing, but it looks like a good list to me.

3Miro
November 5th, 2011, 01:12 AM
Are they C or C++ coders. If they already know C++, then you can skip much of the OOP stuff, they will already know what it is. If they don't know OOP, then spend more time working with that.

Erik1984
November 5th, 2011, 01:26 AM
I recently jumped into python, just started coding without reading to much docs. What I found most surprising compared to other languages I know such as C++, Java and FreeBASIC, were shared class 'members' between all instances. Has cost me some hours not understanding the 'strange' (as you expect different) behavior of my program :P That's a subject you should touch however I guess you already included it in your list.

P1C0
November 5th, 2011, 02:57 AM
Sounds like an entire semester, to me. How many sessions do you have?Well, max 3 I'd say, about 1 hour each.

@3Miro They are C and C++ coders and know a great deal of OOP, so I'll keep the Python OOP part short.

@t0p import __hello__ :P

Lucradia
November 5th, 2011, 01:20 PM
@t0p import __hello__ :P

Make sure to also use __NOTOC__ from MediaWiki ;)