Hi DL,
I started from here https://docs.python.org/3/tutorial/index.html .. And then
found out there should be more which is not covered here, so I was looking for
a book. And then got the journeyman book and started reading it. I am now on
chapter 11. Yet not bored and distracted. The author r
Arup,
Good choice! (thought I recognised the example-problem) The three books
in the "Python Craftsman" series/bundle: "Apprentice", "Journeyman", and
"Master" are a thoroughly recommendable resource. As the titles infer,
they start at a beginner level and become more complex over time. Even
Hello,
DL, the book I am reading is https://leanpub.com/python-journeyman .. It is an
awesome book. The code is in page #351.
David and Chris, The analogy you used to answer my questions were super
helpful. I could answer my own question by putting some effort by dry running
the code ofcourse.
On 2019-04-04 20:48, David Raymond wrote:
Yep, spotted that too! :-) BTW, your fix also a bug: the last word on a
line won't be followed by a space (off-by-one). The easiest fix for that
is to add 1 to line_length initially, another little trick.
Or, equivalently, to reset current_line_length
Arup,
On 5/04/19 7:33 AM, Arup Rakshit wrote:
I am reading a Python book, where the author used a simple word wrap program to
explain another concept. But I am not understanding some parts of the program.
...
A technique for solving this sort of comprehension-problem is to
simulate the opera
> Yep, spotted that too! :-) BTW, your fix also a bug: the last word on a
> line won't be followed by a space (off-by-one). The easiest fix for that
> is to add 1 to line_length initially, another little trick.
> Or, equivalently, to reset current_line_length to -1, which is an elegant
> hack.
I
On Fri, Apr 5, 2019 at 6:16 AM MRAB wrote:
>
> On 2019-04-04 19:53, David Raymond wrote:
> > The function is constructing a list of the lines, which it will combine at
> > the end. Answering the questions in reverse order:
> >
> > 3. Also why that `if` test is required there.
> > The if statement
n-list-bounces+david.raymond=tomtom@python.org] On Behalf Of
Arup Rakshit
Sent: Thursday, April 04, 2019 2:33 PM
To: Python
Subject: I want understand how this word wrap program playing on input
I am reading a Python book, where the author used a simple word wrap program to
explain another co
ginal Message-
From: Python-list
[mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of
Arup Rakshit
Sent: Thursday, April 04, 2019 2:33 PM
To: Python
Subject: I want understand how this word wrap program playing on input
I am reading a Python book, where the author used a s
On Fri, Apr 5, 2019 at 5:34 AM Arup Rakshit wrote:
> lines_of_words = []
> current_line_length = line_length
> for word in words:
> if current_line_length + len(word) > line_length:
> lines_of_words.append([]) # new line
> current
I am reading a Python book, where the author used a simple word wrap program to
explain another concept. But I am not understanding some parts of the program.
def wrap(text, line_length):
"""Wrap a string to a specified line length"""
words = text.split()
lines_of_word
11 matches
Mail list logo