Steve[n], Yes, I figured out what the problem was but while evaluating I also realized that a format string was an ALTERNATIVE that automatically called for an str or repr so in a sense it would work without debugging.
I find that sometimes the long lines make it harder to see the skeleton of the logic as you get bogged down by things that may be of lesser importance. So I close with another idea. I asked about functions with lots of arguments. An example might be making a graph using a library that lets you specify literally hundreds of parameters all at once. I realized that a perfectly valid alternative to make the main purpose more reasonable would be to stuff all the extra arguments in a dictionary like Other_args = { this: value, That : value, ... } That is something in braces that can be wrapped for legibility. Then the main function call can use the ** expansion like so: Ret = function(from, to, **Other_args) Of course, you can also use * with a list or other iterable for the positional args when that makes it easier but at some point you no longer have a feel as to what the function call is doing. But hiding less important details this way seems to be good. Not sure about run-time efficiency, of course. -----Original Message----- From: Tutor <tutor-bounces+avigross=verizon....@python.org> On Behalf Of Steven D'Aprano Sent: Friday, December 14, 2018 12:22 AM To: tutor@python.org Subject: Re: [Tutor] Long Lines techniques On Thu, Dec 13, 2018 at 11:07:59PM -0500, Avi Gross wrote: [...] > There are cases where it may make sense to have a long like connected > by AND or OR given how python does short-circuiting while returning > the last thing or two it touched instead of an actual True/False. For > example, you may want to take the first available queue that is not > empty with something like > this: > > Using = A or B or C or ... or Z > Handling = Using.pop() > > Sure, that could be rewritten into multiple lines. using = (A or B or C or D or E or F) [...] > I recently wrote some code and ran into error messages on lines I was > trying to keep short: > > A = 'text" > A += "more text" > A += object > A+= ... Without knowing the error message, its impossible to say what the problem is. My guess is that the object on line three wasn't a string. In which case, the obvious fix is: A += str(object) -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor