Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Terry Reedy
On 7/7/2017 2:30 AM, Ben S. via Python-list wrote: Can I somehow check from inside a Python script if the executing Python engine is major version v2 or v3? I am thinking about a code similar to if (os.python-majorversion<3) print hello else print (hello) For this, just use print('hell

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 03:38 am, Marko Rauhamaa wrote: > >> Notice that Scheme refers directory to conventional RAM: >> >> Variables and objects such as pairs, vectors, and strings implicitly >> denote locations > > > That implies that it is impossible to implement Scheme: > > - us

Re: Test 0 and false since false is 0

2017-07-07 Thread Peter Otten
Sayth Renshaw wrote: > I was trying to solve a problem and cannot determine how to filter 0's but > not false. > > Given a list like this > ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9] > > I want to be able to return this list > ["a","b",None,"c","d",1,False,1,3,[],1,9,{},9

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > Steve D'Aprano : > >> An address is a concrete location or place, in other words a physical >> position in some space, while identity is the abstract state or >> quality of being identical (sameness), in other words a state of >> being. > > Wh

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > I believe identity can be defined much better, in numerous isomorphic > ways in fact. > > For example, we could equate each object with a sequence number > (unrelated with its id()). You can define that the "None" object is in > fact the natura

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Jeremiah Dodds
"Ben S. via Python-list" writes: > Can I somehow check from inside a Python script if the executing Python > engine is major version v2 or v3? import sys sys.version_info[0] (If you just need to print() consistently, you should follow Terry's advice) -- https://mail.python.org/mailman/listinf

RE: Test 0 and false since false is 0

2017-07-07 Thread Paul D. DeRocco
> From: Dan Sommers > > > On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote: > > > > I have tried or conditions of v == False etc but then the 0's being > > false also aren't moved. How can you check this at once? > > Maybe this will help: > > Python 3.5.3+ (default, Jun 7 2017, 23:2

Re: how to get partition information of a hard disk with python

2017-07-07 Thread Tim Golden
On 07/07/2017 07:18, palashkhair...@gmail.com wrote: On Wednesday, September 22, 2010 at 4:01:04 AM UTC+5:30, Hellmut Weber wrote: Hi list, I'm looking for a possibility to access the partiton inforamtion of a hard disk of my computer from within a python program. Googling I found the module 'p

Re: About the implementation of del in Python 3

2017-07-07 Thread Dan Wissme
Le 06/07/2017 à 20:56, Nathan Ernst a écrit : In Python, "==" is not a reference equality operator (and I hate Java for their misuse of the operator), so I absolutely disagree with using the Java description to describe Python's "==" operator, primarily because, well, it's wrong. Simple example:

Re: Test 0 and false since false is 0

2017-07-07 Thread zhenghao li
you can use the "is" for identity test. l1 = [v for v in array if not v is 0] l2 = [v for v in array if v is 0] On Jul 6, 2017, at 10:31 PM, Sayth Renshaw mailto:flebber.c...@gmail.com>> wrote: I was trying to solve a problem and cannot determine how to filter 0's but not false. Given a list l

Re: About the implementation of del in Python 3

2017-07-07 Thread Robin Becker
On 07/07/2017 07:42, Steve D'Aprano wrote: On Fri, 7 Jul 2017 03:05 am, Marko Rauhamaa wrote: ... [1] It may actually be instinctive -- there are studies that show that even young babies express surprise when they see something that violates the intuitive properties of identity. For e

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano wrote: > On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: >> In Second-Order Logic, you can define identity directly: >> >> ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) > > Translating to English: > > For all x, for all y, x equals y if and only if for all P

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 04:30 pm, Ben S. wrote: > Can I somehow check from inside a Python script if the executing Python engine > is major version v2 or v3? Yes you can, but generally speaking you shouldn't. import sys if sys.version_info >= (3,): # the comma is important print("version 3") el

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 5:29 PM, Dan Wissme wrote: > Strange behavior in Python 3.6.0 i = 3000 j = 3000 i is j > False n = 4000 ; m = 4000 ; n is m > True Firstly, remember that immutables are allowed, but not required, to be shared. So this kind of "strange behaviour" is compl

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Steve D'Aprano wrote: In practice, identity is hardly important in Python, except for a few limited cases, and the prohibition against using `is` when you mean `==`. On the contrary, it's a very important concept needed to make sense of the way things behave when mutation is involved. Witness

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Marko Rauhamaa wrote: In Second-Order Logic, you can define identity directly: ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) That looks more like a definition of *equality* to me. In mathematics, everything is immutable, so there isn't really any distinction between equality and identity. -- Greg -- ht

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Steve D'Aprano wrote: That implies that it is impossible to implement Scheme: - using a programming language where variables and objects may move during their lifetime; - or using a computing device without conventional memory, e.g. implementing Scheme using hydraulics, DNA computing, clockwork

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 05:29 pm, Dan Wissme wrote: > Strange behavior in Python 3.6.0 > >>> i = 3000 > >>> j = 3000 > >>> i is j > False > >>> n = 4000 ; m = 4000 ; n is m > True The Python interpreter is allowed to cache integers and reuse them. The interactive interpreter sometimes does so: if you

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 05:45 pm, Chris Angelico wrote: > On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano > wrote: >> On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: >>> In Second-Order Logic, you can define identity directly: >>> >>> ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) >> >> Translating to English:

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 06:05 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> In practice, identity is hardly important in Python, except for a few limited >> cases, and the prohibition against using `is` when you mean `==`. > > On the contrary, it's a very important concept needed to make > sense

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > >> I believe identity can be defined much better, in numerous isomorphic >> ways in fact. >> >> For example, we could equate each object with a sequence number >> (unrelated with its id()). You can define that the "None" obje

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 06:12 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> That implies that it is impossible to implement Scheme: >> >> - using a programming language where variables and objects may move during >> their lifetime; >> >> - or using a computing device without conventional memory

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: >> >>> I believe identity can be defined much better, in numerous isomorphic >>> ways in fact. >>> >>> For example, we could equate each object with a sequence number >>

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 05:45 pm, Chris Angelico wrote: > >> On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano >> wrote: >>> On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: In Second-Order Logic, you can define identity directly: ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) >>>

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > But the Python virtual machine doesn't require objects to have an > address at all. That's an interesting question. Is it possible to define formal semantics for Python without the notion of an address (under some name)? Ultimately it seems necessary to have an enumerable set (

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 6:58 PM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> But the Python virtual machine doesn't require objects to have an >> address at all. > > That's an interesting question. Is it possible to define formal > semantics for Python without the notion of an address (under some

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: >> Python's integer object 0 might be equated with the (mathematical) >> natural number 18974387634. Python code would have no way of >> introspecting that natural number. >> >> The execution model would determine what prope

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Pavol Lisy
On 7/7/17, Steve D'Aprano wrote: > import sys > if sys.version_info >= (3,): # the comma is important > print("version 3") But be careful inside script! It could live long enough to see python4 :) -- https://mail.python.org/mailman/listinfo/python-list

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Marko Rauhamaa
Pavol Lisy : > On 7/7/17, Steve D'Aprano wrote: > >> import sys >> if sys.version_info >= (3,): # the comma is important >> print("version 3") > > But be careful inside script! It could live long enough to see python4 > :) That's a serious concern. An application doesn't know about Python's

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: >>> Python's integer object 0 might be equated with the (mathematical) >>> natural number 18974387634. Python code would have no way of >>> introspecting that natura

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: >> You can only define the semantics of Python (in this case) by >> providing an *arbitrary* mapping to an imaginary abstract machine. >> There's no way to define the objective abstraction. > > So aside from an artificial se

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 9:48 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: >>> You can only define the semantics of Python (in this case) by >>> providing an *arbitrary* mapping to an imaginary abstract machine. >>> There's no way to define

Re: Test 0 and false since false is 0

2017-07-07 Thread Grant Edwards
On 2017-07-07, Stefan Ram wrote: > Sayth Renshaw writes: >>I have tried or conditions of v == False etc but then the 0's >>being false also aren't moved. How can you check this at >>once? > > »The Boolean type is a subtype of the integer type, and > Boolean values behave like the valu

Re: Test 0 and false since false is 0

2017-07-07 Thread Nathan Ernst
You'd be better off using the builtin "isinstance" function, e.g.: isinstance(x, int). This also has the added benefit of working nicely with inheritance (isinstance returns true if the actual type is derived from the classinfo passed as the second argument). See https://docs.python.org/3/library/f

Re: About the implementation of del in Python 3

2017-07-07 Thread Nathan Ernst
Looks like single expression statements are handled a bit differently than multiple expression statements: Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> n = 4000; m = 4000; n is m True >>> n =

Re: Test 0 and false since false is 0

2017-07-07 Thread Peter Otten
Nathan Ernst wrote: > On Fri, Jul 7, 2017 at 2:04 AM, Peter Otten <__pete...@web.de> wrote: >> >>> sorted([0.0, 0, False, [], "x"], key=lambda x: x == 0 and type(x) == >> int) >> [0.0, False, [], 'x', 0] > You'd be better off using the builtin "isinstance" function, e.g.: > isinstance(x, int). T

Re: About the implementation of del in Python 3

2017-07-07 Thread Random832
On Fri, Jul 7, 2017, at 04:12, Gregory Ewing wrote: > Only if you interpret the word "address" very narrowly. > > By the way, even the low-level notion of "address" that C > programs deal with is, on most modern hardware, a *virtual* > address that goes through a level of translation before it > i

Re: About the implementation of del in Python 3

2017-07-07 Thread Random832
On Fri, Jul 7, 2017, at 10:41, Nathan Ernst wrote: > Looks like single expression statements are handled a bit differently > than > multiple expression statements: > > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" f

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Thu, Jul 6, 2017 at 12:56 PM, Nathan Ernst wrote: > In Python, "==" is not a reference equality operator (and I hate Java for > their misuse of the operator), so I absolutely disagree with using the Java > description to describe Python's "==" operator, primarily because, well, > it's wrong. Si

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 8:41 AM, Nathan Ernst wrote: > Looks like single expression statements are handled a bit differently than > multiple expression statements: > > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" fo

Re: how to get partition information of a hard disk with python

2017-07-07 Thread Tim Chase
Strange. The OP's message didn't make it here, but I'm seeing multiple replies > On Wednesday, September 22, 2010 at 4:01:04 AM UTC+5:30, Hellmut > Weber wrote: > > Hi list, > > I'm looking for a possibility to access the partiton inforamtion > > of a hard disk of my computer from within a python

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread eryk sun
On Fri, Jul 7, 2017 at 7:53 AM, Steve D'Aprano wrote: > On Fri, 7 Jul 2017 04:30 pm, Ben S. wrote: > >> Is there a way to execute a python script with v3 python engine in v2 >> compatibility mode? I am thinking about a command parameter like (python.exe >> is v3.*): >> >> python.exe -execute_as_

Python3 : import

2017-07-07 Thread Andrew Z
this has bee driving me nutz for the past few hours. 2 modules are in the same directory. I want to be able to use them both: [code] [az@hp tst1]$ pwd /home/az/Dropbox/work/Prjs/tst1 [az@hp tst1]$ ls -l total 16 -rw-rw-r--. 1 az az 66 Jul 7 12:58 db.py -rw-rw-r--. 1 az az 182 Jul 7 15:54 uno.

Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:00:51 PM UTC-4, Andrew Z wrote: > this has bee driving me nutz for the past few hours. > 2 modules are in the same directory. I want to be able to use them both: > > [code] > > [az@hp tst1]$ pwd > /home/az/Dropbox/work/Prjs/tst1 > > [az@hp tst1]$ ls -l > total 16 > -

Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:00:51 PM UTC-4, Andrew Z wrote: > this has bee driving me nutz for the past few hours. > 2 modules are in the same directory. I want to be able to use them both: > > [code] > > [az@hp tst1]$ pwd > /home/az/Dropbox/work/Prjs/tst1 > > [az@hp tst1]$ ls -l > total 16 > -

Re: Python3 : import

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z wrote: > [az@hp tst1]$ python3 ./uno.py > Traceback (most recent call last): > File "./uno.py", line 1, in > from . import db > SystemError: Parent module '' not loaded, cannot perform relative import That error message is a bit confusing, but relat

Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:16:38 PM UTC-4, Ian wrote: > On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z wrote: > > [az@hp tst1]$ python3 ./uno.py > > Traceback (most recent call last): > > File "./uno.py", line 1, in > > from . import db > > SystemError: Parent module '' not loaded, cannot perfo

Windows: python3.exe missing

2017-07-07 Thread Andrew Pennebaker
Could the Windows installer for Python 3 provide a "python3" command, such as a python3.bat or python3.exe file, to help with scripts that rely on the interpreter being called "python3"? The py launcher is somewhat helpful, but a proper python3 runnable is preferable. -- https://mail.python.or

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread sohcahtoa82
On Friday, July 7, 2017 at 11:58:33 AM UTC-7, eryk sun wrote: > On Fri, Jul 7, 2017 at 7:53 AM, Steve D'Aprano > wrote: > > On Fri, 7 Jul 2017 04:30 pm, Ben S. wrote: > > > >> Is there a way to execute a python script with v3 python engine in v2 > >> compatibility mode? I am thinking about a comma

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Rick Johnson
On Friday, July 7, 2017 at 2:54:04 AM UTC-5, Steve D'Aprano wrote: > [...] That's now not only backwards compatible, but it is > forward compatible: if Python changes in the future to > bring reduce back into the built-in functions, your code > will automatically keep working. If python starts goi

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 3:49 PM, wrote: > Is there any particular reason the Windows python does it that way? > Certainly it wouldn't be too difficult to include a "python2.exe" and > "python3.exe", even as symbolic links. Windows associates file types with applications by extension. When you

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Random832 wrote: What's not abstract is that if an object has address X and is N bytes long, those bytes (and any larger subobjects) occupy a contiguous range of addresses between X and X+(N-1). If you're talking about Python objects, that's not necessarily true -- there's no requirement that a

Re: Windows: python3.exe missing

2017-07-07 Thread Terry Reedy
On 7/7/2017 5:45 PM, Andrew Pennebaker wrote: Could the Windows installer for Python 3 provide a "python3" command, such as a python3.bat or python3.exe file, to help with scripts that rely on the interpreter being called "python3"? The py launcher is somewhat helpful, but a proper python3 run

Re: Windows: python3.exe missing

2017-07-07 Thread Bill Deegan
py -3.5 py -3.6 works. Don't know about py -3.6.0 py -3.6.1 On Fri, Jul 7, 2017 at 11:25 PM, Terry Reedy wrote: > On 7/7/2017 5:45 PM, Andrew Pennebaker wrote: > >> Could the Windows installer for Python 3 provide a "python3" command, >> such as a python3.bat or python3.exe file, to help with

[RELEASE] Python 3.6.2rc2 is now available for testing

2017-07-07 Thread Ned Deily
On behalf of the Python development community and the Python 3.6 release team, I would like to announce the availability of Python 3.6.2rc2. 3.6.2rc2 is the second release candidate for Python 3.6.2, the next maintenance release of Python 3.6. 3.6.2rc2 includes fixes for three security-related issu