[Tutor] Tuple - Immutable ?

2012-03-08 Thread Sudip Bhattacharya
s=(1,2,3) s=s+(4,5,6) s (1,2,3,4,5,6) The tuple has changed. I thought I read that tuples are sequences (like lists), but they are immutable - They can't be changed once created. Could someone explain please ? ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Steven D'Aprano
Sudip Bhattacharya wrote: s=(1,2,3) s=s+(4,5,6) s (1,2,3,4,5,6) The tuple has changed. No it hasn't. You have created a *new* tuple, and assigned it to the same name. Consider: py s = (1, 2, 3) py id(s) 3083421332 py t = s py id(t) 3083421332 This shows that both s and t are names for

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Walter Prins
On 8 March 2012 11:11, Sudip Bhattacharya sud...@sudipb.com wrote: s=(1,2,3) s=s+(4,5,6) s (1,2,3,4,5,6) The tuple has changed. No, the tuple hasn't changed. That's a *new* tuple. Consider: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32 Type copyright,

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Walter Prins
Just to add, notice that even for lists, l = l + [7,8,9] produces a new list, while l += [7,8,9] does not. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread col speed
On 8 March 2012 18:11, Sudip Bhattacharya sud...@sudipb.com wrote: s=(1,2,3) s=s+(4,5,6) s (1,2,3,4,5,6) The tuple has changed. I thought I read that tuples are sequences (like lists), but they are immutable - They can't be changed once created. Could someone explain please ? I'm just a

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread col speed
On 8 March 2012 18:27, Walter Prins wpr...@gmail.com wrote: Just to add, notice that even for lists, l = l + [7,8,9] produces a new list, while l += [7,8,9] does not. ___ Tutor maillist  -  Tutor@python.org To unsubscribe or change

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Sudip Bhattacharya
That makes perfect sense. What happened was that the old tuple got replaced with a new tuple (old + new items) and NOT changed cause tuple is immutable. Thanks HTH. On Thu, Mar 8, 2012 at 4:53 PM, col speed ajarnco...@gmail.com wrote: On 8 March 2012 18:11, Sudip Bhattacharya sud...@sudipb.com

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Steven D'Aprano
col speed wrote: I was just thinking about the immutability of things and tried this (which -at least I- find interesting: id(1) 154579120 a = 1 id(a) 154579120 a += 2 id(a) 154579096 id(3) 154579096 a is 3 True Although there is probably no other logical way of doing it - I learnt

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread col speed
On 8 March 2012 18:51, Steven D'Aprano st...@pearwood.info wrote: col speed wrote: I was just thinking about the immutability of things and tried this (which -at least I- find interesting: id(1) 154579120 a = 1 id(a) 154579120 a += 2 id(a) 154579096 id(3) 154579096 a is 3

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread John Jensen
From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Sent: Thursday, March 8, 2012 7:51:33 AM Subject: Re: [Tutor] Tuple - Immutable ? col speed wrote: I was just thinking about the immutability of things and tried this (which -at least I- find

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread col speed
On 8 March 2012 19:18, John Jensen jensenjoh...@yahoo.com wrote: From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Sent: Thursday, March 8, 2012 7:51:33 AM Subject: Re: [Tutor] Tuple - Immutable ? col speed wrote: I was just thinking about the

[Tutor] Refactoring

2012-03-08 Thread Ejaj Hassan
Hi, I have been hearing this refactoring of code. Well does it have any thing like this in Python and if it is then what is it all about. Thanks. Regards, Ejaj ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

[Tutor] Python 3.2 - difference between out of dir() and help()

2012-03-08 Thread Flynn, Stephen (L P - IT)
Pythonistas, Tinkering around this morning and noticed the following when I created a tuple and asked for a dir() on it and some help() on it. x=('rod','jane','freddy') dir(x) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__',

Re: [Tutor] Tuple - Immutable ?

2012-03-08 Thread Steven D'Aprano
col speed wrote: On 8 March 2012 18:51, Steven D'Aprano st...@pearwood.info wrote: This makes sense, and is easy to understand. Now for the real boggle: py a = 9912346; b = 9912346 py a is b True Can you guess what is going on here? (Answer will follow later.) Because it's on the same

Re: [Tutor] Refactoring

2012-03-08 Thread Christian Witts
On 2012/03/08 03:13 PM, Ejaj Hassan wrote: Hi, I have been hearing this refactoring of code. Well does it have any thing like this in Python and if it is then what is it all about. Thanks. Regards, Ejaj ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Refactoring

2012-03-08 Thread Robert Sjoblom
Hi,   I have been hearing this refactoring of code. Well does it  have any thing like this in Python and if it is then what is it all about. Thanks. Regards, Ejaj Refactoring is just a way of restructuring code. It can be breaking code apart to more logical pieces -- moving parts of a class

Re: [Tutor] Begginner

2012-03-08 Thread Bozra Moses
Hi all, I have just finished installing python on a centos machine but I don't know where to begin learning this language. Please help on how to go about after installation, any useful materials will help. Thanks regards, Bozra Moses. ___ Tutor

Re: [Tutor] Refactoring

2012-03-08 Thread Steven D'Aprano
Ejaj Hassan wrote: Hi, I have been hearing this refactoring of code. Well does it have any thing like this in Python and if it is then what is it all about. Refactoring is a general technique that applies to any language, not just Python. Refactoring means to take a program which is

Re: [Tutor] Begginner

2012-03-08 Thread Steven D'Aprano
Bozra Moses wrote: Hi all, I have just finished installing python on a centos machine but I don't know where to begin learning this language. Do you know how to search the internet? You should always try searching the Internet first for an answer.

Re: [Tutor] Question about writing to Excel with slavic characters

2012-03-08 Thread Marko Limbek
On Wed, Mar 7, 2012 at 11:36 PM, Steven D'Aprano st...@pearwood.info wrote: Marko Limbek wrote: I put the recommended code savFileName = C:/dropbox/Exc_MarkoL_Zenel/Valicon/crosstabs/Tabela/ipk108_kosovo_data_finale_c1-1.sav with SavReader(savFileName) as sav:    header = sav.next()    

Re: [Tutor] Python 3.2 - difference between out of dir() and help()

2012-03-08 Thread Steven D'Aprano
Flynn, Stephen (L P - IT) wrote: All pretty standard stuff. I did however notice that the dir(x) told me about __class__, __reduce__ and __reduce_ex__ where the help(x) made no mention of them. Why is this difference? I presume the two commands using different means of getting

Re: [Tutor] Question about writing to Excel with slavic characters

2012-03-08 Thread Walter Prins
Hi Marko, I'm going out on a limb here as I know next to nothing about either SPSS or Albert-Jan's wrapper module, and so with that caveat, some comments/observations: On 8 March 2012 14:59, Marko Limbek marko.lim...@valicon.net wrote: I overcame commenting. I managed to read my own file and

[Tutor] disutils

2012-03-08 Thread Ejaj Hassan
Hi, I was just going through a book on python and came across this 'disutils'. Can somebody explained to me about this. Regards, Ejaj ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] disutils

2012-03-08 Thread Alan Gauld
On 08/03/12 23:49, Ejaj Hassan wrote: I was just going through a book on python and came across this 'disutils'. Can somebody explained to me about this. I assume you mean distutils? If so here is the official help description: DESCRIPTION The main package for the

Re: [Tutor] disutils

2012-03-08 Thread Dave Angel
On 03/08/2012 06:49 PM, Ejaj Hassan wrote: Hi, I was just going through a book on python and came across this 'disutils'. Can somebody explained to me about this. Regards, Ejaj Without mentioning the book, how are we supposed to guess what disutils is? Or perhaps you meant distutils? If

[Tutor] Python using RXVT vs Konsole?

2012-03-08 Thread brandon w
I have noticed the difference in terminals when using the Python interpreter. I am able to up-arrow to get the last typed command using rxvt but when I use konsole and I press the up-arrow I get the symbols: ^[[A Why is that? Is this the right place to ask this question? I want to be able to use

Re: [Tutor] Python using RXVT vs Konsole?

2012-03-08 Thread Steven D'Aprano
On Thu, Mar 08, 2012 at 09:07:46PM -0500, brandon w wrote: I have noticed the difference in terminals when using the Python interpreter. I am able to up-arrow to get the last typed command using rxvt but when I use konsole and I press the up-arrow I get the symbols: ^[[A Why is that? Is this

Re: [Tutor] Python using RXVT vs Konsole?

2012-03-08 Thread brandon w
I am using fluxbox an a window manager not KDE. That may have something to do with it. I will ask in another forum. Running: import readline in both terminals succeded. Thank you for your help. Brandon On Thu, Mar 8, 2012 at 9:58 PM, Steven D'Aprano st...@pearwood.info wrote: On Thu, Mar