On 12/5/14 7:34 AM, Steven D'Aprano wrote:
Ned Batchelder wrote:
On 12/5/14 4:53 AM, Steven D'Aprano wrote:
Oh, I learned something new: strictly speaking, this is implementation-
dependent and not guaranteed to work in the future!
def func():
global math
import math
I don't thi
On Fri, Dec 5, 2014 at 11:34 PM, Steven D'Aprano
wrote:
>> I don't think this is implementation-dependent.
>
> The docs say that it is:
>
> https://docs.python.org/3/reference/simple_stmts.html#the-global-statement
>
> Names listed in a global statement MUST NOT [emphasis added] be
> defin
On Fri, Dec 5, 2014 at 11:26 PM, Steven D'Aprano
wrote:
> Chris Angelico wrote:
>
>>> def func():
>>> global math
>>> import math
>>
>> When would you actually *want* this, though? Given that 'import'
>> already caches, there's not much point caching globally, and the idea
>> that a functi
Ned Batchelder wrote:
> On 12/5/14 4:53 AM, Steven D'Aprano wrote:
>> Oh, I learned something new: strictly speaking, this is implementation-
>> dependent and not guaranteed to work in the future!
>>
>> def func():
>> global math
>> import math
>
> I don't think this is implementation-d
Chris Angelico wrote:
> On Fri, Dec 5, 2014 at 8:53 PM, Steven D'Aprano
> wrote:
>> Oh, I learned something new: strictly speaking, this is implementation-
>> dependent and not guaranteed to work in the future!
>>
>> def func():
>> global math
>> import math
>
> When would you actually *
On 12/5/14 4:53 AM, Steven D'Aprano wrote:
Oh, I learned something new: strictly speaking, this is implementation-
dependent and not guaranteed to work in the future!
def func():
global math
import math
I don't think this is implementation-dependent. The import statement is
an assi
On Fri, Dec 5, 2014 at 8:53 PM, Steven D'Aprano
wrote:
> Oh, I learned something new: strictly speaking, this is implementation-
> dependent and not guaranteed to work in the future!
>
> def func():
> global math
> import math
When would you actually *want* this, though? Given that 'impor
Ben Finney wrote:
> Steven D'Aprano writes:
>
>> LJ wrote:
>>
>> > def gt(l):
>> >a["1"] = a["1"] | set([l])
>>
>> The difference between this example and your second one:
>>
>> > def gt2(l):
>> >b=b+l
>>
>>
>> is that the second is a "binding operation" and the first is not.
>
> I disa