Re: A question about import

2024-02-16 Thread Cameron Simpson via Python-list
On 16Feb2024 20:32, MRAB wrote: On 2024-02-16 20:07, Gabor Urban via Python-list wrote: I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime importe

Re: A question about import

2024-02-16 Thread MRAB via Python-list
On 2024-02-16 20:07, Gabor Urban via Python-list wrote: Hi guys, I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime imported automatically? Yes.

A question about import

2024-02-16 Thread Gabor Urban via Python-list
Hi guys, I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime imported automatically? Thanks in advance, -- Urbán Gábor Linux is like a wigwam: no G

Re: New to python - Just a question

2020-07-03 Thread Tim Chase
On 2020-07-03 10:09, Daley Okuwa via Python-list wrote: > Write an algorithm (choose the language you prefer) that given a > character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will > print out the list of characters appearing at least 2 times. In > this specific example, it would return {‘a’

Re: New to python - Just a question

2020-07-03 Thread Rhodri James
On 03/07/2020 11:09, Daley Okuwa via Python-list wrote: Please can someone help Write an algorithm (choose the language you prefer) that given a character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will print out the list of characters appearing at least 2 times. In this specific example

Re: New to python - Just a question

2020-07-03 Thread David Lowry-Duda
Hello! > Please can someone help > > Write an algorithm (choose the language you prefer) that given a > character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will print > out the list of characters appearing at least 2 times. In this > specific example, it would return {‘a’}. Afterwards, c

New to python - Just a question

2020-07-03 Thread Daley Okuwa via Python-list
Please can someone help Write an algorithm (choose the language you prefer) that given a character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will print out the list of characters appearing at least 2 times. In this specific example, it would return {‘a’}. Afterwards, comment out the cost

Re: A question related to the PYTHONPATH

2018-03-26 Thread oyono
Le mardi 27 mars 2018 07:42:57 UTC+2, dieter a écrit : > oyono writes: > > ... > > I was thinking, maybe it could have been done this way to enforce not > > running module files that are supposed to be bundled into packages as > > "independant" python scripts...Therefore, running "python script.

Re: A question related to the PYTHONPATH

2018-03-26 Thread dieter
oyono writes: > ... > I was thinking, maybe it could have been done this way to enforce not running > module files that are supposed to be bundled into packages as "independant" > python scripts...Therefore, running "python script.py" should be reserved to > effectively independant python scrip

Re: A question related to the PYTHONPATH

2018-03-26 Thread oyono
Le lundi 26 mars 2018 08:11:02 UTC+2, dieter a écrit : > adrien oyono writes: > > I have recently read the documentation about how imports work on python, > > and I was wondering why, when you execute a python file, the current > > directory is not added by default to the PYTHONPATH ? > > Maybe,

Re: A question related to the PYTHONPATH

2018-03-26 Thread Ian Kelly
On Mon, Mar 26, 2018 at 1:24 PM, Dan Stromberg wrote: > On Sun, Mar 25, 2018 at 11:10 PM, dieter wrote: >> adrien oyono writes: >>> I have recently read the documentation about how imports work on python, >>> and I was wondering why, when you execute a python file, the current >>> directory is n

Re: A question related to the PYTHONPATH

2018-03-26 Thread Dan Stromberg
On Sun, Mar 25, 2018 at 11:10 PM, dieter wrote: > adrien oyono writes: >> I have recently read the documentation about how imports work on python, >> and I was wondering why, when you execute a python file, the current >> directory is not added by default to the PYTHONPATH ? > > Maybe, to avoid s

Re: A question related to the PYTHONPATH

2018-03-25 Thread dieter
adrien oyono writes: > I have recently read the documentation about how imports work on python, > and I was wondering why, when you execute a python file, the current > directory is not added by default to the PYTHONPATH ? Maybe, to avoid surprises? You can invoke a script from different positio

A question related to the PYTHONPATH

2018-03-25 Thread adrien oyono
Hello everyone, This is my first email to the python list, I'll try my best to do it well. TL;DR I have recently read the documentation about how imports work on python, and I was wondering why, when you execute a python file, the current directory is not added by default to the PYTHONPATH ? Ex

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
#x27;t matter, or they apply to everything, in which case we're stuck with them and shouldn't let them prevent us using the common sense meaning of "same object" when discussing Python `is`. > There's no way to even ask a question like "does a refer > to th

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
time. There's no way to even ask a question like "does a refer to the same object that b did a second ago", because the only way to test object identity is to use the 'is' operator, which takes two expressions evaluated at the same time. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: I don't think that talking about the average integer is meaningful. We're not averaging the integers, we're averaging their numbers of digits, which are natural numbers. To do this rigorously you could write down an expression for the average length of integers up to som

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Pavol Lisy
On 9/8/17, Gregory Ewing wrote: > Steve D'Aprano wrote: >> A harder question is, what if you take a random number from the Integers? >> How >> many digits will it have in (say) base 10? I don't have a good answer to >> that. >> I think it may be ill-defined. > > I think the answer is that on avera

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 11:01 pm, Rhodri James wrote: > On 08/09/17 13:45, Stefan Ram wrote: >> Gregory Ewing writes: >> [a random integer will on average have ] >>> infinitely many >>> digits -- despite every actual integer only having finitely >>> many di

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
one of two things would happen: (1) Either alist inside the function test() would alias the global variable blist (like call by reference), and *both* test() and test1() would change the value of blist; (2) Or alist would be a copy of blist (like call by value), and *neither* test() nor test1()

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 08:20 pm, Ben Bacarisse wrote: > Steve D'Aprano writes: > >> On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: >> >>> languages without mutable objects don't >>> really care whether they're pass-by-X or pass-by-Y. >> >> Only if you don't care about efficiency. >> >> Believe m

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): > Marko Rauhamaa writes: >>I definitely trust that: >>a = b >>assert a is b >>even when b holds an immutable object. > > |Python 3.6.0 ... > |>>> x = 21568 > |>>> x is 21568 > |False I wasn't talking about x or 21568. I was talking about a and b. Marko --

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Antoon Pardon
Op 08-09-17 om 04:09 schreef Steve D'Aprano: > On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote: > >> On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: >>> Rustom Mody wrote: >>> I said: In that case please restate the definition of 'is' from the manual which invok

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:54 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> py> class K: # defines an object >> ... def __init__(self, x): >> ... self.x = x >> ... def append(self, value): >> ... self.x.append(value) >> ... >> py> a = [] >> py> b = K(a) >> py> a is

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Rhodri James
On 08/09/17 13:45, Stefan Ram wrote: Gregory Ewing writes: [a random integer will on average have ] infinitely many digits -- despite every actual integer only having finitely many digits! This is not possible because every integer has a finit

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Chris Angelico
On Fri, Sep 8, 2017 at 10:05 PM, Steve D'Aprano wrote: > On Fri, 8 Sep 2017 05:48 pm, Gregory Ewing wrote: > >> Steve D'Aprano wrote: >>> A harder question is, what if you take a random number from the Integers? >>> How >>> many digits will it have in (say) base 10? I don't have a good answer to

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:48 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> A harder question is, what if you take a random number from the Integers? How >> many digits will it have in (say) base 10? I don't have a good answer to >> that. I think it may be ill-defined. > > I think the answer is

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > >> languages without mutable objects don't >> really care whether they're pass-by-X or pass-by-Y. > > Only if you don't care about efficiency. > > Believe me, the first time you pass a five gigabyte array to a function

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> I definitely trust that: >> >>a = b >>assert a is b >> >> even when b holds an immutable object. > > That's true, but there's rarely a good use case for that > fact that isn't better addressed with an equality comparison > rather than an 'is' test

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Marko Rauhamaa wrote: I definitely trust that: a = b assert a is b even when b holds an immutable object. That's true, but there's rarely a good use case for that fact that isn't better addressed with an equality comparison rather than an 'is' test. As an example, back in the days of s

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: Models are needed Math is one possible model Machines are another I'm not sure there's any real distinction between "math" and "machines". A Turing machine, for example, is an idealised mathematical model of computation. Maybe the distiction you're trying to get at is "stat

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: I'd like to know what these rules are I can't give you a complete list of them off the top of my head, but some examples of the kind of rules I have in mind are: * After the assigment a = b a and b refer to the same object. * After x = [e1, e2, e3, ...] x refers

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: py> class K: # defines an object ... def __init__(self, x): ... self.x = x ... def append(self, value): ... self.x.append(value) ... py> a = [] py> b = K(a) py> a is b # these are not the same object (they're different types) False py> b.appe

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Steve D'Aprano wrote: A harder question is, what if you take a random number from the Integers? How many digits will it have in (say) base 10? I don't have a good answer to that. I think it may be ill-defined. I think the answer is that on average it has infinitely many digits -- despite every

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Gregory Ewing
Rustom Mody wrote: 2. is — machine representation, too fine to be useful No, it's *not* machine representation. As I pointed out before, it's part of the abstract semantics of Python. And it's not "too fine to be useful". On the contrary, being aware of which objects are the same and which are

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Marko Rauhamaa
Gregory Ewing : > There is more leeway when it comes to immutable objects; > implementations are free to cache and re-use them, so well-written > code avoids depending on the result of "is" for immutable objects. I definitely trust that: a = b assert a is b even when b holds an immutable o

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Fri, Sep 8, 2017 at 1:01 PM, Rustom Mody wrote: > >> Can you show an actual false positive (two distinct objects for which `is` >> returns True) or false negative (the same object given as both operands for >> `is` nevertheless returns False)? In the absence of any actual bugs in the >> definit

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
problem with the definition. > Its not that you cant raise philosophical problems if you want But when concretized to (basic) math, there are no disputes so the argument becomes obtuseness to no point In the case of python data model every single interminable thread like this one, obviously

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote: > On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: >> Rustom Mody wrote: >> >> > I said: In that case please restate the definition of 'is' from the manual >> > which invokes the notion of 'memory' without bringing in memo

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 05:15 am, Stefan Ram wrote: > It computing newsgroups, for example, people > ask about how to compute the number of digits > of a number, when, actually, only numerals > (representations of numbers in a particular > numeral system) have digits. Um, yes? That's implici

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > > I said: In that case please restate the definition of 'is' from the manual > > which > > invokes the notion of 'memory' without bringing in memory. > > I don't know whether it's in the manual,

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On 06/09/17 14:02, Stefan Ram wrote: > Chris Angelico writes: >> The 'is' operator tests if two things are the same thing. > >»Roughly speaking, to say of two things that they are >identical is nonsense, and to say of one thing that it >is identical with itself is to say not

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 02:24 am, Chris Angelico wrote: > On Fri, Sep 8, 2017 at 1:30 AM, Steve D'Aprano > wrote: >> On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: >> >>> languages without mutable objects don't >>> really care whether they're pass-by-X or pass-by-Y. >> >> Only if you don't care ab

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Fri, Sep 8, 2017 at 1:30 AM, Steve D'Aprano wrote: > On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > >> languages without mutable objects don't >> really care whether they're pass-by-X or pass-by-Y. > > Only if you don't care about efficiency. > > Believe me, the first time you pass a five

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Steve D'Aprano
On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > languages without mutable objects don't > really care whether they're pass-by-X or pass-by-Y. Only if you don't care about efficiency. Believe me, the first time you pass a five gigabyte array to a function using pass-by-value, on a machine wi

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Chris Angelico
On Thu, Sep 7, 2017 at 11:21 PM, Gregory Ewing wrote: > Rustom Mody wrote: > >> I said: In that case please restate the definition of 'is' from the manual >> which invokes the notion of 'memory' without bringing in memory. > > > I don't know whether it's in the manual, but at least for > mutable o

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Gregory Ewing
Steve D'Aprano wrote: I think that these two increment procedures will be (more or less?) equivalent: procedure increment(var n: integer); begin n := n + 1 end; procedure increment2(p: intpointer); begin p^ := p^ + 1 end; They are, with the proviso that, in standard Pascal, in

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Gregory Ewing
Rustom Mody wrote: I said: In that case please restate the definition of 'is' from the manual which invokes the notion of 'memory' without bringing in memory. I don't know whether it's in the manual, but at least for mutable objects, there is a way to define the notion of "same object" that do

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Marko Rauhamaa
Chris Angelico : > *facepalm* > > I got nothing to say to you. Then why say anything? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-07 Thread Antoon Pardon
Op 07-09-17 om 03:27 schreef Steve D'Aprano: > >> Yes it is. Pascal VAR parameters are exactly like Python a assignment. > Proof by assertion? > > "It is true, because I say it is true!" I didn't just assert, I also explained. That you choose to ignore the explanation doesn't make it a proof by as

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Thu, 7 Sep 2017 12:11 am, Antoon Pardon wrote: [...] > No it would not translate to the above diagram. It would translate to my > diagram. All variables in pascal refer to some object (in memory), they don't > refer to other variables. If you have a pointer variable, you have a variable > that

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 11:02 pm, Stefan Ram wrote: > Chris Angelico writes: >>The 'is' operator tests if two things are the same thing. > > »Roughly speaking, to say of two things that they are > identical is nonsense, and to say of one thing that it > is identical with itself is t

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 10:11 pm, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking of memory? >> >> Yes. >> >> id() returns an abstract

Re: A question on modification of a list via a function invocation

2017-09-06 Thread breamoreboy
On Wednesday, September 6, 2017 at 1:12:22 PM UTC+1, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: > > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > > > > > > > Can you explain what "id" and "is" without talking of memory? > > > > Yes. > >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
On 06-09-17 15:14, Stefan Ram wrote: > Steve D'Aprano writes: >> or any of the other things we can do in a language with references-as-values, >> like C or Pascal. > > I have always taken the stance that one has to use the words > as the language specification of the language one talks > ab

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
Op 06-09-17 om 14:58 schreef Steve D'Aprano: > On Wed, 6 Sep 2017 05:12 pm, Antoon Pardon wrote: > > [...] >>> I'm not saying that we should never use this model. Its a good model. But we >>> should be clear that it is a model of the implementation, and it describes >>> entities which are not part

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rhodri James
On 06/09/17 14:02, Stefan Ram wrote: Chris Angelico writes: The 'is' operator tests if two things are the same thing. »Roughly speaking, to say of two things that they are identical is nonsense, and to say of one thing that it is identical with itself is to say nothing at

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 11:02 PM, Stefan Ram wrote: > Chris Angelico writes: >>The 'is' operator tests if two things are the same thing. > > »Roughly speaking, to say of two things that they are > identical is nonsense, and to say of one thing that it > is identical with itself i

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 05:12 pm, Antoon Pardon wrote: [...] >> I'm not saying that we should never use this model. Its a good model. But we >> should be clear that it is a model of the implementation, and it describes >> entities which are not part of the Python language. We cannot do this: >> >> >>

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 10:44 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:48:48 PM UTC+5:30, Chris Angelico wrote: >> On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: >> a = (1,2) >> b = (1,2) >> a is b >> > False >> x = 1 >> y = 1 >> x is y >> >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 5:48:48 PM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: > > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano > > wrote: > >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > >> > >> > >> > Can you e

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 4:03:40 PM UTC+5:30, ROGER GRAYDON CHRISTMAN wrote: > On 5 Sep 2017 14:28:44, (Dennis Lee Bier) wrote: > > On 5 Sep 2017 17:57:18 GMT, > >> But what does "a C++ reference" refer to? > >> > > > Per Stroustrup (The C++ Programming Language 4th Ed, page 189) >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread nopsidy
https://www.youtube.com/watch?v=pNe1wWeaHOU&list=PLYI8318YYdkCsZ7dsYV01n6TZhXA6Wf9i&index=1 Thank you, -Alex Goretoy http://launchpad.net/~a1g On Wed, Sep 6, 2017 at 7:18 PM, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: >> On Wednesday, September 6, 2017 at 5:08:2

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking of memory? >> >> Yes. >> >> id() returns an abstract

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > > > > Can you explain what "id" and "is" without talking of memory? > > Yes. > > id() returns an abstract ID number which is guaranteed to be an integer, and > guara

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: > Can you explain what "id" and "is" without talking of memory? Yes. id() returns an abstract ID number which is guaranteed to be an integer, and guaranteed to be distinct for all objects which exist at the same time. When an object ceases to exis

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steven D'Aprano wrote: Not in standard Pascal, but most actual Pascal compilers let you perform pointer arithmetic. Well, sort of. In the ones I've seen, it's more like being able to cast a pointer to an integer, do arithmetic on that and then cast it back. The results are about as implementati

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steven D'Aprano wrote: But many (perhaps even most) people have no problem dealing with location as a metaphor, where being in two places (metaphorically) is no problem at all: - I am in love, in trouble and in denial all at once. Sometimes the word "in" implies physical location, sometimes

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rhodri James
On 05/09/17 23:29, Grant Edwards wrote: On 2017-09-05, Marko Rauhamaa wrote: Pointer arithmetics is not an essential part of C. One could argue that it was a mistake to include it in the language. One may argue that it was a mistake, but I remember at least one implementation where pointer ar

Re: A question on modification of a list via a function invocation

2017-09-06 Thread ROGER GRAYDON CHRISTMAN
On 5 Sep 2017 14:28:44, wlfr...@ix.netcom.com (Dennis Lee Bier) wrote: > On 5 Sep 2017 17:57:18 GMT, https://webmail.psu.edu/webmail/retrieve.cgi?mailbox=inbox&start_num=14200&limit=50&sort=0&display=4×tamp=20170906045729&mid=mailman%2e%2e1504662834%2e2732%2epython%2dlist%40python%2eorg#";>r.

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 7:13 PM, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 12:51:25 PM UTC+5:30, Gregory Ewing wrote: >> Rustom Mody wrote: >> > 2. is — machine representation, too fine to be useful >> >> Disagree - "is" in Python has an abstract definition that >> doesn't depend on m

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Chris Angelico
On Wed, Sep 6, 2017 at 7:01 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> You can't do this with Python, since pointer arithmetic fundamentally >> doesn't exist. > > > Pointer arithmetic doesn't exist in Pascal either, yet > Pascal most definitely has pointers as a distinct data > type. >

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Rustom Mody
On Wednesday, September 6, 2017 at 12:51:25 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > 2. is — machine representation, too fine to be useful > > Disagree - "is" in Python has an abstract definition that > doesn't depend on machine representation. > > -- > Greg There is this (AFA

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Chris Angelico wrote: You can't do this with Python, since pointer arithmetic fundamentally doesn't exist. Pointer arithmetic doesn't exist in Pascal either, yet Pascal most definitely has pointers as a distinct data type. Insisting that only pointer arithmetic counts as "manipulating" pointer

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Steve D'Aprano wrote: No, they aren't first-class. Maybe not fully, but you can do a lot more with them than you can in Pascal or Modula-2. - Containers of references are not allowed. You can't have arrays of references, but struct and class members can be references, so you can certainly b

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Gregory Ewing
Rustom Mody wrote: 2. is — machine representation, too fine to be useful Disagree - "is" in Python has an abstract definition that doesn't depend on machine representation. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Antoon Pardon
Op 04-09-17 om 17:43 schreef Steve D'Aprano: > On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > >> Anton gave a picture explaining why/how references are needed and to be >> understood > Antoon gave a picture demonstrating one model of Python's semantics. > > It's a nice model that has a lot going

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Wed, 06 Sep 2017 01:04:17 +0300, Marko Rauhamaa wrote: > Chris Angelico : > >> That shows that the Java '==' operator is like the Python 'is' >> operator, and checks for object identity. You haven't manipulated >> pointers at all. In contrast, here's a C program that actually >> MANIPULATES po

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Tue, 05 Sep 2017 21:17:30 -0700, Rustom Mody wrote: > Sure you can say with Steven that this can be 'explained' by saying an > object can be in two places at one time. > Others would then say 'Humpty-dumpty!' since you have removed the most > basic intuition of objects and you are in effect say

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steven D'Aprano
On Wed, 06 Sep 2017 03:42:31 +, Stefan Ram wrote: > Well, this /is/ from the PRL: > > »An object's identity never changes once it has been created; > you may think of it as the object's address in memory.«. > ¯¯ > - Th

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Marko Rauhamaa
Rustom Mody : > On Wednesday, September 6, 2017 at 3:34:41 AM UTC+5:30, Marko Rauhamaa wrote: >> Pointer arithmetics is not an essential part of C. One could argue that >> it was a mistake to include it in the language. > > This is subjective of course… but still I wonder where you are coming from

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 9:55:10 AM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 2:17 PM, Rustom Mody wrote: > > Well ⅓ the point of pointers may be printing them out — which even in a > > language > > with 1st class pointers like C is rarely done/needed > > But still the us

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 2:17 PM, Rustom Mody wrote: > Well ⅓ the point of pointers may be printing them out — which even in a > language > with 1st class pointers like C is rarely done/needed But still the useless part. You don't actually *achieve* anything by printing out the pointer. > Another

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 9:22:15 AM UTC+5:30, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram wrote: > > Steve D'Aprano writes: > >>So in what sense are references part of the Python language? > > > > It would be possible to describe Python using a concept > > calle

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 1:42 PM, Stefan Ram wrote: > Steve D'Aprano writes: >>So in what sense are references part of the Python language? > > It would be possible to describe Python using a concept > called "reference", it's just that the The Python Language > Reference, Release 3.6.0 (PRL)

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:11 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> The third entity is the reference linking the name to the object (the arrow). >> This isn't a runtime value in Python, nor is it a compile time entity that >> exists in source code. It is pure implementation, and as such,

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Wednesday, September 6, 2017 at 3:34:41 AM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico : > > > That shows that the Java '==' operator is like the Python 'is' > > operator, and checks for object identity. You haven't manipulated > > pointers at all. In contrast, here's a C program that actu

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Grant Edwards
On 2017-09-05, Marko Rauhamaa wrote: > Pointer arithmetics is not an essential part of C. One could argue that > it was a mistake to include it in the language. One may argue that it was a mistake, but I remember at least one implementation where pointer arithmetic was hugely more efficient than

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Marko Rauhamaa
Chris Angelico : > That shows that the Java '==' operator is like the Python 'is' > operator, and checks for object identity. You haven't manipulated > pointers at all. In contrast, here's a C program that actually > MANIPULATES pointers: > > [...] > > You can't do this with Python, since pointer

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 6:42 AM, Stefan Ram wrote: > Chris Angelico writes: >>here's a C program that actually MANIPULATES pointers: > ... >>x += 2; > ... >>You can in C. Can you in Java? > > »dog = null« in Java would correspond to »x = 0« in C. > > It seems, to you, an assignment of »x + 2«

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 5:48 AM, Stefan Ram wrote: > Depends on the meaning of "meaningful". In Java, one can > inspect and manipulate pointers like in this program for > example: > [chomp code] That shows that the Java '==' operator is like the Python 'is' operator, and checks for object id

Re: A question on modification of a list via a function invocation

2017-09-05 Thread MRAB
On 2017-09-05 20:08, Steve D'Aprano wrote: On Tue, 5 Sep 2017 11:47 pm, Gregory Ewing wrote: Steve D'Aprano wrote: [quoting Scott Stanchfield] Figure 7: (Java) Defining a Dog pointer Dog d; When you write that definition, you are defining a pointer to a Dog object, not a D

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 5:28 AM, Dennis Lee Bieber wrote: > On 5 Sep 2017 17:57:18 GMT, r...@zedat.fu-berlin.de (Stefan Ram) declaimed > the following: > >> But what does "a C++ reference" refer to? >> > > Per Stroustrup (The C++ Programming Language 4th Ed, page 189) > > """ > * .

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:47 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> [quoting Scott Stanchfield] >> Figure 7: (Java) Defining a Dog pointer >> Dog d; >> >> When you write that definition, you are defining a pointer to a Dog >> object, not a Dog object itself. >> [e

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:28 PM, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 3:15 AM, Ned Batchelder wrote: >> On 9/5/17 1:02 PM, Steve D'Aprano wrote: >>> On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: >>> Dennis Lee Bieber wrote: > Pascal, probably Modula-2, Visual BASIC are closer to the C++

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Rustom Mody
On Tuesday, September 5, 2017 at 10:45:45 PM UTC+5:30, Ned Batchelder wrote: > On 9/5/17 1:02 PM, Steve D'Aprano wrote: > > On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > > > >> Dennis Lee Bieber wrote: > >>> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference > >>> semanti

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Chris Angelico
On Wed, Sep 6, 2017 at 3:15 AM, Ned Batchelder wrote: > On 9/5/17 1:02 PM, Steve D'Aprano wrote: >> On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: >> >>> Dennis Lee Bieber wrote: Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference semantics, in that the definition

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:08 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>[quote] >>The mistake they make is in the definition of >>Figure 7: (Java) Defining a Dog pointer >>Dog d; >>itself. When you write that definition, you are defining a pointer to a Dog >>object, not a Dog object itself. >>[

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:02 PM, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > >> Dennis Lee Bieber wrote: >>> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference >>> semantics, in that the definition of a function declares how the >>> argument(s) are passed. >>

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > Dennis Lee Bieber wrote: >> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference >> semantics, in that the definition of a function declares how the >> argument(s) are passed. > > Well, sort of. In Pascal and Modula, and also

  1   2   3   4   5   6   7   8   >