ailingSingleton' object has no attribute
'special_value'
Where's the error in my thinking (or code) ?
Thanks,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
the illegal, I suppose, as the self-
introspection capabilities of the language are being
leveraged to achieve a legal purpose.
Which seems akin constructs for generating compatibility
between versions.
It seems the answer is being pointed to in Matts response.
It just mightily surprised me.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
intent: a class where each instance is aware of every other
> instance - yet
> the word "Singleton" implies there's only one (cf a dict full of ...)?
The latter.
Regards,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
class Something( Singleton ):
Could have been but the legacy codebase came with Borg ...
> - from there, plenty of 'templates' exist for Singletons,
... which was taken from the Web ages ago.
> - this article (https://python-patterns.guide/gang-of-four/singleton/)
Reading.
K
(valid) code ...
In Python a distinction can be made between "runnable" and "valid" :-D
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
ttributeError: print('first instantiation'); self.initialized = True
and then changing that to
>>> try: self.initialized:bool
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
> > >>> True
> >
> > and then changing that to
> >
> > >>> try: self.initialized:bool
>
> But that's not equivalent code.
I learned as much (RHS vs LHS).
But it did not _intuitively_ resonate with the sentiment
"type annotation does not change the running of code".
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
y not available in your system's package manager?
... this clearly often answers to "no" for applications of
any complexity.
Is there a suggested proper path to deal with that (Debian is
of interest to me here) ?
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
apt
- needs some packages only available via pip
- needs some packages newer than what is available via apt
?
Thanks,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
Am Fri, Nov 03, 2023 at 05:26:06PM +0100 schrieb Dieter Maurer:
> Karsten Hilbert wrote at 2023-11-3 14:47 +0100:
> > ...
> >> Are they not available in your system's package manager?
> >
> >... this clearly often answers to "no" for applications of
&
g nice and well, but:
How does one "fill" that venv with packages from pip during
apt-get install python3-app-of-interest
?
Is the suggested way really to pip-install into this venv
during apt-get install ?
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
ian does just fine in resolving dependencies it knows
about within its .deb package universe. The problem arises
when there's unpackaged modules required. The only answer
seems to be to package such modules oneself.
If that's been conquered a venv isn't even needed anymore.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
to the venv suggested above.
When they are apt-gettable no venv is needed in the first
place. One would just install the application script like any
other binary, and which loads apt-installed modules just so.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
sed application.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
osts I gather the answer to my question is
"simply": unpackaged-but-needed modules need to be packaged.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
u would need to come up with
> an APT-based installer that doesn't do that.
>
> Obviously it's not unthinkable;
Certainly not, it's just that I had hoped someone goes: look here
and all of this ...
> it is just one more thing to figure out.
... has been thought through before.
Thanks,
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
and values of
str OR
list of anything OR
dict with
keys of str
and values of anything
I'd have thunk list[dict[str,str]] matches that ?
This is on Python 3.11.
Am Fri, Dec 29, 2023 at 01:15:29PM +0100 schrieb Karsten Hilbert via
Python-list:
> I am not sure why mypy thinks this
>
> gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible
> type "List[Dict[str, str]]"; expected
> "
retty good recreation of your psuedo-code description.
I agree that mypy's grasp of my intent from
queries:list[dict[str, str | list | dict[str, Any]]]=None,
into
"List[Dict[str, Union[str, List[Any], Dict[str, Any"
seems accurate. I just don't understand why list[dict[str,
str]] should not pass that construct.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
OR
list[dict[str, str]]
the last of which should provide coverage of
[{'some key': 'some value'}]
> Can you use a TypeGuard here?
Not from what I understand about them...
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
in either str
or int
and have type checking pass either input as valid" -- yet mypy doesn't seem
to share that idea.
Or else there's something I haven't wrapped my head around yet. But what ?
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
ueries)
and run mypy over that (at least inside my complex codebase) I will
get a type mismatch being hinted at.
So far I don't grasp at which point my reasoning above is faulty.
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
ll take it as an opportunity to refactor them.
So, at least that much good has come from the mypy hint ;-)
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
Those are then used
in display rather than being fed to run_queries().
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
Thanks to all. I ended up using Sequence for the list part
and Mapping for the dict part, which does require "import
typing" which I would rather have avoided.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
|dict[str,dict[str, dict[str, Ant]]]
>
> My impression at this moment is that you are write something like: dict[str,
> str | int] as
> as shorthand for dict[str, str] | dict[str, int].
I do.
> But those two are different types.
A-ha ! In what way ?
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
Am Sat, Jan 13, 2024 at 09:20:00PM +0100 schrieb Karsten Hilbert via
Python-list:
> > I was wondering if
> > your type hint for queries shouldn't be the following.
> >
> > queries:list[dict[str,str]|dict[str,list]|dict[str,dict[str, dict[str,
> > Ant]]]
Wait,
just the part you think you are better off using python, namely
personalization ?
Create personalized files and send them with your trusted mailx solution ?
That'll take out wrestling with smptlib et al.
Karsten
--
https://mail.python.org/mailman/listinfo/python-list
> > Why not foxus on just the part you think you are better off using python,
> > namely personalization ?
> >
> > Create personalized files and send them with your trusted mailx solution ?
>
> Karsten,
>
> Too much time. And while mailx accepts the '-a
> On Tue, 30 Jan 2024, Karsten Hilbert wrote:
>
> > It doesn't need to. It just sends the (pre-personalized-by-Python) mail
> > files.
>
> Karsten,
>
> In which case, I might as well have Python format and send the messages. :-)
Certainly. But it seems you
talling using pip.
> You must use a venv to pip install packages from pypi now.
Which makes one wonder how one is supposed to package Python
applications requiring modules not yet packaged by Debian.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
nd, yes, I
can safely inhibit propagation^1
finally:
conn.close()# which should .rollback()
automagically in case we had not reached to .commit()
?
Thanks for insights,
Karsten
#---
^1:
This particul
about the SQL itself
succeeded but then the COMMIT failed due to serialization. I
was wondering about where to best place any needed
conn.commit(). My knee-jerk reaction was to then put it last
in the try: block...
All this is probably more related to Python than to PostgreSQL.
Thanks,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
gmLog2.log_stack_trace()
__safely_close_cursor_and_rollback_close_conn (
curs_close,
tx_rollback,
conn_close
)
raise
if get_col_idx:
col_idx = get_col_indices(curs)
curs_close()
tx_commit()
conn_close()
return (data, col_idx)
#
Best,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
something
Boring and repetitive and safe(r):
try:
do something
except:
log something
try:
.commit()
except:
log something
I eventually opted for the last version, except for factoring
out the second try: exc
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list:
> On 8/09/24 9:20 am, Karsten Hilbert wrote:
> > try:
> > do something
> > except:
> > log something
> > finally:
> > .commit(
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list:
> On 8/09/24 9:20 am, Karsten Hilbert wrote:
> > try:
> > do something
> > except:
> > log something
> > finally:
> > .commit(
e
> important that it does the right thing.
> If it is convenient (it may not be) to put the whole thing in a function, you
> may feel
> that the follwing is less ugly:
The whole thing does reside inside a function but the exit-early pattern
> try:
> d
caught and logged.
I am open to suggestions.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
from a much larger codebase.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
ut that's true only when writable connections are
being pooled, which should be avoidable in many cases.
Any pool worth its salt should rollback any potentially
pending transactions of a connection when it is given back
that pooled connection. Unless explicitely told not to.
Karsten
--
GPG 40
return to the pool ?
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
;re saying it isn't automatic after all,
No again, such shenanigans only start to happen when pooling
is brought into the equation.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
n, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> tex = '\sout{'
>>> tex
'\\sout{'
>>>
Am I missi
t re.search("\sout\{", line):
> if not re.search("\\sout{", line):
> if not re.search("\\sout\{", line):
unwanted_tex = '\sout{'
if unwanted_tex not in line: do_something_with_libreoffice()
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
Am Tue, Oct 08, 2024 at 04:59:48PM -0400 schrieb Alan Bawden via Python-list:
> Karsten Hilbert writes:
>
>Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
>Type "help", "copyright", "credits" or "license
if that means installing every
application into its own *system-wide* venv) - do let me
know.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
Am Sun, Oct 06, 2024 at 12:21:09AM +0200 schrieb Karsten Hilbert via
Python-list:
> Am Sat, Oct 05, 2024 at 10:27:33PM +0200 schrieb Ulrich Goebel via
> Python-list:
>
> > Debian (or even Python3 itself) doesn't allow to pip install required
> > packages system wide
figuration files in the iterable will be read. A single
filename may also be given.
Return list of successfully read files.
So, the very fact that it does not return any output AND
returns an empty list is the (intended) way of knowing the
error state.
Karsten
--
GPG 40BE 5B
y,
http, as in a centralized configuration repository.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
201 - 250 of 250 matches
Mail list logo