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 co

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 integ

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 is

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: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

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 elegan

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 point

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

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 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 the object you are thinking o

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:06 PM, Dave Angel wrote: > On 06/19/2013 03:14 AM, Chris Angelico wrote: >> >> On Wed, Jun 19, 2013 at 3:42 PM, Dave Angel 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 subs

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 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 anot

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 wrote: On 16/6/2013 4:55 ??, Tim Roberts wrote: Nick the Gr33k 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 arbitr

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 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 always have to bo

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 wrote: On 16/6/2013 4:55 ??, Tim Roberts wrote: Nick the Gr33k wrote: Because Python lets you use arbitr

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

2013-06-18 Thread Tim Roberts
Nick the Gr33k wrote: > >On 16/6/2013 4:55 ??, Tim Roberts wrote: > >> Nick the Gr33k 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. Basi

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: 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, Νίκος 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 befor

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 y

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 impo

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 di

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 >> >

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

2013-06-17 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

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: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: In Python 3.2 and older, the data will be either UTF-4 or

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: 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

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 intern

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 eithe

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: >> >> >> >> 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 U

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 stri

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: 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, UTF-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: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,

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 m

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 Terry Reedy
On 6/17/2013 1:17 PM, Νίκος wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton 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 linear series of bits,

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 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

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 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 addr

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 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 addre

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 nam

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 the

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 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 s

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" Firs

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

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

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

2013-06-16 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 addr

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 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 ch

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 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 fuzzy AND it seldom even mat

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

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.

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 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 change

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 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

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, bri

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 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 wrot

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 i

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 compil

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

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 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 = 552315251254

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 c

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 mista

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 variabl

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 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 "google

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 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 6

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 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 vari

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 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 separated by "or", the

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 t

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

2013-06-15 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-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 18:55:05 -0700, Tim Roberts wrote: > Nick the Gr33k 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

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

2013-06-15 Thread Tim Roberts
Nick the Gr33k 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 evaluated as:

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 d

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 quest

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. http://docs.python.o

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 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'

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

2013-06-15 Thread Lele Gaifax
Nick the Gr33k 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 are truthy,

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-14 Thread Larry Hudson
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' are the two values of the boolean type. The

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

2013-06-14 Thread Jussi Piitulainen
Nick the Gr33k writes: > >>> (a or b or c) > 'abcd' > > This for me, should evaluate to True but instead it has been > evaluated to the first variable's value, which is a truthy value of > course since its not an empty string, but shouldn't it return True > instead? In your own programs, write

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

2013-06-14 Thread Chris Angelico
On Sat, Jun 15, 2013 at 2:56 AM, Nick the Gr33k wrote: > What i'm trying to say that both these exprs are Boolean Expressions > therefore should return Boolean values not variable's values, even if they > are truthy. Okay, now we get to the nub of the matter. In some languages, what you say is t

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

2013-06-14 Thread Nick the Gr33k
On 14/6/2013 7:31 μμ, Steven D'Aprano wrote: On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k 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 '

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

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k 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 Grant Edwards
On 2013-06-14, Nick the Gr33k 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! gmail.com -- ht

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 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 ju

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

2013-06-14 Thread rusi
On Jun 14, 6:48 pm, Zero Piraeus wrote: > : > > On 14 June 2013 09:07, Nick the Gr33k 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' o

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 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 i feel sill

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 a

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

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(' %s ' % (i, month) ) else: print(' %s ' % ("==", month) ) This s exactly what i was looking for Denis, thank you. I tough of that myself too, but i had implemented it wrongly

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(' %s ' % (i, month) ) > > to somehow return '==' instead of 0 but don't know how. You could test for (month == 0) instead of re.search('=', month)? Or you

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 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 intera

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 conditional

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: >>> i

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 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 you understand. Serio

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" 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 r

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 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 th

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" 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. >> >

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 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 you like for the rest,

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:41 PM, Nick the Gr33k 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 true

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! -- http://mail.python.or

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" 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 shell? mkdi

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.

  1   2   >