I really liked this Javscript FizzBuzz can it be as nice in Python?

2019-04-04 Thread Sayth Renshaw
I saw this fizzbuzz in Eloquent Javascript and thought its really nice. Not all the usual if else version, just if. for (let n = 1; n <= 100; n++) { let output = ""; if (n % 3 == 0) output += "Fizz"; if (n % 5 == 0) output += "Buzz"; console.log(output || n); } I can't quite get a nice v

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-04 Thread adam . preble
On Thursday, April 4, 2019 at 1:17:02 PM UTC-5, adam@gmail.com wrote: > Thanks for the response. I was meaning to write back earlier, but I've been > spending my free Python time in the evenings reimplementing what I'm doing to > work more correctly. I'm guessing before the code object repre

Re: I want understand how this word wrap program playing on input

2019-04-04 Thread MRAB
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

Logging cf Reporting = Friday Filosofical Finking

2019-04-04 Thread DL Neil
Is the logging module an ideal means to provide (printed) user reports, or is it a 'bad fit' and not designed/fit for such a purpose? PSL's logging module (per discussion 'here' earlier this week) is often quietly avoided by 'the average Python programmer'. It is unwieldy, yet that is, in-par

Re: I want understand how this word wrap program playing on input

2019-04-04 Thread DL Neil
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

RE: I want understand how this word wrap program playing on input

2019-04-04 Thread David Raymond
> 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

Re: I want understand how this word wrap program playing on input

2019-04-04 Thread Chris Angelico
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

Re: I want understand how this word wrap program playing on input

2019-04-04 Thread MRAB
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 is saying "I don't have room on my current line for the next wor

RE: I want understand how this word wrap program playing on input

2019-04-04 Thread David Raymond
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 is saying "I don't have room on my current line for the next word, so time to start a new line" 2. In the

Re: I want understand how this word wrap program playing on input

2019-04-04 Thread Chris Angelico
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 want understand how this word wrap program playing on input

2019-04-04 Thread Arup Rakshit
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

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-04 Thread adam . preble
On Monday, April 1, 2019 at 1:23:42 AM UTC-5, Gregory Ewing wrote: > adam.pre...@gmail.com wrote: > https://eli.thegreenplace.net/2012/06/15/under-the-hood-of-python-class-definitions > > Briefly, it creates a dict to serve as the class's namespace dict, > then executes the class body function pas

RE: scalable bottleneck

2019-04-04 Thread Schachner, Joseph
If you are using Python 3, range does not create at list, it is a generator. If you're using Python 2.x, use xrange instead of range. xrange is a generator. In Python 3 there is no xrange, they just made range the generator. --- Joseph S. -Original Message- From: Sayth Renshaw Se

Re: requests

2019-04-04 Thread Rhodri James
On 04/04/2019 12:57, Jack Dangler wrote: Hi, all. Just getting started but already have an idea for something to save me some grief we have lists of files that reside on a sharepoint site at work that we pick from. These have a variety of data items in them and we need to start the process by

requests

2019-04-04 Thread Jack Dangler
Hi, all. Just getting started but already have an idea for something to save me some grief we have lists of files that reside on a sharepoint site at work that we pick from. These have a variety of data items in them and we need to start the process by copying the entire contents into a local