------------------------------------------- On Sat, 10/26/13, Amit Saha <amitsaha...@gmail.com> wrote:
Subject: Re: [Tutor] why does platform.architecture default to sys.executable? To: "Albert-Jan Roskam" <fo...@yahoo.com> Cc: "Python Mailing List" <tutor@python.org> Date: Saturday, October 26, 2013, 6:51 PM On Sun, Oct 27, 2013 at 2:39 AM, Albert-Jan Roskam <fo...@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. ===> os.uname is Unix-only: http://docs.python.org/2/library/os.html#os.uname os.uname() Return a 5-tuple containing information identifying the current operating system. The tuple contains 5 strings: (sysname, nodename, release, version, machine). Some systems truncate the nodename to 8 characters or to the leading component; a better way to get the hostname is socket.gethostname() or even socket.gethostbyaddr(socket.gethostname()). Availability: recent flavors of Unix. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor