Learn Python The Hard Way(22、23)

本文为Python初学者提供了一套实用的方法,帮助他们通过整理符号列表和在线阅读实际项目源代码来加深对Python语言的理解。文章建议从基础练习开始,逐步过渡到阅读互联网上的真实代码,以此提高代码阅读能力。

There won't be any code in this exercise or the next one, so there's no WYSS or Extra Credit either. In fact, this exercise is like one giant Extra Credit. I'm going to have you do a form of review what you have learned so far.

First, go back through every exercise you have done so far and write down every word and symbol (another name for 'character') that you have used. Make sure your list of symbols is complete. Next to each word or symbol, write its name and what it does. If you can't find a name for a symbol in this book, then look for it online. If you do not know what a word or symbol does, then go read about it again and try using it in some code. You may run into a few things you just can't find out or know, so just keep those on the list and be ready to look them up when you find them.

What You are Learning

It's important when you are doing a boring mindless memorization exercise like this to know why. It helps you focus on a goal and know the purpose of all your efforts. In this exercise you are learning the names of symbols so that you can read source code more easily. It's similar to learning the alphabet and basic words of English, except this Python alphabet has extra symbols you might not know. Just take it slow and do not hurt your brain. Hopefully by now these symbols are natural for you so this isn't a big effort. It's best to take 15 minutes at a time with your list and then take a break. Giving your brain a rest will help you learn faster with less frustration.

-------------------------------------------------------------------------------------------------------------------

You should have spent last week getting your list of symbols straight and locked in your mind. Now you get to apply this to another week reading code on the internet.

This exercise will be daunting at first. I'm going to throw you in the deep end for a few days and have you just try your best to read and understand some source code from real projects. The goal isn't to get you to understand code, but to teach you the following three skills:

        1. Finding Python source code for things you need.

        2. Reading through the code and looking for files.

        3. Trying to understand code you find.


Here's what you do:

1. Go to bitbucket.org with your favorite web browser and search for "python".

2. Pick a random project and click on it.

3. Click on the Source tab and browse through the list of files and directories until you find a .py file (but not         setup.py, that's useless).

4. Start at the top and read through it, taking notes on what you think it does.

5. If any symbols or strange words seem to interest you, write them down to research later.

That's it. Your job is to use what you know so far and see if you can read the code

and get a grasp of what it does. Try skimming the code first, and then read it in

detail. Maybe also try taking very difficult parts and reading each symbol you know

outloud.




转载于:https://my.oschina.net/xtfjt1988/blog/402898

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值