thewhitetulip / build-app-with-python-antitextbook Goto Github PK
View Code? Open in Web Editor NEWAims to teach Python3 by example
License: GNU General Public License v3.0
Aims to teach Python3 by example
License: GNU General Public License v3.0
In 03-01-understanding-variables.md
, under String, it says that escapes like \n\t
are affected by the use of "
or '
. This is incorrect as there is no difference to Python with respect to which quote character you use. The only difference is which character you can use within the string without escaping.
If you do want to disable escape sequences, it requires prefixing the string with r
and it doesn't matter which quote character is used. That is, r'this string\n\t'
or r"this string\n\t"
both do not use the escape sequences and apply the strings literally.
If something goes wrong, our program complains, if everything goes wrong, we say nothing.
Maybe, wrong should be right?
see PEP3101 .format was introduce in python 2.6 and should be the preferred way to do string interpolation
because the changes are that someone already has written a package for that.
Replace changes with chances
We need to teach the user to search and navigate the documentation, hence it would be helpful if we add a link to the topics that we have in the book to the docs
Because of it's English like syntax,
Fix: Change it's to its
current code
>>> import glob
>>> files = glob.glob('*.txt')
>>> files
(in windows python 3.6, calling files without a print statement does not display anything
Fix
import glob
files = glob.glob('*.txt')
print(files)
I think implementing basic algorithms with python is a great way to learn. For examples Stack, Singly Linked Lists, Circular Linked Lists, Doubly Linked Lists, Arrays, Binary Trees, Binary Search, Recursion and String Processing.
import os
files = os.listdir()
for file in files:
if file.endswith(".txt"):
print(file)
Function os.listdir() expects an argument (a folder name)
files = os.listdir("folder")
folder = the folder which contains the text files.
OR
files=os.listdir(".")
//In this case, the files have to be in the same directly as file.py
I applaud you for trying to do this - but I have noted one or more issues :
for i in range(len(l)):
print(l[i])
This is so horrible that it is strongly discouraged. If you need to have the index of an item of the list - do this :
for index, item in enumerate(my_list):
print(index, ':', item )
Please - try to fix these issues - as I say - I applaud you for trying - but if you want to teach - teach best practice.
No example exists for the with clause
is
statement missing
Section: Introduction 2
Issue: Sentence is too long and would require multiple reads to understand.
Because of it's English like syntax, Python makes for an excellent prototyping language, any program implemented in Python has significantly less number of lines as compared to Java, but because it is a dynamically typed language, it is somewhat difficult to debug the programs written in Python or we need to be extra careful while writing them.
Because of its English like syntax, Python makes for an excellent prototyping language**.** Any program implemented in Python has significantly less number of lines as compared to Java. But because it is a dynamically typed language, it is somewhat difficult to debug the programs written in Python. Thus, we need to be extra careful while writing them.
More detailed examples for the operators
import sys
for i, item in enumerate(sys.argv):
print("{} {}".format(i, item))
A mention could be deserved by list comprensions and generators (on which an entire chapter, maybe, should be done).
Specifically, you may want to explain the difference between
[requests.get('http://website.com/page/{}'.format(x) for x in range(0,10)]
and
(requests.get('http://website.com/page/{}'.format(x) for x in range(0,10))
which is a very powerful example on how generators may help during software development.
In an era where computers also are capable to write Python scripts, we need to be better than them!
Fix
In an era where computers also are capable of writing Python scripts, we need to be better than them!
See: https://docs.python.org/3.6/reference/expressions.html#is
x is y
# Can be rewritten as
id(x) == id(y)
The type Tuple is missing from the Variables section and also High level data structure?
You don't show the % (modulus) operator at the top in the beginning but you show it in the interpreter in the division section.
But you don't say what it is and the result you typed is wrong:
>>> 27%7
1
but 27%7 = 6
In https://github.com/thewhitetulip/build-app-with-python-antitextbook/blob/master/manuscript/03-01-understanding-variables.md, it could be helpful to also show the difference between 1
and 1.0
, e.g.
>>> type(1)
<type 'int'>
>>> type(1.)
<type 'float'>
>>> type(1.0)
<type 'float'>
There are a large number of languages out there and new ____ coming out (new) week, so this question is important, why learn Python over X.
Try
There are a large number of languages out there and new ones coming out every week. So the question why learn Python over X is important.
Code that is supposed to run on the Interpreter starts with >>> like >>> not True. In this case, >>> not True is the statement and False is the output.
>>> not True
False
Code that is supposed to run on the Interpreter starts with >>>
Example:
>>> not True
False
In this case, >>> not True is the statement and False is the output.
There is an error in the tutorial, triple quoted strings are told as multiple line comments without mentioning docstrings.
Elaborate more on comments and their importance
All examples are in procedural style. Please, add a chapter about OOP. Thank you!
Feedback from r/learnpython. Need to modify the content to align with the larger goal of writing a guide for a newcomer to Python without presuming a linux background.
But who is this book for? Experienced coders learning Python? Absolute beginners with no coding experience in any language? Something in between? It's hard to tell -- you explain some basic concepts (string liberals, variables), but not others (the difference between the Python command line and the shell; how to get to each). Try to pick a target reader, and go through with that person in mind. An absolute beginner will need more hand-holding than you currently provide in some areas, or at least more indication that they should hold tight and not worry about not understanding everything yet -- sending beginners to the documentation is a sure way to lose them -- while experienced programmers will need a lot less.
glob
in Python 3 supports a wide variety of syntax including **/*.txt
. Being an anti-textbook, glob
is more suitable for 01-intro-to-python.md
, in my opinion.
>>> import glob
>>> glob.glob('*.txt')
['file1.txt',
'file2.txt',
'file3.txt',
'file4.txt',
'file5.txt']
Give your feedback here!
In chapter 03-01 you did type comparison with the expression:
if type(a) == type(""): print("a is string")
You may want to say that everything in Python is an object, and explains why and how
isinstance('a string', str)
works as well.
... python creates a new variable and does not.
From line 151 of manuscript/03-01-understanding-variables.md.
Hi,
Suraj I would like to know how you usually start your books.
Do you first write stuff into an manuscript folder on Github and then import it to Gitbooks or do you first start with an GitBook template?
http://notebooks.azure.com is a free, hosted Jupyter notebook service by microsoft.com
Check out the intro to python sample on the front page.
It would be great if this guide is added so that anyone can view & run it.
Cheers,
s (disclaimer - associated w the project)
Need to update README and chapterone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.