I mean, really? Four lines to do what could be done in a single
expression? Was that written by a PHP programmer, do you think?
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
I mean, really? Four lines to do what could be done in a single
expression? Was that written by a PHP programmer, do you think?
It is not fluent Python, that's for sure. No idea about PHP though. I
have been wondering about PHP recently. The language is painful but the implementation has some attractions and it's widely available.
Is this what you had in mind?
bufferedNumber = f'{doc.GetTime().GetFrame(docFps):04}'
The irony of my putdown is that PHP can do it about as simply. But don’t expect your typical PHP programmers to know that ...
Printf style makes it explicit that it is an integer, and nothing else
will do:
bufferedNumber = "%0.4d" % doc.GetTime().GetFrame(docFps)
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
Printf style makes it explicit that it is an integer, and nothing else
will do:
bufferedNumber = "%0.4d" % doc.GetTime().GetFrame(docFps)
bufferedNumber = f'{doc.GetTime().GetFrame(docFps):04d}'
seems to handle it too.
Regarding PHP, many shared hosting vendors offer it without offering
Python. It's easier with PHP to serve many customers with a single PHP instantiation
Note that “04d” is not quite the same as “0.4d”.
Python has ASGI, which offers your choice of Web frameworks founded on async/await and asyncio. Instead of running as an addon module in the Web server, the Python code runs in a separate process, with its own
independent flow of control. This is much more versatile.
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
0.4d for an integer isn't valid in an f-string.
Python has ASGI, which offers your choice of Web frameworks founded on
async/await and asyncio. Instead of running as an addon module in the
Web server, the Python code runs in a separate process, with its own
independent flow of control. This is much more versatile.
Yes, and the separate processes use more machine resources which is why
low end hosting places prefer PHP.
0.4d for an integer isn't valid in an f-string.I wonder why not?
Separate PHP apps need separate web server processes, anyway.
Looking at this article about the top three languages for getting
programming jobs <https://www.zdnet.com/article/want-a-programming-job-make-sure-you-learn-these-three-languages/>,
naturally I couldn’t help noticing the code in the screenshot at the
top (my transcription):
bufferedNumber = str(doc.GetTime().GetFrame(docFps))
if len(bufferedNumber)<4:
for x in range(len(bufferedNumber),4):
bufferedNumber = "0" + bufferedNumber
I mean, really? Four lines to do what could be done in a single
expression?
Was that written by a PHP programmer, do you think?
Separate PHP apps need separate web server processes, anyway.
I had thought the opposite, but I'm not much of a PHP user.
With Python ASGI, you control what happens. A single process can
handle multiple connections, if you so choose.
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
With Python ASGI, you control what happens. A single process can handle
multiple connections, if you so choose.
Oh, I see what you mean. Yes you can write an ASGI server without multitasking, similar to node.js. Ugh.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 991 |
Nodes: | 10 (1 / 9) |
Uptime: | 132:57:12 |
Calls: | 12,960 |
Calls today: | 2 |
Files: | 186,574 |
Messages: | 3,266,147 |