> > 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
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 wh
> > > 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: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
> > 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: self.ini
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
> > >
> 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
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
On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, avi.e...@gmail.com wrote:
> There are many ways to make transient variables that disappear at some time
> and do we need yet another? Yes, you can create one of those ways but what
> is the big deal with deleting a variable when no longer used?
On 19Oct2023 20:16, Bongo Ferno wrote:
A with statement makes clear that the alias is an alias and is local,
and it automatically clears the variable after the block code is used.
No it doesn't:
>>> with open('/dev/null') as f:
... print(f)
...
<_io.TextIOWrapper name='/dev/
10 matches
Mail list logo