Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Undefined name: xrange() was removed in Python 3 #1258

Merged
merged 1 commit into from
Dec 3, 2018

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Nov 29, 2018

xrange() was removed in Python 3 in favor of a revamped version of range(). This PR proposes adding from six.moves import xrange to ensure equivalent functionality on both Python 2 and Python 3 and to avoid the potential of NameError being raised at runtime on Python 3.

flake8 testing of https://github.com/tensorflow/tensor2tensor on Python 3.7.1

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./tensor2tensor/models/research/vqa_self_attention.py:658:12: F821 undefined name 'xrange'
  for _ in xrange(hparams.num_rec_steps):
           ^
1    F821 undefined name 'xrange'
1

@googlebot googlebot added the cla: yes PR author has signed CLA label Nov 29, 2018
@lukaszkaiser
Copy link
Contributor

Great thanks!

@lukaszkaiser lukaszkaiser merged commit f58a485 into tensorflow:master Dec 3, 2018
@cclauss cclauss deleted the undefined-name-xrange branch December 4, 2018 04:19
theorm added a commit to theorm/tensor2tensor that referenced this pull request Dec 4, 2018
* master: (300 commits)
  Allow vgg_ckpt_dir as a decode_hparam and make it None by default.
  flags.py -> (utils/flags.py)
  Move nfg to models/video for external collaboration.
  Move nfg to models/video for external collaboration.
  Undefined name: xrange() was removed in Python 3 (tensorflow#1258)
  internal merge of PR tensorflow#1257
  Fix universal transformer decoding (tensorflow#1257)
  Let weights_multi_problem_all support tensor taskid
  Delete unused only_last from dataset. The functionality was buggy to
  Internal change
  Add En-Ro translation, reserve ids for extra tasks in TPU adafactor multi-Transformer.
  adding 256*256 imagenet class to t2t.problems.
  internal merge of PR tensorflow#1256
  Differentiate summaries for train and eval. (tensorflow#1256)
  internal merge of PR tensorflow#1242
  Word Error Rate for Speech Recognition (tensorflow#1242)
  internal merge of PR tensorflow#1253
  internal merge of PR tensorflow#1247
  add problems, conll2002_es_ner and conll2002_nl_ner (tensorflow#1253)
  Fix MRPC link (tensorflow#1247)
  ...
kpe pushed a commit to kpe/tensor2tensor that referenced this pull request Mar 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants