On Sat, 9 Mar 2024 at 03:42, Grant Edwards via Python-list
wrote:
>
> On 2024-03-08, Chris Angelico via Python-list wrote:
> > On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list
> > wrote:
> >
> >> One might argue that "global" isn't
On 2024-03-08, Chris Angelico via Python-list wrote:
> On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list
> wrote:
>
>> One might argue that "global" isn't a good choice for what to call the
>> scope in question, since it's not global. It's l
On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list
wrote:
> One might argue that "global" isn't a good choice for what to call the
> scope in question, since it's not global. It's limited to that source
> file. It doesn't make sense to me to call
On 2024-03-07, Cameron Simpson via Python-list wrote:
> Yes. Note that the "global" namespace is the module in which the
> function is defined.
One might argue that "global" isn't a good choice for what to call the
scope in question, since it's not global.
On 06Mar2024 15:12, Jacob Kruger wrote:
So, this does not make sense to me in terms of the following snippet
from the official python docs page:
https://docs.python.org/3/faq/programming.html
"In Python, variables that are only referenced inside a function are
implicitly global. If a variable
Thanks again, all.
I think the python -i scoping2.py would have given me a good beginning
as well - will archive that one for use.
And, to maybe explain how I work - not an excuse at all - but, I am
actually 100% blind, so a lot of the IDE's, or their common
means/methods of interaction do
On 2024-03-07, dn via Python-list wrote:
> The idea of importing a module into the REPL and then (repeatedly)
> manually entering the code to set-up and execute is unusual (surely type
> such into a script (once), and run that (repeatedly). As you say, most
> of us would be working from an IDE
lobals()
functions. You may also have detected that many of us try to avoid
globals and the implicit assumptions about the behavior of mutable
collections (eg lists) when treated as 'global'. Then there are
"closures", the "LEGB" rule, namespaces, scope, and ...
--
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list
Grant Edwards via Python-list schreef op 6/03/2024 om 18:59:
On 2024-03-06, Roel Schroeven via Python-list
wrote:
> Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list:
>> >>> from scoping2 import *
>
> [...]
>
> I would advice not to use 'import *', if at all possible, for
multiple
On 2024-03-06, Roel Schroeven via Python-list wrote:
> Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list:
>> >>> from scoping2 import *
>
> [...]
>
> I would advice not to use 'import *', if at all possible, for multiple
> reasons, one of which is to prevent problems like this.
Unfortun
Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list:
>>> from scoping2 import *
Ah yes, that explains what's happening. After that statement, the name
dt_expiry in the current namespace is bound to the same object that the
name dt_expiry in the namespace of module scoping2 is bound to. F
Ok, Ethan, that makes sense - I generally work with modules in folders,
etc., but, this was just test code, but, 'see' if I instead import
scoping2 as sc2, and then refer to sc2.dt_expiry and sc2.do_it, then it
does operate as it should - thanks, again.
Jacob Kruger
+2782 413 4791
"Resistance
On 3/6/24 08:28, Jacob Kruger via Python-list wrote:
> C:\temp\py_try>python
> Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64
bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from scoping2 import *
And it becomes c
You'll see more details in other mail, but, here I am firing up standard
python interpreter from within windows terminal, and then executing
following line:
from scoping2 import *
And, this is under windows 11 windows terminal, which is where I
generally interact with my python code, via com
n
re-assigning it a new value, it seems like it might then actually
update/manipulate the global variable, but, either just calling
purely content retrieval functions against said objects, or assigning
them new values from scratch seems to then ignore the global scope
specified in the first line inside
Thanks for all your input people, and, yes, I know that besides the
scope oddities the rest of the code is not my normal style either - was
partly due to forms of experimentation to try figure out what could be
causing issues. For example, instead of [:] syntax, was specifically
using copy
Op 6/03/2024 om 16:39 schreef Roel Schroeven via Python-list:
Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list:
If you import the contents of that file into the python interpreter,
[...]
What exactly to you mean by "import the contents of that file into the
python interpreter"? Othe
Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list:
If you import the contents of that file into the python interpreter, [...]
What exactly to you mean by "import the contents of that file into the
python interpreter"? Other people have put your code in a script,
executed it, and saw
tely
dt_expiry = datetime.now()+timedelta(minutes=5)
print(dt_expiry.strftime("%Y-%m-%d %H:%M")) # just to show new
value has been assigned
# grab copy of list for re-use of items
l_temp = copy(l_test)
# following line means l_test will later on retain value i
On 3/6/2024 5:59 AM, Alan Gauld via Python-list wrote:
On 05/03/2024 22:46, Grant Edwards via Python-list wrote:
Unfortunately (presumably thanks to SEO) the enshittification of
Google has reached the point where searching for info on things like
Python name scope, the first page of links are
rom scratch seems to then ignore the global scope specified in
the first line inside the function?
Hope this makes more sense
No, it doesn't. Your code is working as one would expect. For example,
adding prints for the l_test variable, and removing the .clear() which
you claim ma
tes=5)
print(dt_expiry.strftime("%Y-%m-%d %H:%M")) # just to show new
value has been assigned
# grab copy of list for re-use of items
l_temp = copy(l_test)
# following line means l_test will later on retain value in global
scope because it was manipulated inside functio
minutes=5)
print(dt_expiry.strftime("%Y-%m-%d %H:%M")) # just to show new
value has been assigned
# grab copy of list for re-use of items
l_temp = copy(l_test)
# following line means l_test will later on retain value in global
scope because it was manipulated inside function inste
On 05/03/2024 22:46, Grant Edwards via Python-list wrote:
> Unfortunately (presumably thanks to SEO) the enshittification of
> Google has reached the point where searching for info on things like
> Python name scope, the first page of links are to worthless sites like
> geeksforgeeks.
to be worthless.
>From the page https://www.geeksforgeeks.org/global-local-variables-python/
Python Global variables are those which are not defined inside
any function and have a global scope whereas Python local
variables are those which are defined inside a function and their
On 05Mar2024 20:13, Jacob Kruger wrote:
Now, what almost seems to be occurring, is that while just manipulating
the contents of a referenced variable is fine in this context, the
moment I try to reassign it, that's where the issue is occurring .
Because there are no variable definitions in Py
That should, in theory, mean that if I assign a value to that variable
inside one of the functions, it should reflect globally?
However, it seems like that, while inside those functions, it can be
assigned a new list of values, but if I then return to the scope outside
the functions, it has
, mean that if I assign a value to that variable
inside one of the functions, it should reflect globally?
However, it seems like that, while inside those functions, it can be
assigned a new list of values, but if I then return to the scope outside
the functions, it has reverted back to being an
Chris Angelico writes:
> When you import something, all you're doing is getting a local
> reference to it; "from foo import make_adder" is basically like saying
> "import foo; make_adder = foo.make_adder". The function itself is
> still the same, and it still remembers its original context.
Than
om foo and bar in the main
> scope. Or whatever the scope is at the prompt.
That is correct.
> And yet, if I define function foo in module foo and function bar in
> module bar and import as above, I can't call function bar from function
> foo. But if I define functions foo and bar
I ran into what seems odd scoping to me when playing with some matching
examples for 3.10.
I kinda thought that if I do from foo import * and from bar import * in
the Python REPL, I'd get everything from foo and bar in the main
scope. Or whatever the scope is at the prompt.
And yet,
assignment.
>> Also how each print statement looking up the values for the spam variable.
>> This scope thing in python is very confusing too me still. Can anyone help
>> me to understand this code w.r.t to scope in Python?
> ...
>> $ python3 sample.py
>> After
Arup,
On 13/03/19 3:38 AM, Arup Rakshit wrote:
I have questions how nonlocal and global affecting the variable assignment.
Also how each print statement looking up the values for the spam variable. This
scope thing in python is very confusing too me still. Can anyone help me to
understand
On 2019-03-12, Arup Rakshit wrote:
> I have questions how nonlocal and global affecting the variable
> assignment. Also how each print statement looking up the values for
> the spam variable. This scope thing in python is very confusing too
> me still. Can anyone help me to understa
I have questions how nonlocal and global affecting the variable assignment.
Also how each print statement looking up the values for the spam variable. This
scope thing in python is very confusing too me still. Can anyone help me to
understand this code w.r.t to scope in Python?
def scope_test
On 21/02/2019 19:35, mnl.p...@gmail.com wrote:
> (I sent this a few days ago but got bounced without a reason—don’t see it
> posted, so I’m trying one more time.)
No, it got through. And it's in the archive:
https://mail.python.org/pipermail/python-list/2019-February/739548.html
--
https://mail
On 21/02/2019 18:35, mnl.p...@gmail.com wrote:
(I sent this a few days ago but got bounced without a reason—don’t see it
posted, so I’m trying one more time.)
It was posted, and commented on. You can see the thread in the mailing
list archives, if you don't believe me:
https://mail.python.or
(I sent this a few days ago but got bounced without a reason—don’t see it
posted, so I’m trying one more time.)
I thought this new C# feature would be a good thing to add to Python:
https://vcsjones.com/2019/01/30/csharp-8-using-declarations/
The nesting required by context managers can be at od
"mnl.p...@gmail.com" writes:
> with xx.open() as logfile:
> do this
> do that
> logfile.write()
> do this
> do that
> logfile.write()
That's a good sign you have identified a discrete collection of
statements that should be in a function. The function accepts
‘l
On 19/02/2019 05.15, mnl.p...@gmail.com wrote:
> This becomes more ugly if multiple withs get nested.
>
This is what contextlib.ExitStack is for.
--
https://mail.python.org/mailman/listinfo/python-list
On 2019-02-19, mnl.p...@gmail.com wrote:
> I thought this new C# feature would be a good thing to add to Python:
> https://vcsjones.com/2019/01/30/csharp-8-using-declarations/
>
> I find the nesting required by context managers to be at odds with the
> broad intent.
>
> The code indentation in pyt
This is probably better discussed on python-ideas, but here goes:
On 19/02/2019 04:15, mnl.p...@gmail.com wrote:
I thought this new C# feature would be a good thing to add to Python:
https://vcsjones.com/2019/01/30/csharp-8-using-declarations/
I find the nesting required by context managers to
I thought this new C# feature would be a good thing to add to Python:
https://vcsjones.com/2019/01/30/csharp-8-using-declarations/
I find the nesting required by context managers to be at odds with the
broad intent.
The code indentation in python should reflect the program logic and
flow as much
"Steve" writes:
> OK, I wrote:
>
> x = "A"
> print("x = " + x)
>
> def f(y):
> print("x= " + x + " y= "+ y)
>
> f(x)
>
> and it worked, inspite of what I was seeing in my own program.
> How quick I am to blame Python. (:
> When I isolate my function that stumped me, I will post it.
T
it.
Thanks.
Steve
Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Monday, February 18, 2019 12:40 PM
To: Python
Subject: Re: New rules for scope in a function?
On Tue, Feb
On Tue, Feb 19, 2019 at 4:36 AM Steve wrote:
>
> I have been programming for more years than I want to admit and believe that
> I have a good understanding when it comes to the Scope of Variables when
> using functions. Are the rules different when using python?
>
> It loo
I have been programming for more years than I want to admit and believe that I
have a good understanding when it comes to the Scope of Variables when using
functions. Are the rules different when using python?
It looks as if I have to pass all variables to and from the function before it
works
(most recent call last):
> > > File "", line 1, in
> > > File "", line 4, in Too
> > > File "", line 4, in
> > > NameError: name 'XS' is not defined
> > >
> > > The problem confuse me is that is XS a lo
> File "", line 4, in
> > NameError: name 'XS' is not defined
> >
> > The problem confuse me is that is XS a local variable of the list
> > comprehension?
>
> XS is not a local variable in the scope of either comprehension. XS is
> local to
On Fri, Dec 28, 2018 at 8:47 AM eryk sun wrote:
>
> On 12/27/18, Chris Angelico wrote:
> >
> > Class scope is special, and a generator expression within that class
> > scope is special too. There have been proposals to make these kinds of
> > things less special, b
On 12/27/18, Chris Angelico wrote:
>
> Class scope is special, and a generator expression within that class
> scope is special too. There have been proposals to make these kinds of
> things less special, but the most important thing to remember is that
> when you create a generator
On Fri, Dec 28, 2018 at 3:31 AM Ian Kelly wrote:
>
> On Wed, Dec 26, 2018 at 11:21 PM Chris Angelico wrote:
> >
> > On Thu, Dec 27, 2018 at 1:56 PM wrote:
> > >
> > > I saw the code below at stackoverflow. I have a little idea about the
> > >
On Wed, Dec 26, 2018 at 11:21 PM Chris Angelico wrote:
>
> On Thu, Dec 27, 2018 at 1:56 PM wrote:
> >
> > I saw the code below at stackoverflow. I have a little idea about the scope
> > of a class, and list comprehension and generator expressions, but still
> >
fuse me is that is XS a local variable of the list
> comprehension?
XS is not a local variable in the scope of either comprehension. XS is
local to the class statement's scope. For each comprehension, an
iterator for the current object referenced by XS gets instantiated
(early binding) and
On 12/26/2018 9:53 PM, jf...@ms4.hinet.net wrote:
I saw the code below at stackoverflow. I have a little idea about the scope of
a class, and list comprehension and generator expressions, but still can't
figure out why Z4 works and Z5 not. Can someone explain it? (in a
not-too-complicate
eryk sun於 2018年12月27日星期四 UTC+8下午2時31分58秒寫道:
> On 12/26/18, jf...@ms4.hinet.net wrote:
> > I saw the code below at stackoverflow. I have a little idea about the scope
> > of a class, and list comprehension and generator expressions, but still
> > can't figure out wh
On 12/26/18, jf...@ms4.hinet.net wrote:
> I saw the code below at stackoverflow. I have a little idea about the scope
> of a class, and list comprehension and generator expressions, but still
> can't figure out why Z4 works and Z5 not. Can someone explain it? (in a
> not-to
On Thu, Dec 27, 2018 at 1:56 PM wrote:
>
> I saw the code below at stackoverflow. I have a little idea about the scope
> of a class, and list comprehension and generator expressions, but still can't
> figure out why Z4 works and Z5 not. Can someone explain it? (in a
> not
greetings,
1)
Z4 = sum(val for val in XS)
is same as
Z4 = sum(XS)
2)
class Foo()
can also ne written as
class Foo:
3)
in Foo.x you are using the class just to assoxiate some variables with a
name. what is the purpose of tge script / what are you trying to do?
Abdur-Rahmaan Janhangeer
htt
I saw the code below at stackoverflow. I have a little idea about the scope of
a class, and list comprehension and generator expressions, but still can't
figure out why Z4 works and Z5 not. Can someone explain it? (in a
not-too-complicated way:-)
class Foo():
XS = [15, 15, 15, 15]
On Fri, Jul 13, 2018 at 10:43 PM, Ed Kellett wrote:
> On 2018-07-12 18:00, Chris Angelico wrote:
>> What do you mean by "fix"? Make the 'x' bind eagerly? That would break
>> basically every other use of closures.
>
> No. I mean make each x a new variable--closures would work as before,
> for-loops
On 2018-07-12 18:00, Chris Angelico wrote:
> What do you mean by "fix"? Make the 'x' bind eagerly? That would break
> basically every other use of closures.
No. I mean make each x a new variable--closures would work as before,
for-loops would change. If we have subscopes, it seems natural that
ent
On Fri, Jul 13, 2018 at 2:44 PM, wrote:
> On Thursday, July 12, 2018 at 7:16:48 PM UTC-4, Chris Angelico wrote:
>> Not sure, but here's a simpler implementation:
>>
>> except Exception as .err.0:
>> print(.err.0)
>> .err.0 = None
>> del .err.0
>>
>> In other words, exactly the same as
On Thursday, July 12, 2018 at 7:16:48 PM UTC-4, Chris Angelico wrote:
> On Fri, Jul 13, 2018 at 8:10 AM Igor wrote:
> > On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote:
> >> aleiphoenix writes:
> >>
> >> [snip]
> >>
> >> When an exception has been assigned using as target, it
On Thursday, July 12, 2018 at 5:45:52 PM UTC+8, Ben Bacarisse wrote:
>
> Yes, it's intentional, but it's not exactly a scope. In
>
> https://docs.python.org/3/reference/compound_stmts.html#try
>
> --
> Ben.
Thank you for the reply. Never thought of this
On Fri, Jul 13, 2018 at 8:10 AM, wrote:
> On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote:
>> aleiphoenix writes:
>>
>> [snip]
>>
>> When an exception has been assigned using as target, it is cleared at
>> the end of the except clause. This is as if
>>
>> except E as N:
Just word on quoting...
codewiz...@gmail.com writes:
> On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote:
>>
>> [snip]
You cut everything I wrote. What you left is what I quoted from the
Python documentation. In fairness to the authors you should probably
have cut the attrib
On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote:
> aleiphoenix writes:
>
> [snip]
>
> When an exception has been assigned using as target, it is cleared at
> the end of the except clause. This is as if
>
> except E as N:
> foo
>
> was translated to
>
> excep
On Thu, Jul 12, 2018 at 11:23 PM, Ed Kellett wrote:
> Could we fix:
>
> for x in something:
> blah(lambda a: a + x)
>
> while we're at it?
What do you mean by "fix"? Make the 'x' bind eagerly? That would break
basically every other use of closures.
ChrisA
--
https://mail.python.org/mailma
On 2018-07-12 14:03, Chris Angelico wrote:
> Dealing with reference cycles is generally done *periodically* rather
> than immediately (CPython disposes of unreferenced objects immediately
> upon last deref). You can avoid having a dedicated cycle detection
> pass by using a mark-and-sweep GC, but t
On Thu, Jul 12, 2018 at 10:31 PM, Ed Kellett wrote:
> On 2018-07-12 10:59, Steven D'Aprano wrote:
>> On Thu, 12 Jul 2018 01:37:24 -0700, aleiphoenix wrote:
>>
>>> My question is, does except ... as ... create a new scope from outer
>>> block, causing
On 2018-07-12 10:59, Steven D'Aprano wrote:
> On Thu, 12 Jul 2018 01:37:24 -0700, aleiphoenix wrote:
>
>> My question is, does except ... as ... create a new scope from outer
>> block, causing 'err' be hidden from outer scope? Is this intentional?
>
> No
On Thu, 12 Jul 2018 01:37:24 -0700, aleiphoenix wrote:
> My question is, does except ... as ... create a new scope from outer
> block, causing 'err' be hidden from outer scope? Is this intentional?
No, it is not a new scope, and yes, it is intentional. It's a nasty hack,
bu
ot;, line 19, in
> hello()
> File "err.py", line 16, in hello
> return '', err
> UnboundLocalError: local variable 'err' referenced before assignment
>
>
> But without this UnboundLocalError with Python-2.7.14
>
>
> My question is, do
#x27;: ValueError(), 'b': 2}
4: {'b': 2}
Traceback (most recent call last):
File "err.py", line 19, in
hello()
File "err.py", line 16, in hello
return '', err
UnboundLocalError: local variable 'err' referenced before assignmen
Thanks Chris,
Without using nonlocal any other options available?
On 30 Jan 2018 8:30 am, "Chris Angelico" wrote:
> On Tue, Jan 30, 2018 at 1:48 PM, Prahallad Achar
> wrote:
> > def a() :
> > Print (value)
> > def b() :
> > Value = 100
> > Return b
> >
> > Its a nested func
On Tue, Jan 30, 2018 at 1:48 PM, Prahallad Achar wrote:
> def a() :
> Print (value)
> def b() :
> Value = 100
> Return b
>
> Its a nested function. How can I use variable value just one function
> above the parent function.
> This is possible in tcl.. Is it possible in Python
def a() :
Print (value)
def b() :
Value = 100
Return b
Its a nested function. How can I use variable value just one function
above the parent function.
This is possible in tcl.. Is it possible in Python too?
--
https://mail.python.org/mailman/listinfo/python-list
m *x: int*,
also the PEP says "However, annotating a local variable will cause the
interpreter to always make it local to the scope and leaves the variable
uninitialized".
It is unitialized only if you do not initialize it.
Therefore in Python 3.6+ it is syntactically legal to
write:
ax for Variable Annotations
> <https://www.python.org/dev/peps/pep-0526/> was approved, in Python 3.6+
> it is possible to provide type hint information in the form *x: int*,
> also the PEP says "However, annotating a local variable will cause the
> interpreter to always
e type hint information in the form *x: int*, also
the PEP says "However, annotating a local variable will cause the
interpreter to always make it local to the scope and leaves the variable
uninitialized". Therefore in Python 3.6+ it is syntactically legal to
write:
def outer():
Chris Angelico writes:
>>> Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html
>> Heh, at first I read that as a bill to criminalise BSD support :-)
> I spluttered my drink on reading that. Good job Steven!
https://en.wikipedia.org/wiki/BDS_C
--
https://mail.python.org/mailman
On Wed, 26 Jul 2017 06:06 am, Chris Angelico wrote:
> Hmm. Aside from messing around with exec, is there any way to have a
> local and a global with the same name, and use the global?
Use globals['name'].
There's no way to do it with regular name look ups. This doesn't work:
spam = 'outside'
On Wed, Jul 26, 2017 at 4:36 AM, eryk sun wrote:
> On Tue, Jul 25, 2017 at 8:43 AM, Chris Angelico wrote:
>>
>> I'm not actually sure what happens if you use a global declaration at
>> top level. Is it ignored? Is it an error?
>
> It isn't ignored, but it shouldn't make a difference since normall
On Tue, Jul 25, 2017 at 5:38 AM, Thomas Jollans wrote:
> On 2017-07-25 09:28, Chris Angelico wrote:
>> It actually does the equivalent of:
>>
>> finally:
>> e = None
>
> I wonder why it would bother to load None... (as someone not very
> familiar with Python at the bytecode level)
If I may ha
On Tue, Jul 25, 2017 at 8:43 AM, Chris Angelico wrote:
>
> I'm not actually sure what happens if you use a global declaration at
> top level. Is it ignored? Is it an error?
It isn't ignored, but it shouldn't make a difference since normally at
module level locals and globals are the same. It make
On 2017-07-25 09:28, Chris Angelico wrote:
> On Tue, Jul 25, 2017 at 4:47 PM, Rustom Mody wrote:
>> +1
>> You can call it bug or bug-promoted-to-feature :D
>>
>> I call it surprising because I dont know of any other case in python where
>> a delete is user-detectable
>> ie python's delete of objec
On Tue, Jul 25, 2017 at 6:10 PM, Ben Finney wrote:
> I think those are not the only two options (the “except clause has its
> own scope” behaviour is an option that could have been chosen, for
> example).
>
> At this point the behaviour and motivation are clear, having been
> re
On Tue, Jul 25, 2017 at 6:33 PM, Steven D'Aprano
wrote:
> On Mon, 24 Jul 2017 23:47:17 -0700, Rustom Mody wrote:
>
>
> [...]
>> Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html
>
>
> Heh, at first I read that as a bill to criminalise BSD support :-)
>
I spluttered my drink o
On Mon, 24 Jul 2017 23:47:17 -0700, Rustom Mody wrote:
[...]
> Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html
Heh, at first I read that as a bill to criminalise BSD support :-)
--
“You are deluded if you think software engineers who can't write
operating systems or
rom the context, that was bound earlier in the same context.
> So consider this as a de-facto "the except clause "as name" variable
> is treated *as if* it exists in its own scope.
It is not, though. “as if it exists in its own scope” would mean that it
should not affect the ea
are implicitly deleted when they go out of scope.
So consider this as a de-facto "the except clause "as name" variable is
treated *as if* it exists in its own scope.
I agree that the behaviour of except is a little surprising, but that's
(according to the core devs) the les
On Tue, 25 Jul 2017 00:01:11 -0700, Ethan Furman wrote:
> On 07/24/2017 11:47 PM, Rustom Mody wrote:
>
>> Interesting to see this adjacent to news that non-participation is
>> about to be criminalized double of [snip]
>
> Rustom, All,
>
> This is a Python mailing list. Please keep the topics m
On Tue, Jul 25, 2017 at 4:47 PM, Rustom Mody wrote:
> +1
> You can call it bug or bug-promoted-to-feature :D
>
> I call it surprising because I dont know of any other case in python where
> a delete is user-detectable
> ie python's delete of objects always works quietly behind the scenes whereas
>
On Mon, 24 Jul 2017 21:48:56 -0700, Rustom Mody wrote:
> On Tuesday, July 25, 2017 at 7:12:44 AM UTC+5:30, Ben Finney quoted
> Thomas Jefferson's :
>
>> The cost of education is trivial compared to the cost of ignorance.
>
>
> An interesting standard of “trivial”… given…
You're reading the qu
Ben Finney writes:
> Having to make another name for the same object, merely to avoid some
> surprising behaviour, is IMO un-Pythonic.
I suppose my objection is rooted in the fact this behaviour is implicit;
my code has not issued a ‘del’ statement, and so I don't expect one; yet
it occurs impli
Ben Finney schrieb am 25.07.2017 um 08:34:
> Ethan Furman writes:
>
>> Something like:
>>
>> try:
>>
>> except ZeroDivisionError as dead_exc:
>> exc = dead_exc
>>
>>
>> print(text_template.format(exc=exc)
>
> That strikes me as busy-work; the
On 07/24/2017 11:47 PM, Rustom Mody wrote:
Interesting to see this adjacent to news that non-participation is about
to be criminalized double of [snip]
Rustom, All,
This is a Python mailing list. Please keep the topics marginally on-topic.
Thanks.
--
~Ethan~
--
https://mail.python.org/ma
On Tuesday, July 25, 2017 at 12:04:45 PM UTC+5:30, Ben Finney wrote:
> Ethan Furman writes:
>
> > Something like:
> >
> > try:
> >
> > except ZeroDivisionError as dead_exc:
> > exc = dead_exc
> >
> >
> > print(text_template.format(exc=exc)
>
Ethan Furman writes:
> Something like:
>
> try:
>
> except ZeroDivisionError as dead_exc:
> exc = dead_exc
>
>
> print(text_template.format(exc=exc)
That strikes me as busy-work; the name in the ‘except’ clause already
*has* the object, and
1 - 100 of 1043 matches
Mail list logo