[Tutor] why does platform.architecture default to sys.executable?

Amit Saha amitsaha.in at gmail.com
Sat Oct 26 19:13:33 CEST 2013


On Oct 27, 2013 2:51 AM, "Amit Saha" <amitsaha.in at gmail.com> wrote:
>
> On Sun, Oct 27, 2013 at 2:39 AM, Albert-Jan Roskam <fomcl at yahoo.com>
wrote:
> > Hi,
> >
> > Why does the "executable" parameter default to sys.executable?
Yesterday I
> > was surprised to see platform.architecture return "32bit" on a 64-bit
> > system, just because a 32-bit Python interpreter was installed. Wouldn't
> > this make more sense:
> >
> > import sys, platform
> > pf = sys.platform.lower()[:3]
> > executable = "iexplore.exe" if pf[:3] == "win" else "/bin/ls"
>
> I think it's mainly because of avoiding choosing arbitrary programs,
> although they are most certainly guaranteed to be present. Besides,
> there are better ways to find the platform architecture, I think.
> os.uname() comes to mind.

Although that will lie if you have, for example a 32-bit os installed on a
64-bit system. Then, you can read /proc/cpuinfo and look for the lm flag.
If it is present, it is a 64-bit system, else  a 32-bit one. This is
specific to Intel, i think.

>
> -Amit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131027/d420ac9e/attachment-0001.html>


More information about the Tutor mailing list