49 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Importing a feature from the ``++__future__++`` module turns on that feature from a future version of Python in your module. The purpose is to allow you to gradually transition to the new features or incompatible changes in future language versions, rather than having to make the entire jump at once.
Because such changes must be applied to the entirety of a module to work, putting such imports anywhere but in the beginning of the module doesn't make sense. It would mean applying those restrictions to only part of your code. Because that would lead to inconsistencies and massive confusion, it's not allowed.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
name = "John"
from __future__ import division # Noncompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
from __future__ import division
name = "John"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Move this "__future__" import to the top of the module.
'''
== Comments And Links
(visible only on this page)
=== on 29 Apr 2015, 07:09:00 Ann Campbell wrote:
I've edited your edits [~elena.vilchik]. Double-check me, please
endif::env-github,rspecator-view[]