I’m facing a very weird problem in my python script when I use the function all().
The console gives me false (which is obviously correct) for this line:
all(x == 2 for x in (8,2,2,2))
and in my script the same line returns true?!
What is going on here? Are there other all() function which could have overwritten it in my script? I’m importing the following modules:
import os
import sys
import string
import time
from time import gmtime, strftime
from optparse import OptionParser, OptionGroup
import cx_Oracle
from pylab import *
import ROOT
from array import array
import logging
from traceback import format_exc
To access the builtin
all()when it’s being smashed, you can importbuiltins. E.g:(Below the line where
pylabis imported).Alternatively, if you need to access
pylab.all(), you can do:Or, better yet, do
import pylabrather thanfrom pylab import *.You might want to file a bug report with
pylabtoo, that’s seriously bad behaviour. Although do note theimport * from ...usage of imports is discouraged for this reason.As DSM points out in the comments, this is presuming you are using 3.x, under 2.x, it is
__builtin__.