Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f8fed2

Browse files
committed
merge with 3.4
2 parents 92b47a4 + a94ad1e commit 4f8fed2

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

Doc/faq/programming.rst

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,8 @@ What are the "best practices" for using import in a module?
292292
-----------------------------------------------------------
293293

294294
In general, don't use ``from modulename import *``. Doing so clutters the
295-
importer's namespace. Some people avoid this idiom even with the few modules
296-
that were designed to be imported in this manner. Modules designed in this
297-
manner include :mod:`tkinter`, and :mod:`threading`.
295+
importer's namespace, and makes it much harder for linters to detect undefined
296+
names.
298297

299298
Import modules at the top of a file. Doing so makes it clear what other modules
300299
your code requires and avoids questions of whether the module name is in scope.
@@ -308,11 +307,6 @@ It's good practice if you import modules in the following order:
308307
directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc.
309308
3. locally-developed modules
310309

311-
Never use relative package imports. If you're writing code that's in the
312-
``package.sub.m1`` module and want to import ``package.sub.m2``, do not just
313-
write ``from . import m2``, even though it's legal. Write ``from package.sub
314-
import m2`` instead. See :pep:`328` for details.
315-
316310
It is sometimes necessary to move imports to a function or class to avoid
317311
problems with circular imports. Gordon McMillan says:
318312

@@ -343,14 +337,6 @@ module, but loading a module multiple times is virtually free, costing only a
343337
couple of dictionary lookups. Even if the module name has gone out of scope,
344338
the module is probably available in :data:`sys.modules`.
345339

346-
If only instances of a specific class use a module, then it is reasonable to
347-
import the module in the class's ``__init__`` method and then assign the module
348-
to an instance variable so that the module is always available (via that
349-
instance variable) during the life of the object. Note that to delay an import
350-
until the class is instantiated, the import must be inside a method. Putting
351-
the import inside the class but outside of any method still causes the import to
352-
occur when the module is initialized.
353-
354340

355341
Why are default values shared between objects?
356342
----------------------------------------------

Makefile.pre.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ AST_C= $(AST_C_DIR)/Python-ast.c
343343
AST_ASDL= $(srcdir)/Parser/Python.asdl
344344

345345
ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
346-
# XXX Note that a build now requires Python exist before the build starts
346+
# Note that a build now requires Python to exist before the build starts.
347+
# Use "hg touch" to fix up screwed up file mtimes in a checkout.
347348
ASDLGEN= @ASDLGEN@ $(srcdir)/Parser/asdl_c.py
348349

349350
##########################################################################
@@ -1509,7 +1510,10 @@ TAGS::
15091510
etags Include/*.h; \
15101511
for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15111512

1512-
# Touch generated files
1513+
# This fixes up the mtimes of checked-in generated files, assuming that they
1514+
# only *appear* to be outdated because of checkout order.
1515+
# This is run while preparing a source release tarball, and can be run manually
1516+
# to avoid bootstrap issues.
15131517
touch:
15141518
cd $(srcdir); \
15151519
hg --config extensions.touch=Tools/hg/hgtouch.py touch -v

0 commit comments

Comments
 (0)