Git Product home page Git Product logo

build-app-with-python-antitextbook's Introduction

Build applications in Python the anti-textbook

Source Read online Watch Download Code
On Github Free on Gitbooks The YouTube series Leanpub On Github

Who is this tutorial for?

This book is not for a completely noob programmer, it expects some initial programming experience.

What is this?

It's an easy to understand introduction to the Python programming language which focuses on teaching concepts via examples. The initial chapters explain various concepts and in a later chapter, you will build a command line todo list manager.

The motto of this book is not just teach the language, but to enable you to write tools which you would use in day to day life, like a simple todo list manager, we encourage you to explore the language more after you read the book and start writing tools for your daily usage.

Why Python?

There are a large number of languages out there and new ones coming out every week, thus, it begs the question why learn Python over X.

Python has the following advantages:

  1. Easy to understand syntax. Reads just like English.
  2. Huge community.
  3. Open source hence millions of packages available.
  4. Short time needed for writing code.

A programming language's usability is direct proportion to the size of its community squared, this is because the core team writes the language, but the content(books, podcasts, tutorials, packages, Q&A) surrounding the language is created by the community.

Which Python?

This guide focuses only on Python3, Python2 is on life support and we do not recommend using it, unless there is an exceptional scenario.

Writing Style

We have thirteen chapters:

  • Each chapter or topic has an associated YouTube screencast.
  • Each chapter has concepts explained by an example (can be as stupid as 1+1=2)
  • Code that is supposed to run on the Interpreter starts with >>> like >>> not True.
>>> not True
	False

In this case, >>> not True is the statement and False is the output.

  • Code that doesn't start with >>> is supposed to be run in a file with the extension .py
  • If there is significant code for the chapter, you can find a file in the code repository, please look on the basis of chapters.

How to use?

  • Read the chapters end to end.
  • Watch the YouTube screencast, there is a reason why they are free!
  • Do NOT search the Internet for things like "how to do X in python", use the documentation.

Installation

  1. Linux and Mac: Use a package manager to install the python3 package.
  2. Windows: Download the .msi or .exe file from https://python.org, run the installer, click on Next Next until it finishes.
  3. Android: Install termux (https://termux.com/help.html) & run apt-get install python3 to install python inside it.
  4. iOS: Python3 for iOS (not free).

Background

This tutorial is the culmination of the various Python trainings I have given in the past. There was a lack of a guide which taught programming by building tools without overwhelming the readers, thus, this project got started.

They say that write the book you wish existed in the world. This is a book which I wished existed when I was learning the language.

Please note that I don't profess to be a God at anything, but I do feel that good things happen when a group comes together for one goal.

This is an open source guide and I invite you to contribute.

Multiversity

This guide is a part of the Multiversity initiative. The aim is to have high quality open source tutorials along with screencasts.

Contribution

We need your help to become a great guide! All contributions are welcome. Please raise an issue on Github!

Links
Next Index

build-app-with-python-antitextbook's People

Contributors

drbraden avatar jaivasani avatar markwhat1 avatar morenoh149 avatar thewhitetulip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

build-app-with-python-antitextbook's Issues

Readability Fix

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.

Fix

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.

Typo

Introduction

because the changes are that someone already has written a package for that.

Replace changes with chances

Who is this guide for?

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.

Chapter 03-01, isinstance for type comparison

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.

Add list comprehension and generators

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.

Escape sequences do not depend on quote character

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.

Modulus error in the Operators section

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

Unclear and missing words - Section: Why Python

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.

Use `glob` module instead of vanilla walks

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']

Explanation for code should come after

Section: Writing Style

Original

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

Reordered

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.

Change multi line comments to docstrings

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

How do you start your books?

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?

Typo

Section: Introduction 2

Because of it's English like syntax,

Fix: Change it's to its

Implement Basic Algorithms

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.

Sentence stops abruptly

... python creates a new variable and does not.

From line 151 of manuscript/03-01-understanding-variables.md.

Constructs

No example exists for the with clause
is statement missing

Issues

I applaud you for trying to do this - but I have noted one or more issues :

  • Variables page - the id function does not return the address - it returns the object identifier. It is not intended to be nor should it be implied that it is the address.
  • Variables Page - a nit pick here but strictly speaking the variable doesn't have a type. The value has a type and the name simply points to an object which has a value. In Python it is dynamic typing, so you can assign an integer object to a name, and two lines later assign a string object to the same name. Talking about objects (rather than 'memory') is important because only some objects in Python are mutable, and some aren't : adding something to a list will change the list - adding a value to a number will create a brand new object for the new value; that distinction is critical.
  • Your 'more about the language' page mentions 'Batch mode' - no-one I know calls it that. Please use the right terminology.
  • Constructs page : Most beginners wont understand what 'constructs' mean, and if they do, they aren't beginners; I would suggest a page titled making decisions, and another page entitled loops.
  • Constructs page: you mention that indentation is counted as 4 spaces - stricly this is wrong - you can use any level of indentation you want so long as your blocks are consistent. I know indents of 4 spaces are recommeded by you can use 1 space, 3, 8 or anything.
  • Constructs page: You give this example :
    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 )
  • Constructs page : I appreciate you attempting to show your indentation - but I am not sure using [] to illustrate where the intendentations are works - is there a different way to do this ?
  • Constructs page : No mention of else after a loop so that you can execute code only if the list doesn't execute a break.
  • Your list, sets, dicts page contains no details of how to iterate around these (i.e. a for loop), and no mention of using enumerate while iterating to get the index and the element.
  • Your file handling section is poor to be honest - you do a readline() before each loop; not only is this superfluous, but with a very large file you could well end up filling memory. You appear not to realise that an an open file is an iterator (it has been since Python2.3) or earlier, which means you can use a for loop to iterate around the file contents
  • No mention of 'with' to open file safely (i.e. ensure it is always closed). This is much prefered than using open/close and hoping nothing goes wrong.
  • Your file handling page mentions list comprehensions - should this be in the list,set,dict page - or a page on it's own ? Also - no mention of dict or set comprehensions.
  • Exception handling - no mention of using 'else' to execute code if no exception is triggered - different from 'finally'
  • Functions - No mention of mutating arguments (if a function is passed a mutable value as an argument, and the function changes that value, then the calling function will see that change).
  • Functions - no mention of not using 'mutable objects' as default arguments - it doesn't do what most beginners think it should.
  • Todo list manager : Instead of using a '|' to separate title and content and text files - why not show your students the better way to do things - each task should be a dictionary - that enables you to extend the dictionary later - maybe with due dates etc. and then use the pickle library to save and load your list of tasts. It is far better to do that than to try to use text for complex data.
  • CSV to sql - why not use the CSV reader module - you should be showing your students the power of the standard library rather than writing their own.

Please - try to fix these issues - as I say - I applaud you for trying - but if you want to teach - teach best practice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.