Discussion:
name of the package (or style) that uses lots of extra lines in Python programming?
(too old to reply)
HenHanna
2024-08-21 04:55:20 UTC
Permalink
What's the name of the package (or style) that uses
lots of extra lines in Python programming?

it looks like this:

main()
{
int c;
.......
}

like Begin-End of Algol, Pascal from 1960's and 1970's.



it'd look like this in Lisp:

(define (fact x)
(begin
(if (zero? x)
1
(* x
(fact
(- x
1)
)
)
)
)
)
Lawrence D'Oliveiro
2024-08-21 07:20:39 UTC
Permalink
Post by HenHanna
What's the name of the package (or style) that uses
lots of extra lines in Python programming?
Lawrence’s style:

def write_invoice_entry_total(self, total_elapsed, hourly_rate, job_charge) :
if self.first_hours_entry != None :
self.item_para.addElement \
(
odf.text.Span
(
text =
"Total %s hour%s on %s @$%s"
%
(
format_common.my_format_elapsed(total_elapsed),
("", "s")[self.first_hours_entry["time_worked"] > 3600],
format_common.my_format_date
(
self.first_hours_entry["when_worked"]
),
format_common.my_format_amount(hourly_rate),
)
)
)
else :
add_elements \
(
self.item_para,
odf.text.LineBreak(),
odf.text.Span
(
text =
"Total %s hour%s @$%s"
%
(
format_common.my_format_elapsed(total_elapsed),
("", "s")[total_elapsed > 3600],
format_common.my_format_amount(hourly_rate),
)
),
)
#end if
add_elements \
(
self.item_para,
odf.text.Tab(),
odf.text.Span
(
text ="$%s" % format_common.my_format_amount(job_charge)
),
)
self.doc.text.addElement(self.item_para)
self.item_para = None
#end write_invoice_entry_total
HenHanna
2024-08-21 20:25:20 UTC
Permalink
Post by Lawrence D'Oliveiro
Post by HenHanna
What's the name of the package (or style) that uses
lots of extra lines in Python programming?
self.item_para.addElement \
(
odf.text.Span
(
text =
%
(
format_common.my_format_elapsed(total_elapsed),
("", "s")[self.first_hours_entry["time_worked"] > 3600],
format_common.my_format_date
(
self.first_hours_entry["when_worked"]
),
format_common.my_format_amount(hourly_rate),
)
)
)
add_elements \
(
self.item_para,
odf.text.LineBreak(),
odf.text.Span
(
text =
%
(
format_common.my_format_elapsed(total_elapsed),
("", "s")[total_elapsed > 3600],
format_common.my_format_amount(hourly_rate),
)
),
)
#end if
add_elements \
(
self.item_para,
odf.text.Tab(),
odf.text.Span
(
text ="$%s" % format_common.my_format_amount(job_charge)
),
)
self.doc.text.addElement(self.item_para)
self.item_para = None
#end write_invoice_entry_total
___________________________
Post by Lawrence D'Oliveiro
odf.text.Span
(
text ="$%s" % format_common.my_format_amount(job_charge)
),
)
odf.text.Span
( text ="$%s" % format_common.my_format_amount(job_charge) ), )
OR just one line.


_______________________

Giving [Close Parenthesis] (or END or curly-bracket) its own line
----------- if this is discussed anywhere, pls let me know!
Lawrence D'Oliveiro
2024-08-22 00:01:32 UTC
Permalink
Post by HenHanna
Post by Lawrence D'Oliveiro
odf.text.Span
(
text ="$%s" % format_common.my_format_amount(job_charge)
),
)
odf.text.Span
( text ="$%s" % format_common.my_format_amount(job_charge) ), )
OR just one line.
Except that call was inside a construct that was already indented four
steps deep. So it was wrapped to reduce the line length.

rbowman
2024-08-21 07:56:00 UTC
Permalink
Post by HenHanna
What's the name of the package (or style) that uses
lots of extra lines in Python programming?
main()
{
int c; .......
}
like Begin-End of Algol, Pascal from 1960's and 1970's.
If it looks like that it's C not Python.

https://peps.python.org/pep-0008/#blank-lines

'black' is a formatter that will neaten up a file. 'ruff' does quite a bit
more but also can format. If you're stingy with whitespace either will add
extra lines.
Loading...