New submission from Georgiy Treyvus:

Basically in a lot of situations in recent times I've had to make sure a bunch 
of files are all the same. Now diff is great but it only lets me pass two 
files. diff3 and sdiff also aren't what I'm looking for. So I decided to write 
my own little script that does that.

I was doing a few crude preliminary tests on an early version of the utility 
and that's when shit hit the fan. For reasons I can't explain Python 2.7.5 in 
some circumstances said that getstatusoutput wasn't an attribute of the 
commands module. The program executed fine though under Python 3.3.2.

Anyway here's some shell output which will leave you folks scratching your head 
as much as I am. I have several times checked the syntax and I just simply 
don't think I'm doing anything wrong. What are your thoughts?

=======SHELL OUTPUT=======

[georgiy@PANTHER mess]$ python
Python 2.7.5 (default, May 16 2013, 13:44:12) 
[GCC 4.8.0 20130412 (Red Hat 4.8.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import commands as run
>>> run.getstatusoutput
<function getstatusoutput at 0x247a9b0>
>>> 
[georgiy@PANTHER mess]$ python3
Python 3.3.2 (default, May 20 2013, 12:05:55) 
[GCC 4.8.0 20130412 (Red Hat 4.8.0-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess as run
>>> run.getstatusoutput
<function getstatusoutput at 0x7f5880225ef0>
>>> 
[georgiy@PANTHER mess]$ cat allthesame.py 
import sys
if sys.version_info==2:
        import commands as run
else:
        import subprocess as run
baseCommand='diff --recursive '+sys.argv[1]+' '
for item in sys.argv[2:]:
        if run.getstatusoutput(baseCommand+item)[0]!=0:
                print('not all the same')
                exit(1)
print('all the same')
exit(0)
[georgiy@PANTHER mess]$ cat a
test
[georgiy@PANTHER mess]$ cat b
test
[georgiy@PANTHER mess]$ python allthesame.py a b
Traceback (most recent call last):
  File "allthesame.py", line 8, in <module>
    if run.getstatusoutput(baseCommand+item)[0]!=0:
AttributeError: 'module' object has no attribute 'getstatusoutput'
[georgiy@PANTHER mess]$ python3 allthesame.py a b
all the same

----------
messages: 192782
nosy: wfatp
priority: normal
severity: normal
status: open
title: For reasons I can't explain Python in some cases says that 
getstatusoutput is not an attribute of the commands module but it is and should 
be
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18419>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to