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
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
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
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
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
"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
> 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
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
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:
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
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
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
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
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
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
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
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
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
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:
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
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
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
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
>>
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))
>>>
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 (
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
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
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
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
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
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
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
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
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
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 =
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
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
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
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
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
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
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_
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.
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
> -
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
> -
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
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
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
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
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
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
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
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
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
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
55 matches
Mail list logo