Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197885
| From | Maria Sophia <mariasophia@comprehension.com> |
|---|---|
| Newsgroups | comp.sys.mac.system, alt.os.linux, alt.comp.os.windows-11, comp.lang.python |
| Subject | Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB |
| Date | 2026-08-20 08:32 -0800 |
| Organization | BWH Usenet Archive (https://usenet.blueworldhosting.com) |
| Message-ID | <1167a7q$l51$1@nnrp.usenet.blueworldhosting.com> (permalink) |
| References | <116673g$ptq$1@nnrp.usenet.blueworldhosting.com> <1166bch$39qqm$2@dont-email.me> |
Cross-posted to 4 groups.
Lawrence D¢Oliveiro wrote:
> You do this sequence of execute/fetch calls 4 times in your script.
Now, turning to your second set of suggestions regarding a more Pythonic
coding philosophy and perhaps making use of the db_iter helper: ...
It's a good idea where using a generator function to wrap repetitive
execute() and fetching patterns certainly keeps code DRY (Don't Repeat
Yourself) & I can see the advantage of putting the lookup in the loop.
It will take a while for me to fully digest your helpful suggestions, as I
noted in the prior response that I suffer from lack of SQL experience.
In fact, in the original thread, I originally tried to disassemble the
homescreen using SQL queries in DB Browser for SQLite v3.13.1 but gave up.
Message-ID: <1165rqh$163h$1@nnrp.usenet.blueworldhosting.com>
If I were to adapt your db_iter concept while keeping parameterized queries
safe, I'd probably modify it to accept a parameters tuple like this:
Python
def db_iter(conn, cmd, params=(), mapfn=lambda x: x):
"""Executes cmd with parameters and yields mapped results."""
for item in conn.cursor().execute(cmd, params):
yield mapfn(item)
That way, I get the clean generator loop style you recommended and maintain
strict parameter safety. Thanks again for taking the time to review the
code and thank you for offering suggestions such as that refactoring idea.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-20 07:46 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-20 08:14 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-20 08:32 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-20 22:57 +0000
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-21 01:37 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-21 01:54 -0800
Re: PSA: A python script to clone your phone exactly, over Wi-Fi or USB Maria Sophia <mariasophia@comprehension.com> - 2026-08-23 12:36 -0800
csiph-web