Bongo,
Variables in most programming languages either have to be removed manually
or allowed to drift outside a boundary when they disappear for scoping
reasons and perhaps are garbage collected at some point.
There are many ways to make transient variables that disappear at some time
and do we
> You can actually just do that with simple assignment!
>
> short_view = my_object.stuff.long_stuff.sub_object
> print(short_view.some_method())
but then have to delete the variable manually
del short_view
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 19 Oct 2023 at 19:34, Karsten Hilbert wrote:
>
> > > As per my recent foray into abusing existence-checking for Singleton
> > > assurance
> > > along such lines as
> > >
> > > >>> try: self.initialized
> > > >>> except AttributeError: print('first instantiation'); self.initialized
> > >
> > As per my recent foray into abusing existence-checking for Singleton
> > assurance
> > along such lines as
> >
> > >>> try: self.initialized
> > >>> except AttributeError: print('first instantiation'); self.initialized =
> > >>> True
> >
> > and then changing that to
> >
> > >>> try:
On Thu, 19 Oct 2023 at 18:25, Karsten Hilbert wrote:
>
> > > > Fundamentally no, at least not without some shenanigans. Type hints do
> > > > not affect the regular running of the code,
> > >
> > > Except when they do ;-)
> > >
> > > ... depending on what counts as (valid) code ...
> > >
> > > In
> > > Fundamentally no, at least not without some shenanigans. Type hints do
> > > not affect the regular running of the code,
> >
> > Except when they do ;-)
> >
> > ... depending on what counts as (valid) code ...
> >
> > In Python a distinction can be made between "runnable" and "valid" :-D
> >
On Thu, 19 Oct 2023 at 18:04, Karsten Hilbert wrote:
>
> > > or something like that. Basically, any way to avoid writing `= None` over
> > > and over again.
> >
> > Fundamentally no, at least not without some shenanigans. Type hints do
> > not affect the regular running of the code,
>
> Except
> > or something like that. Basically, any way to avoid writing `= None` over
> > and over again.
>
> Fundamentally no, at least not without some shenanigans. Type hints do
> not affect the regular running of the code,
Except when they do ;-)
... depending on what counts as (valid) code ...
In