swaroopch / byte-of-python Goto Github PK
View Code? Open in Web Editor NEWBeginners book on Python - start here if you don't know programming
Home Page: https://python.swaroopch.com/
Beginners book on Python - start here if you don't know programming
Home Page: https://python.swaroopch.com/
In 06-basics.pd it said:
Examples of valid identifier names are
i
,__my_name
,name_23
,>a1b2_c3
.
However, when I define the variable >a1b2_c3
, the python(3.2.3) interpreter just complained
SyntaxError: invalid syntax
So,
- The first character of the identifier must be a letter of the alphabet (uppercase ASCII or lowercase ASCII or Unicode character) or an underscore ('_').
Is it correct?
Thanks for attentions :)
basics.md
Line 310:
Similarly, we assign the literal string to the variable +s+ and then print it.
op_exp.md
Line 197:
We store the result of the expression `length * breadth` in the variable +area+ and then print it using the +print+ function.
control_flow.md
Line 22:
We set the variable +number+ to any integer we want,
My fork is working for translating BoP so I can't make a pull request. Please bear with me. :)
// (divide and floor)
Divide x by y and round the answer down to# the nearest whole number
13 // 3 gives 4
-13 // 3 gives -5
the nearest whole number??
print(9/1.81)
4.972375690607735
print(9//1.81)
4.0
page 61
In C/C, if you want to write `for (int i = 0; i < 5; i)
In C/C++
Lines 65 and 66 refer to "C++" but are translated to "C[]+" and "C+", respectively, in HTML (and ePUB, ...).
In Control Flow chapter, The for Loop section, the Example's explain, there is a line as:
Remember that the else part is optional. When included, it is always executed once after the for loop is over unless a <> statement is encountered.
It seems like the <> part is lost something.
I found in source file control_flow.md
Line 99, this location has something:
Remember that the `else` part is optional. When included,
it is always executed once after the `for` loop is over unless a <<the_break_statement,break>> statement is encountered.
So the problem seems like Markdown doesn't include this <the_break_statement,break>
in HTML file.
Could you check this?
File hint: 22-translations.pd
http://www.swaroopch.org/notes/Python_cn:Table_of_Contents doesn't work.
http://www.pycn.org/python%E5%9C%A8%E7%BA%BF%E6%89%8B%E5%86%8C doesn't work either. www.pycn.org is not a website about Python currently.
The only working link I know is http://woodpecker.org.cn/abyteofpython_cn/chinese/ , which is based on an obsolete version of "A Byte of Python", though.
In control_flow.md xrange is mentioned. xrange is however not a part of python 3. xrange has become range, and range of python 2 is equivalent with list(range()) in python 3.
Hi, in a Kindle paperwhite the layout appears with too many tabs, sometimes the text starts at the next line, attached screenshot:
Note: this is the .mobi file downloaded at the website: http://python.swaroopch.com
What tools are there to convert? Calibre can?
It's worth to mention that the exponentiation operator (**) is right associative, 2 ** 3 ** 4
is equal to 2 ** (3 ** 4)
.
Hello. I am now reading your book as my second book for Python. The book is instructive! I am trying to copy the code from the book's PDF and have problems with formatting when I paste the code into VS Code. Copying the code from your website works correctly. Attach the file from VS Code:
function_keyword.zip
Thanks.
Hi,
Someone compiled translated version of "A byte of Python" and put it online: http://zhgdg.gitcafe.com/static/doc/byte_of_python.html
There are two issues (same in origin version from this repo):
fabfile.py uses "open" command to open the generated HTML file.
However, IIRC, "open" command is specific to Mac OS X. Linux should use "xdg-open" while Windows should use "start".
Fortunately, we may use Python's webbrowser module instead as:
http://docs.python.org/2/library/webbrowser.html
http://docs.python.org/3/library/webbrowser.html
spell mistake in Installation
Specifically, https://swaroopch.com/buybook
Is it that the physical copy can't be bought anymore?
At the bottom of page 9, the Portable section is chopped off by the bottom matter.
Hi Swaroop,
I found this video quite easy and quickly able to explain Decorators in simple manner. Please add it.
I though this change should be discussed a bit.
I propose to format the python code using black, in order to have consistent code across the book.
Consistency is also important in coding, so I though it should be applied in a learning book.
The way file io is explained is very non-pythonic, especially: programs/io_using_file.py
Hi @swaroopch, this is to inform you that I have just updated the Korean translation to match the latest version of the book here:
https://github.com/Byte-of-Python-Korean-Translation/byte_of_python_korean_translation
This is so far the only complete Byte of Python
Korean translation for Python 3.
Thank you so much for writing such an awesome Python guidebook!
In oop.md
Line 49:
(We will learn <<init,more about instantiation>> in the next section)
It seems like it should be a link, but the syntax it is using is not a Markdown style.
Please have a check and fix it.
I enjoyed reading this book. I read the Revision History and would like to suggest Org Mode as the next version. It supports exporting to AsciiDoc, LaTeX (PDF), HTML, etc. It renders well on GitHub. It also is an interactive format if people want, and supports (optionally) export to Jupyter (as requested by #104, #107, and presumably others).
This book is 10 years old - I suggest Org will still be around in 10 years, but many other formats may not exist in another 10 years.
I love the book and the website (I learned python with it). But I wonder if it would be possible to move the content towards a jupyter book such that the compute instructions become executable on something like binder without any needed installs.
note: the project hasn't been completed yet, only 2 pages have been fully translated.
_ current progress: https://github.com/epsimatt/byte-of-python/issues/2
_ gitbook link: https://epsimatt.gitbook.io/byte-of-python/
Reading the EPUB version on a digital reader with e-paper screen is quite difficult due to some light grayed section, which are missing contrast.
Like CAUTION block.
Just above: https://github.com/swaroopch/byte-of-python/blob/master/functions.md#keyword-arguments
How do I re-genrate the EPUB version?
The format method was introduced in the Basic chapter.
Since Python now has String interpolation, maybe it would be an idea to mention that also here?
Right Click on the PDF Document, choose Document Properties, click Security Tab.
"Commenting: Not Allowed"
i was hoping to add comments and bookmarks and hilighting to parts of the document.
Newest (2014-12-02) or older versions of the PDF have the same issue. Have not figured out how to generate my own yet.
It took me a long time before I read somewhere that in at least IPython/Jupyter Notebooks (including those on https://wakari.io), IDLE and Spyder tab completion can be used. Meaning that if you start a statement and then press the tab-key a list pops up from which you can choose a completion of your statement. Coming from Microsoft Visual Studio and RStudio where the lists pop up automatically, I didn't expect something like that. I just thought that Python environments didn't work that well, and Notebooks the least of all, because typing a dot doesn't result in a list.
Tab completion is very helpful for beginners (and experts alike I suppose) so I think it would help if this would be clearly mentioned in the book.
Hi swaroopch,
I am reading your awesome byte-of-python
, but find the following words in Inheritance from Object Oriented Programming
may not be accurate:
To use inheritance, we specify the base class names in a tuple following the class name in the class definition. Next, we observe that the init method of the base class is explicitly called using the self variable so that we can initialize the base class part of the object. This is very important to remember - Python does not automatically call the constructor of the base class, you have to explicitly call it yourself.
I think "Python does not automatically call the constructor of the base class, you have to explicitly call it yourself." will mislead people. The root cause of this example is the __init__
method in derived class overrides the __init__
method in base class. Actually, Python does automatically call the constructor of the base class as long as the derived class doesn't override this method. E.g.:
class Base:
def __init__(self):
print("Base __init__ is called!")
class Derived(Base):
pass
Derived()
The output of above code is like this:
Base __init__ is called!
So if the derived class's method overrides base class's method, the base class's method won't be called, no matter it is __init__
or not:
class Base:
def Haha(self):
print("Base Haha is called!")
class Derived(Base):
def Haha(self):
print("Derived Haha is called!")
Derived().Haha()
The result is:
Derived Haha is called!
Best Regards
Nan Xiao
Links on https://swaroop-c-h.gitbook.io/byte-of-python/#download don't work.
Thanks for this wonderful bytes.
Feature Request
Can we create a Jupyter notebook or google colab notebook .
This will help to run the snippet within the page and the learner may not need to navigate/copy away to another editor/IDE.
The light table link http://docs.lighttable.com/tutorials/python/ in the book is missing videos. I am aware its an issue of Light Table but as this book is for begibnner and video will be really helpful. Kindly provide some alternative link.
In Installation
,
To verify, open the terminal by opening the +Terminal+ application or by pressing
[Alt + F2]
and entering +gnome-terminal+.
I see a nice rendered page at https://www.gitbook.com/book/swaroopch/byte-of-python/details itself but here on https://github.com/swaroopch/byte-of-python/blob/master/README.md I see some dirty things:
{#who-reads-bop}
{{ book.officialUrl }}
{{ book.buyBookUrl }}
{{ book.downloadUrl }}
{{ book.sourceUrl }}
It's not a problem here but for your attention only.
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.