A Very Brief Introduction To Python And It's Data-Types 一篇短小精悍的 python tutorial 。对一些容易被忽视的问题讲得很清楚!很专业的 tutorial!摘录片段如下:
- The Python 'philosophy' emphasises readability, clarity and simplicity, whilst maximising the power and expressiveness available to the programmer. 看到这句话我不自觉地就想起了c++:“The c++ 'philosophy' emphasises performance, performance and performance, whilst maximising the power and expressiveness available to the programmer” ;-) 它们在各自的领域都做得很不错。
- The line of code x = 3 is a statement (more about that in a bit) which means it does a job. The job it does is to assign the value 3 to the variable 'x'. In Python terminology we say that it binds the name 'x' to the number three. This idea of variables being names bound to objects (or names which 'reference' objects) is important in Python.
- 'Under the hood' Python actually uses two types of integer, the integer and the 'long integer' for integers bigger than a certain amount.
- If you need to a lot of complicated maths with floating point numbers, then you may be interested in extensions like numpy or General Multiprecision Python project. These extensions provide very fast ways of doing mathematical operations. For normal use the capabilities built in to Python will be sufficient.
- The name 'string' probably comes from the fact that programming languages often treat text as a sequence of characters 'stringed' together.
- The basic string type (which I have called 'normal strings' below) store the text as a sequence of bytes (numbers) with one byte per character. .... They can also be used for storing binary data in.
- Unicode strings store text internally using the unicode standard. They are slightly more complicated, because you must know the 'encoding' the text is stored in whenever you read the text in or save it out. In the long run this can save a great deal of confusion.
- Because the interpreter knows the length and types of the members of a tuple, working with them can be more efficient than using a list.
- Dictionaries are an extremely useful and flexible datatype. In fact Python is built on them.
- Programs are actually compiled to byte-code before being executed, but the byte-code is then interpreted. In some ways this is similar to Java or .NET which also compile to byte-code. Because these languages are statically typed with JIT compiler, they are generally considered as compiled languages whilst Python is generally considered as being interpreted.
0 评论:
发表评论