Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-26 Thread 88888 Dihedral
Michael Torrie於 2013年6月20日星期四UTC+8下午2時01分11秒寫道: But since the LISP never really got a form beyond S-expressions, leaving us with lots of parenthesis everywhere, Python wins much as the Hitchhiker's Guide to the Galaxy wins. Yep, a list is mutable even it's empty. But constant integers,

Re: A certainl part of an if() structure never gets executed.

2013-06-26 Thread Thomas Rachel
Am 12.06.2013 03:46 schrieb Rick Johnson: On Tuesday, June 11, 2013 8:25:30 PM UTC-5, nagia@gmail.com wrote: is there a shorter and more clear way to write this? i didnt understood what Rick trie to told me. My example included verbatim copies of interactive sessions within the Python

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-20 Thread Michael Torrie
On 06/19/2013 11:48 PM, Steven D'Aprano wrote: On Wed, 19 Jun 2013 23:16:51 -0600, Michael Torrie wrote: The real power and expressivity of Python comes from embracing the abstractions that Python provides to your advantage. There's a certain elegance and beauty that comes from such things,

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-20 Thread Roel Schroeven
Νίκος schreef: Στις 18/6/2013 12:05 μμ, ο/η Steven D'Aprano έγραψε: Names are *always* linked to objects, not to other names. a = [] b = a # Now a and b refer to the same list a = {} # Now a refers to a dict, and b refers to the same list as before I see, thank you Steven. But since this

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Chris Angelico
On Wed, Jun 19, 2013 at 3:42 PM, Dave Angel da...@davea.name wrote: Names are *one of* the ways we specify which objects are to be used. (We can also specify objects via an container and a subscript or slice, or via an attribute of another object. And probably another way or two.) But you

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Νίκος
Στις 19/6/2013 8:08 πμ, ο/η Tim Roberts έγραψε: Nick the Gr33k supp...@superhost.gr wrote: On 16/6/2013 4:55 ??, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr wrote: Because Python lets you use arbitrary values in a Boolean context, the net result is exactly the same. What is an

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Dave Angel
On 06/19/2013 03:14 AM, Chris Angelico wrote: On Wed, Jun 19, 2013 at 3:42 PM, Dave Angel da...@davea.name wrote: Names are *one of* the ways we specify which objects are to be used. (We can also specify objects via an container and a subscript or slice, or via an attribute of another object.

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Chris Angelico
On Wed, Jun 19, 2013 at 6:06 PM, Dave Angel da...@davea.name wrote: On 06/19/2013 03:14 AM, Chris Angelico wrote: On Wed, Jun 19, 2013 at 3:42 PM, Dave Angel da...@davea.name wrote: Names are *one of* the ways we specify which objects are to be used. (We can also specify objects via an

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Steven D'Aprano
On Wed, 19 Jun 2013 18:21:40 +1000, Chris Angelico wrote: You can't reference an object without somewhere having either a name or a literal to start it off. True, but not necessarily a name bound to the object you are thinking of: some_function() gives you an object, but it's not a literal,

Re: A certainl part of an if() structure never gets executed.

2013-06-19 Thread Chris Angelico
On Wed, Jun 19, 2013 at 6:55 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 19 Jun 2013 18:21:40 +1000, Chris Angelico wrote: You can't reference an object without somewhere having either a name or a literal to start it off. True, but not necessarily a name bound to

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-19 Thread Michael Torrie
On 06/18/2013 03:51 AM, Νίκος wrote: Στις 18/6/2013 12:05 μμ, ο/η Steven D'Aprano έγραψε: Names are *always* linked to objects, not to other names. a = [] b = a # Now a and b refer to the same list a = {} # Now a refers to a dict, and b refers to the same list as before I see, thank you

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-19 Thread Michael Torrie
On 06/19/2013 11:16 PM, Michael Torrie wrote: It turns out that lists, hashes (dicts), and classes can pretty much do anything with having to much about with C-style pointers and such. Oh wow. Parse error. should read, pretty much do anything without having to muck about with C-style pointers

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-19 Thread Steven D'Aprano
On Wed, 19 Jun 2013 23:16:51 -0600, Michael Torrie wrote: The real power and expressivity of Python comes from embracing the abstractions that Python provides to your advantage. There's a certain elegance and beauty that comes from such things, which I believe really comes from the elegance

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Steven D'Aprano
On Tue, 18 Jun 2013 00:12:34 -0400, Dave Angel wrote: On 06/17/2013 10:42 PM, Steven D'Aprano wrote: On Mon, 17 Jun 2013 21:06:57 -0400, Dave Angel wrote: On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Larry Hudson
On 06/17/2013 08:50 AM, Simpleton wrote: On 17/6/2013 2:58 μμ, Michael Torrie wrote: a = 5 b = a a --- memory address b --- memory address I like to think a and b as references to the same memory address Not quite: a and b _are_ memory addresses, At the same time, a and b are references to

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Steven D'Aprano
On Mon, 17 Jun 2013 23:39:10 -0700, Larry Hudson wrote: On 06/17/2013 08:50 AM, Simpleton wrote: On 17/6/2013 2:58 μμ, Michael Torrie wrote: a = 5 b = a a --- memory address b --- memory address I like to think a and b as references to the same memory address Not quite: a and b _are_

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Νίκος
Στις 18/6/2013 9:39 πμ, ο/η Larry Hudson έγραψε: Not quite: a and b _are_ memory addresses, At the same time, a and b are references to the data (the objects) stored in those memory locations. The distinction is probably more important in languages like C/C++, where the _language_ gives you

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Steven D'Aprano
On Tue, 18 Jun 2013 11:49:36 +0300, Νίκος wrote: Στις 18/6/2013 9:39 πμ, ο/η Larry Hudson έγραψε: Not quite: a and b _are_ memory addresses, At the same time, a and b are references to the data (the objects) stored in those memory locations. The distinction is probably more important in

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Νίκος
Στις 18/6/2013 12:05 μμ, ο/η Steven D'Aprano έγραψε: Names are *always* linked to objects, not to other names. a = [] b = a # Now a and b refer to the same list a = {} # Now a refers to a dict, and b refers to the same list as before I see, thank you Steven. But since this is a fact how do

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-18 Thread Chris Angelico
On Tue, Jun 18, 2013 at 7:51 PM, Νίκος supp...@superhost.gr wrote: Στις 18/6/2013 12:05 μμ, ο/η Steven D'Aprano έγραψε: Names are *always* linked to objects, not to other names. a = [] b = a # Now a and b refer to the same list a = {} # Now a refers to a dict, and b refers to the same list

Re: A certainl part of an if() structure never gets executed.

2013-06-18 Thread Jan Riechers
On 13.06.2013 20:00, Νικόλαος Κούρας wrote: if '-' not in name + month + year: cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) )

Re: A certainl part of an if() structure never gets executed.

2013-06-18 Thread Tim Roberts
Nick the Gr33k supp...@superhost.gr wrote: On 16/6/2013 4:55 ??, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr wrote: Because Python lets you use arbitrary values in a Boolean context, the net result is exactly the same. What is an arbitrary value? don even knwo what arbitrary means

Re: A certainl part of an if() structure never gets executed.

2013-06-18 Thread Dave Angel
I think this is an excellent description of name binding with mutable objects. I just have one clarification to insert below. On 06/19/2013 01:08 AM, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr wrote: On 16/6/2013 4:55 ??, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr

Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Mon, 17 Jun 2013 08:17:48 +0300, Νίκος wrote: [...] The latter is false because the binding of b to the int 6 was broken in order to bind b to the int 5. Very surprising. a and b was *references* to the same memory address, it was like a memory address having 2 names to be addresses as.

Re: A certainl part of an if() structure never gets executed.

2013-06-17 Thread Michael Weylandt
On Jun 17, 2013, at 6:17, Νίκος supp...@superhost.gr wrote: On 16/6/2013 9:53 μμ, R. Michael Weylandt wrote: On Sun, Jun 16, 2013 at 2:47 PM, Ferrous Cranus supp...@superhost.gr wrote: On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: If, instead of the above, you have a = 6 b = a b = 5

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Simpleton
On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Michael Torrie
On 06/17/2013 05:34 AM, Simpleton wrote: So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? It might be partially equivalent inside the interpreter, but it's not something you should concern yourself with. And in general, no it's not safe to say,

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Terry Reedy
On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace:

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Simpleton
On 17/6/2013 2:58 μμ, Michael Torrie wrote: In python just think of assignment as making a name *be* an object. And if you assign one name to another name, that makes both names be the same object. When names are unbound (either they go out of scope or you manually unbind them), the objects

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Simpleton
On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Joel Goldstick
On Mon, Jun 17, 2013 at 11:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Benjamin Kaplan
On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Νίκος
On 17/6/2013 7:23 μμ, Benjamin Kaplan wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Terry Reedy
On 6/17/2013 1:17 PM, Νίκος wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: When you interpret Python code, do you put data in locations with integer addresses? I lost you here. Memory in biological brains is not a

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Mon, 17 Jun 2013 14:34:57 +0300, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value:

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Νίκος
Στις 18/6/2013 2:09 πμ, ο/η Steven D'Aprano έγραψε: {a: Hello world} Do you see a memory location there? There is no memory location. There is the name, a, and the object it is associated with, Hello world. Either the dict, or the string, may move around memory if the underlying memory manager

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Tue, 18 Jun 2013 02:26:39 +0300, Νίκος wrote: Στις 18/6/2013 2:09 πμ, ο/η Steven D'Aprano έγραψε: {a: Hello world} Do you see a memory location there? There is no memory location. There is the name, a, and the object it is associated with, Hello world. Either the dict, or the string, may

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Dave Angel
On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that was a typo. Do you perhaps UCS-2 or UCS-4 In Python 3.3, the data will be stored in either Latin-1,

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Tue, 18 Jun 2013 00:41:53 +, Steven D'Aprano wrote: In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. In Python 3.3, the data will be stored in either Latin-1, UTF-4, or UTF-8, depending on the contents of the string.

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Mon, 17 Jun 2013 21:06:57 -0400, Dave Angel wrote: On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that was a typo. Do you perhaps UCS-2 or UCS-4

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Steven D'Aprano
On Tue, 18 Jun 2013 02:38:20 +, Steven D'Aprano wrote: On Tue, 18 Jun 2013 00:41:53 +, Steven D'Aprano wrote: In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. In Python 3.3, the data will be stored in either

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Marcin Szamotulski
While you said to me to forget about memory locations, and that's indeed made things easy to follow i still keep wondering, how Python internally keeping tracks of 'x' and 'y' names as well as their referenced objects (i.e. number 6). There is an excellent blog post about CPython

Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Dave Angel
On 06/17/2013 10:42 PM, Steven D'Aprano wrote: On Mon, 17 Jun 2013 21:06:57 -0400, Dave Angel wrote: On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Denis McMahon
On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: In both situations we still have 2 memory units holding values, so hows that different? Consider that each named variable is a pointer to a memory location that holds a value. This is one of the ways in that a typed compiled language

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Nick the Gr33k
On 16/6/2013 9:32 πμ, Denis McMahon wrote: On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: In both situations we still have 2 memory units holding values, so hows that different? Consider that each named variable is a pointer to a memory location that holds a value. This is one of

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Nick the Gr33k
On 16/6/2013 4:55 πμ, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr wrote: Because Python lets you use arbitrary values in a Boolean context, the net result is exactly the same. What is an arbitrary value? don even knwo what arbitrary means literally in English. In a long series

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Denis McMahon
On Sun, 16 Jun 2013 11:07:12 +0300, Nick the Gr33k wrote: On 16/6/2013 9:32 πμ, Denis McMahon wrote: On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: In both situations we still have 2 memory units holding values, so hows that different? Consider that each named variable is a

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Nick the Gr33k
On 16/6/2013 12:22 μμ, Denis McMahon wrote: On Sun, 16 Jun 2013 11:07:12 +0300, Nick the Gr33k wrote: On 16/6/2013 9:32 πμ, Denis McMahon wrote: On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: In both situations we still have 2 memory units holding values, so hows that different?

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread R. Michael Weylandt
On Sun, Jun 16, 2013 at 10:59 AM, Nick the Gr33k supp...@superhost.gr wrote: On 16/6/2013 12:22 μμ, Denis McMahon wrote: For example, in Python a = 6 b = a c = 6 a and b point to one memory location that contains the value 6 c points to a different memory location that contains the value

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Mark Lawrence
On 16/06/2013 11:42, R. Michael Weylandt wrote: Whats the difference of interpreting to compiling ? If only it could be googled Alas, no one has ever written anything about technology on the internet. Ironic that... Michael I'm very sorry but I don't understand the words googled

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Denis McMahon
On Sun, 16 Jun 2013 12:59:00 +0300, Nick the Gr33k wrote: Whats the difference of interpreting to compiling ? OK, I give up! -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Ferrous Cranus
On 16/6/2013 1:42 μμ, R. Michael Weylandt wrote: I believe you are mistaken. a here is not a pointer but variable, which is a memory location that stores value 6. b here is a pointer. It's value is the memory location of variable a which stores value 6. c here is just te same as a , a

OT: C vs Python terminology (was: A certainl part of an if() structure never gets executed)

2013-06-16 Thread Andreas Perstinger
On 16.06.2013 08:32, Denis McMahon wrote: C: int a, b; b = 6; a = b; In C, this places the numeric value 6 into the memory location identified by the variable b, so far so good. then copies the value from the location pointed to by b into the location pointed to by a. Wrong. Neither a

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Jussi Piitulainen
Nick the Gr33k writes: On 16/6/2013 12:22 μμ, Denis McMahon wrote: For example, in Python a = 6 b = a c = 6 a and b point to one memory location that contains the value 6 c points to a different memory location that contains the value 6 I believe you are mistaken. a here is

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Mark Lawrence
On 16/06/2013 12:06, Ferrous Cranus wrote: what id() does, never heard of that function before. what google does, never heard of that function before. -- Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green. Snooker

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread R. Michael Weylandt
On Sun, Jun 16, 2013 at 12:06 PM, Ferrous Cranus supp...@superhost.gr wrote: I appreciate you've returned to your Ferrous Cranus persona for this interchange. It reminds me not to get hung up on concerns of futility... On 16/6/2013 1:42 μμ, R. Michael Weylandt wrote: ## CODE SNIPPET## a =

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread YBM
Le 16.06.2013 13:06, Ferrous Cranus a écrit : what id() does, never heard of that function before. just type help(id) at Python prompt and stop flooding the group with superfluous demands. -- http://mail.python.org/mailman/listinfo/python-list

Compiling vs interpreting [was Re: A certainl part of an if() structure never gets executed.]

2013-06-16 Thread Steven D'Aprano
On Sun, 16 Jun 2013 10:51:31 +, Denis McMahon wrote: On Sun, 16 Jun 2013 12:59:00 +0300, Nick the Gr33k wrote: Whats the difference of interpreting to compiling ? OK, I give up! Actually, that's a more subtle question than most people think. Python, for example, is a compiled

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Steven D'Aprano
On Sun, 16 Jun 2013 09:22:20 +, Denis McMahon wrote: Python: b = 6 a = b In Python, this first puts the value 6 in in a memory location and points b at that memory location, then makes a point to the same memory location as b points to. That may be true in some sense for CPython, the

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Ferrous Cranus
On 16/6/2013 3:04 μμ, R. Michael Weylandt wrote: On Sun, Jun 16, 2013 at 12:06 PM, Ferrous Cranus supp...@superhost.gr wrote: I appreciate you've returned to your Ferrous Cranus persona for this interchange. It reminds me not to get hung up on concerns of futility... On 16/6/2013 1:42 μμ, R.

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Ferrous Cranus
On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: If, instead of the above, you have a = 6 b = a b = 5 you will find that b == 5 and a == 6. So b is not the same as a. Else one would have changed when the other changed. I would say that a and b are different variables. They had the same value,

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread R. Michael Weylandt
On Sun, Jun 16, 2013 at 2:38 PM, Ferrous Cranus supp...@superhost.gr wrote: On 16/6/2013 3:04 μμ, R. Michael Weylandt wrote: ## CODE SNIPPET## a = 552315251254 b = a c = 552315251254 a is b # True _on my machine_ And this pattern continues for any sort of Python object. a is c # False

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread R. Michael Weylandt
On Sun, Jun 16, 2013 at 2:47 PM, Ferrous Cranus supp...@superhost.gr wrote: On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: If, instead of the above, you have a = 6 b = a b = 5 you will find that b == 5 and a == 6. So b is not the same as a. Else one would have changed when the other

Re: Compiling vs interpreting [was Re: A certainl part of an if() structure never gets executed.]

2013-06-16 Thread Mark Janssen
Whats the difference of interpreting to compiling ? OK, I give up! Actually, that's a more subtle question than most people think. Python, for example, is a compiled language. (What did you think the c in .pyc files stood for? and the compile() function?) Careful there. This terminology

Re: Compiling vs interpreting [was Re: A certainl part of an if() structure never gets executed.]

2013-06-16 Thread Steven D'Aprano
On Sun, 16 Jun 2013 12:31:59 -0700, Mark Janssen wrote: Whats the difference of interpreting to compiling ? OK, I give up! Actually, that's a more subtle question than most people think. Python, for example, is a compiled language. (What did you think the c in .pyc files stood for? and

Re: Compiling vs interpreting [was Re: A certainl part of an if() structure never gets executed.]

2013-06-16 Thread Chris Angelico
On Mon, Jun 17, 2013 at 6:02 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 16 Jun 2013 12:31:59 -0700, Mark Janssen wrote: The line between compilers and interpreters is quite fuzzy. It shouldn't be. Of course it should be, because that reflects reality. It's

Re: A certainl part of an if() structure never gets executed.

2013-06-16 Thread Νίκος
On 16/6/2013 9:53 μμ, R. Michael Weylandt wrote: On Sun, Jun 16, 2013 at 2:47 PM, Ferrous Cranus supp...@superhost.gr wrote: On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: If, instead of the above, you have a = 6 b = a b = 5 you will find that b == 5 and a == 6. So b is not the same as a.

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Nick the Gr33k
On 15/6/2013 8:27 πμ, Larry Hudson wrote: On 06/14/2013 09:56 AM, Nick the Gr33k wrote: On 14/6/2013 7:31 μμ, Steven D'Aprano wrote: On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k wrote: Returning True is the same thing as returning a variable's truthy value? NO! 'True' and 'False'

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Lele Gaifax
Nick the Gr33k supp...@superhost.gr writes: On 15/6/2013 8:27 πμ, Larry Hudson wrote: Also they do NOT return a variable's truthy value, they return the variable itself. No, as seen from my above examples, what is returned after the expr eval are the actual variables' values, which in turn

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Nick the Gr33k
On 15/6/2013 12:54 μμ, Lele Gaifax wrote: Nick the Gr33k supp...@superhost.gr writes: On 15/6/2013 8:27 πμ, Larry Hudson wrote: Also they do NOT return a variable's truthy value, they return the variable itself. No, as seen from my above examples, what is returned after the expr eval are

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Michael Torrie
On 06/15/2013 07:07 AM, Nick the Gr33k wrote: result = mylist (since its a no-emoty list) result.append('bar') result is mylist True Never seen the last statement before. What does that mean? result is mylist Yes. Surprisingling good question.

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Nick the Gr33k
On 15/6/2013 6:53 μμ, Michael Torrie wrote: On 06/15/2013 07:07 AM, Nick the Gr33k wrote: result = mylist (since its a no-emoty list) result.append('bar') result is mylist True Never seen the last statement before. What does that mean? result is mylist Yes. Surprisingling good

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Michael Torrie
On 06/15/2013 10:18 AM, Nick the Gr33k wrote: a and b you say are names, which still are memory chunks Yes no matter how you look at it, a dictionary of names and objects is memory and variables in that sense. But at a higher level, we can consider the differences with how a language like C

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Tim Roberts
Nick the Gr33k supp...@superhost.gr wrote: but i'm doing this all day long i just dont comprehend why it works this way. it doesn't make any sense to me. It's just a rule you'll have to learn. The and and or operators in Python simply do not return a boolean value. The expression a or b is

Re: A certainl part of an if() structure never gets executed.

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 18:55:05 -0700, Tim Roberts wrote: Nick the Gr33k supp...@superhost.gr wrote: but i'm doing this all day long i just dont comprehend why it works this way. it doesn't make any sense to me. It's just a rule you'll have to learn. The and and or operators in Python simply

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 4:14 πμ, Steven D'Aprano wrote: On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote: i just want 4 cases to examine so correct execute to be run: i'm reading and reading and reading this all over: if '-' not in ( name and month and year ): and i cant comprehend it.

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Chris Angelico
On Fri, Jun 14, 2013 at 6:03 PM, Nick the Gr33k supp...@superhost.gr wrote: print(name or month or year) print(k in (name and month and year)) Seriously, you can't see the difference between those lines? Either you're trolling - which is still a distinct possibility, but so is the converse - or

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread R. Michael Weylandt
On Fri, Jun 14, 2013 at 9:03 AM, Nick the Gr33k supp...@superhost.gr wrote: name=abcd month=efgh year=ijkl print(name or month or year) abcd Can understand that, it takes the first string out of the 3 strings that has a truthy value. print(k in (name and month and year)) True No

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread R. Michael Weylandt
On Fri, Jun 14, 2013 at 9:24 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Fri, Jun 14, 2013 at 9:03 AM, Nick the Gr33k supp...@superhost.gr wrote: No clue. since the expression in parenthesis returns 'abcd' how can 'k' contained within 'abcd' ? No it's not. See both above

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Jussi Piitulainen
Nick the Gr33k writes: name=abcd month=efgh year=ijkl print(name or month or year) abcd Can understand that, it takes the first string out of the 3 strings that has a truthy value. print(k in (name and month and year)) True No clue. since the expression in parenthesis

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:09, Nick the Gr33k supp...@superhost.gr wrote: print(name and month and year) ijkl Seems here is returning the last string out of 3 strings, but have no clue why Python doing this. You have been told this above. All languages kind of do that. Ever seen this command on a

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. Either way, the interactive prompt is your friend. -- What is now proved was at first only imagined! --

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Chris Angelico
On Fri, Jun 14, 2013 at 6:41 PM, Nick the Gr33k supp...@superhost.gr wrote: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. It does. Not the bool value, but it does return a

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 11:03 πμ, Nick the Gr33k wrote: On 14/6/2013 4:14 πμ, Steven D'Aprano wrote: On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote: i just want 4 cases to examine so correct execute to be run: i'm reading and reading and reading this all over: if '-' not in ( name and month

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Chris Angelico
On Fri, Jun 14, 2013 at 6:44 PM, Nick the Gr33k supp...@superhost.gr wrote: Someone want to explain this? Stop writing. Start reading. It has been explained. In the course of a long and adventurous thread in the principal European courts, it has been revealed to you that ... Fill in whatever

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:51, Nick the Gr33k supp...@superhost.gr wrote: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. Either way, the interactive prompt is your friend. At

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 11:57 πμ, Chris Angelico wrote: On Fri, Jun 14, 2013 at 6:44 PM, Nick the Gr33k supp...@superhost.gr wrote: Someone want to explain this? Stop writing. Start reading. It has been explained. In the course of a long and adventurous thread in the principal European courts, it has

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:56, Nick the Gr33k supp...@superhost.gr wrote: On 14/6/2013 11:03 πμ, Nick the Gr33k wrote: On 14/6/2013 4:14 πμ, Steven D'Aprano wrote: On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote: i just want 4 cases to examine so correct execute to be run: i'm reading

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Chris Angelico
On Fri, Jun 14, 2013 at 7:00 PM, Nick the Gr33k supp...@superhost.gr wrote: but i really wont to understand how 'or' and 'and' works inside an expression. please answer my previous post if you know. *eyeroll* You have all the information. Go play with it in the interactive interpreter until

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Jussi Piitulainen
Nick the Gr33k writes: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. It returns a value that counts as true in a conditional statement or expression: if '2001':

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 12:21 μμ, Jussi Piitulainen wrote: Nick the Gr33k writes: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. It returns a value that counts as true in a

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 12:12 μμ, Chris Angelico wrote: On Fri, Jun 14, 2013 at 7:00 PM, Nick the Gr33k supp...@superhost.gr wrote: but i really wont to understand how 'or' and 'and' works inside an expression. please answer my previous post if you know. *eyeroll* You have all the information. Go play

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Denis McMahon
On Wed, 12 Jun 2013 11:54:25 +0300, Νικόλαος Κούρας wrote: So, i must tell: for i, month in enumerate(months): print('option value=%s %s /option' % (i, month) ) to somehow return '==' instead of 0 but don't know how. You could test for (month == 0) instead of re.search('=',

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 3:03 μμ, Denis McMahon wrote: for i, month in enumerate(months): if i != 0: print('option value=%s %s /option' % (i, month) ) else: print('option value=%s %s /option' % (==, month) ) This s exactly what i was looking for Denis, thank you. I tough of that

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Jussi Piitulainen
Nick the Gr33k writes: On 14/6/2013 12:21 μμ, Jussi Piitulainen wrote: Nick the Gr33k writes: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings are not empty. It returns a value

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 3:40 μμ, Jussi Piitulainen wrote: Nick the Gr33k writes: On 14/6/2013 12:21 μμ, Jussi Piitulainen wrote: Nick the Gr33k writes: On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: 'Parker' and 'May' and '2001' '2001' But why? that expression should return True since all stings

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Zero Piraeus
: On 14 June 2013 09:07, Nick the Gr33k supp...@superhost.gr wrote: Thanks for explaining this but i cannot follow its logic at all. My mind is stuck trying to interpret it as an English sentence: if ('Parker' and 'May' and '2001') if ('Parker' or 'May' or '2001') i just don't get it and

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread rusi
On Jun 14, 6:48 pm, Zero Piraeus sche...@gmail.com wrote: : On 14 June 2013 09:07, Nick the Gr33k supp...@superhost.gr wrote: Thanks for explaining this but i cannot follow its logic at all. My mind is stuck trying to interpret it as an English sentence: if ('Parker' and 'May' and

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 4:48 μμ, Zero Piraeus wrote: : On 14 June 2013 09:07, Nick the Gr33k supp...@superhost.gr wrote: Thanks for explaining this but i cannot follow its logic at all. My mind is stuck trying to interpret it as an English sentence: if ('Parker' and 'May' and '2001') if ('Parker' or

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Grant Edwards
On 2013-06-14, Nick the Gr33k supp...@superhost.gr wrote: Well i do not understand it. Yea. We know. -- Grant Edwards grant.b.edwardsYow! I feel like a wet at parking meter on Darvon!

  1   2   >